Skip to content

feat(goal): refuse todo add when a write scope is already taken - #1619

Merged
huichen merged 2 commits into
mainfrom
pr/huichen
Nov 15, 2026
Merged

huichen merged 2 commits into
mainfrom
pr/huichen

Conversation

@huichen

@huichen huichen commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator

A worker could author its own follow-up todo carrying the same --required-write-scope as 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 add now checks the requested scope against every unfinished todo at authoring time and refuses an overlap.

Commits

  • feat(goal): refuse todo add when a write scope is already taken

Verification

Ran locally on macOS with the pinned toolchain (rustc 1.99.1, Homebrew 1.96.0 shadowed off PATH), ulimit -n 8192, CARGO_TARGET_DIR at the repo target:

  • cargo fmt -p future-goal -- --check → clean
  • cargo check -p future-goal --all-targets → clean
  • cargo clippy -p future-goal --all-targets -- -D warnings → clean
  • cargo test -p future-goal → 550 lib tests plus every integration suite passed, 0 failed (the new write_scope_dependencies cases included)
  • No other crate constructs Todo literally and only future-cli depends on future-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. supervisor builds exactly the classes agent builds; the (role, class) matrix is untouched.

User-visible changes

  • Authoring gate (changed behavior): future goal todo add now refuses a --required-write-scope that 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 --note does not open it. Rollback: revert 8fb7e91.
  • Ledger field: todos now record 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.

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.
@huichen
huichen enabled auto-merge (squash) November 15, 2026 10:26
@huichen
huichen merged commit d488705 into main Nov 15, 2026
14 checks passed
@huichen
huichen deleted the pr/huichen branch November 15, 2026 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant