cohorte 3.0.0 → 3.1.1

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 (69) hide show
  1. package/CHANGELOG.md +122 -0
  2. package/README.md +16 -10
  3. package/bin/cli.js +2 -1
  4. package/core/agents/cohorte-profile-reader.md +21 -31
  5. package/core/agents/cohorte-release.md +6 -3
  6. package/core/agents/cohorte-review.md +31 -5
  7. package/core/agents/implementer.template.md +13 -5
  8. package/core/commands/cohorte-align-ds.md +1 -1
  9. package/core/commands/cohorte-audit.md +11 -4
  10. package/core/commands/cohorte-brainstorm.md +2 -2
  11. package/core/commands/cohorte-build.md +19 -12
  12. package/core/commands/cohorte-doctor.md +11 -9
  13. package/core/commands/cohorte-fix.md +3 -3
  14. package/core/commands/cohorte-fleet.md +2 -2
  15. package/core/commands/cohorte-init-pipeline.md +2 -2
  16. package/core/commands/cohorte-intake.md +4 -4
  17. package/core/commands/cohorte-patch.md +2 -2
  18. package/core/commands/cohorte-refactor.md +73 -8
  19. package/core/commands/cohorte-retro.md +3 -3
  20. package/core/commands/cohorte-revert.md +104 -0
  21. package/core/commands/cohorte-review.md +32 -17
  22. package/core/commands/cohorte-ship.md +26 -9
  23. package/core/commands/cohorte-spec.md +13 -4
  24. package/core/commands/cohorte-update-pipeline.md +12 -8
  25. package/core/commands/cohorte-verify.md +106 -0
  26. package/core/hooks/gate.py +326 -21
  27. package/core/templates/patch.template.md +11 -2
  28. package/core/templates/spec.template.md +23 -2
  29. package/core/templates/steps/init-pipeline/01-detect-stack.md +14 -5
  30. package/core/templates/steps/init-pipeline/02-interview-gaps.md +26 -3
  31. package/core/templates/steps/init-pipeline/03-draft-profile.md +2 -1
  32. package/core/templates/steps/init-pipeline/04-write-render.md +16 -12
  33. package/core/templates/steps/init-pipeline/05-report.md +1 -1
  34. package/core/workflows/audit.js +9 -4
  35. package/core/workflows/loop.js +15 -10
  36. package/core/workflows/refactor.js +116 -9
  37. package/core/workflows/review.js +24 -10
  38. package/lib/doctor.js +37 -3
  39. package/lib/install.js +68 -33
  40. package/lib/project.js +45 -8
  41. package/lib/render.js +3 -3
  42. package/lib/yaml.js +10 -1
  43. package/package.json +2 -2
  44. package/profile/PIPELINE.template.md +39 -1
  45. package/profile/SCHEMA.md +27 -746
  46. package/profile/cohorte.config.template.yaml +1 -1
  47. package/profile/schema/dead-agents.md +29 -0
  48. package/profile/schema/decisions.md +23 -0
  49. package/profile/schema/deferred.md +22 -0
  50. package/profile/schema/feature-diff.md +20 -0
  51. package/profile/schema/kanban.md +95 -0
  52. package/profile/schema/metrics.md +23 -0
  53. package/profile/schema/output-discipline.md +21 -0
  54. package/profile/schema/preflight.md +81 -0
  55. package/profile/schema/profile-block.md +103 -0
  56. package/profile/schema/project-kinds.md +89 -0
  57. package/profile/schema/readiness.md +17 -0
  58. package/profile/schema/reconcile.md +64 -0
  59. package/profile/schema/release-notes.md +29 -0
  60. package/profile/schema/rendering.md +48 -0
  61. package/profile/schema/retrieval.md +58 -0
  62. package/profile/schema/spec-status.md +79 -0
  63. package/profile/schema/specialization.md +41 -0
  64. package/profile/schema/verify.md +115 -0
  65. package/profile/schema/workflows.md +78 -0
  66. package/scripts/kanban-move.sh +45 -3
  67. package/scripts/new-feature.sh.template +7 -1
  68. package/scripts/remove-feature.sh.template +14 -5
  69. package/scripts/verify-run.sh +509 -0
@@ -0,0 +1,64 @@
1
+ ## Reconcile — bringing generated files up to the current core
2
+
3
+ `/cohorte-init-pipeline` is **one-time per project**. Afterwards, `/cohorte-update-pipeline` runs this procedure so a
4
+ core upgrade never requires re-running init — new pipeline features flow into the repo's generated
5
+ files automatically. It works because every generated artifact is a **deterministic function of
6
+ (current template × the profile's data)**; nothing needs re-detecting or re-interviewing.
7
+
8
+ 1. **Profile top-up.** Diff `PIPELINE.md`'s machine block against the current
9
+ `pipeline/PIPELINE.template.md`: every block/field the template has and the profile lacks is added
10
+ with its documented default (e.g. `surfaces[].model: sonnet`, `retrieval.provider: serena`).
11
+ **Ask only when a new field is a genuine human decision** (batch into ONE question set); never
12
+ change a value the profile already sets; never rewrite the prose sections. `release_notes` is one
13
+ such decision and must not be defaulted blind: detect a versioning tool / note-enforcing CI job per
14
+ `/cohorte-init-pipeline` Phase 1, and if there is one, ask Phase 2's release-notes question (anchor
15
+ package, language, bump policy, forbidden levels). No tool found ⇒ top up with `enabled: false`.
16
+ Same for the 3.1 decisions: `commands.security` (ask init Phase 2's security question when a
17
+ scanner is detected, else `[]`), `commands.dev_ready` / `smoke` / `e2e` / `migrate_down` +
18
+ `verify.db` (ask the runtime-verification question when a dev server or e2e runner is detected,
19
+ else leave `dev_ready` empty), and `project.kind` (top up as `web`; ask only if Phase 1 detection
20
+ disagrees).
21
+ 2. **Re-render agent frontmatter + body.** For each `surfaces[]` entry, re-render
22
+ `<agents>/<agent>.md` from the current `implementer.template.md` per §Rendering (`<core>/pipeline/schema/rendering.md`). Safe by
23
+ doctrine: rendered agents are regenerable artifacts — hand-written rules belong in `PIPELINE.md`
24
+ §Conventions (which reconcile never touches), NOT in agent files, where they'd be clobbered here.
25
+ 3. **Additive settings patch.** Run `<sync>` (it owns the gate hook, the pointer,
26
+ `<state>/profile.json` and the `.gitignore` entries — so it runs AFTER step 1's top-up, and again
27
+ if anything later edits the machine block), then bring `<state>/gate-config.json` and the `settings.json` permissions up
28
+ to the current init spec (missing `allow` entries): add what's missing, never remove or rewrite
29
+ existing/custom keys.
30
+ 4. **Capability wiring.** If a top-up added a capability needing external setup (e.g. a `retrieval`
31
+ provider whose MCP server isn't registered yet), run its wiring step from `/cohorte-init-pipeline` Phase 4.
32
+ Even when nothing new was added, re-run the provider's health check (§Code retrieval, `<core>/pipeline/schema/retrieval.md`) — wiring
33
+ rots (PATH changes, uninstalls, hand-edits) — and repair whatever fails.
34
+ 5. **Global config seed.** If `<config>` is absent, seed it from the template
35
+ (`profile/cohorte.config.template.yaml`) so the kanban + shared-vault config has a home. Never
36
+ clobber an existing filled file; report what was seeded. Then **scrub the retired `telemetry:`
37
+ block** if the file still carries one (every install seeded before 2.3.0 does): delete the block
38
+ and its comment header, leaving the rest byte-identical. It is dead config — the sender is gone
39
+ and nothing reads it — but a `telemetry.enabled: true` sitting in a file the human may open reads
40
+ as "this is still sending", which is the one thing it must not imply. This is the single
41
+ exception to "never rewrite the config": a targeted deletion of a block the core no longer
42
+ defines, never a re-seed.
43
+ 6. **Kanban sync.** Run the §Kanban reconcile (`<core>/pipeline/schema/kanban.md`): link/create the project's board if configured, verify
44
+ its columns, and backfill/sync cards from `specs/*.md`.
45
+ 7. **Spec-template top-up.** `specs/_template.md` is seeded once at install and then **never**
46
+ refreshed, so a repo keeps whatever front-matter the core shipped the day it was installed (a
47
+ pre-1.6 copy's `status` comment still lists four states). Top it up the same way as the profile:
48
+ add the **front-matter fields** the current `templates/spec.template.md` has and the repo's copy
49
+ lacks, with their documented defaults, drop `loop_pass`/`loop_phase` (retired with the 2.2.0
50
+ conversational loop driver), and refresh the `status:` comment. Never rewrite its body — the section list is the human's to shape,
51
+ and some repos have deliberately trimmed it. Nothing breaks without this (the fields are written on
52
+ demand when a driver needs them); it just keeps a new spec's front-matter honest about the states
53
+ the pipeline can put it in.
54
+
55
+ 8. **Local-artifact hygiene.** The pipeline's own runtime files must stay out of git:
56
+ `<state>/preflight.ok`, `<state>/pipeline-metrics.jsonl`, `specs/reports/`. Add any missing entry to
57
+ `.gitignore`, and **untrack** what a pre-2.0.0 install let slip in —
58
+ `git rm --cached --ignore-unmatch <state>/preflight.ok` (repeat per stray path). The stamp is the
59
+ one that actively breaks: it records the tree it verified, the commit carrying it moves HEAD past
60
+ that tree, and the committed copy lands in every clone and worktree — so the phase gate ends up
61
+ blocking clean trees and greening unchecked ones. Report what was untracked; the human commits it.
62
+
63
+ Re-running `/cohorte-init-pipeline` remains possible (it reconciles too) but is only *needed* when the stack
64
+ itself changes in ways `/cohorte-build` §1.5 can't auto-grow (e.g. package manager or contract mechanism swap).
@@ -0,0 +1,29 @@
1
+ ## Release notes — the per-feature note the versioning tool consumes
2
+
3
+ Many repos gate merges on a **per-feature release note**: Changesets' `changeset` CI job fails any PR
4
+ that touches product code without a `.changeset/*.md`. That file is **not** something the release
5
+ agent can invent — picking the bump level is project policy (semver over an API vs. over a product,
6
+ a `0.x` rule forbidding `major`, what counts as user-visible), and the prose is outward-facing copy.
7
+ It is the **lead's** to write, exactly like the contract.
8
+
9
+ The failure mode this block exists to prevent is silent and reproducible: the requirement lives in the
10
+ project's `CLAUDE.md`, which the ship flow never reads, so `/cohorte-ship` completes, opens the PR,
11
+ moves the kanban card to **Shipped** — and CI goes red on a job nobody looked at. The feature reads as
12
+ shipped while being unmergeable. Encoding it in the profile is what makes the step survive a stateless
13
+ lead.
14
+
15
+ - **Authored before the dispatch**, next to the `status: shipped` flip (`/cohorte-ship` §2b), so the note
16
+ lands **inside** the release commit. Written after the fact it needs a second commit, and the PR is
17
+ already open and red.
18
+ - **One key in the front-matter** — `anchor_package`. Lockstep/`fixed` version groups propagate the bump
19
+ from it to every other workspace; listing more is how a repo ends up with a package bumped twice.
20
+ - **`forbid_levels`** encodes policy the tool itself may not enforce. The common one: while the product
21
+ is `0.y.z`, a `major` changeset makes Changesets jump to `1.0.0` with no human deciding it — so `0.x`
22
+ repos forbid `major` and declare a breaking change as `minor`.
23
+ - **Ask, don't guess, on an ambiguous bump.** Between two defensible levels (a refactor that also changes
24
+ what the user sees), state the reading and let the human pick — a wrong bump is a published version
25
+ number, not a fixable draft.
26
+ - **`empty_cmd`** covers the honest no-op: a PR that touches product code but must move no version.
27
+ Prefer it to skipping the step; the CI job wants a file, not a version.
28
+
29
+ `enabled: false` (or `tool: none`) ⇒ §2b is a no-op and nothing below applies.
@@ -0,0 +1,48 @@
1
+ ## Rendering / reconciling a surface agent (shared procedure)
2
+
3
+ Both `/cohorte-init-pipeline` (initial render) and `/cohorte-build` (auto-reconcile when a spec needs a new agent) use
4
+ this exact procedure so a surface is always defined the same way. To add surface `S`:
5
+
6
+ 1. **Add the `surfaces[]` entry** to `PIPELINE.md`: `key`, `path` (the disjoint tree it exclusively
7
+ owns), `label`, `agent` (rendered file name), `tools` (add `DesignSync` only if `uses_design: true`;
8
+ append the retrieval provider's MCP tools when `retrieval.provider` ≠ `none` — e.g. `mcp__serena`),
9
+ `model` (tier for the rendered agent: `sonnet` (default) — the implementer mostly applies a frozen
10
+ contract, which Sonnet does well at a fraction of the Opus-lead cost; `haiku` for purely mechanical
11
+ scaffolding; `inherit` only when the surface makes real design decisions worth the lead's model),
12
+ the five `*_cmd`s (derive from the surface's `package.json` / workspace
13
+ filter, mirroring a sibling surface), and `uses_design`. Then run `<sync>`: it regenerates
14
+ `<state>/profile.json` (the parsed machine block agents read), which otherwise lacks `S`.
15
+ 2. **Render the agent file** `<agents>/<agent>.md` from `<core>/pipeline/implementer.template.md`
16
+ — the template is already rendered for this runtime, so only the placeholders are yours to fill —
17
+ substituting `<SURFACE_AGENT>`, `<SURFACE_LABEL>`,
18
+ `<SURFACE_PATH>`, `<SURFACE_TOOLS>`, `<SURFACE_MODEL>`, `<PROJECT_NAME>`, and the surface-specific
19
+ blocks (`<SURFACE_EXTRA_NEVER>`, `<SURFACE_DESIGN_INPUT>`, `<SURFACE_TDD_STEP1>` — leave the design
20
+ ones empty unless `uses_design`). Fill `<SURFACE_CONVENTIONS>` with the surface's convention slice
21
+ **baked at render time**: `PIPELINE.md` §Conventions `### Shared` + this surface's
22
+ `### Surface: <key>` stanza + its §Testing lines, verbatim. At runtime the agent then reads only
23
+ the profile's machine block (the fenced `yaml pipeline-profile`) — never the prose sections. The
24
+ bake stays honest because §Conventions edits go through `/cohorte-update-pipeline`, whose reconcile
25
+ re-renders every agent (§Reconcile step 2, `<core>/pipeline/schema/reconcile.md`); hand-edit the prose without re-rendering and the baked
26
+ 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
27
+ stored `design_project` id — that goes stale on a DS rebuild):
28
+ - `<SURFACE_DESIGN_INPUT>` — a 4th input bullet: _"The **feature design** — the pages this feature
29
+ touches, listed in your dispatch's design slot as full links
30
+ (`https://claude.ai/design/p/<projectId>?file=<file>`); a slot saying `none` means a fix loop with
31
+ no visual work — skip DesignSync entirely. For each link, extract the `<projectId>` (the
32
+ `/p/…` segment) and `<file>` (the `?file=` query) from the URL and read it read-only via `DesignSync
33
+ get_file(<projectId>, <file>)`; `list_files(<projectId>)` to catch linked pages (shared nav/modals)
34
+ this feature also changes. The link is self-contained — no stored project id. Build with the code UI
35
+ kit (the `design_system_project`'s materialization: `@/components/ui/*` + tokens); read a primitive
36
+ via `get_file` only if it's missing/stale in code. Mobile-first."_
37
+ - `<SURFACE_TDD_STEP1>` — a **lead-in paragraph** above the TDD list (not a numbered item; it
38
+ renders as nothing for a non-design surface, which is why the list must not start at it):
39
+ _"**Pull the feature design first** (skip if your dispatch's design slot
40
+ says `none`): `DesignSync get_file(<projectId>, <file>)` for each link in the slot and translate
41
+ each into the code design system (`@/components/ui/*`, `cn()` + CVA), mobile-first — never ad-hoc
42
+ CSS. Then:"_
43
+ 3. **Add a §Conventions + §Testing stanza** for `S` in `PIPELINE.md` (mirror a sibling surface; keep it
44
+ rule-shaped). If `S` is a shared-code surface, its convention is "single owner of shared X; slices
45
+ consume, never redefine."
46
+
47
+ Removing/merging a surface is the reverse: drop the `surfaces[]` entry, delete its agent file, fold its
48
+ conventions, run `<sync>`. Never leave an agent file with no matching `surfaces[]` entry (orphan) or vice-versa.
@@ -0,0 +1,58 @@
1
+ ## Code retrieval — `retrieval.provider`
2
+
3
+ Agents spend most of their wall-clock reading the repo; a retrieval provider replaces grep-and-read
4
+ with symbol/graph queries. The flag is a **value, not a boolean**, so switching provider later is a
5
+ one-line profile change + re-running the wiring (no agent re-render needed — the guidance agents
6
+ follow is provider-agnostic: _"prefer the retrieval MCP tools over Grep/Glob + whole-file Reads"_).
7
+
8
+ | Provider | Mechanism | Freshness | Cost |
9
+ | --- | --- | --- | --- |
10
+ | `serena` (default) | live LSP symbol navigation (find symbol, references, semantic edits) | always current | none — no index |
11
+ | `graphify` | persistent tree-sitter knowledge graph over code + docs | as fresh as the last rescan | index step + re-index discipline |
12
+ | `none` | agents fall back to Grep/Glob/Read | — | — |
13
+
14
+ **Wiring (done by `/cohorte-init-pipeline`, or `/cohorte-update-pipeline` retroactively):**
15
+
16
+ - `serena` — requires the `serena` CLI (`uv tool install -p 3.13 serena-agent`). For day-to-day CLI
17
+ use it should also be on PATH (`uv tool update-shell`; uv installs to `~/.local/bin`). Register at
18
+ **project scope** so the registration is committed and portable (`--project-from-cwd` resolves the
19
+ project at server start, so the committed entry works on every machine) — and register the
20
+ **PATH-proof launcher**, not the bare command: Claude Code spawns MCP servers with whatever
21
+ environment it was launched from (a stale terminal, a GUI/IDE launch that never sourced a shell
22
+ profile), where `~/.local/bin` may be missing from PATH — a bare `serena` entry then dies with
23
+ ENOENT and agents silently fall back to Grep/Read:
24
+
25
+ ```sh
26
+ 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'
27
+ ```
28
+
29
+ (Windows-native teams: no `sh` — register the bare `serena` form instead and ensure the uv tools
30
+ dir is on PATH; keep the `--open-web-dashboard False` flag.) `--open-web-dashboard False` keeps the
31
+ dashboard available (reachable at `http://localhost:24282/dashboard/`) but stops it popping a browser
32
+ tab on every server start — the flag overrides the machine's `serena_config.yml`, so the behaviour is
33
+ the same for everyone on the repo. Gitignore `.serena/` (per-machine cache/config). Optionally
34
+ pre-index large repos once: `serena project index`.
35
+ - `graphify` — requires `uv tool install graphify` + `graphify install`; build the initial graph
36
+ (`/graphify .`) and rescan incrementally after big changes (`--update`). See graphify.net.
37
+ - Rendered agents get the provider's MCP tools appended to their `tools:` list (e.g. `mcp__serena`
38
+ grants the whole server); `none` ⇒ nothing appended.
39
+
40
+ **Serena health check** — run after wiring in `/cohorte-init-pipeline` AND on every `/cohorte-update-pipeline`
41
+ reconcile (wiring that worked once can rot: PATH changes, tool uninstalled, entry hand-edited):
42
+
43
+ 1. **CLI resolves:** `command -v serena`. Fails but `~/.local/bin/serena` exists ⇒ PATH repair
44
+ above; missing entirely ⇒ reinstall.
45
+ 2. **Registered:** this repo's `.mcp.json` has the `serena` entry ⇒ else re-run the `claude mcp add`.
46
+ If the entry is the bare `serena` form on a POSIX machine, upgrade it to the PATH-proof launcher
47
+ above (immune to launch-environment PATH gaps). If a launcher entry predates the
48
+ `--open-web-dashboard False` flag, append it so the dashboard no longer auto-opens a browser tab.
49
+ 3. **Gitignored:** `.serena/` is in `.gitignore` ⇒ else append it.
50
+ 4. **Actually connected:** the `mcp__serena` tools are exposed in the session (or `claude mcp list`
51
+ shows serena connected). If 1–3 pass but this fails, a session restart is needed — say so
52
+ explicitly instead of reporting success.
53
+
54
+ Report each check's result; never report Serena "wired" on registration alone.
55
+
56
+ Teammates cloning the repo get the committed `.mcp.json` and only need the provider CLI installed
57
+ and on PATH — if either is missing, the MCP server fails to start and agents silently fall back to
58
+ Grep/Read; the health check above is the diagnostic.
@@ -0,0 +1,79 @@
1
+ ## Spec status — the lifecycle state machine
2
+
3
+ A spec's front-matter `status` is not a label, it is the pipeline's **state**: every command routes on
4
+ it, `cohorte specs` boards on it, and the kanban backfill maps it to a column. Eight states:
5
+
6
+ | status | meaning | written by | who may build it |
7
+ | --- | --- | --- | --- |
8
+ | `draft` | the interview is open, nothing is frozen | `/cohorte-spec` Mode A | no |
9
+ | `frozen` | the contract is frozen — the handoff to `/cohorte-build` | `/cohorte-spec` Mode A freeze | yes |
10
+ | `in-progress` | a round is under way on this spec (or died mid-way) | an automated driver, if any | yes |
11
+ | `in-review` | reviewed / awaiting the next round or `/cohorte-ship` | `/cohorte-spec` Mode B, `/cohorte-fix` | yes |
12
+ | `blocked` | a round gave up here (non-convergent, no verdict, not implementable) | an automated driver, if any | yes, with the reason named |
13
+ | `shipped` | the PR is open; the status flip is part of the release commit | `/cohorte-ship` | no |
14
+ | `merged` | the PR merged — reconciled from `gh pr view`, never assumed | `/cohorte-ship` §0/§5, `/cohorte-doctor` reconcile | no |
15
+ | `abandoned` | the feature was dropped (PR closed unmerged, or never shipped) — the human's call | `/cohorte-ship` §0, the human | no |
16
+
17
+ **`merged` and `abandoned` close the lifecycle.** `shipped` only says a PR was opened; whether it
18
+ landed is a fact on the host, so it is **reconciled**, not guessed: `/cohorte-ship` re-entered on a
19
+ `shipped` spec and `/cohorte-doctor` both run `gh pr view <branch> --json state` — `MERGED` ⇒
20
+ `merged`; `CLOSED` unmerged ⇒ the human decides (reopen and continue, or `abandoned`). Both are
21
+ terminal: every builder refuses them, the kanban backfill maps them to `shipped`, and a worktree
22
+ still alive for one is a teardown candidate.
23
+
24
+ **`in-progress` and `blocked` are driver states.** No conversational command writes them — the
25
+ human-driven cycle moves `frozen` → `in-review` → `shipped` → `merged`. Their producer is the
26
+ **loop workflow** (`cohorte-loop.js`, from `core/workflows/loop.js` — the successor of the
27
+ 2.2.0-retired conversational driver): it stamps `in-progress` at each round, `in-review` when a
28
+ run ends at zero blocking findings, and `blocked` when a round gives up, with the reason in
29
+ `specs/reports/<id>.loop.json`. A **resumable** stop (a dead agent, a red preflight, an
30
+ unreviewed surface, a report that never landed) writes `reason` and **no** `outcome`, and
31
+ re-invoking the loop resumes at that round; a **terminal** one (treading water, max rounds, a
32
+ contract-change finding) writes both, and the next run starts fresh once a human re-entered
33
+ through `/cohorte-fix` or `/cohorte-build` (which rewrites `readiness.json` after `loop.json`).
34
+ External drivers may write these states too. Every reader routes on
35
+ them either way, and a stamp on a spec with no front-matter stays a silent no-op — no driver
36
+ dies over a status line.
37
+
38
+ **`kind` — feature (default), `patch` or `refactor`.** Orthogonal to `status`, and — with `migrations`
39
+ (below) — the only other front-matter field commands route on. `/cohorte-patch` freezes `specs/patch-<slug>.md` with `kind: patch` from
40
+ `templates/patch.template.md`: a ~60-line bug spec whose §4 **regression test** replaces §5 CONTRACT
41
+ as the thing the diff is checked against. It moves through the same states and the same commands —
42
+ `/cohorte-build` → `/cohorte-review` → `/cohorte-fix`* → `/cohorte-ship` — which is the whole design:
43
+ a patch is a spec, so nothing downstream is special-cased beyond three lines.
44
+
45
+ | what reads `kind: patch` | what it does differently |
46
+ | --- | --- |
47
+ | `/cohorte-build` §1.6 | judges §1 repro + §4 regression test instead of contract completeness; gap check `repro` |
48
+ | `/cohorte-build` §2 | authors no contract when §5 Contract delta is `none` (the usual case) |
49
+ | `/cohorte-ship` §1/§2b/§3 | branches off `vcs.patch_branch_prefix`; a `patch` bump by default; `fix(<scope>)` commit |
50
+
51
+ `/cohorte-refactor` §4 freezes `specs/refactor-<domains>-<date>.md` with `kind: refactor`: no
52
+ contract, §6 = the cleared backlog items, §9 = public behaviour preserved + tests green. It enters at
53
+ `/cohorte-review` (behaviour preservation + items landed + scope instead of contract conformance),
54
+ then `/cohorte-ship` (`refactor(<scope>)` commit) — never `/cohorte-build` or the loop workflow.
55
+
56
+ A patch may span **several surfaces** — one bug, one repro, one spec. What it may never do is add
57
+ **new** contract surface area: two surfaces agreeing on a shape that doesn't exist yet is what §5 is
58
+ for, so `/cohorte-patch` routes that to `/cohorte-spec` instead. Changing an *existing* contract entry
59
+ is a legitimate delta. The patch template keeps contract on **§5** and acceptance on **§9** — the two
60
+ numbers `review.md` and `implementer.template.md` name verbatim — and simply has no §8.
61
+
62
+ **`migrations` — `true` when the spec changes the database.** The third routed field. `/cohorte-spec`
63
+ sets it when §4 adds or alters a migration (or the contract changes what is persisted); absent
64
+ means `false`. It makes `## Rollback` mandatory — `/cohorte-ship` refuses the spec while
65
+ `verify-run.sh rollback-check` calls it empty — and makes `/cohorte-verify` run the migration (and its
66
+ down-then-up) on the dev database. See `<core>/pipeline/schema/verify.md`. `/cohorte-revert` reads
67
+ `## Rollback` for a `merged` spec and, on the human's word, sets `status: abandoned` inside the revert
68
+ commit — so the spec says so only if the revert actually merges.
69
+
70
+ Corollaries worth knowing:
71
+
72
+ - A spec with no front-matter makes every stamp a **silent no-op** — the state is bookkeeping, and the
73
+ loop must never die over a status line.
74
+ - Child commands write `status` too (`/cohorte-fix` sets `in-review`); re-stamping before each phase is what
75
+ keeps `in-progress` true for the duration of the run rather than for its first phase.
76
+ - `blocked` is not a failure to hide: `/cohorte-build` accepts it, names the `loop.json` reason, routes
77
+ by the spec's `## Remediation` (open items ⇒ `/cohorte-fix`), and sets `in-review` once its readiness
78
+ verdict is written. `/cohorte-build <id> --readiness-only` does that re-entry (checks, readiness,
79
+ contract) without dispatching anything — the loop then builds.
@@ -0,0 +1,41 @@
1
+ ## Specialization — when to split one surface into more agents
2
+
3
+ `/cohorte-build` dispatches ONE agent per surface, in parallel, so build wall-clock ≈ the **slowest single
4
+ surface**. More agents only build faster when they let the *slowest* surface's work run concurrently —
5
+ and only if the split is safe. The invariant that keeps parallelism safe is **one owner per tree, and
6
+ the frozen contract as the only cross-surface channel**. So specialization means carving a surface into
7
+ **smaller non-overlapping surfaces**, never pointing two agents at the same tree.
8
+
9
+ **Split a surface into specialized sub-surfaces only when BOTH hold:**
10
+
11
+ 1. **It's a bottleneck** — the surface is large (many modules / high LOC) and dominates build time.
12
+ 2. **The boundary is clean** — its work partitions into trees that don't share files, e.g. feature
13
+ modules (`src/features/*`, `src/modules/*`), route groups, or independent services (`services/*`).
14
+
15
+ **Rules when splitting (non-negotiable — they preserve the invariant):**
16
+
17
+ - **One owner per tree is a convention, not a sandbox.** Nothing mechanical enforces it: an agent's
18
+ `tools:` frontmatter names tools, not paths, and implementers have Write/Edit/Bash on the whole
19
+ repo. It holds because each dispatch names one tree ("Touch only `<surface.path>`"), the rendered
20
+ agent says the same, and review reads the diff per surface — so a stray write shows up there.
21
+ - **Shared code gets its own surface with a single owner.** Anything two slices both touch — routing,
22
+ global state/store, the design-system kit + tokens, shared utils — becomes its OWN surface (e.g.
23
+ `web-shared`), owned by exactly one agent. Never let two feature-slice agents both edit shared trees.
24
+ - **Cross-slice references go through the contract**, not direct imports between slice trees. If
25
+ `web-checkout` needs a shape produced by `api-billing`, that shape lives in the frozen contract.
26
+ - **Don't over-split.** A slice too small to hold ≥1 real task, or one with tangled boundaries, is worse
27
+ than not splitting — the coordination + token cost (each stateless agent re-reads `PIPELINE.md` + spec)
28
+ outweighs the parallelism. When boundaries aren't clean, keep one surface.
29
+
30
+ Coarse first, specialize on evidence: start with one `frontend` / `backend` surface each; split only a
31
+ surface that's proven slow and cleanly separable. The evidence lives in
32
+ the **main checkout's** `<state>/pipeline-metrics.jsonl` (gitignored) — one JSONL line per phase batch
33
+ (`ts`/`feature`/`phase`/`seconds`/`surfaces:{key: result}`), appended by `/cohorte-build`, `/cohorte-review`
34
+ and `/cohorte-fix`.
35
+ **`surfaces` keys are surface keys, nothing else** — run-level facts go in their own top-level
36
+ fields. Anything put inside `surfaces` is read
37
+ as a surface: `cohorte doctor` renders it as a row in the per-surface table and scores a non-`ok`
38
+ value as that surface failing. Always the main checkout, never the feature worktree (which dies at teardown while
39
+ metrics must accumulate across features) — resolve from anywhere with
40
+ `$(dirname "$(git rev-parse --git-common-dir)")/<state>/pipeline-metrics.jsonl`. Read it before
41
+ proposing a split: split the surface that actually dominates wall-clock, not the one that feels big.
@@ -0,0 +1,115 @@
1
+ ## Verify — "does it actually work", migrations and rollback
2
+
3
+ The preflight proves the code compiles and its tests pass; the review proves the diff matches
4
+ the spec. Neither starts the app, so runtime DoD items (the page renders, the migration rolls
5
+ back, the repro is gone) were never ticked by the pipeline. `/cohorte-verify <id>` is that step,
6
+ between a `SHIP` verdict and `/cohorte-ship`. It moves no kanban card: the board has no column
7
+ for it, and the card stays in Review.
8
+
9
+ ### Configured
10
+
11
+ Verify applies when `verify.enabled` is not `false` and the profile has
12
+ `commands.smoke`, `commands.e2e`, or `commands.dev` **with** `commands.dev_ready` (a server nobody
13
+ probes proves nothing). A spec with `migrations: true` and a `commands.migrate` counts too. Not
14
+ configured ⇒ `/cohorte-verify` says so and stops, and `/cohorte-ship` skips its runtime gate
15
+ silently.
16
+
17
+ ### The script
18
+
19
+ `<core>/pipeline/scripts/verify-run.sh run <id> …` takes every
20
+ command as an argument, exactly as the profile spells it, and handles the process work:
21
+
22
+ - It starts `commands.dev` in its own process group and probes `commands.dev_ready` (a URL that
23
+ answers 2xx/3xx, or a command that exits 0).
24
+ - It runs the checks under timeouts, in order: `smoke`, `smoke:<surface>`, `e2e`.
25
+ - When a local Playwright CLI resolves, it takes the screenshots.
26
+ - It **always stops the server**, on every exit path (stale groups from a SIGKILLed run are
27
+ reaped by `verify-run.sh stop <id>` or by the next run).
28
+ - It refuses when the ready probe already answers before the start, because that is someone
29
+ else's server.
30
+ - It never touches git: no checkout, commit, push or merge.
31
+
32
+ The lead never starts, probes or kills a process by hand. Run the call with the Bash timeout at
33
+ 600000 ms. The script's own `--deadline` (540 s) sits below that, so the deadline fires before the
34
+ tool timeout.
35
+
36
+ ### The gate
37
+
38
+ The hook only sees `verify-run.sh …`, so the script asks
39
+ `.claude/hooks/cohorte-gate.py --check` about each command before it runs any of them:
40
+
41
+ - `deny` ⇒ that check is recorded `SKIPPED` and never run.
42
+ - `ask` ⇒ exit 4 and nothing is started. The lead shows the human the list and re-runs with
43
+ `--confirmed` only after a yes in this session.
44
+
45
+ A `commands.migrate_down` that sits in `gate.deny` (`migration:rollback` usually does) is never
46
+ verified. To let the pipeline check rollbacks on the dev DB, move it to `gate.ask`.
47
+
48
+ ### Databases — dev only, never shared
49
+
50
+ Migrations run only when the spec says `migrations: true`.
51
+ `commands.migrate` runs before the app starts. When `commands.migrate_down` is set, the script then
52
+ runs down followed by `migrate` again, as one `rollback` check. `verify.db: shared` (a team DB,
53
+ staging) refuses every migration unless `isolation.db_per_worktree` is true **and** the run is in a
54
+ feature worktree that `new-feature.sh` registered (a row in `isolation.registry` for the branch's
55
+ last path segment), which has its own `<name>_<id>` DB. A bare `git worktree add` shares the main
56
+ checkout's database and is refused. The refusal is decided in the script,
57
+ and the run is then `SKIPPED`. No command ever targets a production database: the pipeline holds no
58
+ credentials for one, and the lead never edits an `.env` to point elsewhere.
59
+
60
+ ### Ports
61
+
62
+ The profile's URLs name the main checkout's ports. In a feature worktree,
63
+ substitute the slot's port (`isolation.port_base.<x>` + the slot from `.worktrees/slots.tsv`) in
64
+ `dev_ready`, `smoke` and `base_url`. Otherwise the probe can hit the main checkout's app, which the
65
+ script reports as "already answering".
66
+
67
+ ### verify.json
68
+
69
+ `specs/reports/<id>.verify.json` is the machine verdict, overwritten with an `incomplete` FAIL at
70
+ the start of every run:
71
+ `{id, phase, ts, verdict: PASS|FAIL|SKIPPED, reason, head, digest_base, digest, digest_after, checks: [{name, status, exit, seconds, cmd, log, note}], evidence: [paths]}`.
72
+ - Any check FAIL ⇒ the verdict is `FAIL`. Otherwise one PASS ⇒ `PASS`. Otherwise `SKIPPED`.
73
+ - `digest` is `feature-diff.sh --base <reviewed_base> --digest` of the verified tree.
74
+ - A check that changes it (a file written outside `specs/` and `.claude/` that is not gitignored)
75
+ adds a `tree` FAIL. Point outputs at `$VERIFY_ARTIFACTS` instead.
76
+ - `<id>.verify.md` is the human copy. Logs and screenshots go in `specs/reports/<id>.verify/`,
77
+ which is a gitignored buffer.
78
+
79
+ ### DoD — runtime items only, evidence or nothing
80
+
81
+ A DoD line that only a running app can prove
82
+ carries a trailing `· runtime: <check>` tag. Verify ticks it only when every check named `<check>`
83
+ or `<check>:…` exists with `PASS`, and it appends the line plus its evidence path under `## DoD` in
84
+ `<id>.verify.md`. A bare `· runtime` (responsive layout, "looks right") is never auto-ticked. A
85
+ screenshot shows that the page rendered, not that it is correct, so it is listed as evidence for a
86
+ human. Verify never ticks an untagged item and never unticks one.
87
+
88
+ ### Ship
89
+
90
+ | verify.json | ship |
91
+ | --- | --- |
92
+ | not configured (above) | silent, no gate |
93
+ | `FAIL`, fresh or stale | **blocks** until a newer run overwrites it |
94
+ | `PASS` with `digest` = spec `reviewed_digest` | proceeds |
95
+ | absent, `SKIPPED`, or stale `PASS` | asks: "not verified at runtime — ship anyway?" |
96
+
97
+ ### Migrations
98
+
99
+ `/cohorte-spec` sets `migrations: true` when §4 adds or changes a
100
+ migration, or when the contract changes what is persisted. It then fills `## Rollback` with three
101
+ lines: what to revert, the data implications (a dropped column's values do not come back), and the
102
+ exact down step. A missing `migrations:` key means `false`, for legacy specs. `verify-run.sh
103
+ rollback-check specs/<id>.md` exits 1 when `migrations: true` and `## Rollback` holds only template
104
+ stubs. `/cohorte-spec` runs it before freezing, and `/cohorte-ship` refuses on it.
105
+
106
+ ### Revert
107
+
108
+ `/cohorte-revert <id>` undoes a `merged` feature as a reviewable PR, never as a push to the
109
+ default branch:
110
+ - It finds the merge or squash commit via `gh`, and asks the human when the PR was rebase-merged.
111
+ - It reads `## Rollback` first, because the revert deletes the spec, which is restored into the
112
+ revert commit.
113
+ - It runs the down step with `verify-run.sh run <id> --phase revert`: same gate consult, same
114
+ dev-only DB rule, writes `<id>.revert.json`. The step runs while the migration files still exist.
115
+ - It opens a PR whose body carries `## Rollback` for the operator who rolls back production.
@@ -0,0 +1,78 @@
1
+ ## Workflows — deterministic multi-agent runs (opt-in)
2
+
3
+ Four scripts run under the Claude Code Workflow runtime instead of the lead reasoning out the
4
+ fan-out turn by turn: `<workflows>/cohorte-review.js`, `cohorte-audit.js`, `cohorte-refactor.js` — each the
5
+ **workflow variant** of its same-named conversational command — plus **the loop workflow**
6
+ (`cohorte-loop.js`), which has **no conversational form at all** (below). For the variant pairs,
7
+ the conversational commands (`/cohorte-review`, `/cohorte-audit`, `/cohorte-refactor`)
8
+ **remain the default path and the fallback** — a workflow runs only when the human explicitly asks
9
+ for it ("run the review workflow"), and requires Claude Code ≥ **2.1.154** with workflows
10
+ enabled.
11
+ `/cohorte-doctor` reports which path a session will take. The interactive commands (`/cohorte-init-pipeline`,
12
+ `/cohorte-brainstorm`, `/cohorte-spec`) and the dispatch-only ones (`/cohorte-build`, `/cohorte-ship`) have **no** workflow variant on
13
+ purpose: they're interviews or already a single parallel dispatch — a script adds nothing.
14
+ The loop workflow does not change that: it **consumes** `/cohorte-build`'s outputs (the frozen
15
+ spec, `readiness.json`, the lead-authored contract, `build.json`) — it is not a build variant,
16
+ and adding one would put the lead-only steps (§1.5 reconcile, §2 contract authoring) inside a
17
+ script that cannot ask.
18
+
19
+ Shared design, all four scripts:
20
+
21
+ - **Phase 0 is always `cohorte-profile-reader`** — workflow scripts have no filesystem or shell access, so a
22
+ dedicated agent (`core/agents/cohorte-profile-reader.md`, haiku, read-only) returns the
23
+ `yaml pipeline-profile` block as JSON — one Read of `<state>/profile.json` (already parsed by
24
+ `<sync>`), falling back to parsing `PIPELINE.md` when that file is absent. Every later phase is parameterized from that object.
25
+ - **Mechanical phases run on haiku** (profile read, preflight, diff staging, report merging/writing);
26
+ judgment phases dispatch the same pinned agents the commands use (`review` at sonnet, the surface
27
+ implementers at their `surfaces[].model` tier) — the per-surface `model:` routing carries over.
28
+ - **Only the verdict comes back.** Bulk (diffs, reports, backlogs) is staged to the same disk
29
+ buffers the commands use (`specs/reports/`, `specs/refactor-backlog.md`); the workflow's return is
30
+ counts + verdict + paths.
31
+ - **A dead agent is never a clean result.** `agent()` resolves to `null` when a subagent dies, and a
32
+ dead *reviewer* returns zero findings — byte-identical to a surface that is genuinely clean. Any
33
+ script that derives a verdict from "how many findings came back" must first subtract the agents
34
+ that never answered: `review.js` names them in `unreviewedSurfaces` and refuses to score
35
+ `SHIP`. `scripts/test-workflows.mjs`
36
+ pins this — it is the one invariant the structural checks in `validate-core.mjs` cannot see.
37
+ The conversational commands enforce the same rule by roll call (§Dead agents, `<core>/pipeline/schema/dead-agents.md`); it was the workflows
38
+ that had it first, and for three releases they had it **alone** — the same crash on the
39
+ conversational path went unreported.
40
+ - **`review.js`** — preflight gate (aborts red, zero agents), the changed paths listed once and the
41
+ hunks staged per touched surface (§Feature diff, `<core>/pipeline/schema/feature-diff.md` — an empty diff aborts, it is never a SHIP), one
42
+ reviewer per surface in parallel (a dead one retried once), then an **adversarial cross-check**
43
+ phase that tries to refute each CRITICAL/security finding before it can trigger a fix loop. The
44
+ verdict — merged and per surface — is recomputed from the surviving findings by the review
45
+ agent's one rule.
46
+ - **`audit.js`** — one auditor per domain (each surface + `shared`), concurrency capped by the
47
+ runtime (~16), merged into `specs/refactor-backlog.md` — only the audited domains' sections are
48
+ rewritten (§Deferred findings, `<core>/pipeline/schema/deferred.md`).
49
+ - **`refactor.js`** — big domains only (it skips domains with a handful of open items — the
50
+ conversational `/cohorte-refactor` is cheaper there): `shared` first and alone (verified with the
51
+ repo-wide commands — it has no surface commands of its own), then the other domains'
52
+ implementers in parallel, each verified per-domain; then, gates green, it freezes the round as one
53
+ `kind: refactor` spec and ticks the backlog with `· refactor:<id>` (review → ship from there).
54
+ - **`loop.js`** (the loop workflow, `cohorte-loop.js`) — build → review → [fix → review]* for ONE feature, unattended and
55
+ resumable. Preconditions it verifies and refuses to work around: frozen/`in-review` spec, a fresh
56
+ `readiness.json` at `READY`/`RESERVATIONS`, the contract on disk, every readiness surface owned by
57
+ the profile. Round exits, in order: child abort relayed → `unreviewed` non-empty → `blocking == 0`
58
+ ⇒ ship → same blocking-item identity two consecutive rounds ⇒ treading water → `maxRounds`
59
+ (default 5). A blocking finding on the contract file aborts (`contract-change` — lead-only, per
60
+ `/cohorte-fix` §1). It calls the review **workflow** per round and reads the same `verdict.json`
61
+ contract the conversational `/cohorte-review` §3 writes; it stamps `in-progress` while running,
62
+ `in-review` on ship, `blocked` on a give-up (resumable or terminal — §Spec status, `<core>/pipeline/schema/spec-status.md`). The review runs
63
+ as a child via `workflow('cohorte-review', {feature})`, the runtime's one-level nesting call; a
64
+ throw (runtime or script missing) closes the run as `review-workflow-unavailable`, resumable.
65
+ **Workflow-only, no command file, ever**
66
+ (`validate-core.mjs` pins it): if the runtime is unavailable it refuses explicitly rather than
67
+ degrading to a lead re-reasoning the fan-out every round at session-model prices.
68
+ - **No input mid-run.** A workflow runs to completion without questions; anything interactive
69
+ (contract changes, human decisions) belongs to the conversational path. The gate hook still
70
+ fires on workflow subagents (see
71
+ §Preflight, `<core>/pipeline/schema/preflight.md`) — in unattended runs its asks become denies. Know what that means for edits:
72
+ workflow subagents run in **`acceptEdits` whatever the session mode**, so for the length of a
73
+ run — and `loop.js` runs long, unattended stretches — `hooks/gate.py` is the only brake on
74
+ what agents write (the project hook also guards the gate's own files on `Write|Edit|MultiEdit|NotebookEdit`). That is stated here rather than discovered.
75
+ - **Permissions:** `/cohorte-init-pipeline` and `/cohorte-update-pipeline` extend the generated `settings.json`
76
+ `allow` list with what workflow agents need (the quiet commands, the shipped
77
+ `pipeline/scripts/*.sh`, read-only git incl. `git rev-parse`, and the retrieval provider's MCP
78
+ tools) so a run never stalls mid-workflow on a permission prompt nobody is watching.
@@ -1,6 +1,6 @@
1
1
  #!/bin/sh
2
2
  # kanban-move.sh — move a feature card on an Obsidian Kanban board without
3
- # loading the board into an agent's context (SCHEMA.md §Kanban "Move a card").
3
+ # loading the board into an agent's context (schema/kanban.md "Move a card").
4
4
  #
5
5
  # kanban-move.sh <board.md|auto> <feature-id> <column|stage> [options]
6
6
  # kanban-move.sh --check resolve only: print the board this
@@ -30,9 +30,10 @@
30
30
  #
31
31
  # Exit codes: 0 ok (incl. "kanban not configured" — and, under `auto`, a configured
32
32
  # board file that is gone: `kanban: board file not found`) · 2 usage · 3 unknown
33
- # column, or an EXPLICIT <board.md> path that does not exist. A board that resolved
33
+ # column, or an EXPLICIT <board.md> path that does not exist · 4 the board stayed locked
34
+ # by another move for ~30 s (moves are serialized). A board that resolved
34
35
  # but cannot be moved is loud; an unconfigured one is quiet — the pipeline never
35
- # blocks on the board. (SCHEMA.md §Kanban states the same contract.)
36
+ # blocks on the board. (schema/kanban.md states the same contract.)
36
37
  set -eu
37
38
 
38
39
  usage='usage: kanban-move.sh <board.md|auto> <feature-id> <column|stage> [--pr <num>] [--title <title>] [--project <name>] [--profile <path>]
@@ -227,6 +228,47 @@ fi
227
228
 
228
229
  [ -f "$board" ] || { echo "error: board not found: $board" >&2; exit 3; }
229
230
 
231
+ # Serialize the read-modify-write: parallel worktrees (/cohorte-fleet, the loop workflow) move
232
+ # cards on ONE board, and two concurrent rewrites used to lose one of the moves.
233
+ # Where flock(1) exists (Linux), the kernel holds the lock and drops it if we die; the lock file
234
+ # lives in $TMPDIR keyed by the board's path, never next to the board in the human's vault.
235
+ # Elsewhere (macOS has no flock) an atomic `mkdir` is the lock and the holder's PID marks it: a
236
+ # lock is stale only when that process is gone, never by age. COHORTE_KANBAN_NO_FLOCK=1 forces
237
+ # the fallback (tests).
238
+ lock="${board}.lock"
239
+ if [ -z "${COHORTE_KANBAN_NO_FLOCK:-}" ] && command -v flock >/dev/null 2>&1; then
240
+ flockfile="${TMPDIR:-/tmp}/cohorte-kanban-$(printf '%s' "$board" | cksum | cut -d' ' -f1).lock"
241
+ exec 9>"$flockfile"
242
+ if ! flock -w 30 9; then
243
+ echo "error: board is locked by another move ($flockfile) — retry" >&2
244
+ exit 4
245
+ fi
246
+ else
247
+ waited=0
248
+ until mkdir "$lock" 2>/dev/null; do
249
+ holder=$(cat "$lock/pid" 2>/dev/null || true)
250
+ if [ -n "$holder" ] && ! kill -0 "$holder" 2>/dev/null; then
251
+ # Dead holder. Remove only if it is still THAT lock (another waiter may have replaced it).
252
+ if [ "$(cat "$lock/pid" 2>/dev/null || true)" = "$holder" ]; then
253
+ rm -f "$lock/pid"; rmdir "$lock" 2>/dev/null || true
254
+ fi
255
+ continue
256
+ fi
257
+ waited=$((waited + 1))
258
+ if [ "$waited" -gt 300 ]; then
259
+ echo "error: board is locked by another move ($lock, pid ${holder:-?}) — retry, or remove the lock if no move is running" >&2
260
+ exit 4
261
+ fi
262
+ sleep 0.1 2>/dev/null || sleep 1
263
+ done
264
+ echo $$ > "$lock/pid"
265
+ # Release only our own lock, and never let the release change the exit status.
266
+ release() { [ "$(cat "$lock/pid" 2>/dev/null || true)" = "$$" ] && { rm -f "$lock/pid"; rmdir "$lock" 2>/dev/null; }; return 0; }
267
+ trap release EXIT
268
+ trap 'exit 130' INT
269
+ trap 'exit 143' TERM
270
+ fi
271
+
230
272
  tmp="${board}.kanban-move.$$"
231
273
  ID="$id" COL="$col" PR="$pr" TITLE="${title:-$id}" awk '
232
274
  # Emit one line, collapsing runs of blank lines to a single one. Without this
@@ -19,10 +19,16 @@
19
19
  set -euo pipefail
20
20
 
21
21
  id="${1:-}"
22
- if [[ -z "$id" ]]; then
22
+ if [[ -z "$id" || $# -gt 1 ]]; then
23
23
  echo "usage: scripts/new-feature.sh <feature_id>" >&2
24
24
  exit 1
25
25
  fi
26
+ # The id becomes a branch name, a directory, a database name and a slot key: kebab-case only
27
+ # (what /cohorte-spec assigns), so nothing downstream has to quote or escape it.
28
+ if [[ ! "$id" =~ ^[a-z0-9][a-z0-9-]{0,62}$ ]]; then
29
+ echo "error: feature id \"$id\" must be kebab-case (a-z, 0-9, -; at most 63 chars), as /cohorte-spec assigns it" >&2
30
+ exit 2
31
+ fi
26
32
 
27
33
  repo_root="$(git -C "$(dirname "${BASH_SOURCE[0]}")" rev-parse --show-toplevel)"
28
34
  branch="__BRANCH_PREFIX__${id}"