Why every record write goes through one locking script
On 20 September two AI sessions wrote the same record id, and a one-line edit mangled the file every session reads first. The fix was a script that takes a lock, allocates ids itself and refuses malformed writes.
Two accidents on 20 September, about an hour apart, showed that the Suite's records could not rest on a convention sessions were asked to follow. The convention was replaced by a script that takes a lock, allocates each record's id itself, and refuses writes it can tell are wrong.
The Authority System Suite is a set of rulebooks that make an AI show its work. Its memory is the Paper Trail: numbered records in plain files, each saying what an AI session did, decided, caught or missed. Everything else in the Suite points back to those ids, so an id has to mean one thing.
On 20 September it stopped meaning one thing. The trail's ledger of misses records what happened in three entries written within about an hour.
Two sessions took the same id
At 16:02 UTC my attended session appended trace record TR-0040 to the trace file. At 16:07 a scheduled, unattended session, which had read the last id at about 15:58 and seen TR-0039, appended its own TR-0040. For six minutes two different entries shared one id, and anything cited in that window pointed at both.
Nothing caught it. The audit, the set of automated checks run over the trail, had 18 checks and none looked for a duplicate id. It surfaced because a count was off by one: 42 trace headers, highest id TR-0041. The cause was that the trail was designed for one session at a time, and two had run together for the first time.
One line of shell corrupted the file every session reads first
Soon after, a sed -i command (an in-place text edit) was issued inside double quotes that contained backticks. The shell treated the backticks as a command, the expression degenerated, and a literal string was prepended to all 223 lines of the state file, the file a session starting cold reads first. Neither the audit nor the static tests validated that file's structure; both ran clean over it.
What saved it was a habit written into a checkpoint skill: after rewriting the state file, read the table back. The first two lines were visibly wrong. That corruption was loud. A subtler one, a single mangled row, would have passed every check the project had.
Every write now goes through one script
Within the hour a decision was recorded on whether every write should go through a single script that takes a lock, allocates the id inside it and logs the write, instead of a convention sessions are asked to follow. It chose the script, on the reasoning that prose rules do not fire and mechanisms do.
It also wrote down how the plan would fail. Its pre-mortem, a list made in advance of how the plan is likely to go wrong, says the likely failure is a session appending directly with cat >> anyway because the script felt like friction. That is why a later audit check compares each file's hash (a fingerprint of its contents) against the log of sanctioned writes.
The tests passed on a filesystem that allowed deletes
At 17:02 the first real append crashed. The script released its lock by deleting a folder, and the trail's folder is mounted without delete permission. Sixteen validation cases had passed, because they ran on a copy in a home directory where deletes work. No step of the validation had asked what the target filesystem refuses to do.
The lock is now taken with an atomic mkdir, a folder creation only one writer can win, and released by renaming it into a .locks/ folder. Nothing in the write path deletes anything.
It refuses bad writes but cannot stop a direct one
As counted on 2 October, the script has 91 refusal points. It refuses a second writer taking an id, a stale rewrite of the state file, a structurally broken one, and a malformed record.
It does not prevent a direct write. The Suite's rules say so: such a write is found afterwards by an audit check, and the folder cannot undo it. The ledger records four direct writes to the trail's README since; the check found three. The fourth was hidden by a later legitimate write to the same file.
Sources and notes (4)
- The pre-mortem technique (Klein) — the pre-mortem technique DAS cites, here the plan's stated failure
- Paper Trail overview — the notes this was written from
- Catches and misses — the notes this was written from
- Decisions — the notes this was written from
Authority System SuiteAll 17 parts →
