Contracts

commit-path-contract.md

Contract: coord-commit correctness (FR-001/002/003/004, NFR-001/002)

Behavioral contract

#GivenWhenThen
1a coord-routed mission, complete identity triplea bookkeeping write commitsroutes to _commit_via_coordination_transaction; commits to the coord worktree; git show <coord_ref>:<path> exists; no primary residue
2a coord-routed mission, INCOMPLETE identity triple (_load_coord_branch_meta returns a None)the commit path runsit FAILS LOUD (misroute guard) — it must NOT reach the legacy leaf and commit coord paths from repo_root
3the legacy leaf is legitimately reached (coord-less path)its porcelain pre-check runsthe pre-check runs against the resolved worktree root (not repo_root); no phantom "already committed" for gitignored coord files
4a deliberately mis-placed write (worktree_rootdestination_ref)safe_commit runsraises SafeCommitHeadMismatch — the write is unrepresentable at commit (NFR-001 negative case)
5a review-cycle (WORK_PACKAGE_TASK, PRIMARY) artifactauthoredlands in its PRIMARY home (tasks/<wp>/), never the coord husk
6ANALYSIS_REPORT (re-homed PRIMARY)authoredlands PRIMARY (target branch); NO coord copy is made
7a status event on a COORD-topology missionemittedcommits to the coord worktree (not primary-uncommitted)
8a status event on a coord-LESS topology (SINGLE_BRANCH/LANES/flat)emittedthe non-transactional primary write path is PRESERVED (no regression)

Invariants (must hold after this mission)

  • assert_partition_invariant green (disjoint-and-total) after the ANALYSIS_REPORT re-home.
  • safe_commit unchanged: HEAD==destination_ref guard + .worktrees/ path-policy intact (git/ is read-only here).
  • No second, independently-writable copy of any COORD artifact (residue factory removed for coord kinds).
  • The modern transaction path is unchanged in behavior — proven by an added regression, not a code edit.

Test contract (NFR-001/002)

CoordinationWorkspace.resolve), CliRunner on agent action implement/review; assert placement via git show <ref>:<path>. Reuse tests/regression/test_issue_2508.py + tests/integration/coord_topology_fixture.py.

with no --invocation-id; assert the failure mode (record whether the block is SafeCommitHeadMismatch = FR-002 seam, or the actor warning = FR-006 seam). The verdict gates the FR-005/006 claim on US2 AC-3.

  • Real-repo e2e (no stubbed safe_commit): real git init + real git worktree add (via production
  • Live #2861 causation repro (runs FIRST): agent action review WP## --agent tool:model:profile:role

gate-and-doctor-contracts.md

Contract: gate exemption (FR-007) + coord staleness (FR-008/009) + actor (FR-005/006)

Runtime-state gate exemption (FR-007, C-004)

#GivenWhenThen
1a diff touching the running mission's OWN status.events.jsonlthe diff-compliance gate runsthat file is exempt (source="runtime-state", no violation); NO occurrence_map entry needed
2a diff renaming ANOTHER mission's runtime filesthe gate runsthose are NOT exempt (feature_dir mismatch)
3a spec.md/plan.md/tasks.md change under the same feature_dirthe gate runsstill classifies (reviewable surface not exempt)
4a non-runtime file under the mission's feature_dirthe gate runsstill classifies/violates per the normal rules

exemptions). check_review_diff_compliance threads the mission's own feature_dir + the named allowlist into assess_file/classify_path.

  • The exemption branch fires BEFORE the path-heuristic classifier (mirroring the existing move/exception

Coord staleness (FR-008/009, C-003/C-005)

#GivenWhenThen
1coord tip is a strict ancestor of target_branchdoctor coordination --check-stalenessreports stale (non-blocking); finalize-tasks prints a non-blocking WARN + recovery command
2strict-ancestor + coord worktree cleandoctor coordination --fixfast-forwards the coord branch to include target's new commits
3coord diverged (not strict-ancestor) OR coord worktree dirtydoctor coordination --fixFAILS LOUD with a unified diff; mutates nothing

"repair arbitrary drifted content" command. The reconciliation gate (review_artifact_consistency, now in merge/) is preserved as a fail-loud net, not deleted (NFR-003).

  • --fix stays MINIMIZED (C-003): it does the Gap-1 fast-forward only. It does NOT grow into a general

Actor identity (FR-005/006, C-002/C-007)

#GivenWhenThen
1compact --agent tool:model:profile:role, no dispatch Opclaim runsactor = {role, tool, profile, model} parsed; tool is the bare token, not the whole string
2partial --agent tool:: (missing segments)claim runsabsent segments stay None on the actor — NO synthetic unknown-model/{tool}-default
3--model without --invocation-idclaim runsstill RAISES (unchanged — C-002/C-007 provenance)
4a correctly-parsed dict actoremitted to the SaaS fanoutaccepted (Union[str,Dict]), not rejected as non-string
5(US2 AC-3) manual review claim succeedsafter the FR-002 fixno --force needed; merge shows no false "hollow reviews" — NOTE: satisfied by FR-002, confirmed by the NFR-002 repro, not by FR-005/006 alone