Repository navigation
v0.5.0: per-agent attribution in the record, and the concurrency fix it needed - #21
Merged
Merged
Conversation
…it needed The record could say what happened and under which loop, but not *who*. With one human and one agent that was fine — everything in the log was "the agent". Running three in three worktrees on one repo, it stops being fine: at merge time, "what was it allowed to do, and what did it do?" needs a subject. Every entry is now stamped with `by` (the agent), `branch`, `worktree`, and `session` when the harness supplies one. Resolution is explicit-first — `--by`, then DOCKET_BY, then a detected agent, then the OS user — and every field is omitted rather than filled with a placeholder that reads like a fact. Read it back with `docket record log --by` and `docket metrics --by`. Two properties stated plainly, because attribution is easy to oversell: `by` is self-reported (provenance, not authentication), and it cannot be revised — it is inside the hashed entry, so rewriting who an old entry blames breaks the chain there. Fixes a real bug found while building it: appending is read-the-head-then- chain-to-it, so parallel agents could both chain to the same entry and leave `verify` reporting "an entry was removed, added, or reordered" on a log nobody had touched. Six concurrent writers corrupted the chain reliably. Appends are now serialized across processes with an exclusive lock file (stale locks broken after 10s, an error rather than an unlocked write if it can't acquire one). A false tamper alarm is worse than no alarm — it teaches people to disbelieve the real one. Also fixes `docket record log --n <not-a-number>` silently printing the entire log instead of erroring, and a stale "this is v0.3.x" in the README. 16 new tests, including five agents writing simultaneously from separate processes; verified they fail when the lock is removed. Eval unchanged: 10,582 checks, zero silent allows, zero fail-open. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019xDGH82gMx6NWh3xqinF9B
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ships the next open roadmap item — per-agent / worktree attribution (a
by:field) — and fixes a real bug found while building it.The record learns who
With one human and one agent,
loopwas subject enough: everything in the log was the agent. Run three, in three worktrees, on one repo, and at merge time "what was it allowed to do, and what did it do?" needs a who.by--by <agent>, thenDOCKET_BY, then a detected agent (Claude Code, Cursor, Gemini CLI, Codex, Aider, GitHub Actions), thenuser:<name>branchworktreesessionStamping happens in
appendRecord, so no writer can forget it: CLI, hook, MCP, anddocket reviewamendments all carry it. Fields with no honest value are omitted rather than filled with a placeholder that reads like a fact, and pre-existing entries read as unattributed — never guessed at.Two properties stated plainly in the README and spec, because attribution is easy to oversell:
byis self-reported. A process that can write to the record can claim any subject. Provenance, not authentication.byis inside the hashed entry, so rewriting who an old entry blames breaks the chain at that entry.The bug this surfaced
Appending is read-the-head-then-chain-to-it, and that pair wasn't atomic. Two agents writing at once both chain to entry 5, and then:
Nobody tampered with anything. A false tamper alarm in an audit trail is worse than no alarm — it teaches people to disbelieve the real one, and it fires precisely in the parallel-agent scenario this feature is for.
Appends are now serialized across processes with an exclusive lock file next to the record: stale locks (dead holder) broken after 10s, and an error rather than an unlocked write if it can't acquire one within 15s. Zero dependencies, one machine in scope — a record on a shared network filesystem is documented as outside the guarantee.
Also fixed
docket record log --n <not-a-number>silently printed the entire log instead of erroring — "20 lines" and "everything since March" are very different answers to the same command.Testing
test/attribution.test.jsandtest/concurrency.test.js, including five agents × twelve writes landing simultaneously from separate processes, stale-lock recovery, lock release on a throwing write, and tamper-detection of a rewrittenby.Docs
README (+
README.zh.mdfor parity),spec/SPEC.md(attribution fields, the self-reported caveat, and a normative concurrency requirement), the docs site, and CLI help. Roadmap item checked off; version bumped to 0.5.0.Generated by Claude Code