@orchestrator-claude/definitions 3.33.0 → 3.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/README.md +32 -0
  2. package/agents/adversarial-reviewer.md +2 -2
  3. package/agents/azure-devops-engineer.md +9 -1
  4. package/agents/cicd-platform-engineer.md +477 -0
  5. package/agents/debug-sidecar.md +5 -0
  6. package/agents/doc-sidecar.md +5 -0
  7. package/agents/frontend-engineer.md +173 -0
  8. package/agents/implementer.md +39 -23
  9. package/agents/methodology-researcher.md +2 -1
  10. package/agents/operational-artifact-builder.md +2 -1
  11. package/agents/orchestrator.md +47 -76
  12. package/agents/planner.md +2 -2
  13. package/agents/presentation-engineer.md +1 -1
  14. package/agents/python-data-engineer.md +214 -0
  15. package/agents/reviewer.md +16 -8
  16. package/agents/specifier.md +1 -1
  17. package/agents/task-generator.md +1 -1
  18. package/agents/test-sidecar.md +14 -3
  19. package/hooks/hooks.json +63 -0
  20. package/manifest.json +75 -27
  21. package/package.json +1 -1
  22. package/skills/artifact-generator/SKILL.md +1 -1
  23. package/skills/artifact-production/SKILL.md +28 -0
  24. package/skills/backlog-synthesis/SKILL.md +8 -3
  25. package/skills/checkpoint-protocol/SKILL.md +7 -0
  26. package/skills/infographic-engine/SKILL.md +116 -0
  27. package/skills/orchestrator/SKILL.md +93 -7
  28. package/skills/persona-library/SKILL.md +1 -1
  29. package/skills/project-conventions/SKILL.md +53 -30
  30. package/skills/project-management-enterprise/SKILL.md +1 -1
  31. package/skills/python-data-engineering/SKILL.md +792 -0
  32. package/skills/release/SKILL.md +29 -18
  33. package/skills/release/release.sh +65 -4
  34. package/skills/storybook-validated-loop/SKILL.md +110 -0
  35. package/skills/tdd-discipline/SKILL.md +16 -0
  36. package/skills/workflow-coordination/SKILL.md +117 -16
@@ -36,6 +36,7 @@ O script atualiza automaticamente:
36
36
  - `packages/mcp-server/package.json`
37
37
  - `packages/sdk/package.json`
38
38
  - `packages/definitions/package.json`
39
+ - `packages/definitions/manifest.json` (regenerado da versao bumped — TD-193)
39
40
  - `packages/cli/src/index.ts` (CLI_VERSION constant)
40
41
  - `src/infrastructure/templates/base/package.json.hbs` (template versions)
41
42
 
@@ -78,13 +79,13 @@ git describe --tags --abbrev=0
78
79
  Sempre faca dry-run primeiro:
79
80
 
80
81
  ```bash
81
- ./scripts/release.sh --dry-run patch
82
+ .claude/skills/release/release.sh --dry-run patch
82
83
  ```
83
84
 
84
85
  ### 3. Executar Release
85
86
 
86
87
  ```bash
87
- ./scripts/release.sh patch
88
+ .claude/skills/release/release.sh patch
88
89
  ```
89
90
 
90
91
  ### 4. Monitorar CI/CD
@@ -101,9 +102,9 @@ User: "Faca release do fix que acabamos de fazer"
101
102
 
102
103
  Claude:
103
104
  1. Verifico pre-requisitos
104
- 2. Executo: ./scripts/release.sh --dry-run patch
105
+ 2. Executo: .claude/skills/release/release.sh --dry-run patch
105
106
  3. Confirmo com usuario
106
- 4. Executo: ./scripts/release.sh patch
107
+ 4. Executo: .claude/skills/release/release.sh patch
107
108
  5. Reporto URL do pipeline
108
109
  ```
109
110
 
@@ -114,9 +115,9 @@ User: "Release da nova feature de dashboard"
114
115
 
115
116
  Claude:
116
117
  1. Verifico CHANGELOG atualizado
117
- 2. Executo: ./scripts/release.sh --dry-run minor
118
+ 2. Executo: .claude/skills/release/release.sh --dry-run minor
118
119
  3. Confirmo com usuario
119
- 4. Executo: ./scripts/release.sh minor
120
+ 4. Executo: .claude/skills/release/release.sh minor
120
121
  ```
121
122
 
122
123
  ### Release de Major (Breaking Change)
@@ -126,10 +127,10 @@ User: "Precisamos fazer release 2.0.0"
126
127
 
127
128
  Claude:
128
129
  1. Verifico CHANGELOG com breaking changes documentados
129
- 2. Executo: ./scripts/release.sh --dry-run 2.0.0
130
+ 2. Executo: .claude/skills/release/release.sh --dry-run 2.0.0
130
131
  3. ALERTA sobre breaking changes
131
132
  4. Confirmo DUAS vezes com usuario
132
- 5. Executo: ./scripts/release.sh 2.0.0
133
+ 5. Executo: .claude/skills/release/release.sh 2.0.0
133
134
  ```
134
135
 
135
136
  ## Output Esperado
@@ -157,6 +158,7 @@ Files to update:
157
158
  - packages/mcp-server/package.json
158
159
  - packages/sdk/package.json
159
160
  - packages/definitions/package.json
161
+ - packages/definitions/manifest.json (regenerated from bumped version)
160
162
  - packages/cli/src/index.ts (CLI_VERSION)
161
163
  - src/infrastructure/templates/base/package.json.hbs (templates)
162
164
 
@@ -234,21 +236,30 @@ O push da tag dispara automaticamente:
234
236
 
235
237
  ## Definitions Manifest Sync
236
238
 
237
- Se houve alteracao em ficheiros de definitions (`packages/definitions/` ou `.claude/agents/`, `.claude/skills/`, `.claude/hooks/`, `.claude/workflows/`, `.claude/kb-docs/`), o `packages/definitions/manifest.json` DEVE ser regenerado **antes** do release.
239
+ O `packages/definitions/manifest.json` e o indice unico de todas as built-in definitions
240
+ com checksums SHA256 e o campo `version`. E consumido pela CLI (seed, sync) e MCP server, e
241
+ o seu campo `version` e asserido pelo `ManifestLoader.test.ts`. Se ficar dessincronizado do
242
+ `package.json`, o build regenera-o em CI para a versao nova e o teste falha — foi o que deixou
243
+ `main` vermelho a cada release ate v3.32.1 (TD-193).
238
244
 
239
- O manifest e o indice unico de todas as built-in definitions com checksums. E consumido pela CLI (seed, sync) e MCP server. Se os checksums estiverem desactualizados, projectos scaffolded vao receber definitions stale.
245
+ **Automatizado (TD-193):** o `release.sh` regenera o manifest **depois** do bump de versao
246
+ (`regenerate_definitions_manifest`, via `npm run generate-manifest -w packages/definitions`),
247
+ valida que `manifest.version === package.version`, e inclui `packages/definitions/manifest.json`
248
+ no commit do bump. Como `generate-manifest` reescanea todas as definitions, isto tambem cobre
249
+ mudancas de conteudo em `.claude/agents/`, `.claude/skills/`, `.claude/hooks/`, `.claude/kb/` —
250
+ os checksums ficam sempre frescos. **Nao e mais necessario regenerar o manifest manualmente
251
+ antes do release.**
240
252
 
241
- ```bash
242
- # Verificar se definitions mudaram desde ultimo release
243
- git diff $(git describe --tags --abbrev=0) -- packages/definitions/ .claude/
253
+ Para regenerar/inspeccionar o manifest fora de um release (debug):
244
254
 
245
- # Se houve mudancas, regenerar manifest
246
- npm run manifest:generate # ou o comando equivalente do projecto
247
- git add packages/definitions/manifest.json
248
- git commit -m "chore: sync definitions manifest checksums"
255
+ ```bash
256
+ npm run generate-manifest -w packages/definitions
257
+ node -p "require('./packages/definitions/manifest.json').version" # deve == package.json
249
258
  ```
250
259
 
251
- **REGRA:** Nunca faca release com definitions alteradas sem manifest actualizado. Isso causa uma release extra desnecessaria (como aconteceu no v3.9.3 -> v3.9.4).
260
+ **REGRA (historica):** antes do TD-193 uma release com definitions alteradas sem manifest
261
+ actualizado causava uma release extra desnecessaria (v3.9.3 -> v3.9.4) ou `main` vermelho
262
+ (v3.32.1). O `release.sh` agora fecha esse gap; nao contorne o script fazendo bump manual.
252
263
 
253
264
  ## Secret Audit (Quarterly — TD-S188-003)
254
265
 
@@ -17,6 +17,10 @@ set -euo pipefail
17
17
  # - packages/cli/package.json
18
18
  # - packages/mcp-server/package.json
19
19
  # - packages/sdk/package.json
20
+ # - packages/definitions/package.json
21
+ # - packages/definitions/.claude-plugin/plugin.json (native plugin manifest — RFC-040 §18, TD-212)
22
+ # - packages/definitions/manifest.json (regenerated from bumped version — TD-193)
23
+ # - packages/project-root-resolver/package.json (published dep of mcp-server — S387)
20
24
  # - packages/cli/src/index.ts (CLI_VERSION constant)
21
25
  # - src/infrastructure/templates/base/package.json.hbs (template versions)
22
26
  #
@@ -315,6 +319,18 @@ update_all_versions() {
315
319
  # Update SDK package
316
320
  update_package_version "packages/sdk/package.json" "$version"
317
321
 
322
+ # Update definitions package (ADR-003)
323
+ update_package_version "packages/definitions/package.json" "$version"
324
+
325
+ # Update native plugin manifest (RFC-040 §18). Keeps the Claude Code plugin
326
+ # version in lockstep with the definitions package; without this the plugin
327
+ # manifest stalls at its scaffold version (TD-212). plugin.json is a plain
328
+ # JSON with a top-level "version" field, so the generic JSON bump applies.
329
+ update_package_version "packages/definitions/.claude-plugin/plugin.json" "$version"
330
+
331
+ # Update project-root-resolver package (published dependency of mcp-server — S387)
332
+ update_package_version "packages/project-root-resolver/package.json" "$version"
333
+
318
334
  # Update CLI_VERSION constant
319
335
  update_cli_version_constant "$version"
320
336
 
@@ -345,6 +361,37 @@ run_build() {
345
361
  log_success "Build completed - dist/ updated with latest templates"
346
362
  }
347
363
 
364
+ # Regenerate packages/definitions/manifest.json AFTER the version bump (TD-193).
365
+ # run_build already regenerates the manifest, but it runs BEFORE update_all_versions,
366
+ # so at that point the manifest still carries the OLD version. generate-manifest sources
367
+ # packages/definitions/package.json, which is now bumped — regenerating here keeps the
368
+ # committed manifest.json in lockstep with package.json and prevents ManifestLoader test
369
+ # drift (root cause of main going red on every release, TD-193).
370
+ regenerate_definitions_manifest() {
371
+ echo "🧾 Regenerating definitions manifest from bumped version..."
372
+
373
+ if [ "$DRY_RUN" = true ]; then
374
+ echo " [dry-run] Would run: npm run generate-manifest -w packages/definitions"
375
+ return
376
+ fi
377
+
378
+ if ! npm run generate-manifest -w packages/definitions > /dev/null 2>&1; then
379
+ log_error "Manifest regeneration failed. Fix errors before releasing."
380
+ exit 1
381
+ fi
382
+
383
+ # Guard: the committed manifest version must now equal the bumped package version.
384
+ local manifest_version pkg_version
385
+ manifest_version=$(node -p "require('./packages/definitions/manifest.json').version")
386
+ pkg_version=$(node -p "require('./packages/definitions/package.json').version")
387
+ if [ "$manifest_version" != "$pkg_version" ]; then
388
+ log_error "Manifest version ($manifest_version) != package version ($pkg_version) after regen"
389
+ exit 1
390
+ fi
391
+
392
+ log_success "Manifest regenerated and version-synced to $manifest_version"
393
+ }
394
+
348
395
  # ============================================================================
349
396
  # Git Functions
350
397
  # ============================================================================
@@ -362,6 +409,10 @@ commit_version_bump() {
362
409
  packages/cli/package.json \
363
410
  packages/mcp-server/package.json \
364
411
  packages/sdk/package.json \
412
+ packages/definitions/package.json \
413
+ packages/definitions/.claude-plugin/plugin.json \
414
+ packages/definitions/manifest.json \
415
+ packages/project-root-resolver/package.json \
365
416
  packages/cli/src/index.ts \
366
417
  src/infrastructure/templates/base/package.json.hbs
367
418
 
@@ -372,6 +423,10 @@ Updates:
372
423
  - packages/cli/package.json
373
424
  - packages/mcp-server/package.json
374
425
  - packages/sdk/package.json
426
+ - packages/definitions/package.json
427
+ - packages/definitions/.claude-plugin/plugin.json (native plugin manifest, RFC-040 §18)
428
+ - packages/definitions/manifest.json (regenerated, TD-193)
429
+ - packages/project-root-resolver/package.json (published dependency of mcp-server, S387)
375
430
  - packages/cli/src/index.ts (CLI_VERSION)
376
431
  - src/infrastructure/templates/base/package.json.hbs (templates)
377
432
 
@@ -446,16 +501,21 @@ main() {
446
501
  echo " - packages/cli/package.json"
447
502
  echo " - packages/mcp-server/package.json"
448
503
  echo " - packages/sdk/package.json"
504
+ echo " - packages/definitions/package.json"
505
+ echo " - packages/definitions/.claude-plugin/plugin.json (native plugin manifest, RFC-040 §18)"
506
+ echo " - packages/definitions/manifest.json (regenerated from bumped version)"
507
+ echo " - packages/project-root-resolver/package.json (published dep of mcp-server, S387)"
449
508
  echo " - packages/cli/src/index.ts (CLI_VERSION)"
450
509
  echo " - src/infrastructure/templates/base/package.json.hbs (templates)"
451
510
  echo ""
452
511
  echo "Actions:"
453
512
  echo " 1. Build project (update dist/ with latest templates)"
454
513
  echo " 2. Update version in all files"
455
- echo " 3. Commit version bump"
456
- echo " 4. Create git tag $tag"
457
- echo " 5. Push main + tag to origin"
458
- echo " 6. CI/CD pipeline will publish npm + Docker"
514
+ echo " 3. Regenerate definitions manifest from bumped version (TD-193)"
515
+ echo " 4. Commit version bump"
516
+ echo " 5. Create git tag $tag"
517
+ echo " 6. Push main + tag to origin"
518
+ echo " 7. CI/CD pipeline will publish npm + Docker"
459
519
  echo ""
460
520
 
461
521
  if [ "$FORCE" = false ] && [ "$DRY_RUN" = false ]; then
@@ -470,6 +530,7 @@ main() {
470
530
  # Execute release steps
471
531
  run_build
472
532
  update_all_versions "$new_version"
533
+ regenerate_definitions_manifest
473
534
  commit_version_bump "$new_version"
474
535
  create_and_push_tag "$new_version"
475
536
 
@@ -0,0 +1,110 @@
1
+ ---
2
+ name: storybook-validated-loop
3
+ description: Loop de prototipagem React component-driven usando Storybook como superfície de validação visual — a alternativa local (zero tokens SaaS, zero deploy) a loops de render SaaS (Bolt/v0/Lovable). Load when "storybook story", "component story", "nova tela react", "DSVL React", "canary para react", "validação visual component-driven", ou quando o frontend-engineer implementa telas. NÃO use para markdown-driven LLM-render (use design-system-validated-loop) nem slide decks (presentation-engineer).
4
+ allowed-tools: Read, Write, Edit, Bash, Grep, Glob
5
+ ---
6
+
7
+ # Storybook Validated Loop — Prototipagem React component-driven
8
+
9
+ ## When to Use This Skill
10
+
11
+ Load this skill when:
12
+ - Vai construir/refinar **telas React** de um app-alvo seguindo um design já aprovado.
13
+ - A request contém: "storybook story", "component story", "nova tela react", "DSVL React", "canary para react", "validação visual component-driven".
14
+ - O agent `frontend-engineer` é despachado para a fase React de um workflow.
15
+
16
+ **Scope boundary — o que esta skill NÃO cobre:**
17
+ - Patches markdown que dirigem LLM-render (Bolt/v0/Lovable) → use `design-system-validated-loop`.
18
+ - Slide decks Slidev → use `presentation-engineer`.
19
+ - Backend/infra (mock-first; sem APIs, sem deploy de servidor).
20
+
21
+ ## Contexto: por que Storybook (local) sobre loops de render SaaS
22
+
23
+ Ferramentas de render SaaS (Bolt/v0/Lovable) cobram tokens por re-ingest/re-render e dependem de deploy externo. O **Storybook** assume o mesmo papel na ponta React do DSVL — superfície de desenvolvimento e validação visual **component-driven** — mas rodando **local** (zero tokens SaaS, zero deploy infra). Esta skill é a versão React-nativa do DSVL: reusa o esqueleto canary HTML e o protocolo de validação Playwright, mas troca "re-ingest/publish no SaaS" por "stories locais no Storybook".
24
+
25
+ | Camada | Loop SaaS (Bolt/v0) | Storybook (local) |
26
+ |---|---|---|
27
+ | Superfície de componente | re-ingest no SaaS | `*.stories.tsx` local |
28
+ | Validação visual | screenshot do render publicado | Playwright sobre Storybook local |
29
+ | Custo | tokens SaaS + re-render | zero (build local) |
30
+ | Audit trail | deploy URL | story + screenshot em `.cobaia-evidence/` |
31
+
32
+ ## O Loop (7 passos)
33
+
34
+ > Anchor: um **design aprovado** (spec + wireframe). Ex: `docs/specs/2026-06-03-entrega-epi-design.md`.
35
+
36
+ ### Passo 0 — Ancorar no design aprovado
37
+ Read o spec + o wireframe aprovado. Confirme escopo (telas, estados, critérios de aceitação). NÃO comece sem design aprovado (HARD GATE — herdado do brainstorming).
38
+
39
+ ### Passo 1 — Auditoria do Design System (Verify-Before-Assert)
40
+ Antes de criar qualquer token/componente, **verifique empiricamente** no working tree:
41
+ - Tokens → `Grep`/`Read` `src/index.css`; confirme cores/raios/tipografia citados no spec. NÃO assuma que um token existe.
42
+ - Componentes → `Glob`/`Read` `src/components/` e `src/layouts/`; confirme reuso vs novo.
43
+ - Se o design-system do projeto for **só `.md`** (não é lib instalável), os componentes reais vivem em `src/components/`.
44
+ Liste patches de token necessários (novos aliases CSS) com justificativa. Divergência spec↔código = sinal: PARE e reporte.
45
+
46
+ ### Passo 2 — Canary HTML ("wire-frame")
47
+ Preview auto-contido HTML dos frames, com os tokens reais, nos viewports (foco **375px**; conferir shell centralizado 768/1920). Reusa o esqueleto canary do DSVL. **Gate 1 (humano):** validação visual antes de virar React. Zero tokens downstream.
48
+
49
+ ### Passo 3 — Build component-driven (React + CSF3)
50
+ Para **cada componente** do inventário:
51
+ 1. Implemente o componente em `src/components/<Global>.tsx` (global) ou `src/screens/<feat>/components/<Local>.tsx` (local), fiel aos tokens do DS.
52
+ 2. Escreva uma **story CSF3** `<Componente>.stories.tsx` cobrindo todos os estados/variantes (default + exceções, ex: EPI válido / a-vencer / bloqueado).
53
+ 3. Use `args`/`argTypes` para controles interativos; `parameters.viewport` para mobile 375px; addon-a11y deve passar.
54
+ Componente isolado na story = contrato visual + sandbox de debug (o que o loop SaaS fazia, agora local).
55
+
56
+ ### Passo 4 — Validação visual no Storybook
57
+ Suba o Storybook (`npm run storybook`) e use Playwright para screenshot de cada story nos viewports relevantes. Salve em `.cobaia-evidence/baseline/` e `.cobaia-evidence/fixed/`. **Gate 2 (humano):** revisão visual das stories antes de compor as telas. addon-a11y sem violações críticas.
58
+
59
+ ### Passo 5 — Composição de telas + rotas + mocks
60
+ Componha os componentes validados nas telas/wizard. Adicione rota(s) em `src/App.tsx` (e shell novo se aplicável). Fixtures em `*.mock.ts` (mock-first: sem backend; integrações externas facial/PDF/hardware simuladas).
61
+
62
+ ### Passo 6 — Playwright E2E do fluxo
63
+ Testes `*.spec.ts` cobrindo o fluxo ponta-a-ponta + estados de exceção, no **viewport 375px** (+ tablet/desktop p/ shell). Adicione um projeto `Mobile` no `playwright.config.ts` SEM remover os existentes. **Gate 3:** todos passam.
64
+
65
+ ### Passo 7 — Evidência + encerramento
66
+ Screenshots de antes/depois, contagem de testes, cobertura. Memórias (RFC-027) sobre gotchas. Commit só quando o humano pedir.
67
+
68
+ ## Convenções de story (CSF3)
69
+
70
+ ```tsx
71
+ import type { Meta, StoryObj } from '@storybook/react-vite';
72
+ import { EpiItemCard } from './EpiItemCard';
73
+
74
+ const meta: Meta<typeof EpiItemCard> = {
75
+ title: 'EntregaEPI/EpiItemCard',
76
+ component: EpiItemCard,
77
+ parameters: { viewport: { defaultViewport: 'mobile1' }, layout: 'centered' },
78
+ tags: ['autodocs'],
79
+ };
80
+ export default meta;
81
+ type Story = StoryObj<typeof EpiItemCard>;
82
+
83
+ export const Valido: Story = { args: { statusCA: 'valido' } };
84
+ export const AVencer: Story = { args: { statusCA: 'a_vencer' } };
85
+ export const Bloqueado: Story = { args: { statusCA: 'vencido', bloqueado: true } };
86
+ ```
87
+
88
+ - `title` agrupa por feature (`EntregaEPI/...`).
89
+ - Uma story por estado relevante (inclua exceções).
90
+ - `parameters.viewport` para mobile; importe `src/index.css` no `.storybook/preview.tsx` (tokens do DS).
91
+
92
+ ## Gates (resumo)
93
+
94
+ | Gate | Quando | Quem |
95
+ |---|---|---|
96
+ | HARD GATE design | antes do Passo 1 | design aprovado existe? |
97
+ | Gate 1 | após canary HTML | humano valida visual |
98
+ | Gate 2 | após stories | humano valida componentes isolados + a11y |
99
+ | Gate 3 | após E2E | Playwright 375px verde |
100
+
101
+ ## O que esta skill substitui do DSVL
102
+
103
+ - Etapa 2.5 Storybook (era validação SaaS-paralela) → vira o **núcleo** do loop React.
104
+ - Etapa 4 "humano sincroniza SaaS + publica" → **removida** (Storybook local; sem SaaS).
105
+ - Etapa 6.5 "route-around-SaaS + F5 manual" → **removida** (edição direta no repo + HMR do Vite).
106
+ - Mantém: esqueleto canary (Etapa 1), protocolo Playwright de validação, estrutura de evidência/memória.
107
+
108
+ ## Token economy
109
+
110
+ Storybook roda local: **zero tokens SaaS**, zero deploy. O custo desloca para build/HMR local (segundos). Substitui o burn de re-ingest/re-render de loops SaaS. Esta é a razão da migração para component-driven local.
@@ -11,6 +11,22 @@ description: TDD protocol for the implementer agent. Use when implementing tasks
11
11
  3. Refactor if needed (Refactor)
12
12
  4. Verify coverage >= 80%
13
13
 
14
+ ### Commit cadence (git-auditability)
15
+
16
+ The RED→GREEN→REFACTOR cycle MUST be reflected in commit history — not collapsed into a single "scaffold" commit. Future reviewers walking `git log` should be able to see:
17
+
18
+ - One commit per RED step (failing tests only — `raise NotImplementedError` stubs or absent impl is fine)
19
+ - One commit per GREEN step (minimum impl that turns tests green)
20
+ - (Optional) One commit per REFACTOR step (no behavior change)
21
+
22
+ **Prohibited:** a single commit that contains BOTH failing tests AND their working implementation. This destroys TDD-discipline evidence post-merge — `git show <sha>` reveals nothing about whether tests were authored first.
23
+
24
+ **Conventional Commits mapping:**
25
+ - `test(<scope>): <TD-or-task-id> RED <one-line description>` — RED commit
26
+ - `feat(<scope>): <TD-or-task-id> GREEN <one-line description>` (or `fix(...)` / `refactor(...)` as appropriate) — GREEN commit
27
+
28
+ **Origin:** S226 wave-3e reviewer LOW-002 (commit `95f9b7c` merged tests+impl in scaffold). Promoted from TD-S226-016.
29
+
14
30
  ### Test File Location
15
31
  - Unit: tests/unit/<layer>/<domain>/<file>.test.ts
16
32
  - Integration: tests/integration/<feature>.integration.test.ts
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: workflow-coordination
3
- description: Teaches the orchestrator how to coordinate workflows via MCP tools. Use when starting, advancing, or managing workflows.
3
+ description: Teaches how to coordinate workflows via MCP tools. Use when starting, advancing, or managing workflows. Aligned with RFC-022 skill-based orchestration.
4
4
  ---
5
5
 
6
6
  ## Workflow Coordination Protocol
@@ -14,10 +14,19 @@ You have access to MCP tools via deferred loading. To use any mcp__* tool:
14
14
  Note: ToolSearch results are cached — you only need to fetch each tool once per session.
15
15
 
16
16
  ### Starting a Workflow
17
- 1. Call ToolSearch to load startWorkflow schema
18
- 2. Call startWorkflow with: { name, type, projectId }
19
- 3. startWorkflow automatically creates the workflow AND sets the first pendingAction
20
- 4. Return the nextStep instruction to the main agent
17
+ 1. Call ToolSearch to load detectWorkflow + startWorkflow schemas
18
+ 2. Call detectWorkflow with: { prompt: "user request" }
19
+ 3. Call startWorkflow with: { name, type, projectId }
20
+ 4. startWorkflow automatically creates the workflow AND sets the first pendingAction
21
+ 5. Dispatch the first phase sub-agent via Agent tool from the main conversation
22
+
23
+ ### Orchestration Model (RFC-022)
24
+
25
+ The **main conversation is the orchestrator**. There is no orchestrator sub-agent.
26
+
27
+ - Phase sub-agents (specifier, planner, implementer, etc.) are dispatched via `Agent(subagent_type: "...")` directly from the main conversation
28
+ - Gates between phases use `AskUserQuestion` — never auto-approve
29
+ - The `/orchestrator` skill is the universal entry point
21
30
 
22
31
  ### Deterministic Hooks (ADR-013)
23
32
 
@@ -25,16 +34,17 @@ Orchestration governance is enforced by hooks, not by prompt instructions:
25
34
 
26
35
  | Hook | When | Effect |
27
36
  |------|------|--------|
28
- | `ping-pong-enforcer` | After every Agent call | Auto-calls getNextAction, injects result |
29
- | `gate-guardian` | Before advancePhase | Auto-evaluates gate, blocks if fails |
30
- | `dangling-workflow-guard` | On session Stop | Warns and completes dangling workflows |
31
-
32
- You do NOT need to manually call getNextAction or evaluateGate — hooks handle this.
37
+ | `gate-guardian` | Before advancePhase | Blocks IMPLEMENT phase without approval |
38
+ | `workflow-guard` | Before Write/Edit on src/ | Blocks code writes without active workflow |
39
+ | `dangling-workflow-guard` | On session Stop | Warns about dangling workflows |
40
+ | `session-orchestrator` | On session Start | Injects workflow status context |
41
+ | `prompt-orchestrator` | On user prompt Submit | Injects workflow hints |
33
42
 
34
43
  ### Phase Advancement
35
- 1. Call advancePhase — the gate-guardian hook evaluates the gate automatically
36
- 2. If gate PASSES: advancePhase proceeds, set pendingAction for next agent
37
- 3. If gate FAILS: hook blocks the call and returns failure reasons
44
+ 1. Present artifact summary to user via AskUserQuestion
45
+ 2. If user approves: call advancePhase
46
+ 3. If user requests changes: re-dispatch the same sub-agent with feedback
47
+ 4. The gate-guardian hook provides an additional safety check
38
48
 
39
49
  ### Phase → Agent Mapping
40
50
 
@@ -51,8 +61,99 @@ You do NOT need to manually call getNextAction or evaluateGate — hooks handle
51
61
  - SPECIFY: spec.md exists in MinIO, has required sections
52
62
  - PLAN: plan.md exists, references spec, has architecture section
53
63
  - TASKS: tasks.md exists, tasks are atomic, has acceptance criteria
54
- - IMPLEMENT: requires human approval (status: awaiting_approval)
64
+ - IMPLEMENT: requires human approval via AskUserQuestion
55
65
 
56
66
  ### Observability
57
- After EVERY action, call startAgentInvocation/completeAgentInvocation
58
- to track your own execution in PostgreSQL.
67
+ Hooks automatically track agent invocations via SubagentStart/SubagentStop events.
68
+ Git checkpoints are created automatically after phase completion.
69
+
70
+ ---
71
+
72
+ ### Starting a Sprint from Parent Document
73
+
74
+ Use this algorithm when the user asks to "start Sprint N of RFC-XXX" or when a sprint decomposition table exists in a parent document.
75
+
76
+ #### Step 1 — Identify the Target Sprint
77
+
78
+ 1. Read the parent RFC or ADR file (e.g. `project-guidelines/rfcs/RFC-027-*.md`)
79
+ 2. Find the **Sprint Decomposition** table
80
+ 3. Identify the target sprint row by index (S1, S2, ... SN)
81
+ 4. Extract: scope, estimate, status, deliverables
82
+
83
+ #### Step 2 — Choose Phase Pipeline
84
+
85
+ Based on the sprint scope, select the appropriate phase pipeline:
86
+
87
+ | Condition | Phase Pipeline |
88
+ |-----------|---------------|
89
+ | Exploration needed before specifying (novel design) | `research → specify → plan → tasks → implement` |
90
+ | Design is clear enough for a spec but not a plan | `specify → plan → tasks → implement` |
91
+ | Scope is well-defined, plan can be derived directly | `plan → tasks → implement` |
92
+
93
+ Default for new sprints: start with `specify` unless the sprint explicitly says "research first".
94
+
95
+ #### Step 3 — Start the Workflow with Sprint Metadata
96
+
97
+ When calling `startWorkflow`, include sprint metadata:
98
+
99
+ ```
100
+ mcp__orchestrator-tools__startWorkflow({
101
+ type: "feature_development",
102
+ prompt: "[Sprint N scope from the parent document]",
103
+ metadata: {
104
+ parentDocument: "project-guidelines/rfcs/RFC-NNN-TITLE.md",
105
+ sprintIndex: N
106
+ }
107
+ })
108
+ ```
109
+
110
+ The `metadata` fields are stored with the workflow for observability and sprint-context seed.
111
+
112
+ #### Step 4 — Seed Sprint Context
113
+
114
+ After the workflow is created, seed `.claude/sprint-context/{workflowId}.json`:
115
+
116
+ ```json
117
+ {
118
+ "schema": "1.0",
119
+ "parentDocument": "project-guidelines/rfcs/RFC-NNN-TITLE.md",
120
+ "sprintIndex": N,
121
+ "sprintScope": "[Sprint N scope]",
122
+ "previousSprints": [
123
+ { "index": 1, "status": "complete", "deliverables": ["..."] },
124
+ { "index": 2, "status": "complete", "deliverables": ["..."] }
125
+ ],
126
+ "workflowId": "{workflowId from startWorkflow response}",
127
+ "createdAt": "{ISO-8601 UTC timestamp}"
128
+ }
129
+ ```
130
+
131
+ Only include sprints with `status: "complete"`, `"skipped"`, or `"in_progress"` (if a prior sprint was abandoned) in `previousSprints`. Omit the current sprint.
132
+
133
+ #### Step 5 — Per-Sprint Brainstorm Context
134
+
135
+ When dispatching a researcher or specifier agent for a sprint that involves brainstorming:
136
+
137
+ 1. Read the parent document excerpt relevant to this sprint
138
+ 2. Include in the agent prompt:
139
+ - The parent document path
140
+ - The Sprint Decomposition table row for this sprint
141
+ - A summary of `previousSprints` (completed deliverables)
142
+ 3. The `user-prompt.ts` hook will automatically inject `[PARENT-DOC-CONTEXT]` if the sprint context file exists and the prompt contains "brainstorm"
143
+
144
+ Example agent prompt structure:
145
+ ```
146
+ Execute Sprint N of {parentDocument}.
147
+ Sprint scope: {sprintScope}
148
+ Previous sprints: {previousSprints summary}
149
+ [Read {parentDocument} for full context before starting]
150
+ ```
151
+
152
+ #### Step 6 — Update Sprint Context After Completion
153
+
154
+ When a sprint workflow completes:
155
+ 1. Update `.claude/sprint-context/{workflowId}.json` with the next sprint's data
156
+ 2. Move the completed sprint to `previousSprints` with `status: "complete"`
157
+ 3. Update `sprintIndex` to N+1 and `sprintScope` to the next sprint row scope
158
+
159
+ This ensures the next sprint brainstorm automatically receives full history context.