Repository navigation
feat(goal): refuse todo add when a write scope is already taken - #1619
Merged
Merged
Conversation
A worker could author its own follow-up todo with the same number and the same `--required-write-scope` as a dispatching todo, and nothing stopped it: the claim-time workspace guard only looks at live leases, so the collision sat in the ledger until the worker claimed the wrong todo (2026-11-15: three misclaims before a human superseded both). `todo add` now checks the requested scope against every unfinished todo (open/deferred/blocked) at authoring time and refuses an overlap — same path, or one an ancestor of the other, the component-aware rule the claim guard already uses. The refusal names the occupying todo, its status, its holder (claimant → owner → author) and the overlapping scopes, so the dispatching side renames and re-issues instead of a worker guessing which duplicate it hit. The one release valve is deliberate sharing by the dispatcher: `--role supervisor --note "why the scopes must be shared"`. `supervisor` builds exactly the classes `agent` builds (the (role, class) matrix rows and their semantics are untouched), and a worker's own `--note` does not open the gate. Todos also record `created_by` (the role token, or `--created-by <id>`), because `role` cannot distinguish a dispatched todo from a worker's self-authored follow-up — the precondition for a harder rule such as "agent-authored todos need supervisor acceptance before they are claimable". The field is `#[serde(default)] Option<String>`, so ledgers written before it existed replay as unknown and need no migration. Tests: new `write_scope_dependencies` cases cover the refusal (same and nested scope, occupant named, ledger untouched), the supervisor-with-note valve, supervisor-without-note and worker-with-note refusals, terminal todos releasing their scope, `created_by` recording, and a pre-`created_by` ledger line replaying and still gating. Disabling the gate fails three of them; removing the release valve fails the supervisor case.
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.
A worker could author its own follow-up todo carrying the same
--required-write-scopeas the todo that dispatched it, and nothing refused it: the claim-time workspace guard only looks at live leases, so the duplicate sat in the ledger until somebody claimed the wrong todo.todo addnow checks the requested scope against every unfinished todo at authoring time and refuses an overlap.Commits
todo addwhen a write scope is already takenVerification
Ran locally on macOS with the pinned toolchain (
rustc 1.99.1, Homebrew 1.96.0 shadowed offPATH),ulimit -n 8192,CARGO_TARGET_DIRat the repo target:cargo fmt -p future-goal -- --check→ cleancargo check -p future-goal --all-targets→ cleancargo clippy -p future-goal --all-targets -- -D warnings→ cleancargo test -p future-goal→ 550 lib tests plus every integration suite passed, 0 failed (the newwrite_scope_dependenciescases included)Todoliterally and onlyfuture-clidepends onfuture-goal(it just embeds the goal CLI), so the added field needs no consumer change.Notes
The refusal names the occupying todo, its status, its holder (claimant → owner → author) and the overlapping scopes, so the dispatching side can rename and re-issue instead of guessing which duplicate it hit.
supervisorbuilds exactly the classesagentbuilds; the (role, class) matrix is untouched.User-visible changes
future goal todo addnow refuses a--required-write-scopethat overlaps an unfinished todo (open, deferred, or blocked) — same path, or one an ancestor of the other, the same component-aware rule the claim guard uses. Before: the overlap was accepted and the collision surfaced later as a misclaim. After: the command refuses at authoring time and prints the occupant. The escape hatch is deliberate sharing by the dispatcher,--role supervisor --note "why the scopes must be shared"; a worker's own--notedoes not open it. Rollback: revert 8fb7e91.created_by(the role token, or--created-by <id>). It is#[serde(default)] Option<String>, so ledgers written before it replay with no migration; the only effect is that new todos show who authored them. Rollback: revert 8fb7e91.