Haunted Doorlatches possessed by the ghosts of spiders crying out in the night "Front Door, 1402 Red St".
The fundamental component of this plan is the spell Hauntshift [LM 66]. It translates (its wording) undead into "haunting presences." [LM 6] Door latches will have hairy spider skeletons hauntshifted into them with careful instructions on when to bolt or unbolt the door, when to explode, and when to make noises.
The Latching Haunt
A Haunting Presence has the following capabilities that we're interested in (paraphrased for brevity and interest):
- Cannot be directly sensed.
- Bound to objects with moving parts.
- Dispelled only on the destruction of the haunting object or a successful exorcism which requires 10 rounds of chanting.
- Bindable to objects from tiny to huge size.
- Can see and hear up to 60' away, but only normally.
- They cannot be turned, rebuked, or destroyed while haunting an object.
- They can choose to speak to "nearby" creatures.
- They can control the movement of moving parts in the object they possess.
Thus, the first part of the requirements are simple. By creating a special mechanism, a door bolt, mounted in the frame, with sealed bead counting arrangements, and an explosive runes spell, the object is ready to be possessed.
A suitable caster (in this case a Dread Necromancer / Binder Anima mage , purely for tradition's sake and the ability to use fell animate cheaply) will be responsible for a number of doors according to the number of Hairy Spiders (1/8 HD, Monsters of Faerun) that he can animate as skeletons. (Other mechanisms will be available as more cheesy options, but this is straightforward enough.) At low levels, hairy spider skeletons will be moving deadbolts back and forth and physically pushing beads around, but possession is much much better here.
For the sake of argument, we will say that each bead counter has a number of beads, with a ratcheting dropper which ensures that, when the dropper is pushed, a single bead is dropped, and that the device can't be turned upside down. It has whatever structural integrity and auditing spells the casters involved feel like putting on it. In the case of an unauthorised breach (defined as anyone picking the lock or breaching the container in any way), the haunt is instructed to read (even though it can't comprehend) the explosive runes.
Rotation of the appropriate key in the keyway will cause the haunt to bolt or unbolt the latch, and logging the action the with the appropriate bead.
Cries in the night
The other half of this setup is the external audit function. These things are cheap enough (especially as complicated lockwork isn't necessary) that most every (important) door can be bolted with one. More to the point, a network of these exceedingly mindless haunts can be made.
Haunts can choose to make sounds, and can hear in a 60' radius. Thus, a series of dedicated haunts can be used to repeat the sounds they hear. A latch can be instructed to speak during locking, unlocking, opening, "opening but no one is there" events, "housing tamper" and "lock tamper" events. So long as a dedicated language is used, the haunts can whisper to each other inside the thick walls of the apartments, and communicate basic information up the chain to community collecting stations. At these stations, normal events can be logged by haunted pens, reacting according to very simple rules. Unusual events can be ... dealt with.
Fundamentally, since this is detecting the state of a lock and a door, being invisible to undead, divinations, or simple invisibility won't be sufficient to defeat this tripwire, an easy trap for unwary adventurers.