@jaggerxtrm/specialists 3.18.0 → 3.18.2

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 (55) hide show
  1. package/config/mandatory-rules/code-quality-defaults.md +58 -1
  2. package/config/mandatory-rules/executor-delivery.md +4 -0
  3. package/config/mandatory-rules/test-runner-execution-scope.md +4 -0
  4. package/config/skills/setup-specialists/SKILL.md +1 -1
  5. package/config/skills/using-script-specialists/SKILL.md +5 -5
  6. package/config/skills/using-specialists/SKILL.md +1135 -879
  7. package/config/skills/using-specialists-auto/SKILL.md +21 -21
  8. package/config/specialists/chain-coordinator.specialist.json +63 -0
  9. package/config/specialists/reviewer.specialist.json +1 -1
  10. package/config/specialists/seconder.specialist.json +1 -1
  11. package/dist/asset-contract.json +8 -13
  12. package/dist/index.js +1070 -81
  13. package/dist/lib.js +185 -9
  14. package/dist/types/cli/clean.d.ts.map +1 -1
  15. package/dist/types/cli/doctor.d.ts.map +1 -1
  16. package/dist/types/cli/feed.d.ts.map +1 -1
  17. package/dist/types/cli/format-helpers.d.ts.map +1 -1
  18. package/dist/types/cli/init.d.ts.map +1 -1
  19. package/dist/types/cli/merge.d.ts.map +1 -1
  20. package/dist/types/cli/ps.d.ts.map +1 -1
  21. package/dist/types/cli/run.d.ts +19 -0
  22. package/dist/types/cli/run.d.ts.map +1 -1
  23. package/dist/types/cli/status.d.ts.map +1 -1
  24. package/dist/types/cli/view.d.ts.map +1 -1
  25. package/dist/types/pi/session.d.ts +1 -0
  26. package/dist/types/pi/session.d.ts.map +1 -1
  27. package/dist/types/specialist/control.d.ts.map +1 -1
  28. package/dist/types/specialist/dead-job-audit.d.ts +20 -0
  29. package/dist/types/specialist/dead-job-audit.d.ts.map +1 -0
  30. package/dist/types/specialist/launch.d.ts +8 -0
  31. package/dist/types/specialist/launch.d.ts.map +1 -1
  32. package/dist/types/specialist/loader.d.ts +12 -0
  33. package/dist/types/specialist/loader.d.ts.map +1 -1
  34. package/dist/types/specialist/observability-db.d.ts +1 -1
  35. package/dist/types/specialist/observability-sqlite.d.ts +76 -0
  36. package/dist/types/specialist/observability-sqlite.d.ts.map +1 -1
  37. package/dist/types/specialist/pr-drift-refresh.d.ts +17 -0
  38. package/dist/types/specialist/pr-drift-refresh.d.ts.map +1 -0
  39. package/dist/types/specialist/process-health.d.ts +16 -1
  40. package/dist/types/specialist/process-health.d.ts.map +1 -1
  41. package/dist/types/specialist/runner.d.ts +3 -0
  42. package/dist/types/specialist/runner.d.ts.map +1 -1
  43. package/dist/types/specialist/status-load.d.ts.map +1 -1
  44. package/dist/types/specialist/supervisor.d.ts +10 -0
  45. package/dist/types/specialist/supervisor.d.ts.map +1 -1
  46. package/dist/types/specialist/timeline-events.d.ts +2 -0
  47. package/dist/types/specialist/timeline-events.d.ts.map +1 -1
  48. package/docs/design/roadmap/chain-templates/README.md +1 -1
  49. package/docs/design/roadmap/chains-prompt-evals.md +3054 -0
  50. package/docs/design/roadmap/specialists-roadmap.md +75 -7
  51. package/docs/design/xt-pi-role-pi-flag-passthrough.md +174 -0
  52. package/docs/skills.md +4 -13
  53. package/package.json +2 -2
  54. package/config/skills/using-specialists-v2/SKILL.md +0 -766
  55. package/config/skills/using-specialists-v3/SKILL.md +0 -1267
@@ -1,1267 +0,0 @@
1
- ---
2
- name: using-specialists-v3
3
- description: >
4
- Canonical specialist orchestration skill. Use proactively for substantial work
5
- that should be delegated, tracked, reviewed, fixed, tested, or merged through
6
- specialists: code review, debugging, implementation, planning, doc sync,
7
- security checks, multi-step chains, integration-phase reconciliation,
8
- debugger-restitch on conflicting chains, pre-dispatch conflict-cluster
9
- mapping, test-failure-map epics, and questions about specialist workflow.
10
- version: 3.5
11
- ---
12
-
13
- # Using Specialists v3
14
-
15
- You are the orchestrator. Turn user intent into a strong bead contract, choose right specialist from live registry, launch chain, monitor it, consume results, drive fixes, and publish through specialist merge path.
16
-
17
- Keep skill practical. Core behavior belongs here; volatile detail stays in live commands.
18
-
19
- > **MANDATORY — Run on skill load and before every new substantial task or epic:**
20
- > ```bash
21
- > specialists list --full
22
- > ```
23
- > Do not rely on remembered roles, models, or permissions. The registry is the source of truth.
24
- > Run it again before dispatching any new chain or starting any epic — specialists change between sessions.
25
-
26
- ## Specialist File Locations
27
-
28
- Specialists live in three layers. Know which layer you are reading or editing:
29
-
30
- | Layer | Path | Purpose |
31
- |-------|------|---------|
32
- | Package (shipped) | `config/specialists/*.specialist.json` | Canonical role definitions; versioned with the repo |
33
- | User override | `.specialists/user/*.specialist.json` | Per-project customizations; wins over package layer for same name |
34
- | Default mirror | `.specialists/default/*.specialist.json` | Repo-managed mirror of package defaults; overrides package fallback |
35
-
36
- The loader resolves in priority order: user → default-mirror → package. A same-name file in `.specialists/user/` fully replaces the package version for that specialist. When creating or editing a specialist, use `config/specialists/` for shipped roles and `.specialists/user/` for project-specific overrides. Never edit `.specialists/default/` by hand — it is managed by `update-specialists`.
37
-
38
- `specialists list --full` shows the resolved set (which layer each specialist comes from) so you always know what will actually run.
39
-
40
- ### Editing Specialist Fields: `sp edit` Is Required
41
-
42
- Direct JSON editing is error-prone and bypasses schema validation. Use `sp edit` for all field changes — it validates dot-paths, handles array append/remove, and writes to the correct layer.
43
-
44
- ```bash
45
- # Read a field
46
- sp edit executor --get specialist.execution.model
47
-
48
- # Set a field (schema-validated)
49
- sp edit executor specialist.execution.model <model-id>
50
-
51
- # Set prompt.system or task_template from a file (required for multi-line content)
52
- sp edit executor --set specialist.prompt.system _ --file ./my-system-prompt.txt
53
-
54
- # Append or remove tags
55
- sp edit executor --set specialist.metadata.tags review,security --append
56
- sp edit executor --set specialist.metadata.tags old-tag --remove
57
-
58
- # Apply a named preset (run sp edit --list-presets for current options)
59
- sp edit executor --preset power
60
- sp edit executor --preset cheap --dry-run # preview first
61
-
62
- # Target a specific scope when name exists in multiple layers
63
- sp edit executor --scope user --set specialist.execution.model <model-id>
64
-
65
- # Bulk read across all specialists
66
- sp edit --all --get specialist.execution.model
67
- ```
68
-
69
- **When `sp edit` is required vs. direct JSON edit:**
70
- - Model, thinking level, timeout, tags, permission, description → always `sp edit`
71
- - `prompt.system` or `task_template` longer than one line → `sp edit --file`
72
- - Structural schema fields (execution flags, output_schema) → `sp edit` with dot-path
73
- - Net-new specialist creation → `specialists-creator` skill, then `sp edit` for tuning
74
- - Bulk cross-specialist reads → `sp edit --all --get <path>`
75
- - Available presets → `sp edit --list-presets` (do not hardcode; varies by install)
76
-
77
- ## Orchestration Discipline (Paranoid Mode)
78
-
79
- You are an orchestrator, not a hero. Move slowly enough to be correct.
80
-
81
- - Run `specialists list --full` and `sp help` again at the start of every new substantial task. Do not skip because "you remember." Roles, models, and flags drift between sessions.
82
- - Re-read the bead before dispatch. If you cannot defend each contract field out loud, the bead is not ready.
83
- - Never dispatch a chain you cannot describe end-to-end (which specialist, which bead, which workspace, which merge target).
84
- - Verify worktree and job state before and after each dispatch with `sp ps` and `git worktree list`. Drift is silent until merge.
85
- - Treat reviewer `PARTIAL` and seconder `FINDINGS` as mandatory fix loops, not advisory noise.
86
- - When unsure, prefer extra explorer/debugger passes over an over-eager executor. Wrong code merged is more expensive than slow research.
87
-
88
- ## Project-Specific Specialists
89
-
90
- Users define their own specialists in `.specialists/user/*.specialist.json` to fit project shape (domain knowledge, language, framework, conventions). These override package defaults and may not match generic role descriptions.
91
-
92
- - Always run `specialists list --full` to see the resolved set, including project-specific roles, before choosing.
93
- - Read `sp help` and the specialist's description/tags to confirm fit. Do not assume a name maps to its package-default behavior — a `.specialists/user/` override may have a different prompt, model, or scope.
94
- - Pick the project-specific specialist when its role matches the task shape. Do not fall back to a generic role just because it is more familiar.
95
- - If the task does not match any project-specific role, use the package default and consider whether a new project-specific specialist would help (use `specialists-creator` skill).
96
-
97
- ## Mandatory Gates: Seconder, Obligations, Security (Iron-style)
98
-
99
- For any substantive production diff, the chain shape is the canonical pipeline from [`docs/design/chain-templates.md` §2](../../../docs/design/chain-templates.md#2-the-canonical-pipeline):
100
-
101
- ```
102
- writer (executor/debugger) → seconder → test-engineer → test-runner → security-auditor (if surface) → obligations-scanner → reviewer → Release Checklist
103
- ```
104
-
105
- Reviewer consumes final QA evidence together with Iron gates: test-engineer output, test-runner classification, smoke/E2E proof, telemetry/log assertions, obligations-scanner, and security-auditor when applicable.
106
-
107
- `seconder`, `test-engineer`, `test-runner`, `obligations-scanner`, and `reviewer` are mandatory on production diffs (shipped via Opp 14 / `unitAI-sfwe1` + Opp 15 / `unitAI-4e194`). `security-auditor` is mandatory when the diff touches a sensitive surface. Reviewer follows canon §2.2 SCRUTINY as a chain-property, not reviewer input.
108
-
109
- ### Seconder Gate — `seconder`
110
-
111
- Mandatory READ_ONLY scope/compliance + smell/type-safety/simplicity dual-verdict gate (canon §2.3). Every change gets one cheap second pair of eyes before QA and reviewer. If `overall_verdict` is FAIL or UNCLEAR where not allowed, route back to writer.
112
-
113
- - Skip permitted ONLY for: test-only diffs (entirely under `test/`, `tests/`, `__tests__/`, `*.spec.*`, `*.test.*`, `*.fixture.*`) or new-file-only diffs (no modifications to existing symbols).
114
- - Any other skip = escalation event. Small diffs hide the worst regressions.
115
-
116
- ### Obligations Gate — `obligations-scanner`
117
-
118
- Mandatory READ_ONLY marker scan. Catches new TODO/FIXME/HACK/XXX/TEMP/WIP/NOTE(release) in production code that would otherwise leak unaccounted. Cheap (<30s, gpt-5.4-mini, bare).
119
-
120
- - Accepts structured `// TODO(<bead-id>): reason` markers if the linked bead exists and is in current bead's NON_GOALS.
121
- - Rejects unstructured markers in production code → reviewer issues PARTIAL "obligation: must resolve or accept".
122
- - Markers under test/fixture/mock/e2e/docs paths are noted but never block.
123
-
124
- The scanner produces JSON; the reviewer consumes its output directly via job feed.
125
-
126
- ### Security Gate — `security-auditor`
127
-
128
- Mandatory when diff touches: auth, secrets, input handling (user/network/file), dependency lockfiles, agent/MCP/config surfaces, token-storage paths, migrations, permissions/hooks. Scan-only; recommendations only; executor applies fixes.
129
-
130
- - Never skip on sensitive-surface diff "because the diff looks small."
131
- - Auto-triggered by reviewer's SCRUTINY auto-escalation table when surface patterns match.
132
-
133
- ### Dispatch mechanics for all three gates
134
-
135
- All run with their own bead and `--job <exec-job>` so they enter the executor workspace.
136
-
137
- Routing across chain phases:
138
-
139
- - **Per-chain dispatch**: gates run on the chain's job in canon order: seconder → test-engineer → test-runner → security-auditor (if surface) → obligations-scanner → reviewer. Seconder FAIL/UNCLEAR routes back to writer; test-runner misclassifications route to test-engineer or writer per canon §2.5.
140
- - **Debugger-restitch**: same gate order on the debugger's job AFTER the restitch turn, BEFORE reviewer.
141
- - **E2E smoke phase**: cross-cutting security-auditor on cumulative integrated diff if any landed chain touched a sensitive surface.
142
- - **Reviewer rebuttal**: seconder OK and security-auditor "no findings" are legitimate evidence in reviewer rebuttals (cite the advisory job id).
143
-
144
- ## Monitoring Long-Running Jobs: Sleep Timers Are Mandatory
145
-
146
- Specialists run async. You will lose the chain if you do not actively monitor it.
147
-
148
- **Required pattern after every dispatch:**
149
-
150
- ```bash
151
- sp run <role> --bead <id> --background ... # dispatch
152
- sleep 10 && sp ps # confirm started
153
- ```
154
-
155
- Then cycle sleeps based on average completion time per role, checking `sp ps` each cycle:
156
-
157
- | Role | Typical duration | Initial sleep cycle |
158
- |------|------------------|---------------------|
159
- | sync-docs, changelog-keeper | 60–180s | `sleep 60` then `sleep 60` |
160
- | seconder, security-auditor | 60–180s | `sleep 60` then `sleep 60` |
161
- | reviewer | 90–240s | `sleep 90` then `sleep 60` |
162
- | explorer, debugger, planner, overthinker | 120–300s | `sleep 120` then `sleep 90` |
163
- | executor | 180–600s+ | `sleep 180` then `sleep 120` |
164
- | test-runner | varies with suite | start at `sleep 120`, adjust |
165
-
166
- Rules:
167
- - After dispatch, **always** `sleep 10 && sp ps` first to confirm the job is `running`, not stuck in `queued` or already `failed`.
168
- - Then sleep again per the table; check `sp ps` each cycle.
169
- - Do not poll faster than every 30s after the initial check — it wastes context.
170
- - When status flips to `completed`, run `sp result <job-id>` immediately to consume output before context grows.
171
- - If a job exceeds 2× its typical duration without completing, inspect with `sp feed <job-id>` before assuming hang.
172
-
173
- You are not "done" until every dispatched job is `completed` or `failed` and consumed.
174
-
175
- ## Worktree Cleanup After Merge
176
-
177
- Merge is now manual (see `Merge And Publication` below). You own cleanup after every merge.
178
-
179
- After every merge, verify:
180
-
181
- ```bash
182
- git worktree list # any orphaned worktrees from this session?
183
- sp ps # any leftover jobs?
184
- git worktree prune # drop stale worktree metadata
185
- ```
186
-
187
- Always remove the merged feature/epic worktree explicitly:
188
-
189
- ```bash
190
- git worktree remove <path>
191
- git branch -d <merged-branch> # only after confirming merged into target
192
- ```
193
-
194
- `sp ps` must have no active jobs and no unresolved terminal problems before session close. If it only shows old terminal history that you have intentionally acknowledged, run `sp clean --ps --dry-run` and then `sp clean --ps` to soft-hide those rows from the default dashboard. This does not delete SQLite history or change job status; use `sp ps --include-cleaned` or `sp ps --all` for audit visibility. Stale worktrees and stale jobs both block future dispatches.
195
-
196
- ## When To Delegate
197
-
198
- Use specialists for substantial work: codebase exploration, debugging, implementation, review, test execution, planning, documentation sync, security/config audit, release publication, and multi-chain epics.
199
-
200
- Do small deterministic edits directly when scope is already obvious and delegation would add ceremony. Do not self-investigate or self-implement a substantial task just because you can read files faster; audit trail and specialist review are part of workflow.
201
-
202
- ## Non-Negotiable Rules
203
-
204
- 1. `--bead` is prompt for tracked work.
205
- 2. Do not dispatch until bead is usable task contract.
206
- 3. Never use `--prompt` to supplement tracked work. Update bead instead.
207
- 4. Choose by task shape, not habit. Check `specialists list --full` when roles may have changed.
208
- 5. Explorer/debugger answer uncertainty before executor writes code.
209
- 6. Executor starts only when scope, constraints, and validation are clear.
210
- 7. Reviewer uses its own bead and executor workspace via `--job <exec-job>`.
211
- 8. Keep executor/debugger jobs alive through review so they can be resumed.
212
- 9. Merge specialist-owned work via the documented manual git workflow (Cherry-Pick Playbook / FF / `git merge --no-ff`). Do NOT use `sp merge` or `sp epic merge` — both are known broken and awaiting a separate rework epic. The skill does not document their usage; if you find them in `sp help` output, ignore.
213
- 10. Specialists must not perform destructive or irreversible operations.
214
- 11. Treat tests as evidence: classify failures as in-scope, pre-existing, or infrastructure before starting fix loop.
215
- 12. Drive routine stages autonomously once task is clear. Escalate only for human judgment, destructive actions, repeated crashes, or reviewer `FAIL`.
216
- 13. The orchestrator NEVER edits code directly. Conflict resolution, even mechanical, goes through a debugger or executor specialist. Manual conflict resolution always escalates to the operator. (Exception: epics that explicitly restructure the specialists themselves — bootstrapping via the specialists they restructure is circular. Such epics are operator-authorized manual-orchestrator-direct work and must say so up-front.)
217
- 14. Before dispatching any chain whose work depends on prior chain output, verify git state per the Git State Precondition section: `git status` clean, HEAD contains prior chain commits, no orphaned worktrees. Stale-base dispatch produces guaranteed debugger-restitch loops downstream.
218
-
219
- ## Escalation Matrix
220
-
221
- | Action | Default | Always escalate to operator |
222
- |---|---|---|
223
- | Code edit | Specialist only | (never orchestrator-direct) |
224
- | Cherry-pick onto integration branch | Auto if non-overlapping | Conflict requiring manual edits |
225
- | Manual conflict resolution | Never | Always |
226
- | Force push | Never | Always |
227
- | Branch delete | Never | Always |
228
- | Stash pop where conflict expected | Auto | Stash conflict that destroys session-start state |
229
- | `bd dolt fsck --revive-journal-with-data-loss` | Never | Always — explicit data-loss warning |
230
- | `sp merge` / `sp epic merge` | Never (prohibited per rule #9; both known broken) | Always — if you reach for these, stop and use manual git workflow |
231
- | Skip `seconder` (mandatory seconder) on production diff | Auto-skip only on test-only or new-file-only diffs | Always escalate on any other skip — seconder OK is reviewer pre-condition |
232
- | Skip `obligations-scanner` on production diff | Auto-skip only on test-only or new-file-only diffs | Always escalate on any other skip |
233
- | Skip `security-auditor` on diff touching auth/secrets/input/agent-config/lockfiles/migrations | Never | Always — sensitive-surface diffs always get the pass |
234
- | Manual merge with conflicts | Never auto-resolve | Always escalate to operator (rule #13) |
235
- | Dispatch chain on stale base (HEAD lacks prior chain commit) | Never | Always — fix base first per Git State Precondition |
236
- | `sp stop <job>` | Auto when job is done/stale | Never on actively-running unless context blown |
237
- | `git push origin <branch>` | Auto for chain branches | Force-push or delete-remote always |
238
- | `npm publish` | Never | Always |
239
- | Dependency bump | Auto for security-patch bumps | Major/minor bumps escalate |
240
- | Config file schema-changing edit | Never | Always |
241
-
242
- ## Live Registry And Help
243
-
244
- Use live registry for role details, permissions, current models, and skills:
245
-
246
- ```bash
247
- specialists list --full
248
- ```
249
-
250
- Use help for command flags and subcommands:
251
-
252
- ```bash
253
- sp help
254
- sp run --help
255
- sp ps --help
256
- sp feed --help
257
- sp result --help
258
- sp resume --help
259
- sp steer --help
260
- sp stop --help
261
- ```
262
-
263
- Do not rely on stale remembered flags when help is available. (Omitted: `sp finalize`, `sp merge`, `sp epic` — see rule #9. They exist in the binary but the skill prohibits their use.)
264
-
265
- ## Writing Bead Contracts Well
266
-
267
- Bead quality controls specialist quality. A title-only bead produces wandering output because specialist has no contract to optimize against. Write contract before dispatch. Tighten vague scope before launch.
268
-
269
- Bad bead:
270
-
271
- ```text
272
- TITLE: Fix bug
273
- PROBLEM: Something is broken.
274
- SUCCESS: It works.
275
- SCOPE: src/
276
- NON_GOALS: N/A
277
- CONSTRAINTS: Be careful.
278
- VALIDATION: Tests pass.
279
- OUTPUT: Done.
280
- ```
281
-
282
- Good bead:
283
-
284
- ```text
285
- TITLE: Fix feed cursor regression in sp result
286
- PROBLEM: specialists feed follow skips events after restart because cursor tracks count, not last seq.
287
- SUCCESS: feed follow resumes from last seen seq; result still reads terminal output.
288
- SCOPE: src/cli/feed.ts, src/cli/result.ts, tests/unit/cli/feed.test.ts
289
- NON_GOALS: No new runtime format, no DB schema change, no unrelated poll changes.
290
- CONSTRAINTS: Preserve existing job IDs, keep backwards-compatible CLI output, avoid file-based fallback drift.
291
- VALIDATION: Add regression test for restart resume; run targeted CLI tests.
292
- OUTPUT: Changed files, test evidence, residual risks.
293
- ```
294
-
295
- Fix three bad smells fast:
296
-
297
- - Title-only bead. Add problem, scope, validation, output.
298
- - Vague SCOPE like `src/`. Name files, symbols, or bounded docs.
299
- - Missing VALIDATION. Say what proves done, not just that work is “finished.”
300
-
301
- What differs: orchestrator writes contract before dispatch, so specialist does less guessing and more useful work.
302
-
303
- ## SCRUTINY taxonomy (Iron-style)
304
-
305
- `SCRUTINY` is a chain-property from canon §2.2, not reviewer input and not a quality tier. Every substantive bead must declare it at creation. It modulates chain structure only; quality stays invariant. New beads without it are invalid unless read-only / none-chain work.
306
-
307
- ```
308
- SCRUTINY: none | low | medium | high | critical
309
- ```
310
-
311
- | Level | Chain-structure modulation | When to use |
312
- |---|---|---|
313
- | `none` | Read-only / design chains only. No production-diff pipeline. | planning, premortem, research-only, triage, doc-sync, memory-hygiene |
314
- | `low` | Minimal production diff. Keep pipeline light. | tiny isolated fixes |
315
- | `medium` | Default production-diff chain. | most implementation beads |
316
- | `high` | Heavier review / evidence floor. | cross-cutting, boundary, public API, persistence, orchestration |
317
- | `critical` | Max structural gating. | auth, money, irreversible state, security-sensitive work |
318
-
319
- Floor rule: author sets the minimum; dispatcher/reviewer can raise it on sensitive surfaces per canon §2.4, never lower it.
320
-
321
- Cross-ref: [`docs/design/chain-templates.md` §2.2](../../../docs/design/chain-templates.md#22-scrutiny-is-a-chain-property--it-modulates-structure-not-quality), [`§2.3`](../../../docs/design/chain-templates.md#23-roles-in-the-canonical-pipeline), [`§2.5`](../../../docs/design/chain-templates.md#25-the-behavioral-validation-contract), [`§2.6`](../../../docs/design/chain-templates.md#26-the-release-checklist), roadmap Opp 15.
322
-
323
- ## Git State Precondition (before any chain dispatch)
324
-
325
- Specialist worktrees fork from the current HEAD of the orchestrator's branch at dispatch time. If prior chain edits aren't merged in yet, the new chain works on a stale base, will conflict at integration, and debugger-restitch becomes mandatory. The fix is upstream: don't dispatch until prior work has landed.
326
-
327
- Required pre-flight before dispatching any chain that depends on prior chain output:
328
-
329
- ```bash
330
- # 1. Working tree clean — no uncommitted edits to inherit or lose
331
- git status # MUST report "working tree clean"
332
-
333
- # 2. HEAD contains prior chain's work
334
- git log -1 --oneline # confirm latest commit
335
- git log main..HEAD --oneline # confirm prior chain branch merged in
336
-
337
- # 3. No orphaned worktrees from prior chains
338
- git worktree list # all prior chain worktrees should be removed
339
- git worktree prune # drop stale metadata
340
-
341
- # 4. If on an integration branch
342
- git log integration/<date>..HEAD # MUST be empty (in sync with integration target)
343
- ```
344
-
345
- Decision rule: if any of the four checks fail, finish the merge/commit/cleanup first. Do not dispatch. A specialist forked from a stale base produces conflict work that costs more turns than the time saved by dispatching early.
346
-
347
- Strictness by scenario:
348
-
349
- | Scenario | Strictness |
350
- |---|---|
351
- | Sequential chains where child.B depends on child.A's edits | **Strict.** child.A merged before child.B dispatch. |
352
- | Parallel chains in same epic with disjoint file scopes | Relaxed. Each dispatches off the shared base; integration reconciles. |
353
- | Chain after orchestrator-direct edit (rule #13 exception epics) | **Strict.** Orchestrator commits + pushes their direct edits before dispatching any dependent chain. |
354
- | Standalone chain (no upstream dependency) | Relaxed. Just `git status` clean. |
355
-
356
- ## Dependency Linking And Relationship Vocabulary
357
-
358
- Link beads with correct edge shape. The edge tells orchestrator what blocks execution, what only preserves context, which bead verifies another, and which issue has been replaced. Do not overload `blocks` for follow-ups, root-cause links, verification pairs, duplicates, or restitch replacements.
359
-
360
- Core commands:
361
-
362
- - `bd dep add <issue> <depends-on>`: issue depends on depends-on; depends-on blocks issue. Default type is `blocks`. Use only for hard sequencing. [source: bd dep add --help]
363
- - `bd dep <blocker> --blocks <blocked>`: reverse phrasing of the same hard sequencing edge. [source: bd dep --help]
364
- - `bd dep add <issue> <other> --type <type>`: store a typed relationship. Supported types: `blocks`, `tracks`, `related`, `parent-child`, `discovered-from`, `until`, `caused-by`, `validates`, `relates-to`, `supersedes`. [source: bd dep add --help]
365
- - `bd dep relate <a> <b>` / `bd dep unrelate <a> <b>`: bidirectional non-blocking `relates_to` link. Use for context, not order. [source: bd dep --help]
366
- - `bd create --parent <epic-id>`: epic-child edge; auto-names child `.1`, `.2`, … and adds parent ownership. Use for chain members that must live under an epic. [source: bd create --help]
367
- - `bd create --deps discovered-from:<id>` or `bd dep add <new> <source> --type discovered-from`: follow-up work discovered from a source bead.
368
- - `bd duplicate <new> --of <canonical>`: close duplicate issue and point at canonical. Use when two beads describe the same required work.
369
- - `bd duplicates` / `bd find-duplicates --status open --method ai --json`: find exact or semantic duplicates before dispatching parallel chains.
370
- - `bd supersede <old> --with <new>` or `bd dep add <new> <old> --type supersedes`: mark a replacement when a better-scoped fix bead replaces an obsolete/abandoned one.
371
- - `bd dep cycles`, `bd dep tree <id>`, and `bd graph <id>`: sanity-check the execution graph before merge/publication.
372
-
373
- Relationship vocabulary for specialist chains:
374
-
375
- | Relationship | Reach for it when | Example command |
376
- | --- | --- | --- |
377
- | `blocks` | Hard must-happen-before sequencing: planner before executor, implementation before reviewer, restitch before publish. | `bd dep add <impl> <plan> --type blocks` |
378
- | `tracks` | A local bead mirrors upstream or cross-project work whose status matters but is not owned here. | `bd dep add <local> external:xtrm-tools:<capability> --type tracks` |
379
- | `related` | Loose topical association when no direction or scheduling effect is intended. Prefer `bd dep relate` for bidirectional relation. | `bd dep add <a> <b> --type related` |
380
- | `parent-child` | Epic owns child chains. Prefer `bd create --parent <epic>` so IDs and parentage stay canonical. | `bd create --parent <epic> --title "Impl auth retry" ...` |
381
- | `discovered-from` | Reviewer, debugger, explorer, or test-runner surfaces new follow-up work from a run. | `bd dep add <follow-up> <reviewer-bead> --type discovered-from` |
382
- | `until` | Time-bounded or event-bounded precondition that blocks only until a stated condition lands. | `bd dep add <chain> <precondition> --type until` |
383
- | `caused-by` | Failure bead points to the root-cause bead/cluster that explains it. Makes test-failure-map epics navigable. | `bd dep add <failing-test> <root-cause> --type caused-by` |
384
- | `validates` | Reviewer, test-runner, seconder, or security-auditor bead verifies an implementation/debugger bead. | `bd dep add <review> <impl> --type validates` |
385
- | `relates-to` | Bidirectional context edge for conflict clusters, sibling designs, or rebuttal patterns. Prefer dedicated relate command. | `bd dep relate <chain-a> <chain-b>` |
386
- | `supersedes` | New fix/design/restitch bead replaces an older bead that should no longer be executed or merged. Prefer `bd supersede`. | `bd supersede <old> --with <new>` |
387
-
388
- Worked high-value patterns:
389
-
390
- ```bash
391
- # Reviewer discovers a separate follow-up during review. Do not block the impl.
392
- bd create --title "Follow up: tighten retry metrics" --type task --priority 3 --description "..."
393
- bd dep add <follow-up> <review> --type discovered-from
394
-
395
- # Test-failure-map root cause: many failures point at one underlying issue.
396
- bd create --title "Root cause: stale fixture factory" --type bug --priority 2 --description "..."
397
- bd dep add <failing-test-bead> <root-cause> --type caused-by
398
-
399
- # Verification bead validates implementation. This is not a hard prerequisite edge.
400
- bd dep add <test-runner-bead> <impl> --type validates
401
- bd dep add <reviewer-bead> <impl> --type validates
402
-
403
- # Replacement bead supersedes an abandoned or wrongly scoped implementation.
404
- bd create --title "Restitch auth retry onto integration state" --type task --priority 2 --description "..."
405
- bd supersede <old-impl> --with <restitch>
406
-
407
- # Before merging an epic or integration branch, prove the graph is sane.
408
- bd dep cycles
409
- bd graph <epic> --compact
410
- ```
411
-
412
- Use each form for a different reason:
413
-
414
- - `blocks` / `--blocks` for must-happen-before dependency only.
415
- - `validates` for review, test, sanity, and security evidence.
416
- - `discovered-from` for spawned follow-up beads.
417
- - `caused-by` for failure-to-root-cause attribution.
418
- - `relates-to` / `bd dep relate` for soft linkage with no schedule effect.
419
- - `parent-child` / `--parent` for epic ownership and child naming.
420
- - `supersedes` / `bd supersede` for replacement work; `duplicate` for same-work issues.
421
-
422
- Cross-repo consistency: keep this vocabulary aligned with the xtrm-tools triaging skill and sibling triage bead `xtrm-drkk`; both should use the same relationship names when rewiring issue graphs.
423
-
424
- What differs: orchestrator chooses edge type deliberately, so graph stays correct for chain execution, epic publish, duplicate cleanup, root-cause navigation, verification evidence, and follow-up traceability.
425
-
426
- ## Bead Contract By Bead Type
427
-
428
- Use shape that fits specialist.
429
-
430
- > **SCRUTINY field is universal.** Every substantive bead should carry `SCRUTINY: none|low|medium|high|critical` at creation. It is a chain-property, not reviewer behavior; it controls chain structure and gate strictness per the SCRUTINY taxonomy section and canon §2.2. Reviewer may auto-escalate but never lower it. Canon refs: §2.2, §2.3, §2.5, §2.6.
431
-
432
- Task/epic bead:
433
-
434
- ```text
435
- PROBLEM: User-facing or project-facing objective.
436
- SUCCESS: End-state across all child beads.
437
- SCRUTINY: none|low|medium|high|critical # required at creation; chain-property, not reviewer input
438
- SCOPE: Area of project affected.
439
- REFERENCES: Optional files, skills, or docs specialist reads only if work needs them.
440
- NON_GOALS: Boundaries for entire effort.
441
- CONSTRAINTS: Sequencing, compatibility, branch/merge rules.
442
- VALIDATION: Final checks before close.
443
- OUTPUT: What orchestrator reports back.
444
- ```
445
-
446
- `SCOPE` is always loaded as context. `REFERENCES` is progressive disclosure: name what exists, but do not force load unless task needs it. Use this when a file would bloat payload today, like citing a huge skill file in scope and dragging in all lines before specialist even knows it must read them.
447
-
448
- Example:
449
-
450
- ```text
451
- SCOPE: config/skills/using-specialists-v3/SKILL.md, docs/specialists/handoff-schema.md
452
- REFERENCES: config/skills/prompt-improving/SKILL.md (xml_core conventions), sibling beads per-turn-handoff-schema and bead-id-verbatim once landed
453
- ```
454
-
455
- Explorer bead:
456
-
457
- ```text
458
- PROBLEM: What is unknown.
459
- SUCCESS: Questions answered with evidence.
460
- SCOPE: Code areas, docs, commands, or symbols to inspect.
461
- NON_GOALS: No implementation, no broad audit outside scope.
462
- CONSTRAINTS: READ_ONLY, cite files/symbols/flows.
463
- VALIDATION: Findings cite evidence.
464
- OUTPUT: Findings, risks, recommended implementation track, stop condition.
465
- ```
466
-
467
- Debugger bead:
468
-
469
- ```text
470
- PROBLEM: Symptom, regression, or failing test.
471
- SUCCESS: Root cause plus minimal fix path.
472
- SCOPE: Logs, reproduction, code paths, and related tests.
473
- NON_GOALS: No broad refactor.
474
- CONSTRAINTS: Preserve behavior outside fault line.
475
- VALIDATION: Repro steps and diagnosis.
476
- OUTPUT: Root cause, fix options, confidence, remaining unknowns.
477
- ```
478
-
479
- Executor bead:
480
-
481
- ```text
482
- PROBLEM: Exact behavior or artifact to change.
483
- SUCCESS: Observable acceptance criteria.
484
- SCRUTINY: none|low|medium|high|critical # required at creation; chain-property, not reviewer input
485
- SCOPE: Target files/symbols; include do-not-touch boundaries.
486
- NON_GOALS: Related improvements explicitly excluded. (Include any accepted in-code obligation markers tracked in follow-up beads.)
487
- CONSTRAINTS: API compatibility, style, migrations, safety.
488
- VALIDATION: Lint/typecheck/tests or manual checks.
489
- OUTPUT: Changed files, verification, residual risks.
490
- ```
491
-
492
- Reviewer bead:
493
-
494
- ```text
495
- PROBLEM: Verify executor output against requirements.
496
- SUCCESS: PASS only if requirements + validation + Release Checklist satisfied.
497
- SCRUTINY: none|low|medium|high|critical # required at creation; chain-property, not reviewer input
498
- SCOPE: Executor job, diff, task bead, acceptance criteria.
499
- NON_GOALS: Do not rewrite unless explicitly asked.
500
- CONSTRAINTS: Code-review mindset; findings first; emit Release Checklist.
501
- VALIDATION: Run or inspect required checks; consume obligations-scanner output.
502
- OUTPUT: PASS/PARTIAL/FAIL with file/line findings + Release Checklist block.
503
- ```
504
-
505
- Test bead:
506
-
507
- ```text
508
- PROBLEM: Validate one or more implementation chains.
509
- SUCCESS: Relevant tests/checks pass or failures are diagnosed.
510
- SCOPE: Commands and implementation beads covered.
511
- NON_GOALS: No broad unrelated suite expansion unless requested.
512
- CONSTRAINTS: Avoid destructive cleanup; report flaky/infra failures separately.
513
- VALIDATION: Command output and failure interpretation.
514
- OUTPUT: Pass/fail summary, failing tests, likely owner.
515
- ```
516
-
517
- Sync-docs bead:
518
-
519
- ```text
520
- PROBLEM: Exactly one doc drifted from source truth.
521
- SUCCESS: One doc updated and drift checked clean.
522
- SCOPE: One doc only.
523
- NON_GOALS: No source-code rewrite.
524
- CONSTRAINTS: Keep doc and source aligned.
525
- VALIDATION: Drift scan or bounded source cross-check.
526
- OUTPUT: Updated doc, drift evidence, remaining doc gaps.
527
- ```
528
-
529
- What differs: orchestrator gives each specialist a contract shape that matches job, so role stays narrow and reviewable.
530
-
531
- For evidence-heavy or multi-item beads, let `SCOPE`, `CONSTRAINTS`, and `EXAMPLES` carry opt-in XML tags. Follow prompt-improving `xml_core` style: wrap only the subpart that needs structure, not whole bead. Example: a debugger bead can put stack trace lines in `<evidence>` and do-not-touch items in `<constraints>`, so specialist can scan facts fast without turning every field into markup.
532
-
533
- ## Choosing The Specialist
534
-
535
- Run `specialists list` if you need live registry. Choose by task, not habit.
536
-
537
- | Need | Specialist | Use when |
538
- | --- | --- | --- |
539
- | Architecture/code mapping | `explorer` | Need evidence and scoped implementation track |
540
- | Root-cause analysis | `debugger` | Symptom, stack trace, failing test, or regression |
541
- | Planning/decomposition | `planner` | Need beads, dependencies, file scopes, sequencing |
542
- | Design/tradeoffs | `overthinker` | Approach is risky, ambiguous, or needs critique |
543
- | Implementation | `executor` | Contract is clear enough to write code or docs |
544
- | Compliance/code review | `reviewer` | Executor/debugger produced changes that need final PASS/PARTIAL/FAIL |
545
- | Seconder gate (mandatory) | `seconder` | Production diff — fused scope/compliance + quality gate; reviewer pre-condition |
546
- | Obligations gate (mandatory) | `obligations-scanner` | Production diff — scans for unstructured TODO/FIXME/HACK/XXX/TEMP/WIP/NOTE(release) markers |
547
- | Security/dependency audit | `security-auditor` | Diff touches auth/secrets/input/lockfiles/migrations/agent-config |
548
- | Test execution | `test-runner` | Need suites run and failures interpreted |
549
- | Docs audit/sync | `sync-docs` | Docs may be stale or need targeted synchronization |
550
- | External/live research | `researcher` | Any library/API/framework/CLI question — dispatch BEFORE answering from training data |
551
- | Specialist config | `specialists-creator` | Creating or changing specialist JSON/config |
552
- | Release publication | `changelog-keeper` | New tag is being cut |
553
-
554
- Selection rules:
555
-
556
- - Explorer is READ_ONLY and should answer specific questions.
557
- - Debugger beats explorer for failures because it traces causes and remediation.
558
- - Planner shapes epic/task graph before executor starts.
559
- - Overthinker defends risky design before code locks in. It is CoT specialist by design, so thinking-heavy turns and `<thinking>` tags fit there.
560
- - Reviewer already uses structured evidence/gap matrices, which is CoT in disguise; keep that structure, do not add freeform `<thinking>` blocks.
561
- - Executor, debugger, changelog-keeper, sync-docs, and test-runner should not carry mandatory `<thinking>` blocks. That bloats output without payoff and hides the real contract.
562
- - Executor does not own full test validation; use reviewer/test-runner for that phase.
563
- - Sync-docs is for audit/sync; executor is for heavy doc rewrites.
564
- - Researcher is for current external info, not repo archaeology. **Dispatch BEFORE answering any library/API/framework/CLI question from training data** — your knowledge is stale by months and APIs drift silently. The cost is one CLI call; the alternative is shipping wrong API usage.
565
- - Specialists-creator should precede specialist config/schema edits.
566
- - `parallel-review` is deprecated — old design that doesn't fit current sp shape. Do not reach for it. Use `overthinker` for independent second opinion or queue a second `reviewer` turn manually if needed.
567
-
568
- ## Bug Diagnosis Chain
569
-
570
- For symptoms, errors, regressions, flakes, or failing tests where cause is unknown, start with diagnosis — not implementation. Do not dispatch executor while cause is unknown; executor is for clear implementation scope only.
571
-
572
- Default chain:
573
-
574
- 1. **test-runner** or **debugger** establishes a fast deterministic feedback loop. If no loop can be built, debugger reports the blocker — do not patch in the dark.
575
- 2. **debugger** reproduces the symptom, writes 3–5 falsifiable hypotheses, and tests one variable at a time. Any temporary instrumentation must be tagged `[DEBUG-<id>]` and removed before completion.
576
- 3. **debugger** applies the minimal root-cause fix on the fault line and verifies via targeted lint/typecheck plus the focused repro.
577
- 4. **test-runner** reruns the original repro/regression command (full-suite validation is its job, not debugger's).
578
- 5. **seconder** runs if the fix smells brittle, overcomplicated, or type-risky. **security-auditor** runs if the fix touches auth/session/secrets/input handling, dependency logic, or agent/MCP/hook config.
579
- 6. **reviewer** gates the final diff against the bead contract.
580
- 7. If no correct regression-test seam exists, route the architecture/testability finding to **overthinker** or **planner** — do not force a brittle test just to close the loop.
581
-
582
- Explorer is useful before diagnosis only when no concrete symptom exists and architecture is unknown. For real bugs with a symptom, use debugger.
583
-
584
- ## Seconder
585
-
586
- The mandatory post-writer gate (canon §2.3): one READ_ONLY dual-verdict pass over the writer's diff that checks **scope/compliance** (does the diff satisfy the bead contract sections?) and **implementation quality** (complexity, duplication, type safety, brittle async/error handling) together, before test-engineer and reviewer.
587
-
588
- Bead shape:
589
-
590
- ```text
591
- PROBLEM: Verify the writer diff satisfies the bead contract and is implementation-sound before expensive QA.
592
- SUCCESS: Dual-verdict isolates any scope or quality issue, or confirms the diff is clean.
593
- SCOPE: Writer diff, risky files, and any nearby helpers.
594
- NON_GOALS: No edits, no broad refactor, no release blessing, no security audit, no broad reviewer phase-2.
595
- CONSTRAINTS: READ_ONLY, keep feedback cheap, cite exact sections/lines/symbols.
596
- VALIDATION: scope_verdict + quality_verdict + overall_verdict with concrete findings.
597
- OUTPUT: JSON dual-verdict (scope_verdict / scope_findings / quality_verdict / quality_findings / overall_verdict).
598
- ```
599
-
600
- The chain reducer reads `overall_verdict`: PASS advances to test-engineer; FAIL routes back to the writer. Hand findings back with `sp resume <exec-job> "Seconder overall_verdict=FAIL — scope: ...; quality: ..."`.
601
-
602
- A seconder PASS is the upstream scope gate for the reviewer; it is not itself a reviewer PASS.
603
-
604
- What differs: orchestrator uses seconder as cheap smell screen, not as merge gate.
605
-
606
- ## Security-auditor
607
-
608
- Use security-auditor when diff touches auth, secrets, input handling, dependency logic, or agent/config surfaces. Keep it advisory and scan-only.
609
-
610
- Bead shape:
611
-
612
- ```text
613
- PROBLEM: Diff may open auth, secrets, input, dependency, or agent-config risk.
614
- SUCCESS: Findings isolate real security concern or confirm no obvious issue.
615
- SCOPE: Executor diff, touched configs, and security-relevant paths.
616
- NON_GOALS: No edits, no package updates, no destructive scans, no live exploit tests.
617
- CONSTRAINTS: LOW permissions, scan-only, recommendations only.
618
- VALIDATION: Findings cite risk surface and why it matters.
619
- OUTPUT: Recommendations for executor to apply in a separate bead.
620
- ```
621
-
622
- Use `sp resume <exec-job> "Security findings: ..."` or `sp resume <exec-job> "Security scan clean; continue to reviewer."`.
623
-
624
- No findings is not reviewer PASS. Executor still applies fixes if any, then reviewer decides publish.
625
-
626
- What differs: orchestrator uses security-auditor to surface risk early, not to bless merge.
627
-
628
- ## Dependency Graph Shapes
629
-
630
- Draw graph before dispatch.
631
-
632
- Simple chain:
633
-
634
- ```text
635
- task -> explore -> impl -> review
636
- ```
637
-
638
- Fix loop:
639
-
640
- ```text
641
- debug -> exec -> seconder? -> security-auditor? -> reviewer
642
- ^ |
643
- |------ resume PARTIAL --------------|
644
- ```
645
-
646
- Epic:
647
-
648
- ```text
649
- epic
650
- ├─ prep/planner
651
- ├─ impl-a
652
- ├─ impl-b
653
- ├─ test-batch
654
- └─ merge/review chain(s)
655
- ```
656
-
657
- What differs: orchestrator sees edge shape up front, so can pick sequential chain, fix loop, or multi-chain epic without graph drift.
658
-
659
- ## Pre-Dispatch: Conflict Cluster Identification
660
-
661
- Before dispatching N parallel chains, build the file-overlap matrix:
662
-
663
- | Chain | Touches | Overlap with |
664
- |-------|---------|--------------|
665
- | chain-A | src/cli/update.ts | chain-B, chain-C |
666
- | chain-B | src/cli/update.ts, src/cli/install.ts | chain-A, chain-C, chain-D |
667
- | chain-C | src/cli/update.ts, src/cli/install.ts, src/cli/doctor.ts | chain-A, chain-B |
668
-
669
- For each cluster of overlapping chains, choose **one** of:
670
-
671
- 1. **Serial dispatch** — execute chains in dependency order, each waits for previous to land. Slowest but cleanest. Encode the order with `blocks`, not notes.
672
- 2. **Unified bead** — collapse all chains into one bead/executor pass. Larger reviewer scope but no merge conflicts. Mark obsolete split beads with `bd supersede <old> --with <unified>`.
673
- 3. **Parallel dispatch + debugger restitch at integration** — dispatch in parallel, plan for ~40% conflict rate (empirical), budget debugger-restitch passes during integration. Link overlapping siblings with `bd dep relate <chain-a> <chain-b>` so the future restitch has visible context without creating fake blockers.
674
-
675
- Example graph rewiring:
676
-
677
- ```bash
678
- # soft conflict-cluster context; does not change schedule
679
- bd dep relate <chain-a> <chain-b>
680
-
681
- # serializing because both chains edit src/cli/update.ts
682
- bd dep add <chain-b> <chain-a> --type blocks
683
-
684
- # replacing scattered duplicate/split beads with one unified implementation
685
- bd supersede <old-chain-a> --with <unified-chain>
686
- bd supersede <old-chain-b> --with <unified-chain>
687
- ```
688
-
689
- Default heuristic: if 3+ chains touch the same file, **serial-dispatch them**. Conflict-resolution time at integration usually exceeds the time saved by parallel dispatch. Run `bd find-duplicates --status open --method ai --json` before launching a large wave; merge or supersede duplicate work before specialists spend tokens on it.
690
-
691
- ## Pre-Epic: Test-Failure-Map Pattern
692
-
693
- Use when:
694
- - A test suite shows ≥ ~5 failures and the operator says "fix all"
695
- - The failures span multiple files / subsystems
696
- - Root causes are not yet attributed per failure
697
-
698
- ### Step-by-step
699
-
700
- 1. **Run the suite once**, save the full log. Do not interpret yet.
701
- 2. **File one mapping bead** (e.g., `test-runner: refresh <epic> failure map`) with contract:
702
- - `PROBLEM:` exact command + exit status + raw failure count.
703
- - `SUCCESS:` cluster table grouping every failure by **likely shared root cause and file scope**, plus recommended fix-chain order.
704
- - `SCOPE:` the log file path + bounded test files involved.
705
- - `CONSTRAINTS:` READ_ONLY, no source/test edits, no fix attempts.
706
- 3. **Dispatch test-runner / explorer / debugger** for this bead READ_ONLY (or fill inline by reading the log).
707
- 4. **Build the cluster table**: cluster name | files (counts) | representative error | root-cause hypothesis | likely-owner area | targeted validation command. Save in bead notes.
708
- 5. **Wire root-cause relationships** so the graph is navigable:
709
- ```bash
710
- bd dep add <failure-cluster-bead> <root-cause-bead> --type caused-by
711
- bd dep add <test-runner-bead> <fix-bead> --type validates
712
- ```
713
- Use `caused-by` for attribution, not `blocks`; use `validates` for the evidence-producing test bead.
714
- 6. **Plan fix chains** off the cluster table:
715
- - One chain per cluster, file scopes disjoint where possible.
716
- - Order by leverage (largest cluster first), then by simplicity.
717
- - Debugger when root cause unclear; executor when bead constraint is concrete.
718
- 7. **Save the topology insight as `bd remember`** — patterns about where a codebase's test fragility concentrates are reusable.
719
-
720
- ### Why this beats dispatch-blind
721
-
722
- When 34 failures collapsed under 5 clusters in one observed run, 56% of failures shared a single root cause. A blind parallel dispatch would have over-dispatched 19 fixes instead of 1. Net specialist spend ~3× higher without the mapping pass.
723
-
724
- ### Failure modes to watch for
725
-
726
- - Clusters that look shared but aren't — same error string in unrelated tests may hide different root causes. Confirm via stack traces, not error text alone.
727
- - One cluster's fix introduces another's regression — each chain's VALIDATION must span all known-failing areas with "no regressions in other clusters."
728
- - Pre-existing failures vs new regressions — name pre-existing failures explicitly in each chain's NON_GOALS so reviewers don't FAIL on them.
729
-
730
- ## Canonical Single-Chain Flow
731
-
732
- Use for one implementation branch.
733
-
734
- ```bash
735
- # 1. Create or claim root task bead with complete contract
736
- bd create --title "Fix token refresh retry" --type task --priority 2 --description "PROBLEM: login and refresh flow have a retry bug when transient token refresh fails before backoff clears stale state. SUCCESS: token refresh retries once, login survives transient failure, and terminal failure stays clear. SCOPE: src/auth/refresh.ts, src/cli/login.ts, tests/unit/auth/refresh.test.ts. NON_GOALS: no auth provider redesign, no storage migration, no UI changes. CONSTRAINTS: preserve token format, keep error text backward-compatible, avoid broad retry changes outside auth flow. VALIDATION: add regression test for fail-then-succeed path and run targeted auth tests. OUTPUT: changed files, test proof, residual risks."
737
- bd update <task> --claim
738
-
739
- # 2. Optional discovery when path is unknown
740
- bd create --title "Explore auth refresh path" --type task --priority 2 --description "PROBLEM: token refresh retry path is undocumented and likely drifts on failure handling. SUCCESS: evidence-backed plan names exact files, symbols, and risk. SCOPE: src/auth/refresh.ts, src/cli/login.ts, tests/unit/auth/*.test.ts. NON_GOALS: no implementation, no broad audit. CONSTRAINTS: READ_ONLY, cite files/symbols/flows, stay within live repo evidence. VALIDATION: findings cite code path and recommended sequence. OUTPUT: tracked discovery plan with stop condition."
741
- bd dep add <explore> <task> --type discovered-from
742
- specialists run explorer --bead <explore> --context-depth 3
743
- specialists result <explore-job>
744
-
745
- # 3. Implementation
746
- bd create --title "Implement token refresh retry" --type task --priority 2 --description "PROBLEM: login fails after transient token refresh error because retry path returns before backoff and clear error state. SUCCESS: retry waits once, preserves session on success, and surfaces final failure clearly. SCOPE: src/auth/refresh.ts, src/cli/login.ts, tests/unit/auth/refresh.test.ts. NON_GOALS: no auth redesign, no storage migration, no UI refresh. CONSTRAINTS: preserve existing token format, keep backward-compatible error text, avoid broad retry changes elsewhere. VALIDATION: add regression test for transient failure then success; run targeted auth tests. OUTPUT: changed files, test evidence, residual risks."
747
- bd dep add <impl> <explore-or-task> --type blocks
748
- specialists run executor --bead <impl> --context-depth 3
749
- specialists result <exec-job>
750
-
751
- # 4. Advisory passes when diff smells risky
752
- bd create --title "Sanity check token retry diff" --type task --priority 2 --description "PROBLEM: auth retry diff has control-flow and state-handling smell that could hide bug. SUCCESS: findings identify concrete simplification or confirm clean shape. SCOPE: executor diff in auth refresh and login flow. NON_GOALS: no edits, no merge gate decision. CONSTRAINTS: READ_ONLY, keep feedback cheap, cite exact lines or symbols. VALIDATION: findings name concrete improvement or say OK. OUTPUT: FINDINGS with severity or OK with caveats."
753
- bd dep add <sanity-bead> <impl> --type validates
754
- specialists run seconder --bead <sanity-bead> --job <exec-job> --context-depth 3
755
-
756
- bd create --title "Security scan token retry diff" --type task --priority 2 --description "PROBLEM: auth refresh code touches secrets and session handling, so security regression is possible. SUCCESS: findings isolate real risk surface or confirm no obvious issue. SCOPE: executor diff in auth, token storage, and login path. NON_GOALS: no edits, no package updates, no destructive scans, no live exploit tests. CONSTRAINTS: LOW permissions, scan-only, recommendations only. VALIDATION: findings cite auth/secrets/input surface and why it matters. OUTPUT: recommendations for executor to apply in separate bead."
757
- bd dep add <security-bead> <impl> --type validates
758
- specialists run security-auditor --bead <security-bead> --job <exec-job> --context-depth 3
759
-
760
- # 5. Final review
761
- bd create --title "Review token refresh retry" --type task --priority 2 --description "PROBLEM: verify executor output against auth retry requirements. SUCCESS: PASS only if retry behavior, error handling, and tests satisfy contract. SCOPE: executor job, diff, acceptance criteria, and target auth files. NON_GOALS: do not rewrite unless explicitly asked. CONSTRAINTS: code-review mindset; findings first; verify security and sanity findings were handled. VALIDATION: inspect targeted checks and regression coverage. OUTPUT: PASS/PARTIAL/FAIL with file/line findings."
762
- bd dep add <review> <impl> --type validates
763
- specialists run reviewer --bead <review> --job <exec-job> --context-depth 3
764
- specialists result <review-job>
765
-
766
- # 6. Close any waiting keep-alive specialists explicitly
767
- sp ps # confirm which jobs are still waiting
768
- sp stop <waiting-job-id> # repeat per waiting job
769
-
770
- # 7. Publish via manual git merge (rule #9 — sp merge is prohibited)
771
- git checkout master
772
- git pull --ff-only origin master
773
- git merge --no-ff feature/<impl-bead>-<slug> -m "Merge <impl-bead>: <summary>"
774
- git push origin master
775
- git worktree remove <chain-worktree-path>
776
- git branch -d feature/<impl-bead>-<slug>
777
- bd close <task> --reason "Reviewer PASS; merged to master."
778
- ```
779
-
780
- Edit-capable specialists with `--bead` auto-provision a clean git worktree. This does **not** provision ignored project dependency artifacts (`node_modules/`, `.venv/`, build caches). If validation tools are missing inside that worktree, have the specialist run the repo's standard bootstrap command (`make bootstrap`, `just setup`, `npm ci`, `uv sync`, etc.) or report that bootstrap is required; do not solve it by tracking dependency directories. `--worktree` is accepted for clarity but usually unnecessary. Use `--job <exec-job>` for reviewer/fix passes that must enter existing executor workspace.
781
-
782
- What differs: orchestrator carries full bead contract inline, so downstream specialists inherit the actual job shape, not a title.
783
-
784
- ## Multi-Chain Epic Flow
785
-
786
- Use epic when multiple implementation chains publish together.
787
-
788
- ```bash
789
- # Epic bead
790
- bd create --title "Epic: auth refresh hardening" --type epic --priority 2 --description "PROBLEM: login and refresh flow have retry drift, weak error surfacing, and unclear follow-up ownership. SUCCESS: epic closes with stable retry behavior, tests, docs, and clean publish. SCOPE: src/auth/*, src/cli/login.ts, tests/unit/auth/*, docs/auth-refresh.md. NON_GOALS: no auth provider swap, no storage migration, no unrelated session revamp. CONSTRAINTS: preserve token format, keep login compatible, sequence risky fixes before merge, use child beads for parallelizable slices. VALIDATION: targeted tests, seconder or security pass if risk appears, final reviewer PASS. OUTPUT: merged chain set with notes on remaining gaps."
791
-
792
- # Planner bead
793
- bd create --parent <epic> --title "Plan auth refresh split" --type task --priority 2 --description "PROBLEM: epic needs disjoint chains before executor starts. SUCCESS: child beads, dependency edges, and file ownership split are explicit. SCOPE: auth refresh epic area. NON_GOALS: no code changes. CONSTRAINTS: keep chains disjoint, identify security-sensitive slice, name review order. VALIDATION: plan names beads and edges. OUTPUT: parallel-ready plan with risk notes."
794
- specialists run planner --bead <plan> --context-depth 3
795
-
796
- # Parallel impl beads
797
- bd create --parent <epic> --title "Impl auth retry" --type task --priority 2 --description "PROBLEM: transient refresh failure breaks login flow. SUCCESS: retry path succeeds after one transient failure and preserves session state. SCOPE: src/auth/refresh.ts, tests/unit/auth/refresh.test.ts. NON_GOALS: no UI changes, no storage migration, no unrelated retry framework edits. CONSTRAINTS: preserve error text, keep backoff bounded, avoid side effects outside auth flow. VALIDATION: regression test for fail-then-succeed path. OUTPUT: code diff, test proof, residual risk list."
798
- bd create --parent <epic> --title "Impl login handoff" --type task --priority 2 --description "PROBLEM: login CLI does not surface refresh outcome clearly enough for operators. SUCCESS: login shows clear success/failure handoff and no stale token state. SCOPE: src/cli/login.ts, tests/unit/cli/login.test.ts. NON_GOALS: no auth protocol redesign. CONSTRAINTS: preserve CLI flags and error codes, keep output terse. VALIDATION: CLI regression test. OUTPUT: login diff and test evidence."
799
-
800
- specialists run executor --bead <impl-a> --context-depth 3
801
- specialists run executor --bead <impl-b> --context-depth 3
802
-
803
- # Per-chain review
804
- bd dep add <review-a> <impl-a> --type validates
805
- bd dep add <review-b> <impl-b> --type validates
806
- specialists run reviewer --bead <review-a> --job <exec-a-job> --context-depth 3
807
- specialists run reviewer --bead <review-b> --job <exec-b-job> --context-depth 3
808
-
809
- # Close waiting keep-alive specialists explicitly (per chain)
810
- sp ps # see what's still waiting
811
- sp stop <waiting-job-id> # repeat per waiting job in each chain
812
-
813
- # Publish via Cherry-Pick Playbook (canonical multi-chain merge — see Integration Phase section)
814
- bd dep cycles # stop if relationship rewiring introduced a cycle
815
- git checkout -b integration/$(date +%Y%m%d)-$EPIC_TAG
816
- # For each PASS chain in dependency order:
817
- git merge --squash feature/<chain-bead>-<slug>
818
- git restore --staged .beads .pi AGENTS.md CLAUDE.md # noise filter
819
- git commit -m "<type>(<scope>): <summary> (<bead-id>)"
820
- # Operator FF-merges integration → master when satisfied.
821
- ```
822
-
823
- Use `--epic <id>` when job belongs to epic but bead is not direct child. Avoid parallel executors on same file; sequence them or consolidate work.
824
-
825
- What differs: orchestrator splits graph first, then launches parallel work only when file scopes are provably disjoint.
826
-
827
- ## Review And Fix Loop
828
-
829
- A chain stays alive until merged or abandoned.
830
-
831
- ```text
832
- executor/debugger -> waiting
833
- optional seconder/security-auditor -> advisory findings
834
- reviewer -> PASS | PARTIAL | FAIL
835
- ```
836
-
837
- - `PASS`: verify expected commit/diff + clean Release Checklist. Close any waiting keep-alive jobs explicitly with `sp stop <job-id>`. Then publish via manual git workflow (per-chain `git merge --no-ff` or Cherry-Pick Playbook for multi-chain epics).
838
- - `PARTIAL`: resume same executor/debugger with exact findings, then re-review (`sp resume <reviewer-job>`).
839
- - `FAIL`: stop and decide whether to replace chain, re-scope bead, or ask operator if judgment is required. If replacing a bad chain with a narrower one, use `bd supersede <failed-impl> --with <replacement>`; if reviewer discovered separate follow-up work, use `bd dep add <follow-up> <reviewer-bead> --type discovered-from`.
840
-
841
- Prefer resume over new fix executor when original job is waiting and context is healthy:
842
-
843
- ```bash
844
- sp resume <exec-job> "Reviewer PARTIAL. Fix only these findings: ..."
845
- ```
846
-
847
- Do not treat job completion, seconder OK, security no-findings, or test-runner pass as equivalent to reviewer PASS.
848
-
849
- What differs: orchestrator uses PASS/PARTIAL/FAIL as real control flow, not just status labels.
850
-
851
- ## Mini-Flows For Under-Promoted Specialists
852
-
853
- Planner:
854
- - Use when epic needs bead split, dependency graph, or file ownership before code starts.
855
- - Bead shape: task/epic contract with clear success criteria, child beads, and edge plan.
856
- - Chain position: first or pre-impl.
857
-
858
- Debugger:
859
- - Use when symptom exists and root cause is unclear.
860
- - Bead shape: reproduction, logs, expected vs actual, scope to investigate.
861
- - Chain position: before executor, or after a failing review when cause is unclear.
862
-
863
- Overthinker:
864
- - Use for risky design, cross-cutting tradeoffs, or premortem before lock-in.
865
- - Bead shape: options, risks, constraint conflicts, decision asked for.
866
- - Chain position: before planner/executor when design uncertainty is high.
867
-
868
- Researcher:
869
- - Dispatch **BEFORE** answering any library/API/framework/CLI question from training data. Training is months stale; APIs change; cheap CLI lookups (`ctx7`, `deepwiki`, `ghgrep`) replace the guess.
870
- - Use for: API syntax checks, config options, version migrations, library-specific debugging, "how do others implement X", recent releases, public repo internals.
871
- - Anti-pattern to break: "I think Library X works like Y…" → instead dispatch researcher with the exact question. The cost (~30s, `openai-codex/gpt-5.4-mini` via tool mode) is far less than shipping wrong API usage.
872
- - Bead shape: source list (which libraries/repos), question set, required citations (library ID or `npx ctx7 docs /org/project "..."` output).
873
- - Chain position: before executor when outside facts matter; alongside explorer when a question mixes local code with external behavior.
874
- - Keep-alive: ask follow-ups in the same job rather than re-dispatching — researcher stays in waiting state after each turn.
875
-
876
- Three modes — researcher picks automatically based on bead shape; you write the bead, not the mode:
877
-
878
- - **Targeted lookup** (most common): "How do I configure X in library Y v1.2?" / "What does Z.method() return now?" / "Are foo and bar still the canonical replacements for baz?" → researcher resolves library ID via `ctx7 library`, then `ctx7 docs /org/project "<intent-rich query>"`. For repo-specific internals (e.g. "How does Vite handle X internally?"), `deepwiki ask <owner/repo> "..."`.
879
- - **Discovery**: "How do production codebases handle X?" / "Find good examples of pattern Y" / "What does the ecosystem do for Z?" → `ghgrep "<literal pattern>" --lang <langs> --repo <maybe>`, scan results, drill into the best repos with `deepwiki toc` + `deepwiki ask`.
880
- - **Media / discussion-recency** (rare): YouTube transcripts, social-media trends. Triggers on URLs or "what are people saying about X right now". Researcher loads `last30days` skill on-demand for this — don't fold its setup into the bead.
881
-
882
- ### Dispatch triggers — when the orchestrator should reach for researcher
883
-
884
- Concrete agent thoughts that MUST be replaced with a researcher dispatch:
885
-
886
- | Agent thought | Researcher bead |
887
- |---|---|
888
- | "I think `useEffect` cleanup works like…" | `ctx7 docs /facebook/react "useEffect cleanup with async operations"` |
889
- | "Next.js app router middleware should be…" | `ctx7 docs /vercel/next.js "app router middleware patterns"` |
890
- | "Let me check if `--target` is a valid flag for tool X" | `ctx7 docs /org/tool-x "--target flag"` or `tool-x --help` (orchestrator-side if it's installed) |
891
- | "Production code probably handles X by…" | `ghgrep "<X-pattern>" --lang TypeScript --limit 5` then `deepwiki ask <best-repo> "<design question>"` |
892
- | "Library Y added feature Z in v3 (I think)" | `ctx7 library <Y> "Z"` → `ctx7 docs /org/Y/<version> "Z"` to verify version + behavior |
893
- | "Repo X's authentication architecture is…" | `deepwiki ask owner/X "How does the auth middleware work? What stores tokens? What controls expiry?"` |
894
- | "Cross-library: do A and B compose like Z?" | `deepwiki ask repo-A repo-B "How do these interact for use-case Z?"` |
895
-
896
- If you catch yourself making any of these claims without first dispatching researcher, you are about to ship stale information. Stop and dispatch.
897
-
898
- ### Cost framing
899
-
900
- Researcher runs on `openai-codex/gpt-5.4-mini` via tool mode, keep-alive. Typical turn: 20-40s wall clock, ~$0.005-0.02 per call. The cost of shipping a wrong API call (debugger turn + executor fix + reviewer re-run, or worse, production regression) is orders of magnitude higher. Default to dispatch.
901
-
902
- ### What researcher does NOT do
903
-
904
- - Local code mapping → use `explorer` (READ_ONLY, traces project code without external CLI cost).
905
- - Bug root-cause when symptoms are local → use `debugger`.
906
- - Reading internal docs already in this repo → use direct file read or `explorer`.
907
- - Security audit of third-party packages → use `security-auditor`; researcher's job is the API surface, not the threat model.
908
-
909
- Test-runner:
910
- - Use when commands need to run and failures need classification, not fixes.
911
- - Bead shape: exact command list, suites, and expected failure taxonomy.
912
- - Chain position: after executor or between fix loops.
913
-
914
- Sync-docs:
915
- - Use when one doc drifts and must be synced to source truth.
916
- - Bead shape: one-doc scope, source cross-check, drift checks.
917
- - Chain position: parallel to code only when doc scope is isolated; otherwise after code settles.
918
-
919
- What differs: orchestrator uses specialists beyond the common trio, so planning, diagnosis, research, tests, and docs do not collapse into executor work.
920
-
921
- ## Specialist Rebuttal As Routine
922
-
923
- Several specialists default to over-cautious verdicts when an evidence gate looks unsatisfied. The orchestrator's job is to challenge that verdict with cited evidence, not to accept it. Common rebuttal-worthy patterns:
924
-
925
- ### Overthinker
926
-
927
- - "Hold for operator decision" without specifying what decision is needed → push: "Cite file/line evidence for why this is a product decision rather than a mechanical resolution."
928
- - "Close as superseded by X" without verification → push: "Read the current state of `<file>` and check whether feature Y from this bead is actually present." If verified, record it structurally with `bd supersede <old> --with <new>` instead of burying the replacement in notes.
929
- - "Run separate small beads" or "run one big bead" without rationale → push: "Pick one and explain operationally — cost difference, conflict expectations, reviewer scope." If one big bead wins, mark replaced split beads with `bd supersede`; if the small beads remain parallel siblings, link overlap with `bd dep relate`, not `blocks`.
930
-
931
- ### Reviewer
932
-
933
- - "PARTIAL — missing `gitnexus_impact` evidence" on a test-only diff → rebut: "Diff is entirely under `test/` (N files). `gitnexus_impact` analyzes runtime call graphs; test fixture mocks have no callers in the production graph. Bead's impact-gate constraint is conditional on modifying a runtime entrypoint, which did not happen here."
934
- - "PARTIAL — missing `gitnexus_impact`" on a small LOW-blast-radius production diff where executor used `gitnexus_detect_changes` instead → rebut: cite the executor's `impact_report.highest_risk: LOW`, the LOC count, single helper / single consumer scope. The reviewer prompt accepts `gitnexus_impact` OR `$gitnexus_summary` OR `gitnexus_detect_changes` OR LOW `impact_report` as evidence.
935
- - "FAIL — full suite shows N+1 fails" where one is a known concurrent-run flake → rebut: rerun the suspect test in isolation, paste clean output, resume reviewer with "Isolated rerun: P/P. Re-evaluate."
936
-
937
- ### General rule
938
-
939
- Resume with explicit ammunition: file/line refs, exact rerun output, link to the bead memory documenting the rebuttal pattern. Don't argue from authority; argue from new evidence. **Findings from seconder / security-auditor are legitimate rebuttal evidence** — a clean seconder OK or a security-auditor "no findings" is concrete proof against a reviewer's "looks too complex" or "may have security risk" gate. Cite the advisory job id when rebutting on this axis.
940
-
941
- **One rebuttal per reviewer is the limit.** Second FAIL after rebuttal means stop and report. After a successful rebuttal, save the rebuttal text to `bd remember "<key>"` so the next session inherits it.
942
-
943
- ## Monitoring And Steering
944
-
945
- Use `sp ps` for state and `sp result` for completed turns.
946
-
947
- ```bash
948
- sp ps # active jobs + unresolved terminal problems
949
- sp ps --active # active jobs only
950
- sp ps --health # include detailed process tables
951
- sp ps --include-terminal # include uncleaned terminal history
952
- sp ps --include-cleaned # include rows hidden by sp clean --ps
953
- sp ps --all # full audit view, including cleaned/dead/history
954
- sp feed <job-id>
955
- sp result <job-id>
956
- ```
957
-
958
- Default `sp ps` is the actionable dashboard, not raw history. Error/cancelled terminal rows stay visible until an operator acknowledges them with `sp clean --ps`; cleaned rows remain in SQLite and are visible via `--include-cleaned`/`--all`.
959
-
960
- If job is running, use `sp feed`. If it is waiting, use `sp result` and decide whether to resume, review, merge, or stop. Avoid tight polling; sleep based on task size, then check once.
961
-
962
- Use `steer` for running jobs and `resume` for waiting jobs:
963
-
964
- ```bash
965
- sp steer <job-id> "Stop broad audit. Answer only the three bead questions."
966
- sp resume <job-id> "Continue with the next scoped fix. Do not refactor."
967
- ```
968
-
969
- Context usage is an action signal when available:
970
-
971
- - 0-40%: healthy.
972
- - 40-65%: monitor.
973
- - 65-80%: steer toward conclusion.
974
- - Above 80%: finish, summarize, or replace job.
975
-
976
- Raw token totals are not context percentages.
977
-
978
- ### Long autonomous runs — dual-mechanism monitoring
979
-
980
- For sessions where the operator is offline (overnight, async windows), use both:
981
-
982
- 1. **Bash sleep timers per dispatch**, sized per role (see Monitoring Long-Running Jobs above). Bash sleep waits for an expected completion.
983
- 2. **External cron loop** (Claude Code: `/loop 180s sp ps`) as a heartbeat at fixed cadence regardless of orchestrator's bash sleeps. Cron catches specialists that finished while the orchestrator was busy reading other results, and catches stalls.
984
-
985
- The two complement: bash sleep waits for an expected completion; cron catches unexpected completions and stalls. Without the cron, the orchestrator can miss specialists that completed during a long bash poll cycle and waste turns re-polling.
986
-
987
- ## Bead Lifecycle And Parallel Commit Ordering
988
-
989
- The bd commit-gate is **project-wide**, not per-worktree. While **any** bead in the project is `in_progress`, **no** worktree can commit. Practical consequences for parallel-chain epics:
990
-
991
- - You CAN dispatch two executors in parallel — they work in separate worktrees, no commit-time collision.
992
- - But once executor A returns and executor B is still running, you CANNOT commit A's worktree until B's bead is closed (or vice versa).
993
- - Workflow: close the finished chain's executor bead FIRST (memory-ack + `bd close`), THEN commit that chain's worktree, THEN wait on the other chain.
994
- - This forces a serial-tail on the commit step. Plan for it: parallel-dispatch saves time on the *thinking* step, not the commit step.
995
-
996
- If the commit-gate blocks unexpectedly mid-orchestration, `bd query "status=in_progress"` reveals which claim is holding it open.
997
-
998
- ### Memory-gate batch close
999
-
1000
- `bd close` is blocked until `memory-acked:<id>` exists. For batch-closing many orchestrator-internal beads (sanity beads, reviewer beads, decomposition trackers), use:
1001
-
1002
- ```bash
1003
- for id in <impl> <sanity?> <review>; do
1004
- bd kv set "memory-acked:$id" "saved:<chain-memory-key>" # OR "nothing novel: <reason>"
1005
- done
1006
- bd close <impl> <sanity?> <review> <parent> --reason "..."
1007
- ```
1008
-
1009
- The chain memory key holds the actual durable insight (one per real fix). Sanity/review beads get "nothing novel" — the parent insight covers them.
1010
-
1011
- ## What Stays Out
1012
-
1013
- - `memory-processor` — memory synthesis specialist; see `/documenting`.
1014
- - `xt-merge`: deferred to xt-merge skill; this skill names specialist flow, not merge-wrapper internals.
1015
- - Session-close reporting (report skeleton, CHANGELOG sync, push) — see `/session-close-report` skill; this skill mandates running it at session end but does not duplicate its content.
1016
- - Release publication (version bump, build, tag, npm publish) — see `/releasing` skill.
1017
-
1018
- ## At Session End — Mandatory Handoff
1019
-
1020
- Before declaring the session done:
1021
-
1022
- 1. Run the `/session-close-report` skill.
1023
- 2. Fill every `<!-- FILL -->` marker in the generated skeleton.
1024
- 3. Sync `CHANGELOG.md` for user-facing changes (the report skill drives this).
1025
- 4. Re-run cleanup checks: `sp ps`, `git worktree list`, `ps -ef` for stale serena/gitnexus, `tmux ls` for `sp-*`.
1026
- 5. Commit the report (and CHANGELOG if updated) before push.
1027
-
1028
- A session that lands code but skips the close-report leaves the next agent cold-starting blind. That cost compounds across sessions.
1029
-
1030
- ## Adjacent xt commands
1031
-
1032
- Source: latest xt report + `xt --help`; keep commands here, not full CLI surface.
1033
- - `xt report` — session report input for release synthesis; see `/session-close-report`.
1034
- - `xt end` — close worktree session: push, PR, merge, cleanup; see `/xt-end`.
1035
- - `xt claude` — launch Claude in sandboxed worktree; see `/using-xtrm`.
1036
- - `xt update` — refresh xtrm-managed files in one repo or many; see `/update-xt`.
1037
- - `xt doctor` — diagnose xtrm drift in current project; see `/update-xt`.
1038
- - `xt init` — bootstrap xtrm in project; see xtrm-tools docs.
1039
- - `xt release prepare/publish` — legacy release path; canonical flow is `/releasing`.
1040
- - `bd prime` — refresh beads workflow context; see `CLAUDE.md`.
1041
- - `memory-processor` — memory synthesis specialist; see `/documenting`.
1042
- - `xt-merge` — defer merge-queue internals to `/xt-merge`.
1043
-
1044
- ## Merge And Publication (manual git is canonical)
1045
-
1046
- > **Rule #9:** `sp merge` and `sp epic merge` are prohibited — known broken, awaiting a separate rework epic. Even if `sp help` shows them, do not use. The Cherry-Pick Playbook below is the canonical merge path for specialist-owned work.
1047
-
1048
- ### Per-chain merge (standalone or one chain at a time inside an epic)
1049
-
1050
- After reviewer PASS on a chain whose work lives in `feature/<bead-id>-<slug>` worktree:
1051
-
1052
- ```bash
1053
- # 1. Verify reviewer PASS verdict was recorded (Release Checklist clean)
1054
- bd show <bead-id> # check notes for the verdict
1055
-
1056
- # 2. Verify the chain's gates passed:
1057
- # seconder OK | obligations-scanner CLEAN | security-auditor clean (if surface)
1058
- # Reviewer's Release Checklist block enumerates these.
1059
-
1060
- # 3. Switch to target branch (master or integration/<date>) and FF or merge
1061
- git checkout <target>
1062
- git pull --ff-only origin <target>
1063
- git merge --no-ff feature/<bead-id>-<slug> -m "Merge <bead-id>: <summary>"
1064
- git push origin <target>
1065
-
1066
- # 4. Cleanup the chain worktree + branch
1067
- git worktree remove <chain-worktree-path>
1068
- git branch -d feature/<bead-id>-<slug>
1069
- git worktree prune
1070
- ```
1071
-
1072
- Use `git update-ref` for FF-equivalent when checkout is blocked by transient working-tree state (e.g., bd auto-export churn on `.beads/issues.jsonl`):
1073
-
1074
- ```bash
1075
- git merge-base --is-ancestor <target> feature/<bead-id>-<slug> && \
1076
- git update-ref refs/heads/<target> feature/<bead-id>-<slug> && \
1077
- git push origin <target>
1078
- ```
1079
-
1080
- ### Multi-chain epic merge
1081
-
1082
- Use the Cherry-Pick Playbook (below). Each chain lands as one squash commit on an integration branch (visible to operator before main), then operator FF-merges integration → main when satisfied.
1083
-
1084
- ### Closing the keep-alive specialists
1085
-
1086
- If reviewer/executor jobs are still `waiting` after PASS:
1087
-
1088
- ```bash
1089
- sp stop <waiting-job-id> # explicit close per job; verify with sp ps before
1090
- ```
1091
-
1092
- No automatic cascade-finalizer. Close each waiting job explicitly. (Yes, this is more ceremony than `sp finalize` provided — but `sp finalize` lived inside the broken sp merge path.)
1093
-
1094
- ### Rules
1095
-
1096
- - Merge only after reviewer PASS + clean Release Checklist unless operator explicitly accepts a draft.
1097
- - Always use `git merge --no-ff` for chain merges to keep the chain branch visible in history.
1098
- - If merge reports a dirty worktree on the target branch, inspect what's dirty. Revert generated noise (e.g., `.beads/issues.jsonl` churn) only when clearly unrelated; otherwise ask the operator.
1099
- - After merge, always remove the chain worktree + delete the branch + prune.
1100
- - Stale-base failures: per Git State Precondition section, dispatch chains only when target branch HEAD contains all prior dependent chains' commits.
1101
-
1102
- ## Integration Phase — Cherry-Pick Playbook (canonical multi-chain merge)
1103
-
1104
- The canonical path for landing multiple specialist chains. Operator gets visibility on an integration branch before the work hits main.
1105
-
1106
- ### Step-by-step
1107
-
1108
- 1. Stash uncommitted state on working branch: `git stash push -u -m "pre-integration"`.
1109
- 2. Create integration branch off the working branch: `git checkout -b integration/<date>-orchestrator`.
1110
- 3. For each non-overlapping chain (security/critical first, then test-baseline, then features):
1111
- - `git merge --squash <chain-branch>`
1112
- - Restore noise files (see "Chain noise filter checklist" below)
1113
- - **Advisory passes** before commit: if the staged diff smells overcomplicated/duplicative/type-risky, dispatch `seconder --job <last-exec-job-of-chain>`; if it touches auth/secrets/input/agent-config, dispatch `security-auditor --job <last-exec-job-of-chain>`. Link those beads with `bd dep add <advisory-bead> <chain-bead> --type validates`. Apply findings or document why skipped.
1114
- - `git commit -m "<type>(<scope>): <summary> (<bead-id>)"` — one squash commit per chain.
1115
- 4. For each overlapping chain, add `bd dep relate <overlap-a> <overlap-b>` if not already linked, then switch to the **debugger-restitch** pattern (next section).
1116
- 5. Before publication, run `bd dep cycles`; fix any accidental cycle before operator FF-merges integration → main.
1117
- 6. After all chains land, run E2E smoke phase (below) before declaring done.
1118
- 7. Operator FF-merges integration → main when satisfied.
1119
-
1120
- ### Chain noise filter checklist
1121
-
1122
- For manual cherry-pick / squash flows, unstage these before committing (otherwise the chain commit will carry orchestrator-bookkeeping noise):
1123
-
1124
- - `.pi/npm` — accidentally created by xt commands inside worktrees
1125
- - `cli/pnpm-lock.yaml`, `cli/pnpm-workspace.yaml` — pnpm side-effects
1126
- - `AGENTS.md`, `CLAUDE.md` — gitnexus stat-refresh hook noise
1127
- - `.beads/issues.jsonl`, `.beads/interactions.jsonl` — bd state churn
1128
- - `.specialists/executor-result.md` — transient specialist output
1129
-
1130
- ```bash
1131
- git restore --staged .beads .pi AGENTS.md CLAUDE.md
1132
- git checkout HEAD -- .beads AGENTS.md CLAUDE.md
1133
- rm -f .pi/npm
1134
- ```
1135
-
1136
- If a chain commits its own `.beads` symlink (older bd-in-worktree behavior), `rm -f .beads` then `git checkout HEAD -- .beads` to restore the real directory.
1137
-
1138
- ## Debugger-Restitch Pattern
1139
-
1140
- When chain X conflicts with already-landed chain Y on shared files, raw `git cherry-pick` will revert Y's work. The debugger-restitch pattern preserves both, but only when the debugger gets an explicit "preserve already-landed work" contract.
1141
-
1142
- 1. **Reopen X**: `bd reopen <X> --reason="integration stitch onto post-Y state"`. If the old X chain is no longer publishable, create a restitch bead and mark replacement explicitly: `bd supersede <X> --with <X-restitch>`. Link X and Y with `bd dep relate <X-restitch> <Y>` for conflict context; use `caused-by` only when a concrete failure bead is attributable to Y's already-landed change.
1143
- 2. **Strengthen the bead contract** with these fields:
1144
- - `## CRITICAL CONSTRAINTS:` heading at the top.
1145
- - "Fork off `integration/<date>-orchestrator`. Verify with `git log integration/...$..HEAD` empty before any commits."
1146
- - List the symbols/lines from Y that MUST be preserved verbatim (with file paths).
1147
- - "ADD X's intent ON TOP" with a numbered list of the additions.
1148
- - "Reference original `feature/<X>-executor` for symbol shapes only — do NOT cherry-pick or merge. Re-implement on integration's current state."
1149
- - `## VALIDATION:` includes both Y's tests passing AND X's new tests passing.
1150
- - `## OUTPUT:` mandates a 5-line code excerpt showing both Y and X features coexisting.
1151
- 3. **Dispatch debugger** with `--force-stale-base` if X is an epic child:
1152
- ```bash
1153
- sp run debugger --bead <X> --force-stale-base --keep-alive --background
1154
- ```
1155
- 4. **Sanity check the result**: when debugger reports back:
1156
- ```bash
1157
- git log integration/<date>..feature/<X>-debugger --oneline
1158
- git diff integration/<date>...feature/<X>-debugger -- <key-files>
1159
- ```
1160
- Confirm the debugger's diff is **additive** — no reverts of Y's lines.
1161
- 5. **Advisory passes**: before landing the restitch, dispatch `seconder --job <debugger-job>` if the restitch added control-flow complexity, and `security-auditor --job <debugger-job>` if it touched a sensitive surface. Link each advisory bead back with `bd dep add <advisory> <X-restitch-or-X> --type validates`. Restitched diffs are higher-risk than fresh executor diffs because the debugger had to thread around already-landed work.
1162
- 6. **Land via FF or cherry-pick the named commit** (NOT the checkpoint commit). Look for the commit with the proper `<type>(<scope>):` message; ignore `checkpoint(debugger):` commits above it.
1163
- 7. **Verify tests** before marking done.
1164
-
1165
- ### Failure mode to watch for
1166
-
1167
- If the debugger forks off the OLD baseline (pre-Y) instead of integration, its commit will revert Y. Symptom: `git diff integration..feature/<X>-debugger -- <Y's-file>` shows DELETIONS of Y's symbols. Fix: resume the debugger with explicit "cd to a fresh worktree forked from `integration/<date>-orchestrator`" instruction. Re-verify with `git log integration..HEAD` empty. If the bad restitch became a tracked bead, supersede it with the corrected restitch bead so nobody merges the obsolete chain.
1168
-
1169
- ## E2E Smoke Phase
1170
-
1171
- Run **every** npm script + entry point that any chain added or modified. The smoke phase is the only way to catch missed chains, false-positive CI gates, missing intermediate files, and runtime regressions invisible to unit tests.
1172
-
1173
- ### Procedure
1174
-
1175
- ```bash
1176
- # Build sanity
1177
- bun run build # or equivalent
1178
-
1179
- # Test sanity — record PRE-baseline first
1180
- git checkout <baseline-branch>
1181
- bun test 2>&1 | tail -5 # record N failed / M passed
1182
-
1183
- # Switch back and re-run
1184
- git checkout integration/<date>-orchestrator
1185
- bun test 2>&1 | tail -5 # MUST be ≥ baseline. Net regression is a stop-the-line.
1186
-
1187
- # Run every check:* script the integration added
1188
- for s in $(jq -r '.scripts | keys[] | select(startswith("check:"))' package.json); do
1189
- echo "=== $s ==="
1190
- npm run "$s" 2>&1 | tail -10
1191
- done
1192
-
1193
- # Targeted unit tests for chains touching the same files
1194
- bunx vitest run <chain-test-files>
1195
- ```
1196
-
1197
- For each smoke that fails, decide before continuing:
1198
- - False positive (script flags itself) → file follow-up bead, document, continue
1199
- - Missing dependency (vendor not run) → expected gate, document
1200
- - Real regression → stop, dispatch debugger to fix, re-smoke
1201
-
1202
- ### Cross-cutting security-auditor pass
1203
-
1204
- If any landed chain in this integration touched auth, secrets, input handling, dependency lockfiles, or agent/MCP/config surfaces, dispatch one `security-auditor` on the cumulative integration diff BEFORE declaring smoke done:
1205
-
1206
- ```bash
1207
- git diff <baseline>..integration/<date>-orchestrator > /tmp/integration-diff.patch
1208
- sp run security-auditor --bead <sec-bead> --context-depth 3 --background
1209
- ```
1210
-
1211
- Per-chain security-auditor passes catch chain-local risks; this cross-cutting pass catches interaction risks that only appear once all chains coexist (e.g. one chain weakens an input validator that another newly relies on). Skipping this on a sensitive-surface integration is an escalation event.
1212
-
1213
- Record all smoke results in the session-close-report under a `## Smoke test results` table (see `/session-close-report` skill).
1214
-
1215
- ## Failure Recovery
1216
-
1217
- When something fails:
1218
-
1219
- ```bash
1220
- sp ps <job-id>
1221
- sp feed <job-id>
1222
- sp result <job-id>
1223
- sp doctor
1224
- ```
1225
-
1226
- Then choose one action:
1227
-
1228
- - Resume waiting executor/debugger with exact findings.
1229
- - Re-run with better bead if contract was weak.
1230
- - Re-scope bead if scope was wrong.
1231
- - Escalate if human decision is needed.
1232
- - Replace specialist only if failure mode repeats.
1233
-
1234
- ### Common failure patterns (and the canonical fix)
1235
-
1236
- | Symptom | Cause | Fix |
1237
- |---|---|---|
1238
- | `git checkout <branch>` aborts with "would overwrite untracked/changes" mid-orchestration | bd auto-export keeps re-staging `.beads/issues.jsonl` after every bd op | Use `git update-ref refs/heads/<target> <source>` for FF-equivalent without checkout; or commit the .beads churn as a separate "chore(beads): export state" commit before switching |
1239
- | Stale `.git/index.lock` blocks git commands | bd hooks or other tooling crashed mid-operation | Check no real git process is running (`ps -ef \| grep "git "`); if clear, `rm -f .git/index.lock` and retry |
1240
- | `git add .beads/issues.jsonl` says "ignored by gitignore" but `git status` shows it modified | File is in `.git/info/exclude` but already tracked in the index | The staged change can still be committed directly (`git commit` without `git add`); don't fight the exclude |
1241
- | Validation fails with `command not found`, `vitest: not found`, missing Python tools, or `ERR_MODULE_NOT_FOUND` in a fresh worktree | Normal git worktree behavior: ignored dependency dirs (`node_modules/`, `.venv/`) are not copied into new worktrees | Run the repo's standard bootstrap inside that worktree (`make bootstrap`, `just setup`, `npm ci`, `uv sync`, etc.) or report bootstrap-required. Do not track dependency artifacts. |
1242
- | `sp ps` shows old terminal jobs after a session | Default dashboard keeps unresolved terminal problems visible until acknowledged | `sp clean --ps --dry-run`, then `sp clean --ps` to soft-hide from default ps; use `sp ps --include-cleaned`/`--all` for audit history |
1243
- | Reviewer keeps returning PARTIAL on functional contracts already met | Reviewer demanding tool-event evidence — typically obsoleted after the gate relaxation, but if it persists check the executor's `gitnexus_detect_changes` ran and use the rebuttal pattern (see Specialist Rebuttal As Routine) | Rebut with cited evidence; second FAIL = escalate |
1244
- | Multiple `sp run` background launches drop silently under shell parallelism | Known launch-ceremony race | Re-check `sp ps` after each dispatch and retry the missing one; serialize when reliability matters |
1245
- | `sp run` returns `Warning: job started but ID not yet available` and nothing appears in `sp ps --bead <id>` after 30s | Dispatch was refused by epic guard or base-staleness check; stderr now surfaces the refusal reason (see `sp run --background` post-fix) | Read the surfaced reason; retry with `--force-stale-base` if intentional, or fix the bead/lineage |
1246
- | `sp feed <job-id>` returns short tail with no tool events | Confirms DB-backed replay is active; if you see ≤10 lines on a real run, the DB is missing events for that job — verify with raw SQL on observability.db | If DB truly lacks events: re-run job; if DB has events but feed truncates: file bug bead — should not happen on current build |
1247
- | bd "database not found" or per-project Dolt server respawn | bd has spawned a per-project Dolt instead of routing to the shared server | `ps aux \| grep "<repo>/.beads/dolt" \| awk '{print $2}' \| xargs -r kill -9`; ensure `.beads/config.yaml` contains `dolt.shared-server: true`; `bd ready` should now route to `~/.beads/shared-server/` |
1248
- | Dolt journal corruption (`possible data loss detected at offset N`) | bd-internal | Operator-only — do NOT auto-recover. Stop bd writes, snapshot `~/.beads/shared-server/dolt`, run `dolt fsck` (read-only) first. Operator decides on `--revive-journal-with-data-loss` after reviewing the warning |
1249
-
1250
- ## What Orchestrator Does Differently Because Of This Skill
1251
-
1252
- - Writes bead contract before dispatch.
1253
- - Chooses edge type before creating chain.
1254
- - Uses specialist role by job shape, not by habit.
1255
- - Keeps fix loops alive with resume, not re-spawn.
1256
- - Treats reviewer PASS as only publish gate.
1257
- - Maps file-overlap surface BEFORE dispatching parallel waves.
1258
- - Files one READ_ONLY test-failure-map bead before fix chains when ≥5 failures span subsystems.
1259
- - Uses overthinker and reviewer as conversation, not one-shot oracles — rebuts with cited evidence once, then escalates.
1260
- - Smokes every npm script and entry point before declaring integration done; runs cross-cutting security-auditor on cumulative diff when sensitive surfaces were touched.
1261
- - Commits debugger-restitch results via FF or cherry-pick of the named commit, not the checkpoint commit above it.
1262
- - Closes finished chain's bead BEFORE committing that worktree when other chains still in_progress (project-wide commit-gate).
1263
- - Applies SCRUTINY field on every substantive bead; lets reviewer auto-escalate.
1264
- - Verifies Git State Precondition before every dependent-chain dispatch.
1265
- - Merges specialist work via manual git workflow (Cherry-Pick Playbook); never `sp merge` / `sp epic merge` (rule #9 — known broken).
1266
- - Runs `/session-close-report` at session end and only then declares done.
1267
- - Keeps memory-processor, xt-merge, session-close-report, and releasing out of this skill on purpose — each has its own.