From 2798459a5e4e817645f421565a21ad15a8f11450 Mon Sep 17 00:00:00 2001 From: kiskaadee Date: Sun, 1 Nov 2026 12:17:32 -0500 Subject: [PATCH] feat(implement-slice): add slice orchestration skill and handoff contracts --- skills/implement-slice/SKILL.md | 44 ++++++++++ .../references/handoff-contracts.md | 80 +++++++++++++++++++ .../references/orchestration-tiers.md | 48 +++++++++++ 3 files changed, 172 insertions(+) create mode 100644 skills/implement-slice/SKILL.md create mode 100644 skills/implement-slice/references/handoff-contracts.md create mode 100644 skills/implement-slice/references/orchestration-tiers.md diff --git a/skills/implement-slice/SKILL.md b/skills/implement-slice/SKILL.md new file mode 100644 index 0000000..05cbfbf --- /dev/null +++ b/skills/implement-slice/SKILL.md @@ -0,0 +1,44 @@ +--- +name: implement-slice +description: >- + Orchestrates end-to-end delivery of a Gitea issue or vertical feature slice + across delegated implementation and QA subagents, checkpoint commits, static + review, and pull request packaging. Never edits implementation code or + self-certifies QA. Not for decomposing epics into issues (use gitea-plan) or + executing a single already-delegated worker task (use tdd and git-manager). +--- + +# Implement Slice + +## Use when +- Delivering an approved Gitea issue or bounded feature slice end to end via coordinated subagents. +- Coordinating multi-task checkpoints, pre-committed QA rubrics, and final review gates. +- Not for decomposing raw epics into milestones and issues: use `gitea-plan`. +- Not inside an already-delegated implementation worker task: follow the assigned worker contract (`tdd`, `git-manager`) without re-invoking `implement-slice`. + +## Steps +1. **Verify session mode and read slice context.** Check active session mode per `profile/AGENTS.md`: if `learning` is active, pause so the user can decide whether to switch to `delivery`. Read target Gitea issue/milestone state (`tea issues`, `tea milestones`), canonical direction docs (`ARCHITECTURE.md`, `ROADMAP.md`, ADRs when present), and `git status --short`. Clarify ambiguous intent with the user; hand off to `gitea-plan` if tracking issues must be created first. +2. **Select orchestration topology (`complexity x risk`).** Combine planning size (`Small`, `Medium`, `Large` from `gitea-plan`) with assurance risk (`Lightweight`, `Standard`, `High-Assurance` from `code-review` and `verify-slice`) per [orchestration-tiers](references/orchestration-tiers.md), letting high-risk surfaces override size upward. Keep pure-orchestrator and context-budget invariants at every tier: retain only the plan, task status, commit SHAs, QA dispositions, blockers, and decisions; never edit implementation files, repair Git via code edits, self-certify QA, or ingest full test logs unless resolving a failure. +3. **Lock plan, workspace topology, and pre-committed QA rubrics.** Decompose the slice into ordered tasks/chunks with explicit scope boundaries, expected `git-manager` checkpoint boundaries, workspace assignment (sequential shared branch vs. isolated `.worktrees/` for concurrent workers), whether a PR applies, and falsifiable QA rubrics written before any worker spawns. Hard gate: pause for human approval before implementation begins. +4. **Assign workspaces and delegate implementation.** Govern branch and worktree lifecycle through `git-manager` per [orchestration-tiers](references/orchestration-tiers.md) (orchestrator decides topology and assigns workspaces; `git-manager` executes branch/worktree operations; workers edit and commit checkpoints inside their assigned workspace). Dispatch worker subagent(s) with the Implementation Assignment in [handoff-contracts](references/handoff-contracts.md). Never run concurrent implementation workers in the same working tree. +5. **Audit worker reports and run rubric QA.** Verify returned Implementation Reports via concise read-only Git checks (`git status --short`, `git log`, `git show --stat`) to confirm clean trees, commit SHAs, and scope containment. When the tier or chunk boundary requires independent QA, spawn a read-only/isolated QA subagent running `verify-slice` against the pre-committed rubric (withholding author narrative for `High-Assurance` black-box runs). +6. **Triage outcomes and route rework.** Classify non-passing outcomes using [handoff-contracts](references/handoff-contracts.md): send code defects or missing seam tests back to the existing worker subagent (`send_message`) when its context remains live; repair or escalate `BLOCKED (env/fixture)`; pause for human authorization on `BLOCKED (out-of-bounds)` (`live-infra`); and if a rubric proves defective, record an explicit justified amendment (pausing for human approval if acceptance criteria or scope change). Loop Steps 4-6 until all slice tasks pass. +7. **Enforce final-`HEAD` evidence invariant and finish.** Run `code-review` across `...HEAD` (including strategic project alignment). Enforce the final-`HEAD` invariant in [handoff-contracts](references/handoff-contracts.md): required `code-review` (`Ready`) and `verify-slice` (zero unhandled `FAIL`) evidence must identify the same final `HEAD` and applicable base revision; any diff change invalidates affected evidence and triggers re-verification (completing any new `RV-*` checks on final `HEAD` via valid handshake reuse). Hard gate: never package a ready PR or declare completion until final-`HEAD` evidence is current. If a PR applies, hand off to `gitea-pr`; otherwise present the final-`HEAD` evidence summary, commit range, and open decisions to the user. + +## Your call +- **Session mode**: decide whether to switch from `learning` to `delivery` before autonomous delegation. +- **Plan and pre-committed rubrics**: approve task decomposition, assurance tier, workspace topology, and QA rubrics before any implementation worker spawns. +- **Rubric amendments, `live-infra`, and trade-offs**: approve any rubric change that relaxes criteria or alters scope, authorize `live-infra` checks, and adjudicate unresolved conflicts or review disagreements. +- **PR packaging and release**: approve PR creation/updates and authorize merge (or accept local slice delivery when no PR applies). + +## Done when +- All slice checkpoints are committed on a clean target branch, `code-review` (`Ready`) and `verify-slice` (zero unhandled `FAIL`) match the same final `HEAD` and base revision, and either `gitea-pr` has packaged the PR or final evidence has been delivered directly when no PR applies. + +## Hands off to +- `gitea-plan`: when goals or epics require milestone and issue decomposition before slice execution. +- `git-manager`: to create/integrate slice branches and worktrees, commit worker checkpoints, or stop on conflicts. +- `tdd`: inside implementation workers for seam-level red-green development. +- `verify-slice`: inside QA subagents for pre-committed chunk and final-`HEAD` runtime verification. +- `code-review`: for final-slice 4-axis static and strategic alignment inspection. +- `diagnose`: when an unexpected failure requires evidence-first root-cause investigation. +- `gitea-pr`: when a PR applies and final-`HEAD` review plus verification packets are ready. diff --git a/skills/implement-slice/references/handoff-contracts.md b/skills/implement-slice/references/handoff-contracts.md new file mode 100644 index 0000000..787a515 --- /dev/null +++ b/skills/implement-slice/references/handoff-contracts.md @@ -0,0 +1,80 @@ +# 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. 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 using `tdd` and `git-manager`; do not invoke `implement-slice` or spawn nested workers unless explicitly authorized. +- **Task ID & Objective**: Concrete deliverable outcome and linked Gitea issue (`#` 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-manager` Conventional Commits. +- **Required Compact Report**: Request concise structured output (no raw multi-hundred-line logs unless a check fails). + +## 2. 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 --short` is clean. +- **Scope Deviations or Open Risks**: Any unexpected constraint, untouched edge case, or blocker encountered (`None` if clean). + +--- + +## 3. 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; leave `git status --short` clean. +- **Assurance Tier & Mode**: `Lightweight`, `Standard`, or `High-Assurance` per `verify-slice`. For `High-Assurance` black-box runs, withhold the diff narrative and worker self-audit. +- **Pre-Committed Falsifiable Checks**: Numbered checks with scope (`local` vs. `live-infra`), exact pass conditions, `FAIL if ...` signals, and any `code-review` Step 6 `RV-*` checks. +- **Authorization Boundary**: Explicitly state whether any `live-infra` check has human owner authorization for this run (default: unauthorized -> record `BLOCKED (out-of-bounds)`). + +## 4. QA Report (QA Subagent -> Orchestrator) + +Follows the `verify-slice` disposition contract: + +- **Tested Revision**: Confirmed `HEAD` SHA and clean working-tree verification. +- **Check Dispositions**: Per-criterion result (`PASS`, `FAIL`, `BLOCKED (env/fixture)`, `BLOCKED (out-of-bounds)`, or `INCONCLUSIVE`) 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. + +--- + +## 5. 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. | + +--- + +## 6. Final-HEAD Evidence Invariant and Terminal Delivery + +### The Invariant + +> Before `gitea-pr` creates or marks a PR ready (or before terminal delivery when no PR applies), the required `code-review` and `verify-slice` evidence must identify the same final `HEAD` and applicable base revision. Any change to the reviewed diff invalidates affected evidence. + +### Recovery Rules When `HEAD` Advances or Checks Emit + +1. **Post-QA commit**: If `HEAD` changes after `verify-slice` (for example, to address a `code-review` finding or rebase onto base), rerun `verify-slice` against the new `HEAD`. +2. **Post-review commit**: If `HEAD` changes after `code-review`, rerun `code-review` against `...HEAD`. +3. **Emitted `RV-*` runtime checks**: If `code-review` Step 6 emits executable `RV-*` checks, execute them via `verify-slice` against the final `HEAD` before packaging. +4. **Handshake reuse condition**: `verify-slice` may reuse a preceding `code-review` report for static provenance only when its recommendation is `Ready` (including `Ready (Conditional)` once open items are adjudicated by the human owner per `code-review`) and its recorded base SHA, `HEAD` SHA, and working-tree diff fingerprint still match exactly. + +### Conditional Terminal Paths + +- **PR applies**: Once `code-review` (`Ready`) and `verify-slice` (zero unhandled `FAIL`) match final `HEAD`, hand off both packets to `gitea-pr` to 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-`HEAD` evidence invariant, then present the commit range (`..HEAD`), static review disposition, runtime verification ledger, and any open residual-risk decisions directly to the user. diff --git a/skills/implement-slice/references/orchestration-tiers.md b/skills/implement-slice/references/orchestration-tiers.md new file mode 100644 index 0000000..505e697 --- /dev/null +++ b/skills/implement-slice/references/orchestration-tiers.md @@ -0,0 +1,48 @@ +# Orchestration Topology, Boundaries, and Workspace Ownership + +Reference for `implement-slice`. Defines how the orchestrator combines existing planning and assurance tiers without redefining them, preserves context efficiency, and prevents workspace contention. + +## 1. Pure-Orchestrator and Context-Budget Invariants + +These boundaries hold across every slice size and risk tier: + +1. **No implementation or self-certified QA**: The orchestrator never edits product or test files, creates ad-hoc fixup commits, executes mutations to repair broken code, or declares runtime QA passing without worker/QA evidence. Read-only inspection (`tea`, `git status`, `git log`, `git diff --stat`, targeted file reads to check a contradiction) is allowed. +2. **Context-budget discipline**: + - **Retain in orchestrator context**: approved slice plan, task dependency status, assigned workspace/branch refs, checkpoint commit SHAs, QA check dispositions, active blockers, and open human decisions. + - **Delegate out of orchestrator context**: full test suite transcripts, build logs, browser traces, and line-by-line edit narratives. Require concise structured reports with exact references (commit SHAs, `path:line` locations, check IDs, or log/artifact paths) and inspect raw output only when resolving a discrepancy or failure. + +--- + +## 2. Combining `Complexity x Risk` (Single-Owner Tier Mapping) + +`implement-slice` does not define new sizing or risk vocabularies; it composes the canonical tiers owned by sibling skills: + +- **Planning size (`Small`, `Medium`, `Large`)**: owned by [`gitea-plan`](../../gitea-plan/references/decomposition-tiers.md). Governs Gitea planning ceremony and task decomposition granularity. +- **Assurance rigor (`Lightweight`, `Standard`, `High-Assurance`)**: owned by [`code-review`](../../code-review/references/axes.md) and [`verify-slice`](../../verify-slice/references/perspectives.md). Governs worker independence, runtime check depth, and static review isolation. + +**Risk override rule**: Always compute assurance rigor from failure consequences, never diff line count alone. Touching authentication, permissions, secrets, payments, concurrent state, data migrations, deployment/infrastructure, destructive operations, or core shared libraries elevates even a `Small` slice to `High-Assurance` verification and review while keeping `Small` planning ceremony. + +| Planning Size x Assurance Rigor | Worker Delegation | Mid-Slice QA (`verify-slice`) | Final Slice Gate (`...HEAD`) | +| :--- | :--- | :--- | :--- | +| **`Small` x `Lightweight`** | 1 implementation worker subagent on slice branch (`tdd` where applicable + `git-manager` checkpoint commit + self-audit). | Skip separate mid-slice QA subagent if deterministic worker evidence satisfies the pre-committed rubric; run final-`HEAD` `verify-slice` Lightweight checks. | Single-pass `code-review` (`Lightweight`) + final-`HEAD` `verify-slice` confirmation. | +| **`Small`/`Medium` x `Standard`** | Sequential worker subagent(s) per task/chunk on slice branch (or isolated worktrees only if tasks are genuinely independent). | Spawn independent rubric QA subagent (`verify-slice` `Standard`) at chunk boundary or slice completion when stateful/UI/API behavior warrants separation. | Independent `code-review` (`Standard`, including strategic alignment) + final-`HEAD` `verify-slice` packet. | +| **Any Size x `High-Assurance`** (or `Large` multi-chunk slice) | Sequential tasks on slice branch or isolated per-task worktrees for independent tracks; strict checkpoint boundaries. | Spawn clean black-box QA subagent (`verify-slice` `High-Assurance`), withholding diff narrative and worker self-audit per `verify-slice` Step 3. | Isolated multi-axis `code-review` (`High-Assurance`) + final-`HEAD` `verify-slice` packet (including any emitted `RV-*` checks). | + +--- + +## 3. Branch, Worktree, and QA Ownership Boundaries + +Explicit ownership prevents concurrent working-tree corruption and keeps Git recovery out of the orchestrator: + +| Role | Exact Responsibility | +| :--- | :--- | +| **Orchestrator (`implement-slice`)** | Decides branch/worktree topology in the approved plan, assigns each worker an explicit workspace path and target branch, and verifies resulting refs/SHAs read-only. Never repairs broken Git state by editing files or committing directly. | +| **`git-manager`** | Owns and governs branch creation, `.worktrees/` creation/removal, branch integration (`rebase`, `merge`, `cherry-pick`), conflict stops, and evidence-first `reflog` recovery. On any merge/rebase conflict or unfamiliar dirty tree, `git-manager` stops immediately for human decision. | +| **Implementation Worker** | Modifies code and tests only inside its assigned workspace and scope boundary; runs local checks via `tdd` and commits verified checkpoints autonomously on the non-default working branch per `git-manager`. | +| **QA Subagent (`verify-slice`)** | Evaluates a pinned commit SHA (`HEAD`) without modifying tracked repository files. Writes temporary fixtures or scratch state only in isolated temp directories (such as `mktemp -d`), leaving `git status --short` clean. | + +### Contention and Worker Reuse Rules + +1. **Sequential default**: Prefer sequential task delegation on a single slice branch when tasks touch related modules or take minutes rather than hours; parallel worktrees pay an integration cost. +2. **Mandatory isolation for concurrency**: Never run two implementation subagents concurrently in the same working directory. Concurrent implementation tasks require separate `git-manager` worktrees and an explicit integration step before final-`HEAD` review. +3. **Stateful worker reuse**: Retain each worker's subagent `conversationId`. When QA or `code-review` routes actionable rework back on a task, message that existing worker (`send_message`) so it retains design context instead of spawning a cold worker. Spawn a fresh worker only for a distinct new task or when the original worker session is unavailable.