feat(shepherd): enforce canonical owner gate#2180
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 7955c89b-a997-42aa-9c45-ef4c7fe4b1e7
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 7955c89b-a997-42aa-9c45-ef4c7fe4b1e7
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 7955c89b-a997-42aa-9c45-ef4c7fe4b1e7
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 7955c89b-a997-42aa-9c45-ef4c7fe4b1e7
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 7955c89b-a997-42aa-9c45-ef4c7fe4b1e7
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 7955c89b-a997-42aa-9c45-ef4c7fe4b1e7
Docs sync advisoryVerdict: no_change * Pages affected: 0 * LLM calls: 0/15 * Took: 1s SummaryNo documentation changes needed for this PR. The diff changes maintainer orchestration primitives, their deterministic evals, unit tests, design/plan records, and deployed-content hashes. It does not change a CLI command, flag, public schema, runtime behavior, or any page under |
There was a problem hiding this comment.
Pull request overview
This PR hardens the shepherding workflow by making the canonical-owner architecture gate a required, schema-enforced part of shepherd-driver terminal completions, and propagates that contract into batch-bug-shepherd prompts, invariants, and deterministic eval anchors to prevent “ready-to-merge” without architecture evidence.
Changes:
- Adds
architecture_evidenceto the shepherd-driver completion JSON Schema and requires it forready-to-merge/advisory-with-deferred. - Updates shepherd-driver and batch-bug-shepherd skill prose/prompts to run and report the canonical-owner gate (fail-closed) plus dual-guardrail evidence when required.
- Adds unit tests and content-eval anchors, and synchronizes deployed skill copies + lockfile hashes.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/test_shepherd_driver_completion_schema.py | New regression tests for schema-level enforcement of canonical-owner completion evidence. |
| packages/shepherd-driver/SKILL.md | Inserts Phase X.2.5 canonical-owner gate into the driver loop and terminal return expectations. |
| packages/shepherd-driver/assets/shepherd-driver-prompt.md | Adds Step X.2.5 canonical-owner gate procedure and documents required architecture_evidence in the completion return. |
| packages/shepherd-driver/assets/completion-schema.json | Extends completion schema with architecture_evidence and requires it for terminal success-like statuses. |
| packages/batch-bug-shepherd/.apm/skills/batch-bug-shepherd/SKILL.md | Updates invariants summary to include driver-enforced canonical-owner gate. |
| packages/batch-bug-shepherd/.apm/skills/batch-bug-shepherd/references/invariants.md | Adds full binding invariant for canonical-owner gate and clarifies driver vs orchestrator responsibilities. |
| packages/batch-bug-shepherd/.apm/skills/batch-bug-shepherd/evals/fixtures/three-issues-mixed.with_skill.md | Adds with-skill fixture evidence text for architecture classification + fail-closed behavior. |
| packages/batch-bug-shepherd/.apm/skills/batch-bug-shepherd/evals/fixtures/sweep-bug-queue.with_skill.md | Adds with-skill fixture evidence text for architecture classification + dual-guardrail evidence. |
| packages/batch-bug-shepherd/.apm/skills/batch-bug-shepherd/evals/content/three-issues-mixed.json | Adds content-eval anchors for architecture classification, dual-guardrail evidence, and fail-closed behavior. |
| packages/batch-bug-shepherd/.apm/skills/batch-bug-shepherd/evals/content/sweep-bug-queue.json | Adds content-eval anchors for architecture classification, dual-guardrail evidence, and fail-closed behavior. |
| packages/batch-bug-shepherd/.apm/skills/batch-bug-shepherd/assets/fix-prompt.md | Propagates architecture classification + dual-guardrail expectations into greenfield fix prompt. |
| packages/batch-bug-shepherd/.apm/skills/batch-bug-shepherd/assets/final-report-template.md | Adds reporting fields for canonical-owner gate classification / blocked counts. |
| docs/superpowers/specs/2026-07-12-canonical-owner-gate-design.md | Design write-up capturing motivation, contract, failure modes, and delivery strategy. |
| docs/superpowers/plans/2026-07-12-shepherd-canonical-owner-gate.md | Implementation plan for the workflow hardening and validation steps. |
| docs/superpowers/plans/2026-07-12-pr-2177-subset-propagation-guard.md | Plan for adding static architecture guards to PR #2177’s authority seam. |
| docs/superpowers/plans/2026-07-12-pr-2176-subset-owner-hardening.md | Plan for hardening subset owner boundary checks (AST-based checker + lint wiring). |
| docs/superpowers/plans/2026-07-12-pr-2170-relative-link-validation.md | Plan for fixing remaining relative links and adding a build-time relative-link validator. |
| docs/superpowers/plans/2026-07-12-pr-2094-windows-stable-path-guard.md | Plan for enforcing install.ps1 as the sole owner of Windows stable executable path derivation. |
| apm.lock.yaml | Updates deployed file hashes/content hashes for synchronized installed skill copies. |
| .agents/skills/shepherd-driver/SKILL.md | Synchronizes deployed skill copy with package source. |
| .agents/skills/shepherd-driver/assets/shepherd-driver-prompt.md | Synchronizes deployed prompt copy with package source. |
| .agents/skills/shepherd-driver/assets/completion-schema.json | Synchronizes deployed schema copy with package source. |
| .agents/skills/batch-bug-shepherd/SKILL.md | Synchronizes deployed skill copy with package source. |
| .agents/skills/batch-bug-shepherd/references/invariants.md | Synchronizes deployed invariants copy with package source. |
| .agents/skills/batch-bug-shepherd/evals/fixtures/three-issues-mixed.with_skill.md | Synchronizes deployed eval fixture copy with package source. |
| .agents/skills/batch-bug-shepherd/evals/fixtures/sweep-bug-queue.with_skill.md | Synchronizes deployed eval fixture copy with package source. |
| .agents/skills/batch-bug-shepherd/evals/content/three-issues-mixed.json | Synchronizes deployed eval anchors copy with package source. |
| .agents/skills/batch-bug-shepherd/evals/content/sweep-bug-queue.json | Synchronizes deployed eval anchors copy with package source. |
| .agents/skills/batch-bug-shepherd/assets/fix-prompt.md | Synchronizes deployed fix prompt copy with package source. |
| .agents/skills/batch-bug-shepherd/assets/final-report-template.md | Synchronizes deployed report template copy with package source. |
Review details
- Files reviewed: 30/30 changed files
- Comments generated: 3
- Review effort level: Low
| "decisions": { | ||
| "type": "array", | ||
| "description": "Every durable decision the PR touches, with its canonical owner and the evidence that each consumer routes through that owner. Empty array is legal for ordinary-fix / not-applicable.", | ||
| "items": { | ||
| "type": "object", |
| "architecture_evidence": { | ||
| "classification": classification, | ||
| "decisions": [], | ||
| "dual_guardrail_required": dual_guardrail_required, | ||
| "boundary_lint": "exit 0 on exact head", | ||
| }, |
| decision's canonical owner and consumer routing, run | ||
| `bash scripts/lint-architecture-boundaries.sh` on the head, and -- | ||
| for a new owner, centralization, or split repair -- require the full |
harden(shepherd): enforce the canonical-owner gate
TL;DR
Bug shepherding now classifies every PR against the canonical-owner architecture before it can reach a terminal state.
shepherd-driverowns enforcement, whilebatch-bug-shepherdsupplies fix-time context and reports the returned evidence without reimplementing the gate. The completion schema fails closed when architecture evidence or required dual guardrails are missing.Important
This is the systemic follow-up to the PR #2155 architecture audit: the four affected bug PRs remain independently scoped, while this PR prevents the same review gap from recurring.
Problem (WHY)
ready-to-mergewith behavioral coverage but without the static architecture guard required for its lockfile-to-replay ownership seam.completion_returnschema could prove CI and lint status, but it had no field for architecture classification, canonical-owner routing, or dual-guardrail evidence.new-ownerandsplit-authority-repairto self-reportdual_guardrail_required=false; a regression test reproduced that bypass before the schema was tightened.apm audit --ci; this branch now synchronizes all 11 records.These findings came from real execution, matching the Agent Skills guidance to "Run the skill against real tasks, then feed the results — all of them, not just failures — back into the creation process." The terminal contract is intentionally strict because "Be prescriptive when operations are fragile, consistency matters, or a specific sequence must be followed:".
Approach (WHAT)
shepherd-driverthe single enforcement owner.completion-schema.jsonImplementation (HOW)
packages/shepherd-driver/SKILL.mdandassets/shepherd-driver-prompt.mdblocked.packages/shepherd-driver/assets/completion-schema.jsonarchitecture_evidenceforready-to-mergeandadvisory-with-deferred.new-ownerandsplit-authority-repairforcedual_guardrail_required=true; that flag requires behavioral, static, architecture-test, and mutation-break evidence.packages/batch-bug-shepherd/.apm/skills/batch-bug-shepherd/{SKILL.md,references/invariants.md}packages/batch-bug-shepherd/.apm/skills/batch-bug-shepherd/assets/{fix-prompt.md,final-report-template.md}packages/batch-bug-shepherd/.apm/skills/batch-bug-shepherd/evals/**.agents/skills/{shepherd-driver,batch-bug-shepherd}/**tests/unit/test_shepherd_driver_completion_schema.pyapm.lock.yamldocs/superpowers/specs/2026-07-12-canonical-owner-gate-design.mddocs/superpowers/plans/2026-07-12-*.mdThe exact implementation is anchored at
1e2b983de067512c4476b5c8a8f799931512762c.Diagrams
Legend: the dashed stages are new; follow the path from fix implementation to either schema-valid terminal evidence or a blocked/iterating result.
flowchart LR subgraph Fix[Fix implementation] F1[Behavioral regression] F2[Follow-ups folded] end subgraph Driver[shepherd-driver phase X.2.5] C1[Classify architecture impact] C2[Record owner and consumer routing] G{Dual guardrail required} E[Collect four evidence fields] L[Run exact-head boundary lint] end subgraph Contract[Completion contract] S[Validate architecture_evidence] R[Ready or advisory] B[Iterate or blocked] end F1 --> F2 --> C1 --> C2 --> G G -->|yes| E --> L --> S G -->|no| L S -->|valid| R S -->|missing| B classDef new stroke-dasharray: 5 5; class C1,C2,G,E,L,S,B new;Trade-offs
new-ownerandsplit-authority-repaircannot disable the guardrail. A centralizingowner-extensionstill requires model judgment because JSON Schema cannot infer code semantics; the prompt requires a rationale naming the existing guard when the flag is false.apm install.apm install --dry-runproposed 234 unrelated removals in this checkout, so the PR updates only the 11 canonical hashes computed for changed deployed files and proves the result withapm audit --ci.Benefits
architecture_evidence; missing evidence is schema-invalid.Validation
uv run apm audit --ci:uv run --extra dev pytest -q tests/unit/test_shepherd_driver_completion_schema.py:uv run --extra dev python packages/batch-bug-shepherd/.apm/skills/batch-bug-shepherd/scripts/run_evals.py:Repository lint and parity gates
uv run --extra dev ruff check src/ tests/:uv run --extra dev ruff format --check src/ tests/:uv run --extra dev python -m pylint --disable=all --enable=R0801 --min-similarity-lines=10 --fail-on=R0801 src/apm_cli/:bash scripts/lint-auth-signals.sh && bash scripts/lint-architecture-boundaries.sh:diff -rqacross both package/deployed skill trees produced no output.Scenario Evidence
tests/unit/test_shepherd_driver_completion_schema.py::test_ready_completion_requires_architecture_evidencetests/unit/test_shepherd_driver_completion_schema.py::test_authority_creating_classification_cannot_disable_dual_guardrailtests/unit/test_shepherd_driver_completion_schema.py::test_new_owner_requires_complete_dual_guardrail_evidencepackages/batch-bug-shepherd/.apm/skills/batch-bug-shepherd/evals/content/{three-issues-mixed,sweep-bug-queue}.jsonviascripts/run_evals.pytests/unit/test_shepherd_driver_completion_schema.py::test_completion_schema_mirror_is_byte_identicalplusapm audit --ciHow to test
new-ownerfixture todual_guardrail_required=false; expect schema validation to fail.uv run apm audit --ci; expect all 9 checks to pass with no drift.Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com