agent-concepts 0.0.0-stage → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +771 -2
  3. package/concepts/bc-brainstorming/body/SKILL.md +43 -0
  4. package/concepts/bc-code-review/body/SKILL.md +120 -0
  5. package/concepts/bc-codebase-design/body/SKILL.md +54 -0
  6. package/concepts/bc-codebase-docs/body/SKILL.md +150 -0
  7. package/concepts/bc-council-audit-security/body/SKILL.md +72 -0
  8. package/concepts/bc-council-chain/body/SKILL.md +71 -0
  9. package/concepts/bc-council-challenge-plan/body/SKILL.md +78 -0
  10. package/concepts/bc-council-find-bugs/body/SKILL.md +70 -0
  11. package/concepts/bc-council-improve-architecture/body/SKILL.md +52 -0
  12. package/concepts/bc-council-mode/body/SKILL.md +56 -0
  13. package/concepts/bc-council-mode/body/examples/agents/README.md +11 -0
  14. package/concepts/bc-council-mode/body/examples/agents/council-change.md +14 -0
  15. package/concepts/bc-council-mode/body/examples/agents/council-compat.md +14 -0
  16. package/concepts/bc-council-mode/body/examples/agents/council-risk.md +14 -0
  17. package/concepts/bc-council-mode/body/references/pass-contracts.md +133 -0
  18. package/concepts/bc-delegate-investigation/body/SKILL.md +119 -0
  19. package/concepts/bc-delegate-investigation/body/examples/pi-settings-snippet.json +8 -0
  20. package/concepts/bc-delegate-investigation/body/pi.md +168 -0
  21. package/concepts/bc-design/body/SKILL.md +49 -0
  22. package/concepts/bc-design/body/design-framework.md +39 -0
  23. package/concepts/bc-design/body/existing-app.md +9 -0
  24. package/concepts/bc-design/body/new-work.md +22 -0
  25. package/concepts/bc-design/body/principles.md +34 -0
  26. package/concepts/bc-design/body/surfaces.md +13 -0
  27. package/concepts/bc-diagnosing-bugs/body/SKILL.md +83 -0
  28. package/concepts/bc-dispatching-parallel-agents/body/SKILL.md +63 -0
  29. package/concepts/bc-domain-modeling/body/SKILL.md +40 -0
  30. package/concepts/bc-executing-plans/body/SKILL.md +50 -0
  31. package/concepts/bc-explain-visually/body/SKILL.md +167 -0
  32. package/concepts/bc-find-bugs/body/SKILL.md +90 -0
  33. package/concepts/bc-finishing-development-branch/body/SKILL.md +73 -0
  34. package/concepts/bc-grilling/body/SKILL.md +22 -0
  35. package/concepts/bc-handoff/body/SKILL.md +104 -0
  36. package/concepts/bc-handoff/body/pickup.md +107 -0
  37. package/concepts/bc-handoff/body/writing.md +217 -0
  38. package/concepts/bc-improve-codebase-architecture/body/SKILL.md +101 -0
  39. package/concepts/bc-json-canvas/body/SKILL.md +40 -0
  40. package/concepts/bc-json-canvas/body/references/EXAMPLES.md +71 -0
  41. package/concepts/bc-json-canvas/body/references/SPEC.md +55 -0
  42. package/concepts/bc-json-canvas/body/references/VALIDATION.md +26 -0
  43. package/concepts/bc-minimal-solution-ladder/body/SKILL.md +120 -0
  44. package/concepts/bc-obsidian-bases/body/SKILL.md +59 -0
  45. package/concepts/bc-obsidian-bases/body/references/EXAMPLES.md +80 -0
  46. package/concepts/bc-obsidian-bases/body/references/FUNCTIONS.md +49 -0
  47. package/concepts/bc-obsidian-bases/body/references/SYNTAX.md +82 -0
  48. package/concepts/bc-obsidian-bases/body/references/TROUBLESHOOTING.md +41 -0
  49. package/concepts/bc-obsidian-markdown/body/SKILL.md +47 -0
  50. package/concepts/bc-obsidian-markdown/body/references/CALLOUTS.md +40 -0
  51. package/concepts/bc-obsidian-markdown/body/references/EMBEDS.md +35 -0
  52. package/concepts/bc-obsidian-markdown/body/references/PROPERTIES.md +37 -0
  53. package/concepts/bc-optimize-code/body/SKILL.md +41 -0
  54. package/concepts/bc-performance-guardrails/body/SKILL.md +53 -0
  55. package/concepts/bc-performance-guardrails/body/measuring.md +29 -0
  56. package/concepts/bc-performance-guardrails/body/targets.md +20 -0
  57. package/concepts/bc-pipeline-to-done/body/SKILL.md +205 -0
  58. package/concepts/bc-pipeline-to-done/body/agents/bc-drain-auditor.md +19 -0
  59. package/concepts/bc-pipeline-to-done/body/agents/bc-drain-reviewer.md +19 -0
  60. package/concepts/bc-pipeline-to-done/body/agents/bc-drain-worker.md +19 -0
  61. package/concepts/bc-pipeline-to-done/body/execute-issue.md +71 -0
  62. package/concepts/bc-pipeline-to-done/body/recovery-bundle.md +79 -0
  63. package/concepts/bc-pipeline-to-done/body/review-contract.md +105 -0
  64. package/concepts/bc-pipeline-to-done/body/roles.md +13 -0
  65. package/concepts/bc-pipeline-to-done/body/scripts/publish-check.py +172 -0
  66. package/concepts/bc-pipeline-to-done/body/source-issues.md +86 -0
  67. package/concepts/bc-pipeline-to-done/body/source-work-items.md +76 -0
  68. package/concepts/bc-plain-language/body/SKILL.md +134 -0
  69. package/concepts/bc-plan-slicing/body/SKILL.md +56 -0
  70. package/concepts/bc-plan-to-pipeline/body/SKILL.md +89 -0
  71. package/concepts/bc-prd-drafting/body/SKILL.md +43 -0
  72. package/concepts/bc-prompting-agents/body/SKILL.md +278 -0
  73. package/concepts/bc-prototype/body/SKILL.md +40 -0
  74. package/concepts/bc-qmd/body/SKILL.md +64 -0
  75. package/concepts/bc-research/body/SKILL.md +26 -0
  76. package/concepts/bc-security-audit/body/AI-AND-LLM.md +25 -0
  77. package/concepts/bc-security-audit/body/ATTACK-CLASSES.md +35 -0
  78. package/concepts/bc-security-audit/body/DESKTOP-MOBILE-AND-LOCAL-IPC.md +28 -0
  79. package/concepts/bc-security-audit/body/RECONNAISSANCE.md +49 -0
  80. package/concepts/bc-security-audit/body/SKILL.md +117 -0
  81. package/concepts/bc-security-audit/body/SUPPLY-CHAIN-AND-RELEASE.md +28 -0
  82. package/concepts/bc-security-audit/body/VALIDATION-AND-REPORTING.md +124 -0
  83. package/concepts/bc-security-audit/body/WEB-PROTOCOL-AND-AUTH.md +27 -0
  84. package/concepts/bc-security-audit/body/validate_audit.py +151 -0
  85. package/concepts/bc-self-improve/body/SKILL.md +104 -0
  86. package/concepts/bc-seo/body/CITATIONS.md +23 -0
  87. package/concepts/bc-seo/body/IMAGE-SEO.md +350 -0
  88. package/concepts/bc-seo/body/SKILL.md +453 -0
  89. package/concepts/bc-setup-project/body/SKILL.md +252 -0
  90. package/concepts/bc-setup-project/body/scaffold.py +2751 -0
  91. package/concepts/bc-setup-project/body/starter-items.md +157 -0
  92. package/concepts/bc-setup-project/body/work-data.md +114 -0
  93. package/concepts/bc-setup-project/body/work_index.py +626 -0
  94. package/concepts/bc-setup-project/body/work_spent.py +220 -0
  95. package/concepts/bc-subagent-driven-development/body/SKILL.md +61 -0
  96. package/concepts/bc-tdd/body/SKILL.md +184 -0
  97. package/concepts/bc-tdd/body/formal.md +77 -0
  98. package/concepts/bc-tdd/body/mocking.md +49 -0
  99. package/concepts/bc-tdd/body/properties.md +59 -0
  100. package/concepts/bc-tdd/body/refactoring.md +12 -0
  101. package/concepts/bc-tdd/body/scripts/confirm-red.py +136 -0
  102. package/concepts/bc-tdd/body/tests.md +59 -0
  103. package/concepts/bc-teach/body/GLOSSARY-FORMAT.md +36 -0
  104. package/concepts/bc-teach/body/LEARNING-RECORD-FORMAT.md +60 -0
  105. package/concepts/bc-teach/body/MISSION-FORMAT.md +34 -0
  106. package/concepts/bc-teach/body/RESOURCES-FORMAT.md +53 -0
  107. package/concepts/bc-teach/body/REVIEW-FORMAT.md +48 -0
  108. package/concepts/bc-teach/body/SKILL.md +281 -0
  109. package/concepts/bc-teach/body/WIKI-FORMAT.md +58 -0
  110. package/concepts/bc-teach/body/scripts/due.py +65 -0
  111. package/concepts/bc-to-spec/body/SKILL.md +21 -0
  112. package/concepts/bc-to-tickets/body/SKILL.md +21 -0
  113. package/concepts/bc-triage/body/AGENT-BRIEF.md +38 -0
  114. package/concepts/bc-triage/body/OUT-OF-SCOPE.md +51 -0
  115. package/concepts/bc-triage/body/SKILL.md +81 -0
  116. package/concepts/bc-unslop/body/SKILL.md +269 -0
  117. package/concepts/bc-using-git-worktrees/body/SKILL.md +91 -0
  118. package/concepts/bc-wiki-maintain/body/SKILL.md +361 -0
  119. package/concepts/bc-wiki-maintain/body/runner/README.md +552 -0
  120. package/concepts/bc-wiki-maintain/body/runner/bc-wiki-lint.service +24 -0
  121. package/concepts/bc-wiki-maintain/body/runner/bc-wiki-lint.timer +15 -0
  122. package/concepts/bc-wiki-maintain/body/runner/bc-wiki-maintain-all.service +29 -0
  123. package/concepts/bc-wiki-maintain/body/runner/bc-wiki-maintain-all.timer +16 -0
  124. package/concepts/bc-wiki-maintain/body/runner/bc-wiki-maintain.service +28 -0
  125. package/concepts/bc-wiki-maintain/body/runner/bc-wiki-maintain.timer +12 -0
  126. package/concepts/bc-wiki-maintain/body/runner/bc-wiki-notify@.service +15 -0
  127. package/concepts/bc-wiki-maintain/body/runner/notify-failure.sh +92 -0
  128. package/concepts/bc-wiki-maintain/body/runner/run-lint.sh +69 -0
  129. package/concepts/bc-wiki-maintain/body/runner/run-promotion-all.sh +103 -0
  130. package/concepts/bc-wiki-maintain/body/runner/run-promotion.sh +270 -0
  131. package/concepts/bc-wiki-maintain/body/wiki_lint.py +958 -0
  132. package/concepts/bc-wiki-maintain/body/wiki_search.py +206 -0
  133. package/concepts/bc-work-sync/body/PLAN.md +46 -0
  134. package/concepts/bc-work-sync/body/SKILL.md +71 -0
  135. package/concepts/bc-writing-plans/body/SKILL.md +79 -0
  136. package/package.json +130 -4
  137. package/packages/agent-kernel-pi/AGENT-KERNEL.md +109 -0
  138. package/packages/agent-kernel-pi/index.js +8 -0
  139. package/packages/agent-kernel-pi/package.json +12 -0
@@ -0,0 +1,205 @@
1
+ ---
2
+ name: bc-pipeline-to-done
3
+ description: Autonomously build a repo's ready queue (planned work items marked ready for an agent, or ready-for-agent and rework-for-agent GitHub issues) with isolated worktrees, bounded rework, independent review, and driver-owned landing. Run after /bc-plan-to-pipeline.
4
+ disable-model-invocation: true
5
+ argument-hint: "[max-iters=20] [max-parallel=3] (optional caps; max-parallel 1 = sequential)"
6
+ ---
7
+
8
+ # Pipeline to done (AFK executor)
9
+
10
+ Drain eligible units of work through isolated build, independent Spec and Standards review, bounded same-worktree rework, and driver-owned landing. The driver owns global state and publishing; fresh workers own code/tests/validation only. This separation prevents a worker from publishing its own unreviewed result.
11
+
12
+ ## Choose the source
13
+
14
+ A unit of work comes from one of two sources, and each source page owns choosing, claim key, contract, parking and finishing for its units:
15
+
16
+ - **Work items** — [source-work-items.md](source-work-items.md): the project keeps a `work/` pipeline (a "Where things go" table in `.bc-agent/AGENTS.md`) and at least one item carries the line `Ready for agent: yes`.
17
+ - **Issues** — [source-issues.md](source-issues.md): the project has a GitHub remote and its GitHub issues carry `ready-for-agent` or `rework-for-agent`. Without a GitHub remote there is no issue source: do not query it or ask about it.
18
+
19
+ If only one source has ready units, use it. If both do, ask the owner which to drain before preflight; if neither does, report an empty queue and stop. Read only the chosen source page.
20
+
21
+ The rules below and the shared contracts are written for one unit of work. Where they say "issue", `#<n>` or `issue-<n>`, read the chosen source's unit and claim key (`issue-<n>` for an issue, `item-<slug>` for a work item); where they name a label, comment or close, do what the source page says instead.
22
+
23
+ Use these detailed contracts when entering their phases:
24
+
25
+ - Builder: [execute-issue.md](execute-issue.md)
26
+ - Reviewers: [review-contract.md](review-contract.md)
27
+ - Deferred-work capture/restore: [recovery-bundle.md](recovery-bundle.md)
28
+
29
+ ## Jobs
30
+
31
+ The workflow is harness-agnostic. It launches three jobs, each a fresh subagent that does not inherit the broad skill catalog and gets only the skills this contract passes:
32
+
33
+ - **auditor** — read-only, fresh context; audits a high-risk unit's contract before code.
34
+ - **builder** — writes only in its own worktree and never commits; builds and reworks.
35
+ - **reviewer** — read-only, fresh context; one review axis or the combined review.
36
+
37
+ By default the jobs run as the roles this skill's Pi package ships (see [roles.md](roles.md)): `bc-drain-auditor`, `bc-drain-worker` (the builder) and `bc-drain-reviewer`. If `~/.config/agent-concepts/overlays/bc-pipeline-to-done.md` exists, read it; roles or models it names for a job override the defaults. Set model effort explicitly per this contract. Because the jobs do not inherit the broad skill catalog, pass the worker disciplines explicitly (`bc-minimal-solution-ladder` on every implementation packet, plus `bc-tdd`, `bc-diagnosing-bugs`, and/or `bc-optimize-code` where applicable); auditor and reviewer jobs get none up front: [review-contract.md](review-contract.md) gives the reviewer the `bc-codebase-design` vocabulary and says when to load `bc-codebase-docs`. Bound each read-only auditor/reviewer to four assistant turns and 12 tool calls; mutation-capable workers receive narrow packets and are never arbitrarily interrupted mid-write. Use the configured compact tool descriptions, set top-level `artifacts:false` or an external artifact/session root (including resumed runs), and keep outputs outside unit worktrees. These are economy controls, not permission to weaken correctness gates.
38
+
39
+ Before full baseline/landing suites, worktree creation and multi-worker launch, run the machine's storage health check if one exists, and stop and report on critical or unknown health or if the configured check cannot run. If no storage health check is configured, skip it and note that in one line in the report. Include in packets: run pytest through the guarded test runner the project's or machine's instructions name (otherwise plain `pytest`, with `tmp_path` for test fixtures and cleanup even on failure; never custom `--basetemp`), and make scratch folders with `mktemp -d`, never under `/tmp`. Before releasing an integrated worktree or branch, prove its commits are in `HEAD` (ancestor or patch-equivalent) and record that landing proof in the run manifest. The `agent-kernel` concept's Storage safety section holds the temp-file and scratch-folder rules, when loaded. Why: unattended loops multiply storage leaks.
40
+
41
+ ## Claim before work
42
+
43
+ No auditor, worker, or worktree starts on a unit until the driver has claimed it through the authorized claim protocol in [Select, classify, and claim](#select-classify-and-claim): no-force create-if-absent, or lease-guarded reuse of a Released Claim Marker, with a lost race skipped before dispatch. Local-only and single-driver modes record a local claim instead and never write claim refs. Why: labels, comments and folder moves are advisory across drivers, so the claim ref is the only thing that stops two drivers or machines building the same unit. This rule lives here, in the skill itself, because projects with the visible layout no longer generate `.bc-agent/conventions/planning-workflow.md`, which used to carry the pointer.
44
+
45
+ ## Where project files go
46
+
47
+ This skill names project files by role: the **work-planned**, **work-active** and **work-done** folders, which hold work items, and the **ideas** file. Resolve each role in the "Where things go" table in the project's `.bc-agent/AGENTS.md`, and follow the work-item rules in the same file. Why: each project has one table, so a project that keeps something elsewhere changes one place and every skill follows.
48
+
49
+ ## Preflight — before the loop
50
+
51
+ Stop and report if a required check fails; AFK work must not invent mid-run decisions.
52
+
53
+ Before any claims, worktrees or baseline validation, verify that the harness can launch fresh subagents and that executable roles are available for all three jobs above. In Pi, check the `subagent` tool and its role list. If the tool is missing, ask once whether to run `pi install npm:pi-subagents`; if the user agrees, run it, then stop and tell them to restart Pi and start the pipeline again; otherwise stop. If a role is missing or does not meet the job's limits, stop, name the job and point to [roles.md](roles.md). In other harnesses, name the missing capability or job and ask the user to configure it. Do not substitute the driver for a required job.
54
+
55
+ 1. Resolve the **target branch** (where work lands) once. An explicit target in the project's instructions wins. Otherwise read `git symbolic-ref refs/remotes/origin/HEAD` and strip `refs/remotes/origin/`. Only when there is no Git remote, use the current named branch (`git symbolic-ref --short HEAD`). If the target cannot be determined, stop and report; do not guess. Confirm the target repo is clean and checked out on that branch. Capture the remote and base SHA and record them with `target_branch` in the run manifest. Use the recorded branch throughout the run, including recovery; if resuming, verify the checkout against the manifest rather than resolving the branch again.
56
+ 2. For this repo, remote and recorded target branch, run the checker named by the private overlay, or, if none is named, run `python3 <skill-dir>/scripts/publish-check.py --repo <repo> --remote <remote-url> --branch <target-branch>` from the installed skill's copy. A pass authorizes only the configured operations and conditions. Only when the checker explicitly reports that the policy file does not exist:
57
+ - If the owner can answer, ask once per run, in plain words that name no policy file, claim or tier: “May I push finished work to `<remote name>` `<target branch>`?” (for example “May I push finished work to `origin` `main`?”) Record the answer and exact destination in the run manifest. An explicit yes authorizes only this run’s target-branch push and sets single-driver mode in the manifest (`max-parallel=1`, no remote claim-ref writes). If more parallelism was requested, build one unit at a time and say why in the report. The yes does not authorize issue mutations. A no stops the run unless local-only was agreed. On resume, use the recorded decision for the same run and destination; do not ask again.
58
+ - If the owner is away or cannot be asked, record local-only mode, commit locally, push nothing, and report that outcome.
59
+
60
+ Otherwise, a denial or missing/unusable check aborts unless the user pre-agreed to commit-only-local mode. Never write or edit the policy to authorize a run. A push that includes a policy change still requires separate, explicit current user instruction covering that change.
61
+ 3. Skip claim-ref authorization in preflight’s single-driver or local-only mode. Otherwise, confirm no-force creation/deletion of `bc-drain-claims/issue-<n>` is authorized. For marker reuse, also confirm authorization for lease-guarded fast-forward acquisition from a valid marker; optional marker cleanup requires lease-guarded deletion authorization. Both leases must name the exact inspected marker SHA. This never authorizes force-updating a non-marker tip. Without that authorization, stop unless the user explicitly selected single-run mode; in that case record single-driver mode in the manifest and use its limits. Without marker authorization, continue, but report each valid-marker issue and skip it for the run. Why: the marker paths update an existing ref, which a no-force-only policy does not cover, and an unauthorized marker should cost one issue, not the run. Labels/comments are advisory, not locks.
62
+ 4. Run the chosen source's preflight checks.
63
+ 5. Record the launch caps: `max-iters` (default 20) and `max-parallel` (default 3; 1 in single-driver or local-only mode), plus the review bound of an initial review and at most three rework/re-review cycles.
64
+ 6. Choose a run artifact root outside every worktree for review packets, `review-packet/issue-<n>/round-<r>/`, and verify it is writable.
65
+ 7. Set worker effort explicitly: low for ordinary slices, medium for high-risk slices. Rework rounds after review run at low even for high-risk slices, never at the role cap: the slice is already built and reviewed, and the rework packet names the findings to fix. Never silently inherit a higher AFK parent effort.
66
+ 8. Verify worktree support and a root outside the checkout, default `${BC_DRAIN_WT_ROOT:-${TMPDIR:-/tmp}/bc-drain-worktrees/$(basename "$PWD")}`. Never build in the main checkout. Fixed-port tooling may require `max-parallel=1`.
67
+ 9. Choose persistent recovery root `${XDG_STATE_HOME:-$HOME/.local/state}/bc-drain/recovery/<repo-key>/` and verify it can be written safely.
68
+ 10. If a global qmd collection covers the repo, run `qmd update && qmd embed` once. Workers search it but never re-index.
69
+ 11. Cache full project baseline validation once per base SHA: command, exit status, failing test IDs, concise summary, raw-log path outside the worktree, and content hash. This separates known failures from regressions without paying for a full suite every round.
70
+
71
+ ## Resuming an interrupted run
72
+
73
+ A drain dies between phases more easily than it fails: a killed pane, a lost harness session, a restarted machine. Claims, worktrees, and uncommitted diffs all outlive it. Recover before relaunching — dispatching a fresh drain over live state pays again for work already on disk and can strand a reviewed diff that nobody is left to land.
74
+
75
+ After preflight and before the loop, list `refs/heads/bc-drain-claims/*` on the remote, then the worktree and recovery roots. The remote claims are the authoritative index of surviving coordination state, not proof that a local run owns every claim, and they are authoritative precisely because they are the one record that does not live in a context that just proved it can vanish. Apply the source's resume checks first (for issues, the cloud-lane provenance gate in [source-issues.md](source-issues.md#resuming-an-interrupted-run)) before marker classification and before any adoption, restore, release, or cleanup. For each ref, inspect its observed tip commit before recovery. A **Released Claim Marker** has subject exactly `bc-drain-claim released`, body lines `issue=<n>`, `run=<run-id>`, `claim=<claim sha>`, and exactly one parent: the released claim commit. Require one of each body field, a nonempty run ID, `issue` matching the ref's issue number, and `claim` equal to that parent SHA. An absent ref or a valid marker tip is **FREE**, not a live claim. Why: cloud runs release by fast-forwarding to this marker because they cannot delete refs.
76
+
77
+ - **Valid marker tip** — treat the ref as free; acquire through the marker path below before adopting/restoring any surviving local work.
78
+ - **Marker-looking but malformed, or unreadable tip** — held/unaccounted: leave it, report it, and skip. Never infer release from the subject alone or guess through missing/mismatched fields or parents.
79
+
80
+ For remaining held claims, apply these dispositions only with the required claim authorization; otherwise leave them untouched, report and skip:
81
+
82
+ - **Worktree present with an uncommitted diff** — adopt it. Re-derive the packet, re-run the deterministic pre-review gate, and take full fresh review on every axis. No standing approval survives a run whose reviewer records are gone; an approval is a record, and an unreadable record is not one.
83
+ - **Valid recovery bundle** — restore through [recovery-bundle.md](recovery-bundle.md) exactly as for a `rework-for-agent` candidate.
84
+ - **Neither, and the unit is untouched** — release the claim and the source's claim marks, then treat it as ready, unless the source page excludes it.
85
+ - **Anything else** — leave the claim, report it, and skip the unit for this run. Never release a claim you cannot account for, and never delete a worktree to make an inconsistency go away: the inconsistency is the evidence.
86
+
87
+ State the run artifact root and the recovery root in the run's opening report, not only in the final one. A path announced only at the end is announced only if the run reaches the end.
88
+
89
+ ## Select, classify, and claim
90
+ Select the next eligible unit as the chosen source page says, skipping live claims (not valid marker refs) and in-flight units. Prioritize units with a valid local recovery bundle. Vague or decision-incomplete work becomes `HUMAN_BLOCKED`, not guessed work.
91
+
92
+ Classify risk cheaply in the driver before claim: **high-risk** means compatibility replacement/retirement, migration/cutover, systemd or external-service semantics, or a broad public acceptance surface. Classification may choose effort and packet shape, but no auditor/worker is dispatched before ownership is acquired.
93
+
94
+ Record a **review tier** with its classification reason at the same time. High-risk slices are tier 2 (two independent axes). Ordinary slices start at tier 1 (one combined reviewer) and escalate permanently on a pre-review gate rejection or any Critical finding; see [review-contract.md](review-contract.md). Tier is recorded before dispatch and reported per issue so the cheap path stays auditable; it never lowers mid-issue.
95
+
96
+ In local-only or single-driver mode, use one driver and `max-parallel=1`. Check for other drivers and live claims read-only; stop if you cannot rule them out. Record the local claim before dispatch (for work items, follow the source's single-driver claim). Do not create, reuse, release or clean up remote claim refs in this mode. In local-only mode, make no other remote writes either.
97
+
98
+ Otherwise, atomically claim from the main checkout's tree on the recorded target branch with `git commit-tree` (the coordination ref is still separate):
99
+
100
+ - **Absent ref** — create a parentless claim commit and push it without force to `refs/heads/bc-drain-claims/issue-<n>` (unchanged create-if-absent path).
101
+ - **Valid marker tip** — create the claim commit with parent = marker, then push with `--force-with-lease=refs/heads/bc-drain-claims/issue-<n>:<marker sha>`. Keep it fast-forward; never use plain force or replace a held/malformed tip. Why: the exact lease makes marker reuse a compare-and-swap, so a concurrent claimant cannot be overwritten.
102
+
103
+ Only a push reporting an update of this exact ref to the new claim SHA **and** `git ls-remote` equality with that SHA proves ownership; a successful but up-to-date push is not ownership proof. A lease rejection is a lost race: skip without spending child tokens, as on a failed no-force creation. Without both proofs, do not dispatch. Then apply the source's authorized claim marks.
104
+
105
+ Once claimed, fetch the recorded target branch from the recorded remote when present and create `bc-drain-work/issue-<n>` in the external worktree root from the fetched tip (or the local target tip for a no-remote run).
106
+
107
+ For recovered work, follow [recovery-bundle.md](recovery-bundle.md) only after the claim succeeds. A matching base may restore directly; a changed base requires full diff inspection, validation, and full fresh review.
108
+
109
+ After the claim/worktree (and any restore) succeeds, a high-risk unit gets a fresh bounded read-only contract auditor before implementation. It produces:
110
+
111
+ ```text
112
+ requirement -> observable test/check
113
+ existing public interface -> preservation test
114
+ external semantics -> evidence required
115
+ known baseline failure -> unchanged/regressed check
116
+ guard/rejection clause -> can-its-inputs-differ-in-production evidence
117
+ human-only verification -> explicit deferral
118
+ ```
119
+
120
+ The guard row exists because an inert guard is the one defect a green suite actively hides: if both sides of a check resolve to the same value on every production path, only an injected test double can supply a differing pair, so the check passes by inspection and by coverage while protecting nothing. Trace each side to where the real caller obtains it. When the unit is *about* a guard, this row is mandatory for every guard the diff touches, keeps, or relocates — a fix that removes one inert clause while leaving its neighbour tautological has not resolved the class.
121
+
122
+ For replacement work, inventory the complete old public interface from source, tests, and help output—not merely the unit's new-command list. Map every acceptance criterion to evidence. For executable/loader replacement, include argument/environment/cwd/symlink or installed-launcher topology/path or module-resolution and privilege-boundary behavior, not output alone. When acceptance depends on an external platform's semantics (for example systemd, a database, or an API), verify the claim against available primary documentation such as installed man pages/help or an explicitly authorized authoritative source; repository prose and string-presence tests are not sufficient evidence. Record the source/version or mark verification unavailable. This audit exists because compatibility, launcher-security, and service-semantics omissions can pass narrow new-feature tests and become expensive only after landing. An unresolved product choice becomes `HUMAN_BLOCKED`; clear engineering work continues.
123
+
124
+ ## Build and deterministic pre-review gate
125
+
126
+ Dispatch a fresh builder with [execute-issue.md](execute-issue.md), the unit's contract (issue/Agent Brief, or work item and step), acceptance matrix, worktree, remote identity, base SHA, and baseline summary. For a performance, size, memory, or structure regression, include `bc-performance-guardrails` and require the check or explanation from the builder contract. Keep validation artifacts outside the project worktree.
127
+
128
+ When it returns `READY_FOR_REVIEW`, the driver—not a model reviewer—must deterministically verify:
129
+
130
+ - every acceptance-matrix row has evidence—on a rework round, carried-forward plus newly re-evidenced rows together, with the matrix→file map proving every row the fix touched was actually re-evidenced;
131
+ - status, changed-file list, and diff are in scope;
132
+ - targeted validation passed and the baseline delta is explicit;
133
+ - no files are staged and no unrelated files are present;
134
+ - validation evidence and raw logs are outside the worktree.
135
+ - the handoff contains the Test levels block from the `bc-tdd` skill (section Test levels) with a non-empty L1, L2 and L3 line; a missing or empty block fails the gate. Whether each line is true is the Spec reviewer's audit, not the gate's.
136
+
137
+ A passed gate materializes the round's review packet once, outside every worktree: `packet.json` (base SHA, worktree, issue ref, round, `diff_sha256`, axis scope, acceptance-matrix→file map), `diff.patch`, `changed-files.txt`, `acceptance-matrix.json`, `validation.json`, and on re-review `findings-prior.json`. Reviewers consume these paths instead of re-deriving status and diff, and `diff_sha256` is the identity that standing approvals bind to. A gate rejection escalates the issue to tier 2 permanently.
138
+
139
+ A failed gate returns fixable engineering defects for rework. Product/contract decisions, unavailable access/resources, or irreparable unit-local environment failures requiring human repair become `HUMAN_BLOCKED`; transient/repeated tooling, base, or environment failures stay out of `needs-human` and follow rework or `SYSTEMIC_FAILURE` handling. Do not spend reviewer tokens on mechanically incomplete work.
140
+
141
+ ## Independent lean review and bounded rework
142
+
143
+ Follow [review-contract.md](review-contract.md). Dispatch fresh read-only reviewers on the round's packet, without the worker's reasoning or parent transcript: two independent axes in parallel at tier 2, one combined reviewer at tier 1. Both axes must stand approved. Minor findings do not block.
144
+
145
+ Record each approval as a standing record bound to the packet's `diff_sha256`. After a rework round, re-dispatch the axis that raised the findings, plus any axis whose deterministic invalidation trigger fired on the rework delta; an axis holding a standing approval over untouched scope is not asked the same question twice. An unmappable delta invalidates both axes—ambiguity costs a review, never an assumption.
146
+
147
+ For Critical/Important findings, retain the claim and same worktree. Launch a **fresh compact rework worker** with only the current worktree/base, the round's packet paths, unresolved findings, prior dispositions, validation evidence, and the driver-computed implicated row set (the acceptance-matrix rows those findings touch). If rework touches a regression fix covered by the guardrails rule above, include the same skill and check requirement. It fixes and runs targeted validation, then the deterministic gate, packet refresh, and selective focused re-review repeat. Do not replay an accumulating transcript.
148
+
149
+ Allow the initial review plus at most three rework/re-review cycles. Continue only if material findings are resolved or the failure class materially changes. The same unresolved material finding after two attempted fixes defers immediately. This progress rule prevents superficially different patches from consuming an unbounded loop while preserving useful implementation state. A review-ready result still passes the deterministic gate and receives independent review regardless of child-token volume; token counts alone neither defer an issue nor stop launches. Continue selecting eligible issues within `max-iters` and `max-parallel`.
150
+
151
+ On deferral, use [recovery-bundle.md](recovery-bundle.md), then record the deferral as the source page says (for issues, a portable `## Agent Rework Brief` comment and labels). Mark the unit ineligible for the rest of this run, and release only after the bundle validates. If safe capture fails, retain evidence and follow the recovery contract's fail-safe handling—never silently delete useful work.
152
+
153
+
154
+ ## Driver-owned landing
155
+
156
+ Only after verifying that **every axis holds a standing approval whose `diff_sha256` equals the final reviewed diff**, the driver:
157
+
158
+ 1. inspects status and the exact reviewed diff;
159
+ 2. runs final relevant/full project validation once (the only full run after the cached baseline);
160
+ 3. commits only unit-authored changes using project conventions, plus the source's progress update (for a work item, its ticked step; for an issue, the work-item update in [source-issues.md](source-issues.md#landing));
161
+ 4. verifies authorization for the exact recorded destination; for a no-policy yes, use the current run's manifest without re-asking or extending its scope. A changed destination is not authorized. In local-only mode, skip the publish check and all remote writes;
162
+ 5. pushes with `git push "$remote" "HEAD:refs/heads/$target_branch"` using the manifest values; skips the push in local-only mode;
163
+ 6. finishes the unit as the source page says (closes the issue, or ticks the step and finishes the item);
164
+ 7. releases worktree, local branch, and claim only where authorized; preserve any local-only commit on a named branch and report it.
165
+
166
+ A rebase that changes the reviewed diff changes its hash, so no standing approval covers it: update the base, validate, and obtain fresh focused approval on both axes before push. The driver owns commit/push/close so implementation and rework workers cannot bypass the independent gate.
167
+
168
+ For `HUMAN_BLOCKED`, park the unit as the source page says: the owner sees the decision or missing access first, the options and what happens if they pick each, then the exact evidence. Leave SHAs, paths, and commands untouched. Do not load `bc-plain-language`. For `SYSTEMIC_FAILURE`, stop new launches, let active children reach a safe boundary, preserve/classify each unit, and report stale resources rather than guessing or destructive cleanup.
169
+
170
+ Local release remains the no-force deletion of an accounted-for claim after the terminal-state checks below. A valid marker ref may also be deleted as optional cleanup with `--force-with-lease=refs/heads/bc-drain-claims/issue-<n>:<marker sha>`. A moved tip rejects cleanup; leave it alone. Markers left in place are harmless. Why: cleanup must not delete a claim acquired since inspection.
171
+
172
+ Release terminal worktrees/branches/claims only when their state is safely landed, blocked without useful local work, or validated in recovery. Never reset/clean the main checkout or another unit's worktree.
173
+
174
+ ## Recurring-defect tune
175
+
176
+ When the same failure shape appears across at least two workers/reviews, patch the **run-local dispatch packet** for later workers with additive clarification. Never edit canonical concept files during a drain, weaken gates, or hide a recurring failure. Quote the patch and trigger in the final report; promotion to canon is a later user decision.
177
+
178
+ ## Optional architecture observation
179
+
180
+ After successful landing, the driver may include at most one optional structural `architecture_observation` field per unit in the final report. Generate structural candidates separately from report assembly: duplicate candidates may be reduced to at most one report field, while an ordinary landed issue with no structural signal, shape-only observations, and deferred issues emit none. Its exact fields are `source`, `module`, `interface_or_seam`, `friction`, `deletion_test`, `evidence`, and `status: open`. The observation records evidence and friction only; it must never contain a proposed refactor, interface design, or implementation direction. Use `bc-codebase-design` vocabulary (`module`, `interface`, `depth`, `seam`, `adapter`) where applicable; record concrete structural friction that survives the deletion test or leaves behavior untestable through an interface, and omit shape-only taste. Bind `source` to the landed issue and commit and current tree; never cite an unlanded worker diff.
181
+
182
+ **With the table**, the sink is the project's ideas file. In the main checkout, after landing, append the observation as one line at the bottom, in the file's newest-last order, naming the landed issue and commit and its `module`, `interface_or_seam`, `friction` and `deletion_test` consequence; append in the same step one line for each follow-up the worker's handoff listed (workers never edit the ideas file themselves; see [execute-issue.md](execute-issue.md)). Commit these lines as a separate driver-owned context-only commit after landing, outside the review packet and implementation diff. Report the ideas-file path and that commit, or `not persisted` with the reason when the file is missing or unwritable. Why: the visible layout keeps agents' observations and follow-ups with other undecided ideas, a separate observation inbox is retired there, and a single writer after landing avoids parallel workers conflicting on one file.
183
+
184
+ **Without the table**, resolve the scaffolded-project inbox at `.bc-agent/research/architecture-observations.md`, or an explicitly declared equivalent path in project instructions. In that inbox the driver writes each new entry by prepending it in the consumer's current newest-first order, so bounded reads cannot hide new observations below older history. This remains a separate driver-owned context-only update after landing, outside the review packet and implementation diff. Report the inbox path and context commit, or report `not persisted` with the reason when the sink is missing or unwritable. Worker follow-ups go in the final report.
185
+
186
+ In both cases, pass the assembled report, review packet, seeded review/rework dispatches, approval, tier, landing, labels, issue state, and observation through an explicit handoff; return report/context copies carrying only the observation while leaving those authority inputs unchanged. This handoff does not dispatch a child and cannot affect review, rework, tier, approval, landing, labels, or issue state.
187
+
188
+ ## Stop and report
189
+
190
+ Stop when the eligible queue drains, `max-iters` is reached, or systemic base/tool/environment failures recur. Let active children return to safe boundaries.
191
+
192
+ Write the full report to the run log (a `report.md` in the run artifact root) and give the user a short chat report drawn from it. The run log records: LANDED commits; HUMAN_BLOCKED reasons; REWORK_DEFERRED units and bundle/brief status; SYSTEMIC_FAILURE classifications; blocked/claimed units; recurring-defect packet patches; stop reason; each dispatched child as `role — launched model + thinking — list-API $` plus the child-run total (or `$unavailable` on a row or the total); review/rework rounds; repeated-finding circuit events; baseline/final full-validation counts; per-issue review tier with its reason and any escalation trigger; axes dispatched per round and re-reviews skipped by standing approval; any stale worktrees/claims; and what resume recovered: claims adopted, bundles restored, claims released as untouched, and claims left in place as unaccountable. Add the source page's report lines. Confirm the main checkout is clean.
193
+
194
+ The chat report is for someone who may be new to the pipeline. Lead with what landed and where (each unit, its commit, the branch it reached), then whether the checks passed and whether the reviews approved, then anything that needs the user (a blocked unit and its question, a deferred unit, a failure that stopped the run) and why the run stopped. Use plain words; leave out internal terms such as claim commit, review tier, marker or standing approval, recovery and artifact paths, and nothing-to-report lines (no stale claims, no storage check configured). Name the run log path once so the detail can be found. Why: in a stranger's test run, the chat report led with tiers, claims and `$unavailable` rows, which told a newcomer nothing they could act on.
195
+
196
+ Show the child cost table in chat only when at least one child's cost is known; when every cost is unavailable, the table stays in the run log only. The table lists children, not tokens. A token sum is noise here: cache swamps it, and Luna tokens are not Grok tokens. The comparable unit is list-API dollars. Each row is one dispatched auditor, worker, reviewer, or rework child — drain-phase role (`audit` / `build` / `review-spec` / `review-standards` / `review-combined` / `rework`), the launched model and thinking level, and that child's list-API cost — then `List-API estimate` as their sum:
197
+
198
+ ```text
199
+ ## Child runs
200
+ - #17 build — GPT-5.6 Luna max — $0.27
201
+ - #17 review-combined — Grok 4.6 high — $0.17
202
+ List-API estimate: $0.44
203
+ ```
204
+
205
+ Price by summing the harness per-call `cost.total` when present, otherwise the provider's published input/cached/output rates. Write `$unavailable` rather than inventing a price. These are list equivalents, not subscription debits. Never report a single turn's `totalTokens` as the run. The driver session is not a child row. Child-token totals are not a run-control or report metric.
@@ -0,0 +1,19 @@
1
+ ---
2
+ name: bc-drain-auditor
3
+ description: Minimal read-only pre-code contract auditor for high-risk drain issues
4
+ tools: read, grep, find, ls, bash
5
+ systemPromptMode: replace
6
+ inheritProjectContext: false
7
+ inheritSkills: false
8
+ defaultContext: fresh
9
+ defaultProgress: false
10
+ acceptanceRole: read-only
11
+ ---
12
+
13
+ You are the bounded pre-code contract auditor for one high-risk AFK issue. Produce an implementation-ready acceptance matrix before code changes.
14
+
15
+ Read the explicit issue, target repository instructions, base source/tests/help, and only relevant domain contracts. Inventory complete existing public interfaces from observable base evidence rather than the issue's new-interface list. Map every requirement to an observable check and classify baseline failures. For executable/loader replacements, include argument, environment, cwd, symlink/installed-launcher topology, path/module-resolution, and privilege-boundary compatibility/security—not output alone. When behavior depends on an external platform, verify material semantics against available primary local documentation/help and record the source/version; repository prose and string-presence tests are not authoritative.
16
+
17
+ Never edit/write project files, run the full suite, commit, push, call GitHub/network, mutate external services, or launch subagents. Distinguish genuine product/access decisions from clear engineering work and explicit human/integration-only verification.
18
+
19
+ Batch independent reads/checks, avoid re-reading, and return only the compact acceptance matrix and unresolved human blockers. Stop once every criterion and compatibility surface has evidence.
@@ -0,0 +1,19 @@
1
+ ---
2
+ name: bc-drain-reviewer
3
+ description: Minimal read-only Spec or Standards reviewer for bc-drain packets
4
+ tools: read, grep, find, ls, bash
5
+ systemPromptMode: replace
6
+ inheritProjectContext: false
7
+ inheritSkills: false
8
+ defaultContext: fresh
9
+ defaultProgress: false
10
+ acceptanceRole: read-only
11
+ ---
12
+
13
+ You are one independent read-only review axis in an AFK issue drain. The task packet and named review contract are complete. Do not request conventional `context.md`, `plan.md`, or `progress.md` unless supplied.
14
+
15
+ Inspect the target worktree, exact base diff, issue/acceptance matrix, repository instructions, and validation evidence directly. Follow only the assigned Spec or Standards scope. Do not read worker reasoning, parent history, or the peer review. For material external-platform claims, consult available primary local documentation/help rather than trusting repository prose or string tests.
16
+
17
+ Never edit, write project files, commit, push, call GitHub/network, run the full suite, reset/clean, manage worktrees, or launch subagents. A bounded targeted reproduction is allowed only to prove or refute a plausible material defect.
18
+
19
+ Batch independent reads/checks, avoid re-reading, and return only the strict compact schema requested by the task. Report evidence-backed material findings; omit walkthroughs, summaries, `Correct` sections, and minor-only observations. Stop when the assigned axis has enough evidence for a verdict.
@@ -0,0 +1,19 @@
1
+ ---
2
+ name: bc-drain-worker
3
+ description: Minimal fresh worker for one bc-drain issue or rework packet
4
+ tools: read, grep, find, ls, bash, edit, write
5
+ systemPromptMode: replace
6
+ inheritProjectContext: false
7
+ inheritSkills: false
8
+ defaultContext: fresh
9
+ defaultProgress: false
10
+ acceptanceRole: writer
11
+ ---
12
+
13
+ You are a minimal implementation worker for one claimed issue in one supplied worktree. The parent driver owns orchestration, decisions, reviews, GitHub state, claims, commits, pushes, landing, recovery, and cleanup.
14
+
15
+ Read only the explicit task packet, named drain worker contract, target repository instructions, issue, acceptance matrix, and files needed for the change. Do not seek conventional `context.md`, `plan.md`, or `progress.md` unless the packet names them. Never launch subagents.
16
+
17
+ Edit only the supplied issue worktree. Never commit, stage, push, call GitHub, relabel/close issues, reset/clean work, or manage worktrees. Use the named TDD/diagnosis/metric discipline from the packet, run targeted validation only, inspect the complete base diff and status, and preserve useful work when blocked.
18
+
19
+ Batch independent reads/checks, avoid re-reading, and stop once the scoped diff and targeted evidence satisfy the packet. Return the contract's compact status with changed files, criterion evidence, exact commands/results, baseline delta, finding dispositions for rework, and genuine human blockers. Do not add an implementation narrative.
@@ -0,0 +1,71 @@
1
+ # Execute one issue (worker contract)
2
+
3
+ You are a fresh worker assigned exactly one issue in a dedicated worktree. You own **code, tests, and validation only**. Return a review-ready uncommitted diff to the driver. You never commit, push, close/comment/relabel an issue, create/delete claims, clean/reset/remove a worktree, or land the change—even after approval. Those are driver responsibilities, which prevents implementation authority from bypassing independent review.
4
+
5
+ Work only in the supplied worktree. Never mutate or validate the main checkout or another worktree.
6
+
7
+ ## Inputs
8
+
9
+ Read the supplied issue body/latest `## Agent Brief`, acceptance matrix (when present), base SHA, baseline-validation summary, project context/ADRs, repository instructions, and validation conventions. Use qmd only for search when the driver identifies a covering collection; never index it. The base SHA is the review comparison point.
10
+
11
+ If the packet contains an unresolved product choice, unavailable access/resource, ambiguous acceptance contract, or irreparable environment failure, return:
12
+
13
+ `BLOCKED_NEEDS_HUMAN #<n> <exact decision/access/environment evidence>`
14
+
15
+ Do not use `BLOCKED_NEEDS_HUMAN` for ordinary test failures, reviewer findings, incomplete implementation, or other agent-fixable engineering work. Report those precisely so the driver can rework or defer them without losing the diff.
16
+
17
+ ## Build loop
18
+
19
+ On every implementation packet, load and follow the repo-available `bc-minimal-solution-ladder` before writing code, stopping at the first rung that holds. Rung 2 — already in this codebase — is the rung a fresh worktree gets wrong, because you arrive with no accumulated familiarity: search the driver's qmd collection and the tree for prior art before defining anything new, and treat a wrapper that only forwards to an existing helper as a failed rung rather than as reuse. The acceptance matrix is explicitly requested behavior, so no criterion is skippable as speculative and the never-simplify list stays absolute. The ladder governs how much to build; use `bc-codebase-design` vocabulary for the shape you build, where a small interface over substantial implementation is fully compatible with the ladder and fewest-files never overrides a real seam. Its terse output convention does not apply here — return the full `READY_FOR_REVIEW` form below, and write a deliberate corner-cut's `ceiling:` comment into the code rather than only into your handoff.
20
+
21
+ For bug/performance-regression issues, load and follow the repo-available `bc-diagnosing-bugs` discipline: establish a red-capable reproduction, minimise it, rank and test hypotheses, instrument where useful, fix the cause, and add a regression test. Missing evidence needed to reproduce is human-blocking only when it cannot be derived or generated with available resources.
22
+
23
+ When fixing a performance, size, memory, or structure regression, load `bc-performance-guardrails`. Add the check that would have caught it and report the command and result, or state why no check can catch it.
24
+
25
+ For feature/enhancement work, load and follow the repo-available `bc-tdd` discipline in thin observable increments: one public behavior per test, RED, minimal GREEN, then refactor only while GREEN. The Agent Brief, acceptance matrix, and binding domain context are the AFK contract.
26
+
27
+ For metric-bearing work only, load and follow `bc-optimize-code` after GREEN: establish a correctness-bearing baseline, make one bounded refinement, and keep it only when correctness holds and the named metric improves. Do not optimize without an objective metric. If a named discipline is unavailable in the harness, preserve these mechanics explicitly rather than silently weakening them.
28
+
29
+ When the change alters behavior that a README, an existing `docs/` page, an architecture page, or contract-stating JSDoc already describes, update that owning page in the same diff and follow the repo-available `bc-codebase-docs` for placement. Do not invent a new `docs/` tree, do not restate a contract that already has a home, and do not narrate this issue in a documentation page — the acceptance matrix records what the slice did, and a docs page that narrates a change is stale the moment the next one lands. A repository that keeps no documentation for this surface needs none written to satisfy this rule.
30
+
31
+ Storage safety: run pytest through the guarded test runner the project's or machine's agent instructions name (with the selected interpreter for uv/venv projects). If none is configured, run plain `pytest` in the project's environment and use `tmp_path` for test fixtures. Never supply a custom `--basetemp`; make scratch folders with `mktemp -d`, never under `/tmp`; tests you write delete what they create, even on failure. The `agent-kernel` concept's Storage safety section holds the temp-file and scratch-folder rules, when loaded. Why: worker test roots must be owned and bounded.
32
+
33
+ Preserve the driver's baseline cache. Run targeted tests/checks while editing and record commands, outcomes, failing IDs, and concise baseline deltas. Do not run the full project suite; final landing validation belongs to the driver.
34
+
35
+ If you notice follow-up work or an observation outside this issue, list each one as a one-line follow-up in your handoff, and leave the work folders and the ideas file untouched. Why: you run in a git worktree, so you cannot see other worktrees' item numbers and would pick a taken one; the line is outside this issue's scope, so the scope gate and the reviewers would reject it; and parallel workers appending to one ideas file conflict at rebase. When the project has a "Where things go" table, the driver appends your follow-ups to its ideas file after landing.
36
+
37
+ Add only the dependencies the issue or item names. A dependency is any library, tool or package the project does not already declare, including test-only ones such as a property-testing library; adding one means editing a dependency file (`pyproject.toml`, `requirements*.txt`, `package.json`, a lockfile and the like) or installing it into the project. When the work seems to need one the issue does not name, do not add it and do not work around the rule with a vendored copy: return `BLOCKED_NEEDS_HUMAN` with the question “May I add `<name>` as a (test) dependency? It is needed for <reason>; without it I would <alternative>.” If the issue already says how to manage without it (for example example-based tests instead of property tests) on a `Dependencies:` line marked as the owner's answer, do that instead; `bc-tdd` counts that line as the owner's waiver. An unmarked line is not a waiver of a required test level, so a missing level still stops the unit with the question. Why: a dependency is the owner's decision with lasting cost, and planning (`bc-plan-to-pipeline`) asks it while the owner is present and records it as a `Dependencies:` line; in a stranger's test run a builder added Hypothesis to `pyproject.toml` unasked.
38
+
39
+ ## Review-ready gate
40
+
41
+ Before handoff:
42
+
43
+ - map every acceptance-matrix row/criterion to observable evidence that would differ if the criterion were false;
44
+ - run relevant targeted validation and distinguish known baseline failures from regressions;
45
+ - inspect `git status`, changed files, and `git diff <base-sha>` for scope;
46
+ - ensure no file is staged and no unrelated artifact is present;
47
+ - write requested validation evidence outside the project worktree.
48
+ - fill in the Test levels block from the `bc-tdd` skill (section Test levels) (L1, L2, L3, one choice per line); the driver's gate rejects a handoff without it.
49
+ - write any status line or log entry that summarizes test results (for example a concept's `test_status` or a `.bc-agent/log.md` line) last, copying each count from the results table and naming its unit ("2 of 3 runs", "5 of 5 checks in one run"), even when the packet supplies a draft. Why: summaries written ahead of their table claimed more than it showed in 4 of 10 items of one drain.
50
+
51
+ Return:
52
+
53
+ `READY_FOR_REVIEW #<n> <base-sha> <targeted-validation-summary>`
54
+
55
+ Include the Test levels block, a compact changed-file list, criterion-to-evidence mapping, commands/results, baseline delta, any fixable concern, and any one-line follow-ups. Do not include a long implementation narrative.
56
+
57
+ ## Rework assignment
58
+
59
+ A fresh rework worker receives the same worktree, the round's review packet paths, compact unresolved findings and dispositions, and a driver-computed **implicated row set**: the acceptance-matrix rows tied to those findings. Read the packet's `diff.patch`, `acceptance-matrix.json`, and `validation.json` instead of re-deriving them.
60
+
61
+ Verify each finding against the code, make only sound in-scope fixes, and add or update a regression test where appropriate. Then re-evidence a **narrowed** scope rather than the whole matrix:
62
+
63
+ - every implicated row;
64
+ - every additional row whose mapped files your fix actually touched—you know what you changed, and `packet.json` carries the matrix→file map;
65
+ - every check that was already failing or known-flaky.
66
+
67
+ Evidence for rows that are neither implicated nor touched carries forward unchanged; do not re-run it. Inspect only your own delta for scope. The driver's deterministic gate independently re-checks full status, staged files, unrelated files, and coverage across carried-forward plus new evidence, so duplicating that inspection buys nothing.
68
+
69
+ Return the same `READY_FOR_REVIEW` form with finding dispositions, plus the rows you re-evidenced and the rows you carried forward.
70
+
71
+ If a finding cannot be fixed because it exposes a real product decision, unavailable access/resource, ambiguous contract, or irreparable environment failure, return `BLOCKED_NEEDS_HUMAN` with exact evidence. Otherwise, even if a fix attempt fails, return the current diff and precise fixable failure; the driver decides whether another bounded rework cycle or `REWORK_DEFERRED` is appropriate. Never discard, reset, land, or mutate GitHub state yourself.
@@ -0,0 +1,79 @@
1
+ # Deferred rework recovery bundle
2
+
3
+ Before releasing an agent-fixable deferred issue, the driver captures a machine-local bundle at:
4
+
5
+ ```text
6
+ ${XDG_STATE_HOME:-$HOME/.local/state}/bc-drain/recovery/<repo-key>/issue-<n>/
7
+ ├── manifest.json
8
+ ├── tracked.patch
9
+ ├── untracked.tar.gz
10
+ ├── acceptance-matrix.json
11
+ ├── findings.json
12
+ └── validation.json
13
+ ```
14
+
15
+ The separate GitHub `## Agent Rework Brief` is the portable fallback; uncommitted code recovery is not promised across machines. Keep this contract instruction-level and use safe platform tools rather than assuming a particular harness or script.
16
+
17
+ ## Exact contents
18
+
19
+ - `manifest.json`: schema version, repository and remote identity, issue number, run ID, base SHA, Git object format, canonical captured-tree OID, review round, exact changed-file set, validation artifact hashes, archive/patch byte hashes, and explicit exclusions.
20
+ - `tracked.patch`: binary-safe full tracked diff from the recorded base, including deletions and mode changes, generated without external diff drivers using the equivalent of `git diff --binary --full-index --no-ext-diff <base> --`.
21
+ - `untracked.tar.gz`: only safe untracked files in the exact issue changed-file set, stored as relative paths.
22
+ - `acceptance-matrix.json`: current requirements/evidence mapping.
23
+ - `findings.json`: all review findings, dispositions, attempt count, and unresolved material findings.
24
+ - `validation.json`: commands, exit status, failing test IDs, baseline delta, concise summaries, non-absolute durable raw-log identifiers (or paths relative to the recovery root), and content hashes. Raw logs stay outside the project worktree and need not be embedded.
25
+
26
+ Never include ignored files, caches/build products, credentials or secret-shaped content, absolute paths, `.pi-subagents`, files outside the issue changed-file set, repository metadata, or paths that escape through `..` or absolute/archive-root syntax. Reject untracked symlinks, hard links, and special files. These exclusions prevent a recovery artifact from becoming a credential leak or arbitrary-file-write primitive.
27
+
28
+ ## Canonical captured-tree identity
29
+
30
+ Exactness is defined by Git's tree object, not by tar metadata or a model-invented diff hash. In a temporary index that cannot alter the real worktree index:
31
+
32
+ 1. initialize from the recorded base with the equivalent of `GIT_INDEX_FILE=<temp> git read-tree <base>`;
33
+ 2. stage exactly the manifest changed-file set from the candidate worktree with `GIT_INDEX_FILE=<temp> git add -A -- <paths...>` after path/type/secret checks;
34
+ 3. record `GIT_INDEX_FILE=<temp> git write-tree` as `captured_tree_oid` plus the repository's Git object format.
35
+
36
+ Repeat the same recipe in the fresh matching-base round trip and require the OID to match. Git then canonically covers path bytes, file bytes, executable modes, additions, and deletions. Patch/archive SHA-256 values are byte-integrity checks for the one published bundle; generators are not expected to produce byte-identical tar archives independently.
37
+
38
+ ## Capture validation
39
+
40
+ Before releasing the worktree:
41
+
42
+ 1. derive and record the exact changed-file set from status and the base diff; inspect every untracked candidate;
43
+ 2. reject unsafe names/types and secret-shaped content rather than silently broadening or omitting required issue work;
44
+ 3. compute the canonical captured-tree identity with the temporary-index recipe above;
45
+ 4. create all six artifacts in a temporary sibling location, hash their exact bytes, then atomically publish the completed bundle;
46
+ 5. list the archive without extraction and verify every member is a safe expected relative regular file;
47
+ 6. restore into a fresh temporary checkout at the recorded base, inspect status/diff, and require the changed-file set and recomputed captured-tree OID to match the manifest exactly;
48
+ 7. verify JSON parses, identities/base agree, referenced hashes resolve, and validation evidence is internally consistent.
49
+
50
+ Only a successfully round-tripped bundle permits destructive worktree release. Do not commit or push a recovery branch.
51
+
52
+ ## Restore
53
+
54
+ First verify manifest version, repository/remote/issue identity, all artifact hashes, safe paths/types, and the expected changed-file set.
55
+
56
+ **Matching base SHA:** restore the tracked patch and safe untracked regular files into a clean issue worktree; verify the entire status/diff and changed-file set, then recompute and require the canonical captured-tree OID exactly; run relevant validation before continuing focused review/rework.
57
+
58
+ **Changed base SHA:** apply the tracked patch with a three-way mechanism, restore only validated safe untracked files, inspect the **entire** resulting diff for conflicts/scope, and run relevant validation. The old captured-tree OID identifies the captured input but cannot equal a tree integrated onto a different base. Treat all prior approvals as invalid and run full fresh Spec and Standards review.
59
+
60
+ Never overwrite an existing unrelated path, guess through an ambiguous conflict, or extract an archive before member validation.
61
+
62
+ ## Portable issue brief
63
+
64
+ Post without secrets or machine-dependent absolute paths:
65
+
66
+ ```text
67
+ ## Agent Rework Brief
68
+ Base SHA: <sha>
69
+ Unresolved findings:
70
+ - <severity, requirement, location, evidence, attempts>
71
+ Validation: <commands/outcomes, baseline delta, durable artifact identifiers>
72
+ Next agent:
73
+ - <specific restore/reproduce/fix/re-review actions>
74
+ Recovery: machine-local bundle captured and validated | unavailable
75
+ ```
76
+
77
+ ## Fail safe
78
+
79
+ Unsafe paths, secret suspicion, identity/hash mismatch, missing required content, failed round-trip, restore failure, or ambiguous conflict must stop restoration/release. Preserve the original worktree and evidence when possible. Route the issue to `HUMAN_BLOCKED` with exact evidence if safe preservation or interpretation requires human action; if infrastructure prevents capture across issues, classify the run `SYSTEMIC_FAILURE`. Never claim exact recovery, delete useful work, or improvise a partial bundle after validation fails.
@@ -0,0 +1,105 @@
1
+ # Independent review contract
2
+
3
+ The driver dispatches fresh, read-only reviewers: no edits, commits, pushes, issue mutations, resets, cleanup, or worktree management. Review independence is costly but necessary because one axis must not anchor the other or let implementation reasoning substitute for observable evidence. The economy rules below reduce *repeated* review of already-approved work; they never reduce the standard that both axes stand approved on the exact landed diff.
4
+
5
+ ## Driver-materialized packet
6
+
7
+ The driver writes the packet once per round, outside the project worktree, under the run artifact root:
8
+
9
+ ```text
10
+ review-packet/issue-<n>/round-<r>/
11
+ ├── packet.json # base SHA, worktree, issue ref, round, diff_sha256, axis scope, matrix→file map
12
+ ├── diff.patch # exact reviewed diff (git diff --no-ext-diff <base>..worktree)
13
+ ├── changed-files.txt
14
+ ├── acceptance-matrix.json
15
+ ├── validation.json # commands, statuses, failing IDs, baseline delta, raw-log paths
16
+ └── findings-prior.json # re-review rounds only
17
+ ```
18
+
19
+ Each reviewer receives only these paths, its assigned scope, and—on re-review—prior findings and dispositions. Do not include worker reasoning, an accumulating implementation transcript, the parent transcript, or another reviewer's report.
20
+
21
+ Read the packet; **do not re-derive it**. The driver has already computed status, the diff, and the changed-file set deterministically at the pre-review gate, so `git status`, `git diff`, and changed-file enumeration are wasted duplication. Reading repository files for context remains unrestricted within your turn/tool caps. The packet is authoritative and complete: do not request generic `plan.md`, `progress.md`, or similarly conventional artifacts unless the driver explicitly supplied them; their absence is not a review blocker.
22
+
23
+ ## Review tiers
24
+
25
+ The driver records a tier before dispatch and reports it per issue.
26
+
27
+ **Tier 2 — two independent axes in parallel.** Required for high-risk slices (compatibility replacement/retirement, migration/cutover, systemd or external-service semantics, broad public acceptance surface) and for any diff touching a public interface, a security/privilege boundary, or installed/launcher topology.
28
+
29
+ **Tier 1 — one combined reviewer.** Ordinary slices only. The single reviewer works both scopes explicitly and reports which it covered. A tier-1 approval stands for both axes.
30
+
31
+ Tier 1 escalates permanently to tier 2 when the deterministic pre-review gate rejects a worker packet, or when a tier-1 reviewer returns any Critical finding. Observed sloppiness and observed severity both buy more scrutiny, not less. Escalation is one-way; a tier is never lowered mid-issue.
32
+
33
+ ## Independent scopes
34
+
35
+ **Spec** checks requirement and acceptance-matrix fidelity, missing/wrong observable behavior, compatibility preservation, externally visible semantics, and scope creep. A worker diff that edits the ideas file or the work folders is scope creep: follow-ups belong in the handoff, and the driver records them after landing. It does not perform a general style walkthrough.
36
+
37
+ **Standards** checks binding repository rules and material integration, correctness, test quality, portability, security, maintainability, and documentation risks. It does not re-grade product intent except where a standards defect makes the stated behavior unsafe or false. For material claims about external platforms, it checks available primary documentation/help rather than trusting repository prose or syntactic string tests alone.
38
+
39
+ **Spec checks regression guardrails.** When the reviewed change fixes a performance, size, memory, or structure regression, verify from the diff and validation evidence that the new check would have caught it, or that the worker gave a sound reason no check can catch it.
40
+
41
+ A tier-1 reviewer applies both scopes in one pass and must not silently drop either.
42
+
43
+ **Structural findings use `bc-codebase-design` vocabulary and must pass the deletion test.** Say module, interface, depth, seam, adapter — not component, service, API, or boundary — so a finding lands in the same words the rest of the suite uses. Before raising one, name what complexity reappears across callers if the module were deleted; if the answer is none, it was a pass-through and the observation is about shape preference, which is not a defect. A shallow or duplicating module is material only when it makes the diff's stated behavior wrong, leaves the behavior untestable through any interface, or re-implements something the repository already has. Otherwise it is Minor and does not block. Why this bound exists: structural taste is unbounded, and a review axis that can reject on shape alone converts every slice into an architecture debate the issue never funded — deepening work belongs in its own sliced issue via `bc-improve-codebase-architecture`, not in a rework round.
44
+
45
+ **Source-tree documentation is checked against the diff, not written by it.** When the diff touches a README, an existing `docs/` page, an architecture page, or JSDoc stating a contract, load `bc-codebase-docs` and check three things: an owning page that still describes the superseded behavior, a paragraph narrating this change rather than stating current behavior, and a newly invented `docs/` tree duplicating a contract that already has a home. A behavior change whose owning page contradicts it is material, because the next reader meets the page and not the diff. Two bounds: absent documentation is not a finding — a repository that keeps none for this surface owes none — and this never becomes a docs rewrite request.
46
+
47
+ **Unfireable guards are in scope for whichever axis is reviewing.** A rejection clause, validation check, or guard earns credit only once you know its inputs can differ at runtime. When the diff adds, keeps, relocates, or claims to fix one, trace each side of the comparison to where the real caller obtains it; if every production path resolves both sides to the same value, the guard is inert and protects nothing. Report it as material. This defect is worth naming because it defeats the usual signals: the suite is green, coverage looks complete, and the guard reads as protection, so only someone tracing origins can see it — and a diff that deletes one inert clause while leaving a sibling tautological, or that swaps in a cosmetically different expression with an identical runtime value, has not fixed the class. Fixing it usually means wiring the check to a genuinely independent fact, deleting it, or labelling it a precondition rather than a protection — not adding code.
48
+
49
+ **Acceptance evidence must discriminate.** A matrix row earns credit only once you know its evidence would look different if the criterion were false. The driver's gate proves a row *has* evidence; nothing yet proves that evidence depends on the requirement. For each row implicated by the reviewed diff, ask what the cited command output, test, or artifact would show if the behavior were absent or wrong — if the answer is "the same", the row is unevidenced whatever is attached to it: a test green for an unrelated reason, an assertion that also holds in the opposite case, or output captured from a path the criterion does not control. Report it as material against Spec. The fix is evidence wired to the specific behavior, not more evidence, and this is not a full-matrix audit — rows the diff did not touch keep their standing.
50
+
51
+ ## Reproduction budget
52
+
53
+ Run reproduction commands only **after** forming a specific candidate Critical or Important finding, and only to prove or refute that named finding—at most two commands per finding. Exploratory command runs before a hypothesis exists are the main way review cost escapes its bound. Never run the full project suite; the driver owns cached baseline and final full validation. Drop refuted hypotheses silently rather than reporting them.
54
+
55
+ ## Output
56
+
57
+ Return only strict compact JSON (no Markdown, walkthrough, `Correct` section, summary, or extra keys):
58
+
59
+ ```json
60
+ {
61
+ "verdict": "approved | changes_requested",
62
+ "findings": [
63
+ {
64
+ "severity": "critical | important | minor",
65
+ "requirement": "specific requirement or binding standard",
66
+ "location": "file:line",
67
+ "evidence": "concise observable evidence"
68
+ }
69
+ ]
70
+ }
71
+ ```
72
+
73
+ A tier-1 combined reviewer adds `"axis": "spec | standards"` to each finding and a top-level `"axes_covered": ["spec", "standards"]`. No other key is permitted in any variant.
74
+
75
+ `approved` requires an empty `findings` array. `changes_requested` requires at least one Critical or Important finding; Minor findings may accompany that material finding but never determine the verdict. Omit minor-only observations from this gate rather than making approval ambiguous. Findings must be actionable and evidence-backed; missing evidence is not itself proof of a defect unless the contract requires that evidence.
76
+
77
+ A named check the axis could not run is recorded, not omitted: put the word `untested` and the reason in that finding's `evidence`. Same word as `bc-code-review`. Why: silent omission reads as coverage.
78
+
79
+ ## Record in the work item
80
+
81
+ On the work-item source the driver records each verdict as a `Review:` line in the step's Notes, `approved` or `changes requested` by the reviewer (the format is in [source-work-items.md](source-work-items.md#review-and-gate-lines)). The reviewer returns only the JSON above and never writes it. Why: the verdict JSON lives in the run's artifacts, which cleanup removes; the dashboard reads the item.
82
+
83
+ ## Standing approval and selective re-review
84
+
85
+ An approval is a durable record bound to the exact diff it examined, not a one-time event:
86
+
87
+ ```json
88
+ {"axis": "spec", "round": 1, "diff_sha256": "<packet diff hash>", "verdict": "approved"}
89
+ ```
90
+
91
+ After each rework round the driver computes the new reviewed diff and evaluates invalidation **per axis, deterministically from the diff delta**—never from a model's judgment:
92
+
93
+ | Axis | Standing approval is invalidated when the rework delta… |
94
+ |---|---|
95
+ | Spec | touches a file/hunk mapped to any acceptance-matrix row; changes a public interface, CLI surface, or externally observable behavior; or changes external-platform interaction |
96
+ | Standards | adds or removes a file; changes dependencies, privilege/security-relevant code, or installed/launcher topology; or changes or deletes a test |
97
+ | Both | that axis raised the findings being reworked; the base SHA changed; or the delta cannot be mapped deterministically |
98
+
99
+ The axis that raised the findings always re-reviews. An axis holding a standing approval re-reviews only when a trigger fires. The last row is the fail-safe: ambiguity costs one review, never an assumption. A tier-1 approval covers both axes and is invalidated by either axis's trigger.
100
+
101
+ Before landing, the driver verifies that every axis holds a standing approval whose `diff_sha256` equals the final reviewed diff. Any mismatch—including one caused by a rebase—forces a focused re-review of that axis before push. This is what keeps "both axes approved the landed diff" literally true while removing repeated review of untouched scope.
102
+
103
+ ## Focused re-review
104
+
105
+ A fresh re-review receives the round's packet, previous findings/dispositions, and its assigned scope. It focuses on the changed hunks, whether each prior material finding is resolved, and regression risk created by the fix. It retains authority to report a newly introduced material defect, but must not reopen unchanged, already-disposed questions without new evidence or expand into a full-codebase review. Output uses the same schema.
@@ -0,0 +1,13 @@
1
+ # Pipeline roles for Pi
2
+
3
+ `bc-pipeline-to-done` launches three jobs (see [Jobs](SKILL.md#jobs)). The Agent Concepts Pi package ships one `pi-subagents` profile per job, in [agents/](agents/); `pi-subagents` finds them through the package manifest, so installing the package and `pi-subagents` is the whole setup:
4
+
5
+ - `bc-drain-auditor` — the auditor: read-only pre-code contract audit for high-risk units.
6
+ - `bc-drain-worker` — the builder: writes the change for one unit or rework packet in its worktree; never commits.
7
+ - `bc-drain-reviewer` — the reviewer: read-only Spec or Standards review axis.
8
+
9
+ They set no model on purpose: a child takes the session's model, and the pipeline sets thinking per launch. To pin a model, set it for the role in `pi-subagents`' agent overrides, or copy the profile into `~/.pi/agent/agents/` (a user profile of the same name wins over the package's) and add `model: provider/your-model-id`.
10
+
11
+ To use other roles for a job, name them in `~/.config/agent-concepts/overlays/bc-pipeline-to-done.md`. Any replacement keeps these tool lists and authority lines: the pipeline's correctness gates assume the auditor and reviewer cannot write and the builder cannot commit.
12
+
13
+ Only the three profiles live in `agents/`: `pi-subagents` reads every Markdown file there as a profile.