cohorte 3.0.0-dev.7 → 3.0.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 (229) hide show
  1. package/CHANGELOG.md +1532 -0
  2. package/README.md +106 -185
  3. package/bin/cli.js +212 -0
  4. package/bin/report.js +141 -0
  5. package/core/agents/cohorte-profile-reader.md +50 -0
  6. package/core/agents/cohorte-release.md +58 -0
  7. package/core/agents/cohorte-review.md +174 -0
  8. package/core/agents/implementer.template.md +146 -0
  9. package/core/commands/cohorte-align-ds.md +33 -0
  10. package/core/commands/cohorte-audit.md +67 -0
  11. package/core/commands/cohorte-brainstorm.md +73 -0
  12. package/core/commands/cohorte-build.md +241 -0
  13. package/core/commands/cohorte-doctor.md +133 -0
  14. package/core/commands/cohorte-fix.md +80 -0
  15. package/core/commands/cohorte-fleet.md +111 -0
  16. package/core/commands/cohorte-init-pipeline.md +30 -0
  17. package/core/commands/cohorte-intake.md +92 -0
  18. package/core/commands/cohorte-patch.md +118 -0
  19. package/core/commands/cohorte-refactor.md +57 -0
  20. package/core/commands/cohorte-retro.md +85 -0
  21. package/core/commands/cohorte-review.md +224 -0
  22. package/core/commands/cohorte-ship.md +155 -0
  23. package/core/commands/cohorte-spec.md +105 -0
  24. package/core/commands/cohorte-update-pipeline.md +115 -0
  25. package/core/hooks/gate.py +2931 -0
  26. package/core/templates/agent-handoff.md +34 -0
  27. package/core/templates/brainstorm-return.md +42 -0
  28. package/core/templates/decisions.template.md +42 -0
  29. package/core/templates/design-brief.md +37 -0
  30. package/core/templates/patch.template.md +86 -0
  31. package/core/templates/pr-body.md +25 -0
  32. package/core/templates/review-feedback.md +46 -0
  33. package/core/templates/spec.template.md +88 -0
  34. package/core/templates/steps/init-pipeline/01-detect-stack.md +44 -0
  35. package/core/templates/steps/init-pipeline/02-interview-gaps.md +55 -0
  36. package/core/templates/steps/init-pipeline/03-draft-profile.md +9 -0
  37. package/core/templates/steps/init-pipeline/04-write-render.md +91 -0
  38. package/core/templates/steps/init-pipeline/05-report.md +11 -0
  39. package/core/templates/steps/review-pr/01-pr-mode.md +54 -0
  40. package/core/workflows/audit.js +306 -0
  41. package/core/workflows/loop.js +687 -0
  42. package/core/workflows/refactor.js +291 -0
  43. package/core/workflows/review.js +491 -0
  44. package/install.ps1 +72 -0
  45. package/install.sh +69 -0
  46. package/lib/doctor.js +472 -0
  47. package/lib/install.js +377 -0
  48. package/lib/project.js +322 -0
  49. package/lib/render.js +121 -0
  50. package/lib/versions.js +145 -0
  51. package/lib/yaml.js +174 -0
  52. package/package.json +36 -17
  53. package/profile/PIPELINE.template.md +250 -0
  54. package/profile/SCHEMA.md +749 -0
  55. package/profile/cohorte.config.template.yaml +43 -0
  56. package/scripts/feature-diff.sh +118 -0
  57. package/scripts/kanban-move.sh +307 -0
  58. package/scripts/metrics/collect.mjs +542 -0
  59. package/scripts/metrics/prices.json +42 -0
  60. package/scripts/new-feature.sh.template +122 -0
  61. package/scripts/preflight.sh +114 -0
  62. package/scripts/remove-feature.sh.template +56 -0
  63. package/assets/manifest.json +0 -203
  64. package/assets/migrations/config/README.md +0 -12
  65. package/assets/migrations/state/0001_init.sql +0 -154
  66. package/assets/prompts/README.md +0 -11
  67. package/assets/prompts/agents/brainstormer.md +0 -3
  68. package/assets/prompts/agents/fixer.md +0 -7
  69. package/assets/prompts/agents/implementer.md +0 -12
  70. package/assets/prompts/agents/reviewer.md +0 -8
  71. package/assets/prompts/agents/security-reviewer.md +0 -7
  72. package/assets/prompts/agents/spec-author.md +0 -3
  73. package/assets/prompts/phases/build.md +0 -5
  74. package/assets/prompts/phases/review.md +0 -5
  75. package/assets/prompts/phases/test.md +0 -5
  76. package/assets/prompts/system.md +0 -11
  77. package/assets/schemas/agent-output.schema.json +0 -225
  78. package/assets/schemas/auth-status.schema.json +0 -87
  79. package/assets/schemas/command-result.schema.json +0 -192
  80. package/assets/schemas/commands.schema.json +0 -959
  81. package/assets/schemas/config.schema.json +0 -2281
  82. package/assets/schemas/doctor-report.schema.json +0 -104
  83. package/assets/schemas/events.schema.json +0 -8514
  84. package/assets/schemas/fake-script.schema.json +0 -549
  85. package/assets/schemas/inspect.schema.json +0 -3133
  86. package/assets/schemas/manifest.schema.json +0 -79
  87. package/assets/schemas/ownership.schema.json +0 -52
  88. package/assets/schemas/policy-verdict.schema.json +0 -282
  89. package/assets/schemas/project-model.schema.json +0 -783
  90. package/assets/schemas/project-status.schema.json +0 -217
  91. package/assets/schemas/reconcile-plan.schema.json +0 -154
  92. package/assets/schemas/run-diff.schema.json +0 -177
  93. package/assets/schemas/run-snapshot-manifest.schema.json +0 -2104
  94. package/assets/schemas/run-state.schema.json +0 -1755
  95. package/assets/schemas/runtime-capabilities.schema.json +0 -1545
  96. package/assets/schemas/sandbox-capabilities.schema.json +0 -116
  97. package/assets/schemas/skill.schema.json +0 -87
  98. package/assets/schemas/spec.schema.json +0 -202
  99. package/assets/schemas/tool-catalogue.schema.json +0 -655
  100. package/assets/schemas/trust-record.schema.json +0 -38
  101. package/assets/skills/README.md +0 -9
  102. package/assets/skills/inspect-surface.md +0 -4
  103. package/dist/agent-host.mjs +0 -2187
  104. package/dist/agent-host.mjs.map +0 -1
  105. package/dist/bundle-manifest.json +0 -128
  106. package/dist/chunks/__host-DgGPyco9.mjs +0 -18
  107. package/dist/chunks/__host-DgGPyco9.mjs.map +0 -1
  108. package/dist/chunks/align-ds-r_X_1aQ_.mjs +0 -93
  109. package/dist/chunks/align-ds-r_X_1aQ_.mjs.map +0 -1
  110. package/dist/chunks/approve-Cv135UqI.mjs +0 -19
  111. package/dist/chunks/approve-Cv135UqI.mjs.map +0 -1
  112. package/dist/chunks/audit-B4ZWQ_DI.mjs +0 -179
  113. package/dist/chunks/audit-B4ZWQ_DI.mjs.map +0 -1
  114. package/dist/chunks/auth-BT5oVp76.mjs +0 -132
  115. package/dist/chunks/auth-BT5oVp76.mjs.map +0 -1
  116. package/dist/chunks/auth-Dnlksuo5.mjs +0 -141
  117. package/dist/chunks/auth-Dnlksuo5.mjs.map +0 -1
  118. package/dist/chunks/brainstorm-DasVwI1D.mjs +0 -123
  119. package/dist/chunks/brainstorm-DasVwI1D.mjs.map +0 -1
  120. package/dist/chunks/build-crOld8gE.mjs +0 -19
  121. package/dist/chunks/build-crOld8gE.mjs.map +0 -1
  122. package/dist/chunks/cancel-KV_cpsqS.mjs +0 -15
  123. package/dist/chunks/cancel-KV_cpsqS.mjs.map +0 -1
  124. package/dist/chunks/canonical-C8UxeEmB.mjs +0 -57
  125. package/dist/chunks/canonical-C8UxeEmB.mjs.map +0 -1
  126. package/dist/chunks/catalogue-IaCJdfB8.mjs +0 -1549
  127. package/dist/chunks/catalogue-IaCJdfB8.mjs.map +0 -1
  128. package/dist/chunks/compose-DRKjQcn0.mjs +0 -7333
  129. package/dist/chunks/compose-DRKjQcn0.mjs.map +0 -1
  130. package/dist/chunks/config-Cqu5XQoP.mjs +0 -96
  131. package/dist/chunks/config-Cqu5XQoP.mjs.map +0 -1
  132. package/dist/chunks/contract-DjssDPpS.mjs +0 -335
  133. package/dist/chunks/contract-DjssDPpS.mjs.map +0 -1
  134. package/dist/chunks/contract-bQ9FJl4N.mjs +0 -123
  135. package/dist/chunks/contract-bQ9FJl4N.mjs.map +0 -1
  136. package/dist/chunks/deny-ClTxSvHJ.mjs +0 -15
  137. package/dist/chunks/deny-ClTxSvHJ.mjs.map +0 -1
  138. package/dist/chunks/diff-Qw0II0sj.mjs +0 -101
  139. package/dist/chunks/diff-Qw0II0sj.mjs.map +0 -1
  140. package/dist/chunks/discover-BZPolSZG.mjs +0 -21
  141. package/dist/chunks/discover-BZPolSZG.mjs.map +0 -1
  142. package/dist/chunks/doctor-DcDFPvQM.mjs +0 -222
  143. package/dist/chunks/doctor-DcDFPvQM.mjs.map +0 -1
  144. package/dist/chunks/fix-B_oGzGVn.mjs +0 -82
  145. package/dist/chunks/fix-B_oGzGVn.mjs.map +0 -1
  146. package/dist/chunks/fleet-yWHQY2ya.mjs +0 -297
  147. package/dist/chunks/fleet-yWHQY2ya.mjs.map +0 -1
  148. package/dist/chunks/gc-BBXlBF5w.mjs +0 -161
  149. package/dist/chunks/gc-BBXlBF5w.mjs.map +0 -1
  150. package/dist/chunks/init--FxxkrcT.mjs +0 -63
  151. package/dist/chunks/init--FxxkrcT.mjs.map +0 -1
  152. package/dist/chunks/inspect-Buby4cQD.mjs +0 -22
  153. package/dist/chunks/inspect-Buby4cQD.mjs.map +0 -1
  154. package/dist/chunks/intake-Dd1KVXnO.mjs +0 -12
  155. package/dist/chunks/intake-Dd1KVXnO.mjs.map +0 -1
  156. package/dist/chunks/logs-Giq5sUau.mjs +0 -25
  157. package/dist/chunks/logs-Giq5sUau.mjs.map +0 -1
  158. package/dist/chunks/loop-BWsUpyus.mjs +0 -212
  159. package/dist/chunks/loop-BWsUpyus.mjs.map +0 -1
  160. package/dist/chunks/migrate-DuYCAbE3.mjs +0 -33
  161. package/dist/chunks/migrate-DuYCAbE3.mjs.map +0 -1
  162. package/dist/chunks/models-Btp6X2YZ.mjs +0 -24
  163. package/dist/chunks/models-Btp6X2YZ.mjs.map +0 -1
  164. package/dist/chunks/obsidian-BHLkXx_H.mjs +0 -235
  165. package/dist/chunks/obsidian-BHLkXx_H.mjs.map +0 -1
  166. package/dist/chunks/patch-sAgVqjpx.mjs +0 -50
  167. package/dist/chunks/patch-sAgVqjpx.mjs.map +0 -1
  168. package/dist/chunks/pause-BASBfKLO.mjs +0 -16
  169. package/dist/chunks/pause-BASBfKLO.mjs.map +0 -1
  170. package/dist/chunks/policy-Du7WVBFX.mjs +0 -139
  171. package/dist/chunks/policy-Du7WVBFX.mjs.map +0 -1
  172. package/dist/chunks/providers-Dx78imKj.mjs +0 -19
  173. package/dist/chunks/providers-Dx78imKj.mjs.map +0 -1
  174. package/dist/chunks/reconcile-BHn66X3C.mjs +0 -50
  175. package/dist/chunks/reconcile-BHn66X3C.mjs.map +0 -1
  176. package/dist/chunks/refactor-CoNoqLZr.mjs +0 -153
  177. package/dist/chunks/refactor-CoNoqLZr.mjs.map +0 -1
  178. package/dist/chunks/render-DyZr5Lgi.mjs +0 -53
  179. package/dist/chunks/render-DyZr5Lgi.mjs.map +0 -1
  180. package/dist/chunks/resume-GJQRb2Eb.mjs +0 -15
  181. package/dist/chunks/resume-GJQRb2Eb.mjs.map +0 -1
  182. package/dist/chunks/retro-Dr-2RTNN.mjs +0 -78
  183. package/dist/chunks/retro-Dr-2RTNN.mjs.map +0 -1
  184. package/dist/chunks/retry-CLrUem1H.mjs +0 -15
  185. package/dist/chunks/retry-CLrUem1H.mjs.map +0 -1
  186. package/dist/chunks/review-ZsBqp3vZ.mjs +0 -35
  187. package/dist/chunks/review-ZsBqp3vZ.mjs.map +0 -1
  188. package/dist/chunks/run-NGAxdsIX.mjs +0 -105
  189. package/dist/chunks/run-NGAxdsIX.mjs.map +0 -1
  190. package/dist/chunks/run-tool-C3rAv4XF.mjs +0 -26
  191. package/dist/chunks/run-tool-C3rAv4XF.mjs.map +0 -1
  192. package/dist/chunks/scan-C5uDr7Yq.mjs +0 -167
  193. package/dist/chunks/scan-C5uDr7Yq.mjs.map +0 -1
  194. package/dist/chunks/schema-Bq9qtgsd.mjs +0 -583
  195. package/dist/chunks/schema-Bq9qtgsd.mjs.map +0 -1
  196. package/dist/chunks/send-BdnJ85Nz.mjs +0 -19
  197. package/dist/chunks/send-BdnJ85Nz.mjs.map +0 -1
  198. package/dist/chunks/ship-BizfUe62.mjs +0 -140
  199. package/dist/chunks/ship-BizfUe62.mjs.map +0 -1
  200. package/dist/chunks/shutdown-BM92Iyv2.mjs +0 -15
  201. package/dist/chunks/shutdown-BM92Iyv2.mjs.map +0 -1
  202. package/dist/chunks/skip-DZG5kpcH.mjs +0 -18
  203. package/dist/chunks/skip-DZG5kpcH.mjs.map +0 -1
  204. package/dist/chunks/spec-C2h3U64g.mjs +0 -65
  205. package/dist/chunks/spec-C2h3U64g.mjs.map +0 -1
  206. package/dist/chunks/spec-path-tptqR7W8.mjs +0 -10
  207. package/dist/chunks/spec-path-tptqR7W8.mjs.map +0 -1
  208. package/dist/chunks/src-Bfr1yzsn.mjs +0 -1689
  209. package/dist/chunks/src-Bfr1yzsn.mjs.map +0 -1
  210. package/dist/chunks/src-CPW2_Ons.mjs +0 -5487
  211. package/dist/chunks/src-CPW2_Ons.mjs.map +0 -1
  212. package/dist/chunks/src-Cu3TxNob.mjs +0 -783
  213. package/dist/chunks/src-Cu3TxNob.mjs.map +0 -1
  214. package/dist/chunks/src-DNsLSxgm.mjs +0 -928
  215. package/dist/chunks/src-DNsLSxgm.mjs.map +0 -1
  216. package/dist/chunks/src-DbS9gkJy.mjs +0 -117
  217. package/dist/chunks/src-DbS9gkJy.mjs.map +0 -1
  218. package/dist/chunks/src-yi5whv3n.mjs +0 -2118
  219. package/dist/chunks/src-yi5whv3n.mjs.map +0 -1
  220. package/dist/chunks/status-SMjiOMYy.mjs +0 -29
  221. package/dist/chunks/status-SMjiOMYy.mjs.map +0 -1
  222. package/dist/chunks/tail-BuhT-2PH.mjs +0 -25
  223. package/dist/chunks/tail-BuhT-2PH.mjs.map +0 -1
  224. package/dist/chunks/update-BXIppsbi.mjs +0 -16
  225. package/dist/chunks/update-BXIppsbi.mjs.map +0 -1
  226. package/dist/chunks/update-pipeline-Du-Gu1Pl.mjs +0 -56
  227. package/dist/chunks/update-pipeline-Du-Gu1Pl.mjs.map +0 -1
  228. package/dist/cli.mjs +0 -186
  229. package/dist/cli.mjs.map +0 -1
@@ -0,0 +1,749 @@
1
+ # PIPELINE.md profile — field reference
2
+
3
+ `/cohorte-init-pipeline` fills the `yaml pipeline-profile` block in `PIPELINE.md` (from
4
+ `PIPELINE.template.md`) plus the prose sections. This documents every field and how the
5
+ generic pipeline uses it, so a stateless agent can read/regenerate the profile correctly.
6
+
7
+ ## `yaml pipeline-profile` block
8
+
9
+ | Field | Type | Used by | Meaning |
10
+ | ------------------------------------ | ------------ | --------------------------------- | ------------------------------------------------------------- |
11
+ | `name` | string | all | Project name, used in agent prose + commit scopes. |
12
+ | `one_liner` | string | brainstorm/spec | One-sentence product description. |
13
+ | `ui_language` | string | implementer, review | Language of ALL user-facing copy. |
14
+ | `package_manager` | enum | all | `pnpm`/`npm`/`yarn`/`bun`/`pip`/`cargo`/`go`. |
15
+ | `vcs.host` | enum | release | `github`→use `gh`; else emit compare URL. |
16
+ | `vcs.remote` | string | release | `owner/repo` for the PR/compare URL. |
17
+ | `vcs.default_branch` | string | build, review, release | Base branch for diffs + PRs. |
18
+ | `vcs.feature_branch_prefix` | string | ship, isolation script | `feature/` → branch `feature/<id>`. |
19
+ | `vcs.patch_branch_prefix` | string | ship | Same, for a `kind: patch` spec: `fix/` → branch `fix/patch-<slug>`. Optional — a profile that predates it falls back to `fix/`. |
20
+ | `repo.layout` | enum | build, audit | `monorepo` (many surfaces) or `single`. |
21
+ | `repo.workspace_tool` | enum | audit | `turborepo`/`nx`/`none`. |
22
+ | `retrieval.provider` | enum | init, update-pipeline, implementer | `serena` (default) / `graphify` / `none` — see §Code retrieval. |
23
+ | **`surfaces[]`** | list | **build, review, refactor, init** | One per independently-built area. Grows via reconcile (below). |
24
+ | `surfaces[].key` | string | build | Short id + review scope. |
25
+ | `surfaces[].path` | string | implementer | The ONLY tree that surface's agent may touch. |
26
+ | `surfaces[].label` | string | build, init (`<SURFACE_LABEL>`) | Human label + framework, e.g. `frontend (React)`. |
27
+ | `surfaces[].agent` | string | build (`subagent_type`) | Rendered agent file name. |
28
+ | `surfaces[].tools` | list | init | Frontmatter `tools:` for the rendered agent. |
29
+ | `surfaces[].model` | enum | init (`<SURFACE_MODEL>`) | Frontmatter `model:` tier — `sonnet`/`haiku`/`inherit`. Default `sonnet` (implementers mostly apply a frozen contract — far cheaper than the Opus lead the dispatcher runs on, and Sonnet handles it well); `haiku` for purely mechanical surfaces (scaffolding); `inherit` only for surfaces with real design decisions worth the lead's model. |
30
+ | `surfaces[].*_cmd` | string | implementer | test/lint/format/typecheck/build commands. |
31
+ | `surfaces[].test_quiet_cmd` `.lint_quiet_cmd` | string | implementer, preflight, workflows | Bridled variants agents actually run (dot reporter / `--quiet` / failures-only). `""` ⇒ `<cmd> 2>&1 \| tail -40`. See §Output discipline. |
32
+ | `surfaces[].uses_design` | bool | build, frontend | Whether this surface consumes designs. |
33
+ | `contract.enabled` | bool | build | `false` ⇒ skip contract authoring (§2 of /cohorte-build). |
34
+ | `contract.mechanism` | enum | build, lead | `shared-types-zod`/`openapi`/`protobuf`/`json-schema`/`none`. |
35
+ | `contract.path` `.ext` `.index` | string | build | Where `<feature_id>` contract is authored + barrel. |
36
+ | `contract.authored_by` | const `lead` | build | Implementers import it read-only, never edit. |
37
+ | `release_notes.enabled` | bool | ship | `false` ⇒ skip note authoring (§2b of /cohorte-ship). See §Release notes. |
38
+ | `release_notes.tool` | enum | ship | `changesets`/`none` — what consumes the file. |
39
+ | `release_notes.dir` `.filename` | string | ship | Where the per-feature note is authored, e.g. `.changeset/<feature_id>.md`. |
40
+ | `release_notes.anchor_package` | string | ship | Sole key in the note's front-matter; a lockstep/`fixed` group propagates the bump. |
41
+ | `release_notes.language` | string | ship | Language of the note's prose — usually `ui_language`. |
42
+ | `release_notes.forbid_levels` | list | ship | Bump levels project policy refuses, e.g. `[major]` while `0.x`. |
43
+ | `release_notes.empty_cmd` | string | ship | Escape hatch when no version should move; `""` if none. |
44
+ | `release_notes.ci_job` | string | ship | CI job that fails on a missing note — lets §5 name the red check. |
45
+ | `release_notes.guidance` | string | ship | Project policy the lead follows when picking the bump + writing the prose. |
46
+ | `commands.*` | string | all | Repo-wide install/dev/lint/format/typecheck/test + migrate. |
47
+ | `commands.test_quiet` `.lint_quiet` | string | review, audit, workflows | Repo-wide bridled variants — what the `/cohorte-review` pre-flight runs. Same fallback as the per-surface ones. |
48
+ | `rbac.enabled` | bool | brainstorm, review | Toggle RBAC personas + authz audit. |
49
+ | `rbac.hierarchy` | list | review | Highest→lowest role list. |
50
+ | `design.enabled` | bool | build, frontend, align-ds | `false` ⇒ design steps are no-ops. |
51
+ | `design.provider` | enum | frontend, align-ds | `claude-design`/`figma`/`none`. |
52
+ | `design.design_system_project` | id | align-ds, frontend | UI-kit source of truth. |
53
+ | `design.design_project` | id | build, frontend | Legacy fallback for bare-filename `design_files` only; default `none`. New specs use full `…/design/p/<projectId>?file=<file>` links that carry their own project + page (nothing to go stale on a DS rebuild). |
54
+ | `design.snapshot_dir` | path | align-ds | Committed DS snapshot for diffing. |
55
+ | `design.ui_kit_path` `.tokens_path` | path | align-ds, frontend | Where the kit + tokens live in code. |
56
+ | `isolation.enabled` | bool | new-feature script | `false` ⇒ build in main checkout. |
57
+ | `isolation.db_per_worktree` | bool | new-feature script | Create `<name>_<id>` DB per worktree. |
58
+ | `isolation.db_name_pattern` | string | new-feature script | `<name>_<id>`. |
59
+ | `isolation.port_base` | map | new-feature script | `api`/`web` base ports; +slot per worktree. |
60
+ | `isolation.compose_file` `.registry` | path | new-feature script | Docker stack + slot registry. |
61
+ | `gate.deny[]` | list | hooks/gate.py, settings | Command substrings hard-denied, on any branch. |
62
+ | `gate.ask[]` | list | hooks/gate.py, settings | Command substrings that require confirm, on any branch. |
63
+ | `gate.ask_on_default_branch[]` | list | hooks/gate.py | Confirm ONLY on `default_branch`; free on feature branches. |
64
+ | `gate.default_branch` | string | hooks/gate.py | Protected branch (default `main`); gate resolves via git. |
65
+ | `gate.preflight.enabled` | bool | hooks/gate.py, review | Phase gate: review dispatches need a fresh preflight stamp. See §Preflight. |
66
+ | `gate.preflight.agents[]` | list | hooks/gate.py | `subagent_type`s the stamp gates (default `[cohorte-review]`; `review` still accepted). |
67
+ | `gate.preflight.max_age_minutes` | number | hooks/gate.py | Stamp freshness window (default 30). |
68
+
69
+ ## Prose sections
70
+
71
+ - **Conventions** — per-surface rules the implementer follows and review audits.
72
+ - **Testing** — the TDD contract per surface (what a test must cover, DB isolation).
73
+ - **Design brief note** — feeds `/cohorte-spec` §8 and the Claude Design step.
74
+ - **Personas** — the `/cohorte-brainstorm` panel; include one per RBAC role when `rbac.enabled`.
75
+
76
+ ## How the pieces reference this file
77
+
78
+ - **Agents** (`implementer`, `review`, `release`) are told at dispatch: _read `PIPELINE.md`
79
+ §Commands / §Conventions / §Surfaces first._ They have `Read`, so they load it live.
80
+ - **Commands** (`/cohorte-build`, `/cohorte-review`, …) parse the `yaml pipeline-profile` block to know how
81
+ many surfaces to dispatch, the contract mechanism, the commands, and the capability flags.
82
+ - **Hook** (`gate.py`) reads `gate.deny`/`gate.ask`/`gate.ask_on_default_branch`/`gate.default_branch`
83
+ from a generated `<state>/gate-config.json`. The last two make git + docker free on feature branches
84
+ but confirm-gated on the default branch (branch resolved at run time via `git rev-parse`).
85
+ - **Scripts** (`new-feature.sh`) read the `isolation` block (rendered in at init).
86
+
87
+ ## Code retrieval — `retrieval.provider`
88
+
89
+ Agents spend most of their wall-clock reading the repo; a retrieval provider replaces grep-and-read
90
+ with symbol/graph queries. The flag is a **value, not a boolean**, so switching provider later is a
91
+ one-line profile change + re-running the wiring (no agent re-render needed — the guidance agents
92
+ follow is provider-agnostic: _"prefer the retrieval MCP tools over Grep/Glob + whole-file Reads"_).
93
+
94
+ | Provider | Mechanism | Freshness | Cost |
95
+ | --- | --- | --- | --- |
96
+ | `serena` (default) | live LSP symbol navigation (find symbol, references, semantic edits) | always current | none — no index |
97
+ | `graphify` | persistent tree-sitter knowledge graph over code + docs | as fresh as the last rescan | index step + re-index discipline |
98
+ | `none` | agents fall back to Grep/Glob/Read | — | — |
99
+
100
+ **Wiring (done by `/cohorte-init-pipeline`, or `/cohorte-update-pipeline` retroactively):**
101
+
102
+ - `serena` — requires the `serena` CLI (`uv tool install -p 3.13 serena-agent`). For day-to-day CLI
103
+ use it should also be on PATH (`uv tool update-shell`; uv installs to `~/.local/bin`). Register at
104
+ **project scope** so the registration is committed and portable (`--project-from-cwd` resolves the
105
+ project at server start, so the committed entry works on every machine) — and register the
106
+ **PATH-proof launcher**, not the bare command: Claude Code spawns MCP servers with whatever
107
+ environment it was launched from (a stale terminal, a GUI/IDE launch that never sourced a shell
108
+ profile), where `~/.local/bin` may be missing from PATH — a bare `serena` entry then dies with
109
+ ENOENT and agents silently fall back to Grep/Read:
110
+
111
+ ```sh
112
+ claude mcp add --scope project serena -- sh -c 'exec "$(command -v serena || echo "$HOME/.local/bin/serena")" start-mcp-server --context claude-code --project-from-cwd --open-web-dashboard False'
113
+ ```
114
+
115
+ (Windows-native teams: no `sh` — register the bare `serena` form instead and ensure the uv tools
116
+ dir is on PATH; keep the `--open-web-dashboard False` flag.) `--open-web-dashboard False` keeps the
117
+ dashboard available (reachable at `http://localhost:24282/dashboard/`) but stops it popping a browser
118
+ tab on every server start — the flag overrides the machine's `serena_config.yml`, so the behaviour is
119
+ the same for everyone on the repo. Gitignore `.serena/` (per-machine cache/config). Optionally
120
+ pre-index large repos once: `serena project index`.
121
+ - `graphify` — requires `uv tool install graphify` + `graphify install`; build the initial graph
122
+ (`/graphify .`) and rescan incrementally after big changes (`--update`). See graphify.net.
123
+ - Rendered agents get the provider's MCP tools appended to their `tools:` list (e.g. `mcp__serena`
124
+ grants the whole server); `none` ⇒ nothing appended.
125
+
126
+ **Serena health check** — run after wiring in `/cohorte-init-pipeline` AND on every `/cohorte-update-pipeline`
127
+ reconcile (wiring that worked once can rot: PATH changes, tool uninstalled, entry hand-edited):
128
+
129
+ 1. **CLI resolves:** `command -v serena`. Fails but `~/.local/bin/serena` exists ⇒ PATH repair
130
+ above; missing entirely ⇒ reinstall.
131
+ 2. **Registered:** this repo's `.mcp.json` has the `serena` entry ⇒ else re-run the `claude mcp add`.
132
+ If the entry is the bare `serena` form on a POSIX machine, upgrade it to the PATH-proof launcher
133
+ above (immune to launch-environment PATH gaps). If a launcher entry predates the
134
+ `--open-web-dashboard False` flag, append it so the dashboard no longer auto-opens a browser tab.
135
+ 3. **Gitignored:** `.serena/` is in `.gitignore` ⇒ else append it.
136
+ 4. **Actually connected:** the `mcp__serena` tools are exposed in the session (or `claude mcp list`
137
+ shows serena connected). If 1–3 pass but this fails, a session restart is needed — say so
138
+ explicitly instead of reporting success.
139
+
140
+ Report each check's result; never report Serena "wired" on registration alone.
141
+
142
+ Teammates cloning the repo get the committed `.mcp.json` and only need the provider CLI installed
143
+ and on PATH — if either is missing, the MCP server fails to start and agents silently fall back to
144
+ Grep/Read; the health check above is the diagnostic.
145
+
146
+ ## Specialization — when to split one surface into more agents
147
+
148
+ `/cohorte-build` dispatches ONE agent per surface, in parallel, so build wall-clock ≈ the **slowest single
149
+ surface**. More agents only build faster when they let the *slowest* surface's work run concurrently —
150
+ and only if the split is safe. The invariant that keeps parallelism safe is **one owner per tree, and
151
+ the frozen contract as the only cross-surface channel**. So specialization means carving a surface into
152
+ **smaller non-overlapping surfaces**, never pointing two agents at the same tree.
153
+
154
+ **Split a surface into specialized sub-surfaces only when BOTH hold:**
155
+
156
+ 1. **It's a bottleneck** — the surface is large (many modules / high LOC) and dominates build time.
157
+ 2. **The boundary is clean** — its work partitions into trees that don't share files, e.g. feature
158
+ modules (`src/features/*`, `src/modules/*`), route groups, or independent services (`services/*`).
159
+
160
+ **Rules when splitting (non-negotiable — they preserve the invariant):**
161
+
162
+ - **One owner per tree is a convention, not a sandbox.** Nothing mechanical enforces it: an agent's
163
+ `tools:` frontmatter names tools, not paths, and implementers have Write/Edit/Bash on the whole
164
+ repo. It holds because each dispatch names one tree ("Touch only `<surface.path>`"), the rendered
165
+ agent says the same, and review reads the diff per surface — so a stray write shows up there.
166
+ - **Shared code gets its own surface with a single owner.** Anything two slices both touch — routing,
167
+ global state/store, the design-system kit + tokens, shared utils — becomes its OWN surface (e.g.
168
+ `web-shared`), owned by exactly one agent. Never let two feature-slice agents both edit shared trees.
169
+ - **Cross-slice references go through the contract**, not direct imports between slice trees. If
170
+ `web-checkout` needs a shape produced by `api-billing`, that shape lives in the frozen contract.
171
+ - **Don't over-split.** A slice too small to hold ≥1 real task, or one with tangled boundaries, is worse
172
+ than not splitting — the coordination + token cost (each stateless agent re-reads `PIPELINE.md` + spec)
173
+ outweighs the parallelism. When boundaries aren't clean, keep one surface.
174
+
175
+ Coarse first, specialize on evidence: start with one `frontend` / `backend` surface each; split only a
176
+ surface that's proven slow and cleanly separable. The evidence lives in
177
+ the **main checkout's** `<state>/pipeline-metrics.jsonl` (gitignored) — one JSONL line per phase batch
178
+ (`ts`/`feature`/`phase`/`seconds`/`surfaces:{key: result}`), appended by `/cohorte-build`, `/cohorte-review`
179
+ and `/cohorte-fix`.
180
+ **`surfaces` keys are surface keys, nothing else** — run-level facts go in their own top-level
181
+ fields. Anything put inside `surfaces` is read
182
+ as a surface: `cohorte doctor` renders it as a row in the per-surface table and scores a non-`ok`
183
+ value as that surface failing. Always the main checkout, never the feature worktree (which dies at teardown while
184
+ metrics must accumulate across features) — resolve from anywhere with
185
+ `$(dirname "$(git rev-parse --git-common-dir)")/<state>/pipeline-metrics.jsonl`. Read it before
186
+ proposing a split: split the surface that actually dominates wall-clock, not the one that feels big.
187
+
188
+ ## Measuring cost — what's slow vs what's expensive
189
+
190
+ `pipeline-metrics.jsonl` records **wall-clock seconds** per phase batch (§Specialization) — it tells you
191
+ what's SLOW. Tokens are recorded only where they can be read honestly: the **workflow paths**
192
+ (`loop.js`, `review.js`) stamp an approximate `tokens` field per batch from the runtime's own
193
+ counter (`budget.spent()` deltas), and the loop's return carries a per-round breakdown in its
194
+ `history`. The **conversational** commands still record none — a lead cannot reliably read a
195
+ subagent's token count, and a guessed number is worse than a missing one. `cohorte metrics` sums
196
+ whatever is stamped (a token-less line aggregates as 0, rendered as absent, never as "free").
197
+ For exact spend, use Claude Code's own accounting:
198
+
199
+ - **`/cost`** (built-in, zero setup) — reports per-**subagent** and per-**slash-command** share of your usage
200
+ over the last 24 h / 7 d (e.g. _"Top subagents: frontend 7 %, backend 4 % · Top skills: /cohorte-build 1 %,
201
+ /cohorte-review 1 %"_). That IS the per-phase ledger — approximate (share-of-total, machine-local, not exact
202
+ tokens). Read it to see which surface/command actually dominates the bill before you tune a `model` tier.
203
+
204
+ **Lead context discipline — the silent bill.** The lead session's conversation history is re-sent as
205
+ input on EVERY turn; a session that spans spec→build→review→fix without clearing re-pays the
206
+ accumulated spec walk-through, handoffs, and reports on each turn. The pipeline is built so this is
207
+ never necessary: every phase handoff (spec, contract, diff, staged reports) lives on disk, so `/clear`
208
+ at each phase boundary is always safe — each command's closing line recommends it. Corollaries the
209
+ commands enforce: never paste a diff into a dispatch (agents compute their own, scoped); never echo a
210
+ staged report or design brief into chat; redirect bulky command output to a file and grep it.
211
+
212
+ ## Output discipline — quiet commands
213
+
214
+ A test runner's default output is written for a human watching a terminal: one line per test, banners,
215
+ timing tables. An agent pays input price for every one of those lines, on every turn they survive in its
216
+ context. The profile therefore stores **two forms of each noisy command**:
217
+
218
+ - `test_cmd` / `lint_cmd` — the full form, for a human running it by hand.
219
+ - `test_quiet_cmd` / `lint_quiet_cmd` (per surface) and `commands.test_quiet` / `commands.lint_quiet`
220
+ (repo-wide) — the **bridled** form agents actually execute: dot/failures-only reporter
221
+ (`--reporter=dot`, `--quiet`, `-q`, `--silent`, framework equivalent) so a green run costs lines,
222
+ not pages, and a red run prints only the failures.
223
+
224
+ Rules for every consumer (implementers, preflight, `/cohorte-audit` gates, workflow agents):
225
+
226
+ 1. Run the quiet variant when set.
227
+ 2. Quiet variant empty/absent (older profile) ⇒ run `<full cmd> 2>&1 | tail -40` — never the bare
228
+ command into your context.
229
+ 3. Need the full log? Redirect it to a file and grep it; never print it.
230
+
231
+ `/cohorte-init-pipeline` **asks** for these variants (detected defaults offered first) instead of silently
232
+ storing a bare `pnpm test` as the thing agents execute; `/cohorte-update-pipeline` tops up older profiles.
233
+
234
+ ## Spec status — the lifecycle state machine
235
+
236
+ A spec's front-matter `status` is not a label, it is the pipeline's **state**: every command routes on
237
+ it, `cohorte specs` boards on it, and the kanban backfill maps it to a column. Eight states:
238
+
239
+ | status | meaning | written by | who may build it |
240
+ | --- | --- | --- | --- |
241
+ | `draft` | the interview is open, nothing is frozen | `/cohorte-spec` Mode A | no |
242
+ | `frozen` | the contract is frozen — the handoff to `/cohorte-build` | `/cohorte-spec` Mode A freeze | yes |
243
+ | `in-progress` | a round is under way on this spec (or died mid-way) | an automated driver, if any | yes |
244
+ | `in-review` | reviewed / awaiting the next round or `/cohorte-ship` | `/cohorte-spec` Mode B, `/cohorte-fix` | yes |
245
+ | `blocked` | a round gave up here (non-convergent, no verdict, not implementable) | an automated driver, if any | yes, with the reason named |
246
+ | `shipped` | the PR is open; the status flip is part of the release commit | `/cohorte-ship` | no |
247
+ | `merged` | the PR merged — reconciled from `gh pr view`, never assumed | `/cohorte-ship` §0/§5, `/cohorte-doctor` reconcile | no |
248
+ | `abandoned` | the feature was dropped (PR closed unmerged, or never shipped) — the human's call | `/cohorte-ship` §0, the human | no |
249
+
250
+ **`merged` and `abandoned` close the lifecycle.** `shipped` only says a PR was opened; whether it
251
+ landed is a fact on the host, so it is **reconciled**, not guessed: `/cohorte-ship` re-entered on a
252
+ `shipped` spec and `/cohorte-doctor` both run `gh pr view <branch> --json state` — `MERGED` ⇒
253
+ `merged`; `CLOSED` unmerged ⇒ the human decides (reopen and continue, or `abandoned`). Both are
254
+ terminal: every builder refuses them, the kanban backfill maps them to `shipped`, and a worktree
255
+ still alive for one is a teardown candidate.
256
+
257
+ **`in-progress` and `blocked` are driver states.** No conversational command writes them — the
258
+ human-driven cycle moves `frozen` → `in-review` → `shipped` → `merged`. Their producer is the
259
+ **loop workflow** (`cohorte-loop.js`, from `core/workflows/loop.js` — the successor of the
260
+ 2.2.0-retired conversational driver): it stamps `in-progress` at each round, `in-review` when a
261
+ run ends at zero blocking findings, and `blocked` when a round gives up, with the reason in
262
+ `specs/reports/<id>.loop.json`. A **resumable** stop (a dead agent, a red preflight, an
263
+ unreviewed surface, a report that never landed) writes `reason` and **no** `outcome`, and
264
+ re-invoking the loop resumes at that round; a **terminal** one (treading water, max rounds, a
265
+ contract-change finding) writes both, and the next run starts fresh once a human re-entered
266
+ through `/cohorte-fix` or `/cohorte-build` (which rewrites `readiness.json` after `loop.json`).
267
+ External drivers may write these states too. Every reader routes on
268
+ them either way, and a stamp on a spec with no front-matter stays a silent no-op — no driver
269
+ dies over a status line.
270
+
271
+ **`kind` — feature (default) or `patch`.** Orthogonal to `status`, and the only other front-matter
272
+ field commands route on. `/cohorte-patch` freezes `specs/patch-<slug>.md` with `kind: patch` from
273
+ `templates/patch.template.md`: a ~60-line bug spec whose §4 **regression test** replaces §5 CONTRACT
274
+ as the thing the diff is checked against. It moves through the same states and the same commands —
275
+ `/cohorte-build` → `/cohorte-review` → `/cohorte-fix`* → `/cohorte-ship` — which is the whole design:
276
+ a patch is a spec, so nothing downstream is special-cased beyond three lines.
277
+
278
+ | what reads `kind: patch` | what it does differently |
279
+ | --- | --- |
280
+ | `/cohorte-build` §1.6 | judges §1 repro + §4 regression test instead of contract completeness; gap check `repro` |
281
+ | `/cohorte-build` §2 | authors no contract when §5 Contract delta is `none` (the usual case) |
282
+ | `/cohorte-ship` §1/§2b/§3 | branches off `vcs.patch_branch_prefix`; a `patch` bump by default; `fix(<scope>)` commit |
283
+
284
+ A patch may span **several surfaces** — one bug, one repro, one spec. What it may never do is add
285
+ **new** contract surface area: two surfaces agreeing on a shape that doesn't exist yet is what §5 is
286
+ for, so `/cohorte-patch` routes that to `/cohorte-spec` instead. Changing an *existing* contract entry
287
+ is a legitimate delta. The patch template keeps contract on **§5** and acceptance on **§9** — the two
288
+ numbers `review.md` and `implementer.template.md` name verbatim — and simply has no §8.
289
+
290
+ Corollaries worth knowing:
291
+
292
+ - A spec with no front-matter makes every stamp a **silent no-op** — the state is bookkeeping, and the
293
+ loop must never die over a status line.
294
+ - Child commands write `status` too (`/cohorte-fix` sets `in-review`); re-stamping before each phase is what
295
+ keeps `in-progress` true for the duration of the run rather than for its first phase.
296
+ - `blocked` is not a failure to hide: `/cohorte-build` accepts it, names the `loop.json` reason, routes
297
+ by the spec's `## Remediation` (open items ⇒ `/cohorte-fix`), and sets `in-review` once its readiness
298
+ verdict is written. `/cohorte-build <id> --readiness-only` does that re-entry (checks, readiness,
299
+ contract) without dispatching anything — the loop then builds.
300
+
301
+ ## Dead agents — silence is not a green light
302
+
303
+ A subagent can die mid-run: a rate limit, a transport error that outlived its retries, its own context
304
+ exhausted on a big surface. When it does it returns **nothing** — and nothing is byte-identical to
305
+ "finished, nothing to report". Every phase that fans out therefore does a **roll call** before it
306
+ integrates anything, because the default reading of silence is the most dangerous one available:
307
+
308
+ | phase | what a dead agent looks like | what the phase must do |
309
+ | --- | --- | --- |
310
+ | `/cohorte-build` | a surface with no handoff | retry it **once** alone (byte-identical prompt), then mark it `dead`, verify the tree with that surface's own quiet commands, never call the batch ok |
311
+ | `/cohorte-review` | a reviewer with no report ⇒ **zero findings** | retry once, then list the surface in `unreviewed` and refuse to score `SHIP` |
312
+ | `/cohorte-fix` | a re-dispatched agent with no handoff | retry once, then leave **every** one of its items `- [ ]` — a dead agent never ticks a box |
313
+ | workflows | `agent()` resolves to `null` | already enforced (`review.js` `unreviewedSurfaces`) — the doctrine started here |
314
+
315
+ Non-negotiables, in every phase:
316
+
317
+ - **Retry once, alone, byte-identical.** Most deaths are transient, and the other surfaces' work is
318
+ already on disk — so recovery costs one agent, never a rebuild. Never retry an agent that answered.
319
+ - **Never speak for a dead agent.** You did not see its work: report what the *tree* says (quiet
320
+ commands, redirected to a file, grepped), not what a handoff would have said.
321
+ - **Never let it reach a driver as clean.** `/cohorte-build` writes `dead[]` into
322
+ `specs/reports/<id>.build.json`, `/cohorte-review` writes `unreviewed[]` into the verdict; a driver
323
+ must abort on either *before* it reads `blocking`, since a dead reviewer makes
324
+ `blocking == 0` a statement about code nobody read.
325
+ - **`unreviewed` is separate from `blocking` on purpose.** Faking a count in `blocking` to force a
326
+ driver's hand would corrupt the one field the whole contract rests on; a driver reads them as two
327
+ different facts — "what was found" and "what was covered".
328
+ - **Write the metrics line anyway** (`"<key>":"dead"`). An incomplete batch is exactly the batch worth
329
+ recording; holding the append back "until it's complete" deletes the evidence that anything failed.
330
+
331
+ ## Readiness — the gate between a frozen spec and N implementers
332
+
333
+ `/cohorte-build` §1.6 scores the frozen spec on **implementability** before authoring the contract and before
334
+ dispatching anything, and writes `specs/reports/<id>.readiness.json`
335
+ (`verdict`: `READY` · `RESERVATIONS` · `NOT-READY`, plus `gaps[]`). It costs **zero extra agents** — the
336
+ lead already holds the spec, the profile and the reconciled surface list — which is the whole economics
337
+ of the step: a spec that cannot be built does not get cheaper by being built on N surfaces in parallel.
338
+
339
+ - Five checks: contract completeness · surface coverage · dependencies exist · residual ambiguity ·
340
+ the design gate. Each maps to `NOT-READY` (a surface would have to invent the answer) or
341
+ `RESERVATIONS` (a surface can proceed on a stated assumption).
342
+ - **`NOT-READY` aborts the build with no agent spawned** and sends the human to `/cohorte-spec`.
343
+ A driver reads the same file and must stop rather than retry — it is the one outcome more passes
344
+ cannot fix.
345
+ - **`RESERVATIONS` never blocks.** Each gap is inlined verbatim into the dispatch of the surface it
346
+ affects, as an assumption the implementer must apply *and* flag in its handoff. A gate that stalled a
347
+ sound build on a missing error case would cost more human round-trips than it saves.
348
+
349
+ ## Deferred findings — real, but not this feature's problem
350
+
351
+ `/cohorte-review` ends on "zero blocking findings", so everything non-blocking used to be discarded with the
352
+ report. A **deferred** finding is one the reviewer judges true and **out of this feature's scope**
353
+ (pre-existing code the staged diff never touched, adjacent debt the spec never claims to fix). The
354
+ review agent returns them in their own `## Deferred` section — never in `findings` — each carrying its
355
+ own out-of-scope reason.
356
+
357
+ - They count in **no** severity row, enter **no** verdict, and are **never** cross-checked: a deferred
358
+ item cannot cost a fix loop an iteration, and refuting one would spend an agent arguing about
359
+ something that cannot change the outcome.
360
+ - **Not deferrable, ever:** anything the diff touched or introduced, any spec violation, any security
361
+ issue on a path this feature adds, calls or modifies.
362
+ - `/cohorte-review` §3.5 routes them, **on every verdict**, into `specs/refactor-backlog.md` under the
363
+ `## <domain>` heading of the owning surface, tagged `deferred:<feature_id>` — the same grouping
364
+ `/cohorte-audit` writes, so `/cohorte-refactor <domain>` picks them up with no extra plumbing. Never into the spec's
365
+ `## Remediation`, which is what `/cohorte-fix` re-dispatches.
366
+ - `/cohorte-audit` (both paths) **rewrites only the sections of the domains it audited**, carrying their
367
+ open `deferred:` items over, and leaves every other domain's section untouched — overwriting the
368
+ file with one run's items is the one way they silently vanish.
369
+ - The verdict JSON carries `deferred: <n>` (informational, outside `blocking`), so a driver can name
370
+ them in its closing line without reading a report.
371
+
372
+ ## Decisions — the transverse decision journal
373
+
374
+ `PIPELINE.md` is a **stack profile** (surfaces, commands, conventions); it says nothing about what this
375
+ project has *decided*. Without somewhere for those, every `/cohorte-spec` re-discovers or contradicts them.
376
+ `specs/_decisions.md` (from `core/templates/decisions.template.md`) is that place, deliberately small:
377
+
378
+ - **Append-only, one line per decision, ≤ ~160 chars:**
379
+ `- <YYYY-MM-DD> · <area> · <decision> — because <reason> · <origin>`, where `<origin>` is the
380
+ `feature_id` that decided it — or the originating command (`retro`) when no single feature owns
381
+ it. Reversal never edits a line:
382
+ append a superseding one (`· supersedes <date> <area>`) and move the old one to `## Superseded`. When
383
+ `## Live` passes ~100 lines, sweep the superseded ones down.
384
+ - **Written by** `/cohorte-spec` at freeze (the decisions that outlive the feature — typically 0–3 lines, and
385
+ zero is a normal outcome), `/cohorte-build` §1.5 when it adds or splits a surface, and
386
+ `/cohorte-retro` §4 when the human ratifies a convention rule (one line per adopted rule).
387
+ - **Read by the deciding stages only** — `/cohorte-brainstorm` (so the panel argues about the idea, not about
388
+ settled ground), `/cohorte-spec` (so a new spec does not silently un-decide something), `/cohorte-audit` (standing
389
+ decisions are part of the rulebook it audits against).
390
+ - **Never read by implementers or reviewers.** They work from the frozen contract, which already tells
391
+ them what to do; shipping them the rationale would cost `surfaces × dispatches` tokens per feature
392
+ for a fact they cannot act on. This is what keeps the journal cheap enough to be worth having.
393
+ - The `_` prefix is load-bearing: `/cohorte-doctor`, the `cohorte specs` scanner and the kanban backfill all skip
394
+ `specs/_*.md`, so the journal is never mistaken for a spec (no phantom card, no bogus stage).
395
+
396
+ ## Feature diff — what "the feature changed" means
397
+
398
+ Every diff the pipeline reads — the review's changed-path list and per-surface hunks, an
399
+ implementer's self-diff, the freshness digest `/cohorte-review` stamps and `/cohorte-ship` re-checks —
400
+ comes from ONE shipped script, `<core>/pipeline/scripts/feature-diff.sh`, never a bare `git diff`:
401
+
402
+ ```
403
+ feature-diff.sh --default <default_branch> (--numstat|--name-only|--patch|--digest|--base-only) [-- <pathspec>…]
404
+ feature-diff.sh --base <sha> (same modes)
405
+ ```
406
+
407
+ - **Untracked files are in.** Feature work stays uncommitted until `/cohorte-ship`, and `git diff <ref>`
408
+ never shows an untracked file — new modules escaped review, and an adds-only feature reviewed as an
409
+ empty diff that scored SHIP. The script diffs a **throwaway index** (seeded from the real one,
410
+ `git add -A` on the copy); the human's index and what they staged are never touched.
411
+ - **The base is the merge-base**, not the default branch's tip (which blames the feature for every
412
+ file `main` gained since). Local `<branch>` and `origin/<branch>` are both tried; the newer
413
+ merge-base wins (fleet worktrees branch off the remote ref).
414
+ - **`.claude/` and `specs/` are always excluded** (the pipeline's own writes), gitignored files never
415
+ enter. Exit 3 = the base cannot be resolved: the caller stops — it never falls back to `git diff`.
416
+
417
+ ## Preflight — the deterministic phase gate
418
+
419
+ `/cohorte-review` starts by running `pipeline/scripts/preflight.sh` — a plain shell script (no
420
+ agent) that executes the profile's mechanical checks in order (typecheck → lint → tests, quiet
421
+ variants) with all output redirected to `specs/reports/<id>.preflight.txt`:
422
+
423
+ - **Any check red** ⇒ the script prints the last 40 lines raw and exits 1. The command **aborts
424
+ there: zero agents are spawned.** A reviewer dispatched onto code that doesn't compile burns its
425
+ whole run rediscovering what `tsc` already printed for free — the failure goes straight to the
426
+ human (or `/cohorte-fix`) instead.
427
+ - **All green** ⇒ the script stamps `<state>/preflight.ok` (`<epoch> <HEAD sha> <tree digest>` —
428
+ local and **gitignored**; a versioned stamp describes the tree *before* its own commit and rides
429
+ into every clone and worktree, which breaks the gate both ways).
430
+
431
+ `hooks/gate.py` enforces the stamp as a **phase gate** (the `preflight` block of `gate-config.json`,
432
+ generated from `gate.preflight`): an `Agent` (formerly `Task`) dispatch of a listed `subagent_type` (default
433
+ `cohorte-review`) with a missing/stale stamp — older than `max_age_minutes`, or the digest no longer
434
+ matches the working tree (`.claude` and `specs` excluded, so the pipeline's own writes and a
435
+ commit of already-verified code do not invalidate it) — gets an
436
+ "ask", so a lead can't accidentally skip the gate but a human can consciously override it. The gate
437
+ hook fires for **every** agent in the session, including subagents spawned by the Workflow runtime
438
+ (they run in `acceptEdits` whatever the session mode — Write/Edit auto-approved — but Bash and Agent
439
+ still pass through hooks). In `bypassPermissions` (headless runs) every gate "ask" is escalated to a
440
+ hard deny, because nobody is there to answer a prompt.
441
+
442
+ ## Rendering / reconciling a surface agent (shared procedure)
443
+
444
+ Both `/cohorte-init-pipeline` (initial render) and `/cohorte-build` (auto-reconcile when a spec needs a new agent) use
445
+ this exact procedure so a surface is always defined the same way. To add surface `S`:
446
+
447
+ 1. **Add the `surfaces[]` entry** to `PIPELINE.md`: `key`, `path` (the disjoint tree it exclusively
448
+ owns), `label`, `agent` (rendered file name), `tools` (add `DesignSync` only if `uses_design: true`;
449
+ append the retrieval provider's MCP tools when `retrieval.provider` ≠ `none` — e.g. `mcp__serena`),
450
+ `model` (tier for the rendered agent: `sonnet` (default) — the implementer mostly applies a frozen
451
+ contract, which Sonnet does well at a fraction of the Opus-lead cost; `haiku` for purely mechanical
452
+ scaffolding; `inherit` only when the surface makes real design decisions worth the lead's model),
453
+ the five `*_cmd`s (derive from the surface's `package.json` / workspace
454
+ filter, mirroring a sibling surface), and `uses_design`.
455
+ 2. **Render the agent file** `<agents>/<agent>.md` from `<core>/pipeline/implementer.template.md`
456
+ — the template is already rendered for this runtime, so only the placeholders are yours to fill —
457
+ substituting `<SURFACE_AGENT>`, `<SURFACE_LABEL>`,
458
+ `<SURFACE_PATH>`, `<SURFACE_TOOLS>`, `<SURFACE_MODEL>`, `<PROJECT_NAME>`, and the surface-specific
459
+ blocks (`<SURFACE_EXTRA_NEVER>`, `<SURFACE_DESIGN_INPUT>`, `<SURFACE_TDD_STEP1>` — leave the design
460
+ ones empty unless `uses_design`). Fill `<SURFACE_CONVENTIONS>` with the surface's convention slice
461
+ **baked at render time**: `PIPELINE.md` §Conventions `### Shared` + this surface's
462
+ `### Surface: <key>` stanza + its §Testing lines, verbatim. At runtime the agent then reads only
463
+ the profile's machine block (the fenced `yaml pipeline-profile`) — never the prose sections. The
464
+ bake stays honest because §Conventions edits go through `/cohorte-update-pipeline`, whose reconcile
465
+ re-renders every agent (step 2 below); hand-edit the prose without re-rendering and the baked
466
+ slice goes stale — that's the trade for not re-reading the prose on every dispatch. For a `uses_design` surface, fill them **link-based** (never with a
467
+ stored `design_project` id — that goes stale on a DS rebuild):
468
+ - `<SURFACE_DESIGN_INPUT>` — a 4th input bullet: _"The **feature design** — the pages this feature
469
+ touches, listed in your dispatch's design slot as full links
470
+ (`https://claude.ai/design/p/<projectId>?file=<file>`); a slot saying `none` means a fix loop with
471
+ no visual work — skip DesignSync entirely. For each link, extract the `<projectId>` (the
472
+ `/p/…` segment) and `<file>` (the `?file=` query) from the URL and read it read-only via `DesignSync
473
+ get_file(<projectId>, <file>)`; `list_files(<projectId>)` to catch linked pages (shared nav/modals)
474
+ this feature also changes. The link is self-contained — no stored project id. Build with the code UI
475
+ kit (the `design_system_project`'s materialization: `@/components/ui/*` + tokens); read a primitive
476
+ via `get_file` only if it's missing/stale in code. Mobile-first."_
477
+ - `<SURFACE_TDD_STEP1>` — a **lead-in paragraph** above the TDD list (not a numbered item; it
478
+ renders as nothing for a non-design surface, which is why the list must not start at it):
479
+ _"**Pull the feature design first** (skip if your dispatch's design slot
480
+ says `none`): `DesignSync get_file(<projectId>, <file>)` for each link in the slot and translate
481
+ each into the code design system (`@/components/ui/*`, `cn()` + CVA), mobile-first — never ad-hoc
482
+ CSS. Then:"_
483
+ 3. **Add a §Conventions + §Testing stanza** for `S` in `PIPELINE.md` (mirror a sibling surface; keep it
484
+ rule-shaped). If `S` is a shared-code surface, its convention is "single owner of shared X; slices
485
+ consume, never redefine."
486
+
487
+ Removing/merging a surface is the reverse: drop the `surfaces[]` entry, delete its agent file, fold its
488
+ conventions. Never leave an agent file with no matching `surfaces[]` entry (orphan) or vice-versa.
489
+
490
+ ## Release notes — the per-feature note the versioning tool consumes
491
+
492
+ Many repos gate merges on a **per-feature release note**: Changesets' `changeset` CI job fails any PR
493
+ that touches product code without a `.changeset/*.md`. That file is **not** something the release
494
+ agent can invent — picking the bump level is project policy (semver over an API vs. over a product,
495
+ a `0.x` rule forbidding `major`, what counts as user-visible), and the prose is outward-facing copy.
496
+ It is the **lead's** to write, exactly like the contract.
497
+
498
+ The failure mode this block exists to prevent is silent and reproducible: the requirement lives in the
499
+ project's `CLAUDE.md`, which the ship flow never reads, so `/cohorte-ship` completes, opens the PR,
500
+ moves the kanban card to **Shipped** — and CI goes red on a job nobody looked at. The feature reads as
501
+ shipped while being unmergeable. Encoding it in the profile is what makes the step survive a stateless
502
+ lead.
503
+
504
+ - **Authored before the dispatch**, next to the `status: shipped` flip (`/cohorte-ship` §2b), so the note
505
+ lands **inside** the release commit. Written after the fact it needs a second commit, and the PR is
506
+ already open and red.
507
+ - **One key in the front-matter** — `anchor_package`. Lockstep/`fixed` version groups propagate the bump
508
+ from it to every other workspace; listing more is how a repo ends up with a package bumped twice.
509
+ - **`forbid_levels`** encodes policy the tool itself may not enforce. The common one: while the product
510
+ is `0.y.z`, a `major` changeset makes Changesets jump to `1.0.0` with no human deciding it — so `0.x`
511
+ repos forbid `major` and declare a breaking change as `minor`.
512
+ - **Ask, don't guess, on an ambiguous bump.** Between two defensible levels (a refactor that also changes
513
+ what the user sees), state the reading and let the human pick — a wrong bump is a published version
514
+ number, not a fixable draft.
515
+ - **`empty_cmd`** covers the honest no-op: a PR that touches product code but must move no version.
516
+ Prefer it to skipping the step; the CI job wants a file, not a version.
517
+
518
+ `enabled: false` (or `tool: none`) ⇒ §2b is a no-op and nothing below applies.
519
+
520
+ ## Reconcile — bringing generated files up to the current core
521
+
522
+ `/cohorte-init-pipeline` is **one-time per project**. Afterwards, `/cohorte-update-pipeline` runs this procedure so a
523
+ core upgrade never requires re-running init — new pipeline features flow into the repo's generated
524
+ files automatically. It works because every generated artifact is a **deterministic function of
525
+ (current template × the profile's data)**; nothing needs re-detecting or re-interviewing.
526
+
527
+ 1. **Profile top-up.** Diff `PIPELINE.md`'s machine block against the current
528
+ `pipeline/PIPELINE.template.md`: every block/field the template has and the profile lacks is added
529
+ with its documented default (e.g. `surfaces[].model: sonnet`, `retrieval.provider: serena`).
530
+ **Ask only when a new field is a genuine human decision** (batch into ONE question set); never
531
+ change a value the profile already sets; never rewrite the prose sections. `release_notes` is one
532
+ such decision and must not be defaulted blind: detect a versioning tool / note-enforcing CI job per
533
+ `/cohorte-init-pipeline` Phase 1, and if there is one, ask Phase 2's release-notes question (anchor
534
+ package, language, bump policy, forbidden levels). No tool found ⇒ top up with `enabled: false`.
535
+ 2. **Re-render agent frontmatter + body.** For each `surfaces[]` entry, re-render
536
+ `<agents>/<agent>.md` from the current `implementer.template.md` per §Rendering above. Safe by
537
+ doctrine: rendered agents are regenerable artifacts — hand-written rules belong in `PIPELINE.md`
538
+ §Conventions (which reconcile never touches), NOT in agent files, where they'd be clobbered here.
539
+ 3. **Additive settings patch.** Run `<sync>` (it owns the gate hook, the pointer and the
540
+ `.gitignore` entries), then bring `<state>/gate-config.json` and the `settings.json` permissions up
541
+ to the current init spec (missing `allow` entries): add what's missing, never remove or rewrite
542
+ existing/custom keys.
543
+ 4. **Capability wiring.** If a top-up added a capability needing external setup (e.g. a `retrieval`
544
+ provider whose MCP server isn't registered yet), run its wiring step from `/cohorte-init-pipeline` Phase 4.
545
+ Even when nothing new was added, re-run the provider's health check (§Code retrieval) — wiring
546
+ rots (PATH changes, uninstalls, hand-edits) — and repair whatever fails.
547
+ 5. **Global config seed.** If `<config>` is absent, seed it from the template
548
+ (`profile/cohorte.config.template.yaml`) so the kanban + shared-vault config has a home. Never
549
+ clobber an existing filled file; report what was seeded. Then **scrub the retired `telemetry:`
550
+ block** if the file still carries one (every install seeded before 2.3.0 does): delete the block
551
+ and its comment header, leaving the rest byte-identical. It is dead config — the sender is gone
552
+ and nothing reads it — but a `telemetry.enabled: true` sitting in a file the human may open reads
553
+ as "this is still sending", which is the one thing it must not imply. This is the single
554
+ exception to "never rewrite the config": a targeted deletion of a block the core no longer
555
+ defines, never a re-seed.
556
+ 6. **Kanban sync.** Run the §Kanban reconcile: link/create the project's board if configured, verify
557
+ its columns, and backfill/sync cards from `specs/*.md`. See §Kanban.
558
+ 7. **Spec-template top-up.** `specs/_template.md` is seeded once at install and then **never**
559
+ refreshed, so a repo keeps whatever front-matter the core shipped the day it was installed (a
560
+ pre-1.6 copy's `status` comment still lists four states). Top it up the same way as the profile:
561
+ add the **front-matter fields** the current `templates/spec.template.md` has and the repo's copy
562
+ lacks, with their documented defaults, drop `loop_pass`/`loop_phase` (retired with the 2.2.0
563
+ conversational loop driver), and refresh the `status:` comment. Never rewrite its body — the section list is the human's to shape,
564
+ and some repos have deliberately trimmed it. Nothing breaks without this (the fields are written on
565
+ demand when a driver needs them); it just keeps a new spec's front-matter honest about the states
566
+ the pipeline can put it in.
567
+
568
+ 8. **Local-artifact hygiene.** The pipeline's own runtime files must stay out of git:
569
+ `<state>/preflight.ok`, `<state>/pipeline-metrics.jsonl`, `specs/reports/`. Add any missing entry to
570
+ `.gitignore`, and **untrack** what a pre-2.0.0 install let slip in —
571
+ `git rm --cached --ignore-unmatch <state>/preflight.ok` (repeat per stray path). The stamp is the
572
+ one that actively breaks: it records the tree it verified, the commit carrying it moves HEAD past
573
+ that tree, and the committed copy lands in every clone and worktree — so the phase gate ends up
574
+ blocking clean trees and greening unchecked ones. Report what was untracked; the human commits it.
575
+
576
+ Re-running `/cohorte-init-pipeline` remains possible (it reconciles too) but is only *needed* when the stack
577
+ itself changes in ways `/cohorte-build` §1.5 can't auto-grow (e.g. package manager or contract mechanism swap).
578
+
579
+ ## Workflows — deterministic multi-agent runs (opt-in)
580
+
581
+ Four scripts run under the Claude Code Workflow runtime instead of the lead reasoning out the
582
+ fan-out turn by turn: `<workflows>/cohorte-review.js`, `cohorte-audit.js`, `cohorte-refactor.js` — each the
583
+ **workflow variant** of its same-named conversational command — plus **the loop workflow**
584
+ (`cohorte-loop.js`), which has **no conversational form at all** (below). For the variant pairs,
585
+ the conversational commands (`/cohorte-review`, `/cohorte-audit`, `/cohorte-refactor`)
586
+ **remain the default path and the fallback** — a workflow runs only when the human explicitly asks
587
+ for it ("run the review workflow"), and requires Claude Code ≥ **2.1.154** with workflows
588
+ enabled.
589
+ `/cohorte-doctor` reports which path a session will take. The interactive commands (`/cohorte-init-pipeline`,
590
+ `/cohorte-brainstorm`, `/cohorte-spec`) and the dispatch-only ones (`/cohorte-build`, `/cohorte-ship`) have **no** workflow variant on
591
+ purpose: they're interviews or already a single parallel dispatch — a script adds nothing.
592
+ The loop workflow does not change that: it **consumes** `/cohorte-build`'s outputs (the frozen
593
+ spec, `readiness.json`, the lead-authored contract, `build.json`) — it is not a build variant,
594
+ and adding one would put the lead-only steps (§1.5 reconcile, §2 contract authoring) inside a
595
+ script that cannot ask.
596
+
597
+ Shared design, all four scripts:
598
+
599
+ - **Phase 0 is always `cohorte-profile-reader`** — workflow scripts have no filesystem or shell access, so a
600
+ dedicated agent (`core/agents/cohorte-profile-reader.md`, haiku, read-only) reads `PIPELINE.md` and returns
601
+ the `yaml pipeline-profile` block as JSON. Every later phase is parameterized from that object.
602
+ - **Mechanical phases run on haiku** (profile read, preflight, diff staging, report merging/writing);
603
+ judgment phases dispatch the same pinned agents the commands use (`review` at sonnet, the surface
604
+ implementers at their `surfaces[].model` tier) — the per-surface `model:` routing carries over.
605
+ - **Only the verdict comes back.** Bulk (diffs, reports, backlogs) is staged to the same disk
606
+ buffers the commands use (`specs/reports/`, `specs/refactor-backlog.md`); the workflow's return is
607
+ counts + verdict + paths.
608
+ - **A dead agent is never a clean result.** `agent()` resolves to `null` when a subagent dies, and a
609
+ dead *reviewer* returns zero findings — byte-identical to a surface that is genuinely clean. Any
610
+ script that derives a verdict from "how many findings came back" must first subtract the agents
611
+ that never answered: `review.js` names them in `unreviewedSurfaces` and refuses to score
612
+ `SHIP`. `scripts/test-workflows.mjs`
613
+ pins this — it is the one invariant the structural checks in `validate-core.mjs` cannot see.
614
+ The conversational commands enforce the same rule by roll call (§Dead agents); it was the workflows
615
+ that had it first, and for three releases they had it **alone** — the same crash on the
616
+ conversational path went unreported.
617
+ - **`review.js`** — preflight gate (aborts red, zero agents), the changed paths listed once and the
618
+ hunks staged per touched surface (§Feature diff — an empty diff aborts, it is never a SHIP), one
619
+ reviewer per surface in parallel (a dead one retried once), then an **adversarial cross-check**
620
+ phase that tries to refute each CRITICAL/security finding before it can trigger a fix loop. The
621
+ verdict — merged and per surface — is recomputed from the surviving findings by the review
622
+ agent's one rule.
623
+ - **`audit.js`** — one auditor per domain (each surface + `shared`), concurrency capped by the
624
+ runtime (~16), merged into `specs/refactor-backlog.md` — only the audited domains' sections are
625
+ rewritten (§Deferred findings).
626
+ - **`refactor.js`** — big domains only (it skips domains with a handful of open items — the
627
+ conversational `/cohorte-refactor` is cheaper there): `shared` first and alone (verified with the
628
+ repo-wide commands — it has no surface commands of its own), then the other domains'
629
+ implementers in parallel, each verified per-domain.
630
+ - **`loop.js`** (the loop workflow, `cohorte-loop.js`) — build → review → [fix → review]* for ONE feature, unattended and
631
+ resumable. Preconditions it verifies and refuses to work around: frozen/`in-review` spec, a fresh
632
+ `readiness.json` at `READY`/`RESERVATIONS`, the contract on disk, every readiness surface owned by
633
+ the profile. Round exits, in order: child abort relayed → `unreviewed` non-empty → `blocking == 0`
634
+ ⇒ ship → same blocking-item identity two consecutive rounds ⇒ treading water → `maxRounds`
635
+ (default 5). A blocking finding on the contract file aborts (`contract-change` — lead-only, per
636
+ `/cohorte-fix` §1). It calls the review **workflow** per round and reads the same `verdict.json`
637
+ contract the conversational `/cohorte-review` §3 writes; it stamps `in-progress` while running,
638
+ `in-review` on ship, `blocked` on a give-up (resumable or terminal — §Spec status). The review runs
639
+ as a child via `workflow('cohorte-review', {feature})`, the runtime's one-level nesting call; a
640
+ throw (runtime or script missing) closes the run as `review-workflow-unavailable`, resumable.
641
+ **Workflow-only, no command file, ever**
642
+ (`validate-core.mjs` pins it): if the runtime is unavailable it refuses explicitly rather than
643
+ degrading to a lead re-reasoning the fan-out every round at session-model prices.
644
+ - **No input mid-run.** A workflow runs to completion without questions; anything interactive
645
+ (contract changes, human decisions) belongs to the conversational path. The gate hook still
646
+ fires on workflow subagents (see
647
+ §Preflight) — in unattended runs its asks become denies. Know what that means for edits:
648
+ workflow subagents run in **`acceptEdits` whatever the session mode**, so for the length of a
649
+ run — and `loop.js` runs long, unattended stretches — `hooks/gate.py` is the only brake on
650
+ what agents write (the project hook also guards the gate's own files on `Write|Edit|MultiEdit`). That is stated here rather than discovered.
651
+ - **Permissions:** `/cohorte-init-pipeline` and `/cohorte-update-pipeline` extend the generated `settings.json`
652
+ `allow` list with what workflow agents need (the quiet commands, the shipped
653
+ `pipeline/scripts/*.sh`, read-only git incl. `git rev-parse`, and the retrieval provider's MCP
654
+ tools) so a run never stalls mid-workflow on a permission prompt nobody is watching.
655
+
656
+ ## Kanban — mirroring the pipeline onto an Obsidian board
657
+
658
+ An **optional, user-scoped** mirror of the dev flow: each pipeline stage moves a card across an
659
+ [Obsidian Kanban](https://github.com/mgmeyers/obsidian-kanban) board, one board per project. Config
660
+ lives in the consolidated global config `<config>` §`kanban` (NOT in
661
+ `PIPELINE.md` — the board path points at the user's personal vault, so it is machine-specific and must
662
+ not be committed). Everything below **no-ops silently** when the config is absent, `kanban.enabled` is
663
+ false, no board is configured for the current project, or the board file is missing — the pipeline never
664
+ blocks on the board.
665
+
666
+ **Config & board resolution.** `kanban.boards` is keyed by the project's `PIPELINE.md` `name`. To resolve
667
+ the current project's board: read `name` from `PIPELINE.md`, look up `kanban.boards[name]`. Found ⇒ the
668
+ board file is `<obsidian.vault_path>/<boards[name].board>`, its columns are `boards[name].columns` if
669
+ present else `kanban.columns`. Not found ⇒ kanban off for this project.
670
+
671
+ **Card format.** A card is a Kanban list item under a `## <column>` heading:
672
+ `- [ ] <human title> #<feature_id>`. The `#<feature_id>` tag is the join key between a card and its
673
+ `specs/<feature_id>.md`; it is how every stage finds *its* card (Grep the board for `#<id>`). Free-text
674
+ notes a human writes as sub-bullets under an Ideas card are seed context for `/cohorte-brainstorm`. Never touch
675
+ the trailing `%% kanban:settings … %%` block or the `kanban-plugin: board` front-matter.
676
+
677
+ Once shipped, `/cohorte-ship` appends the **PR number** to the card — `- [ ] <title> #<feature_id> — PR #<num>`.
678
+ The bare `#<num>` is what a board reader renders as a clickable link to the GitHub PR, so `/cohorte-ship` always
679
+ writes it when a PR was actually created.
680
+
681
+ **Move a card (the core op).** One call — the script does resolution AND the move outside the
682
+ agent's context (find, dedupe, sub-notes carried along, settings block preserved):
683
+
684
+ ```
685
+ <core>/pipeline/scripts/kanban-move.sh auto <id> <stage> [--pr <num>] [--title <title>]
686
+ ```
687
+
688
+ It creates
689
+ the card in the target column when none exists, keeps the first and drops duplicates, and appends
690
+ ` — PR #<num>` with `--pr`.
691
+
692
+ **`auto` is not a convenience, it is the contract.** It reads `name` from `PIPELINE.md`, then
693
+ `kanban.enabled` / `obsidian.vault_path` / `boards[name]` from `<config>`
694
+ (override with `COHORTE_CONFIG`, or skip the profile with `--project <name>`), and it maps the
695
+ **stage key** (`ideas` · `brainstorm` · `spec` · `ready` · `building` · `review` · `fix` · `ship` ·
696
+ `shipped`) to that board's heading through `boards[name].columns` → `kanban.columns` → the built-in
697
+ default. An explicit `<board.md>` path and a literal heading both still work, for one-off and
698
+ non-pipeline moves.
699
+
700
+ **Never conclude "no board is configured" without running it.** The command that resolves nothing
701
+ prints `kanban: <reason>` — naming the missing link (no config file, `enabled: false`, no entry for
702
+ this project, vault unset, board file gone) — and exits **0**. A configured board that cannot be
703
+ moved is loud instead: exit 2 on usage, exit 3 on an unknown column — or on an explicit
704
+ `<board.md>` path that does not exist (under `auto`, a configured board file that is gone is one of
705
+ the `kanban: board file not found` no-ops above, exit 0). Both readings are printed, so a caller
706
+ reports which one it got. This exists because inference was the
707
+ actual failure mode: with only "no-op silently if no board" to go on, a fresh phase session (every
708
+ phase runs after a `/clear`) decided there was no board without ever opening the config, and cards
709
+ stopped moving mid-pipeline while every command still reported success.
710
+
711
+ **Fallback when the script is absent** (older core): do it by hand, but never read the whole board
712
+ into context — it grows with every feature ever tracked: `grep -n` for `#<id>` and the `## ` headings
713
+ to locate lines, then use offset-limited Reads + targeted Edits around the matches. Either way: one
714
+ card per `#<id>`, whole line moved tag-preserved, card created in the target column if missing.
715
+
716
+ **Tag before you move.** The join key is the `#<id>` tag, and an **Ideas** card a human typed by hand
717
+ does not have one. Moving it first finds nothing, creates a second card, and strands the original in
718
+ Ideas — so `/cohorte-brainstorm` appends the tag to the picked line before its first move.
719
+
720
+ **Stage → column**, used both by each pipeline command (to move its card live) and by backfill:
721
+
722
+ | Pipeline moment | Column |
723
+ | --------------------------------------- | --------------- |
724
+ | human drops a raw idea (manual) | `ideas` |
725
+ | `/cohorte-brainstorm` picks it up | `brainstorm` |
726
+ | `/cohorte-spec` opens (draft) | `spec` |
727
+ | `/cohorte-spec` freezes (`status: frozen`) | `ready` |
728
+ | `/cohorte-patch` triages / freezes | `spec` → `ready` (card titled `[patch] <title>`, tag `#patch-<slug>`) |
729
+ | `/cohorte-build` | `building` |
730
+ | `/cohorte-review` | `review` |
731
+ | `/cohorte-fix` | `fix` |
732
+ | loop workflow, per phase (`in-progress`) | `building` → `review` → `fix`, as each phase starts |
733
+ | a round gave up (`blocked`) | `fix` |
734
+ | `/cohorte-ship` starts | `ship` |
735
+ | PR opened (`status: shipped`) | `shipped` (+ `PR #<num>` on the card) |
736
+
737
+ **Backfill / sync from specs (reconcile).** `specs/*.md` is the source of truth. For each spec, read its
738
+ `feature_id` (front-matter or filename) and `status`, map `status`→column — `frozen`→`ready`,
739
+ `in-progress`→`building` (the phase is unknown from the status alone; the next live move corrects it),
740
+ `in-review`→`review`, `blocked`→`fix`, `shipped`/`merged`/`abandoned`→`shipped`, anything else / a spec with no
741
+ status→`spec` — then **full
742
+ sync**: card absent ⇒ add it in that column; card present ⇒ **move it** to that column so the board
743
+ always reflects the specs (this repositions cards the human may have moved by hand). Report cards
744
+ added vs. moved vs. already-correct.
745
+
746
+ **Create a board.** When linking a project with no board file yet: write
747
+ `<obsidian.vault_path>/<folder>/Tasks.md` with the `kanban-plugin: board` front-matter, one `## <heading>`
748
+ per configured column in pipeline order, and the closing `%% kanban:settings %%` block
749
+ (`{"kanban-plugin":"board","list-collapse":[false,…]}` with one `false` per column).