V3 Issue #242: Atomic Working Plan edits
Issue: #242 — Implement atomic plan edits, ordering, dependencies, and validation
Requirements: R048–R052, R056, R082–R085, R089–R090, R098–R099
Branch: Evan/v3-242-atomic-plan-edits, based on main at d71d2bd42b68485feb4571d3aad490d7d8327aa3
Delivery: one GPG-signed PR; leave it unmerged and issue open.
Scope and ownership
Extend the current TaskManager, typed update_plan registry tool, TasksRepository, and existing SQLite schema. The repository owns atomic persistence and optimistic revision checks; TaskManager validates a defensive candidate and updates its in-memory projection only after commit. Preserve complexity/tasks callers through the same validation and transaction path. Do not add revision-history storage (#244), Strategic Plan behavior (#245), or material-change approval (#246).
Indexed implementation plan
Task 1 — Revision contract and ordered operation validation
- [x] Add failing tests for required
plan_id/expected_revision, revision-zero creation, stale edits, supported operations, batch-local task references, invalid fields, duplicate references, incomplete reorder, unknown/cross-plan dependencies, cycles, and illegal state transitions. - [x] Extend the existing plan model/repository contract with a revision and defensive task metadata snapshot needed for validation.
- [x] Implement ordered
add,update,cancel,reorder,add_dependency, andremove_dependencyoperations, returning revision, ordered tasks, and batch-local reference mapping through the existingToolResult. - [x] Keep legacy
complexity/tasksinput as an explicit adapter into the same candidate validation path.
Task 2 — Atomic persistence and progress concurrency
- [x] Add a minimal SQLite migration for the plan revision and reuse existing JSON metadata fields.
- [x] In one
BEGIN IMMEDIATEtransaction, check current revision and task progress/claim state, validate persisted membership, apply task rows and ordering, increment revision, and append plan mutation events. - [x] Ensure stale revisions, validation failures, injected storage errors, or concurrent claims leave database and
TaskManagermemory unchanged. - [x] Preserve receipts/evidence and executed records. Require cancellation plus a new task identity for semantic changes to executed work; never silently reopen completed work.
Task 3 — Scheduling, compatibility, and recovery
- [x] Make claim/scheduling honor explicit plan order and dependencies; only successful prerequisites satisfy dependencies. Failed, blocked, or cancelled prerequisites keep dependents undispatchable.
- [x] Ensure cancellation prevents future dispatch while making no claim that an already-running process was terminated.
- [x] Test legacy tool shape, ToolResult response, migration/restart recovery, scoped plan isolation, stale writers, and status/evidence preservation.
- [x] Update tool schemas, prompts/docs and compatibility fixtures only where required by the new API.
Task 4 — Validation and delivery
- [x] Run focused tests on Python 3.12 and 3.13, then full suites,
make check,make lint,make docs-check, Go TUI tests, and offline agent/subagent/TUI acceptance. - [x] Independently review the complete diff, reproduce valid findings, and fix material defects. No PR threads exist until publication.
- [ ] Verify GPG signature locally and on GitHub, attach the PR, and wait for final-head CI. Keep PR #283 and this PR unmerged until user confirmation.
Review focus
Check storage concurrency under BEGIN IMMEDIATE, in-memory rollback on all exceptions, preventing stale candidate state from overwriting new claims/evidence, and scheduler behavior for failed prerequisites and reordered tasks.
Validation record
Implementation is complete on Evan/v3-242-atomic-plan-edits. Python 3.12 and 3.13 each passed all 815 tests with browser tests enabled. make check, make lint, make docs-check, make tui-test, make tui-acceptance, make agent-acceptance, and make subagent-acceptance passed. Focused plan and migration suites passed (46 tests). Independent review found and verified fixes for typed operation schemas, atomic scheduling claims, and rejection of mixed legacy/canonical arguments. No paid provider calls or new dependencies were used. The repository and issue were refreshed before creating this plan; main was d71d2bd42b68485feb4571d3aad490d7d8327aa3, issue #242 remains open, and PR #283 remains open and unmerged.