- gt-usage: add verified gt api recipes for --template none board creation, column listing, POST creation, in-place PATCH reconciliation (title, hex color, sorting), default column assignment, and card moving. - gitea-plan: standardize the 5-column pipeline (Backlog #475569, Ready #1d76db, Work in Progress #d97706, Review #6d28d9, Completed #15803d), non-destructive in-place column reconciliation by semantic role aliases, and pinning the resolved column_id map in AGENTS.md. - implement-slice: own Backlog -> Ready during Step 1 preflight readiness reconciliation (when not --dry-run), Ready -> Work in Progress at Step 4 worker delegation, and Work in Progress -> Review at Step 7 final-HEAD gate (plus Review -> Completed when direct merge applies). - gitea-pr: ensure linked issue card sits in Review on PR creation/review and move Review -> Completed once the human owner authorizes gt pr merge. - code-review: keep strictly read-only, delegating board mutations to implement-slice and gitea-pr. - tests: add test_project_board_reconciliation_and_card_transitions.
10 KiB
Handoff Contracts, Failure Triage, and Final-HEAD Invariant
Reference for implement-slice. Every delegation uses explicit, bounded schemas so subagents execute deterministically and return compact evidence packets.
1. Preflight Branch and Worktree Safeguards
Before decomposing or delegating work, inspect git status --short and git branch -v:
| Working Tree & Branch State | Classification | Orchestrator Action |
|---|---|---|
| Clean tree on target base branch | CLEAN_BASE |
Proceed directly to plan formulation. |
| Tree contains uncommitted changes matching the target slice | ADOPTABLE_DIFF |
Offer to adopt uncommitted changes into the new slice branch. |
| Tree has uncommitted edits to unrelated files or sits on an unmerged PR branch | CONFLICTING_STATE |
Hard Stop. Report active branch and diff stat. Offer structured options (stash, commit to existing branch, switch). |
| Current branch does not match intended base | WRONG_BASE |
Hard Stop. Halt and prompt user to switch to target base before branching. |
2. Implementation Assignment (Orchestrator -> Worker)
Provide before spawning (or messaging) an implementation worker:
- Session Mode & Anti-Recursion: Active mode (
mode: delivery) plus explicit instruction: execute this task directly usingtddandgit-manager; do not invokeimplement-sliceor spawn nested workers unless explicitly authorized. - Task ID & Objective: Concrete deliverable outcome and linked Gitea issue (
#<id>when applicable). - Assigned Workspace & Branch: Exact repository/worktree path and non-default working branch name.
- Scope Boundary: In-scope files/interfaces and explicit out-of-scope exclusions (preventing opportunistic refactors).
- Acceptance Criteria: Numbered, falsifiable conditions this task must satisfy.
- Checkpoint Expectation: Expected coherent commit boundary (or boundaries) following
git-managerConventional Commits. - Required Compact Report: Request concise structured output (no raw multi-hundred-line logs unless a check fails).
3. Implementation Report (Worker -> Orchestrator)
Require each worker to return:
- Summary of Changes: Touched files/seams and 2-5 bullet summary of what changed.
- Criteria Coverage: Mapping from assigned acceptance criteria to test or command proof.
- Verification Summary: Commands run (
pytest,cargo test, typecheck, lint) with exit codes and pass counts. - Checkpoint Commits: Exact commit SHA(s) and subject lines created, plus confirmation that
git status --shortis clean. - Scope Deviations or Open Risks: Any unexpected constraint, untouched edge case, or blocker encountered (
Noneif clean).
4. Pre-Committed QA Rubric Assignment (Orchestrator -> QA Subagent)
The rubric is written and approved during Step 3 (before implementation begins). When spawning the QA subagent:
- Target Revision & Workspace: Exact commit SHA (
HEAD), base ref, and workspace path. State clearly: do not modify tracked files; leavegit status --shortclean. - Assurance Tier & Mode:
Lightweight,Standard, orHigh-Assuranceperverify-slice. ForHigh-Assuranceblack-box runs, withhold the diff narrative and worker self-audit. - Pre-Committed Falsifiable Checks: Numbered checks with scope (
localvs.live-infra), exact pass conditions,FAIL if ...signals, and anycode-reviewStep 6RV-*checks. - Authorization Boundary: Explicitly state whether any
live-infracheck has human owner authorization for this run (default: unauthorized -> recordBLOCKED (out-of-bounds)).
5. QA Report (QA Subagent -> Orchestrator)
Follows the verify-slice disposition contract:
- Tested Revision: Confirmed
HEADSHA and clean working-tree verification. - Check Dispositions: Per-criterion result (
PASS,FAIL,BLOCKED (env/fixture),BLOCKED (out-of-bounds), orINCONCLUSIVE) with concise observable evidence. - Confirmed Defects: Reproducible failure steps, severity, and expected vs. actual behavior.
- Rubric Fitness: Explicit note if any rubric criterion proved ambiguous, untestable, or mismatched against repository reality.
6. The Tripartite Workflow Contract Schemas
A. Planned Workflow Schema (Step 3 Gate)
### Planned Workflow
- **Task Breakdown**:
- `TASK-01`: <Objective> (Role: Worker, Scope: <files>, Commits: <expected-commits>)
- **Verification Plan**:
- `CHK-01`: Claim: <invariant>, Method: <cmd>, Executor: <role>, Pass: <condition>, Failure: <route>
- **Workflow Graph**:
```mermaid
<dynamic-projection-from-nodes>
### B. Execution Record Schema (Steps 4–5 Log)
Updated dynamically in orchestrator turns:
```markdown
| Node ID | Claim / Invariant | Method | Executor | Evidence | Pass Condition | Status |
| :--- | :--- | :--- | :--- | :--- | :--- | :--- |
| `TASK-01` | <claim> | <method> | <role> | Commit `<sha>` | Clean tree | `passed` |
| `CHK-01` | <claim> | <method> | <role> | Exit 0 stdout | Exit 0 | `passed` |
C. Deviation Report Schema (Step 6 Handoff)
### Execution Deviation Report
- **Skipped Checks**: <None | List of skipped checks with explicit rationale>
- **Added Checks**: <None | New checks introduced in response to findings>
- **Rework Iterations**: <0 | Details of remediation loops and commit references>
- **Scope Drift**: <None | Differences between planned and actual seams>
Dynamic Mermaid Projection Rules
- Derive directly from nodes: Nodes in the graph must match
node_ids from the planned workflow table. - Expose falsification routes: Graph edges must explicitly show failure paths (e.g.
QA -- "Fail (rework)" --> Worker). - Never paste generic templates: Every diagram must reflect the exact slice tasks and assurance checks.
7. Failure Triage and Rubric Amendment Routing
Never relay "QA failed" blindly. Classify each non-passing outcome and route to the right owner:
| Observed Outcome | Classification | Orchestrator Action |
|---|---|---|
Behavioral check FAIL or code-review Needs Rework |
Implementation or test defect | Send targeted actionable feedback (check ID, repro, expected contract) to the existing worker via send_message when live. |
| Acceptance criterion lacks public-seam test proof | Missing seam test | Route back to the existing worker (tdd) to add a non-tautological seam test and commit checkpoint. |
BLOCKED (env/fixture) |
Environment or fixture blocker | Delegate fixture/devshell repair (nix-devshell or worker task) or surface environment blocker to user before judging product code. |
BLOCKED (out-of-bounds) |
Unauthorized live-infra boundary |
Preserve exact command and criteria; pause for human owner authorization, operator run, or documented deferral. |
| Symptom contradicts hypotheses across retries | Unknown root cause | Stop blind retries; hand off to diagnose for evidence-first root-cause investigation. |
| Criterion contradicts actual system architecture or tests the wrong seam | Defective rubric | Record an explicit Rubric Amendment stating what changed and why. Pause for human approval whenever an amendment relaxes an acceptance criterion or alters slice scope; never silently rewrite criteria to match worker output. |
8. Final-HEAD Evidence Invariant and Terminal Delivery
The Invariant
Before
gitea-prcreates or marks a PR ready (or before terminal delivery when no PR applies), the requiredcode-reviewandverify-sliceevidence must identify the same finalHEADand applicable base revision. Any change to the reviewed diff invalidates affected evidence.
Recovery Rules When HEAD Advances or Checks Emit
- Post-QA commit: If
HEADchanges afterverify-slice(for example, to address acode-reviewfinding or rebase onto base), rerunverify-sliceagainst the newHEAD. - Post-review commit: If
HEADchanges aftercode-review, reruncode-reviewagainst<base>...HEAD. - Emitted
RV-*runtime checks: Ifcode-reviewStep 6 emits executableRV-*checks, execute them viaverify-sliceagainst the finalHEADbefore packaging. - Handshake reuse condition:
verify-slicemay reuse a precedingcode-reviewreport for static provenance only when its recommendation isReady(includingReady (Conditional)once open items are adjudicated by the human owner percode-review) and its recorded base SHA,HEADSHA, and working-tree diff fingerprint still match exactly.
Conditional Terminal Paths
- PR applies: Once
code-review(Ready) andverify-slice(zero unhandledFAIL) match finalHEAD, hand off both packets togitea-prto draft the PR description, pause for human PR approval, create/update the PR, and report merge readiness. - No PR applies (local repo, approved solo-branch workflow, or bounded spike): Enforce the identical final-
HEADevidence invariant, then present the commit range (<base>..HEAD), static review disposition, runtime verification ledger, and any open residual-risk decisions directly to the user.
9. Project Board Card Transitions Owned by implement-slice
When the repository tracks a Gitea Project Board (resolved from the AGENTS.md planning contract or gt project list), implement-slice owns moving the target issue's card across the pipeline using the gt-usage move recipe (POST /repos/{owner}/{repo}/projects/<project-id>/issues/<global-issue-id>/move -F column_id=<target-col-id>):
| Step | Transition | Condition |
|---|---|---|
| Step 1 (Preflight & Readiness) | Backlog -> Ready |
Blocking issues are closed, issue acceptance criteria are reconciled against current HEAD and AGENTS.md, and --dry-run is not active. |
| Step 4 (Worker Delegation) | Ready -> Work in Progress |
Human owner approved the Step 3 Planned Workflow and implementation branch/worker starts. |
| Step 7 (Final-HEAD Gate) | Work in Progress -> Review |
Final-HEAD code-review (Ready) and verify-slice pass with zero unhandled FAIL outcomes. |
| Step 7 (Direct Merge Only) | Review -> Completed |
Only when repository policy permits direct fast-forward merge to main, human owner approves, and the issue is closed. Otherwise gitea-pr owns Review -> Completed. |