@luanpdd/kit-mcp 1.34.0 → 1.36.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 (118) hide show
  1. package/README.md +1 -1
  2. package/bin/cli.js +2 -2
  3. package/bin/mcp.js +6 -6
  4. package/bin/ui.js +74 -74
  5. package/gates/ai-prompt-stability.md +120 -120
  6. package/gates/budget-description.md +68 -68
  7. package/gates/confidence.md +29 -29
  8. package/gates/dependency-check.md +33 -33
  9. package/gates/dept-cycle-prevention.md +179 -179
  10. package/gates/golden-signals-coverage.md +133 -133
  11. package/gates/legacy-refactor-safety.md +178 -178
  12. package/gates/multi-tenant-rls-coverage.md +102 -102
  13. package/gates/no-personal-uuid.md +72 -72
  14. package/gates/obs-agents-mcp-supabase.md +86 -86
  15. package/gates/obs-skills-frontmatter.md +76 -76
  16. package/gates/observability-coverage.md +151 -151
  17. package/gates/omm-no-regression.md +83 -83
  18. package/gates/postmortem-template-required.md +127 -127
  19. package/gates/prr-checklist-coverage.md +128 -128
  20. package/gates/regression.md +32 -32
  21. package/gates/release-pipeline-policy.md +132 -132
  22. package/gates/secrets-scan.md +33 -33
  23. package/gates/service-role-not-in-user-facing.md +113 -113
  24. package/gates/skill-must-include.md +71 -71
  25. package/gates/sync-idempotent.md +62 -62
  26. package/gates/verify-phase-goal.md +34 -34
  27. package/kit/agents/designer-ui.md +216 -216
  28. package/kit/agents/workflow-generator.md +537 -0
  29. package/kit/commands/adicionar-backlog.md +1 -1
  30. package/kit/commands/adicionar-fase.md +1 -1
  31. package/kit/commands/adicionar-tarefa.md +1 -1
  32. package/kit/commands/auditar-observabilidade.md +103 -103
  33. package/kit/commands/auditar-toil.md +129 -129
  34. package/kit/commands/caracterizar-prompt.md +195 -195
  35. package/kit/commands/criar-workflow.md +158 -0
  36. package/kit/commands/definir-perfil.md +1 -1
  37. package/kit/commands/definir-slo.md +108 -108
  38. package/kit/commands/fio.md +1 -1
  39. package/kit/commands/golden-signals.md +142 -142
  40. package/kit/commands/instrumentar-fase.md +200 -200
  41. package/kit/commands/investigar-producao.md +162 -162
  42. package/kit/commands/observabilidade.md +118 -118
  43. package/kit/commands/postmortem.md +179 -179
  44. package/kit/commands/prr.md +205 -205
  45. package/kit/commands/publicar-rapido.md +207 -207
  46. package/kit/commands/risk-budget.md +220 -220
  47. package/kit/commands/sre.md +230 -230
  48. package/kit/file-manifest.json +5 -2
  49. package/kit/framework/references/output-style.md +22 -22
  50. package/kit/hooks/post-apply-migration.js +199 -199
  51. package/kit/hooks/sidecar-tool-publisher.js +210 -210
  52. package/kit/skills/_shared-dados-distribuidos/glossary.md +224 -224
  53. package/kit/skills/_shared-legacy/glossary.md +389 -389
  54. package/kit/skills/_shared-multi-tenant/glossary.md +186 -186
  55. package/kit/skills/_shared-observability/glossary.md +396 -396
  56. package/kit/skills/_shared-sre/glossary.md +712 -712
  57. package/kit/skills/_shared-supabase/glossary.md +234 -234
  58. package/kit/skills/blameless-postmortems/SKILL.md +340 -340
  59. package/kit/skills/burn-rate-alerting/SKILL.md +258 -258
  60. package/kit/skills/cascading-failures/SKILL.md +311 -311
  61. package/kit/skills/core-analysis-loop/SKILL.md +352 -352
  62. package/kit/skills/distributed-tracing/SKILL.md +362 -362
  63. package/kit/skills/dynamic-workflow-authoring/SKILL.md +327 -0
  64. package/kit/skills/eliminating-toil/SKILL.md +243 -243
  65. package/kit/skills/event-based-slos/SKILL.md +296 -296
  66. package/kit/skills/four-golden-signals/SKILL.md +314 -314
  67. package/kit/skills/hermetic-builds/SKILL.md +323 -323
  68. package/kit/skills/legacy-monster-methods/SKILL.md +444 -444
  69. package/kit/skills/llm-as-dependency/SKILL.md +436 -436
  70. package/kit/skills/load-shedding-graceful-degradation/SKILL.md +396 -396
  71. package/kit/skills/observability-driven-development/SKILL.md +315 -315
  72. package/kit/skills/observability-maturity-model/SKILL.md +222 -222
  73. package/kit/skills/opentelemetry-standard/SKILL.md +351 -351
  74. package/kit/skills/production-readiness-review/SKILL.md +305 -305
  75. package/kit/skills/release-engineering/SKILL.md +367 -367
  76. package/kit/skills/retry-strategies/SKILL.md +372 -372
  77. package/kit/skills/sre-risk-management/SKILL.md +221 -221
  78. package/kit/skills/structured-events/SKILL.md +265 -265
  79. package/kit/skills/supabase-cron-queues/SKILL.md +275 -275
  80. package/kit/skills/supabase-database-functions/SKILL.md +332 -332
  81. package/kit/skills/supabase-declarative-schema/SKILL.md +183 -183
  82. package/kit/skills/supabase-pgvector-rag/SKILL.md +253 -253
  83. package/kit/skills/supabase-postgres-style/SKILL.md +138 -138
  84. package/kit/skills/supabase-storage/SKILL.md +234 -234
  85. package/kit/skills/telemetry-pipelines/SKILL.md +259 -259
  86. package/kit/skills/telemetry-sampling/SKILL.md +256 -256
  87. package/kit/skills/ui-anti-padroes-ia/SKILL.md +261 -261
  88. package/kit/skills/ui-contexto-produto/SKILL.md +248 -248
  89. package/kit/skills/ui-cor-estrategia/SKILL.md +213 -213
  90. package/kit/skills/ui-critica-auditoria/SKILL.md +260 -260
  91. package/kit/skills/ui-motion-funcional/SKILL.md +264 -264
  92. package/kit/skills/ui-ritmo-espacial/SKILL.md +259 -259
  93. package/kit/skills/ui-tipografia/SKILL.md +211 -211
  94. package/package.json +1 -1
  95. package/src/cli/index.js +1114 -1114
  96. package/src/cli/render.js +194 -194
  97. package/src/cli/upgrade-check.js +135 -135
  98. package/src/core/error-redaction.js +76 -76
  99. package/src/core/failures.js +153 -153
  100. package/src/core/gate-runner.js +205 -205
  101. package/src/core/gates.js +82 -82
  102. package/src/core/logger.js +170 -170
  103. package/src/core/manifest-verify.js +174 -174
  104. package/src/core/metrics.js +268 -268
  105. package/src/core/notify.js +60 -60
  106. package/src/core/path-safety.js +141 -141
  107. package/src/core/replays.js +120 -120
  108. package/src/core/ui.js +185 -185
  109. package/src/mcp-server/install.js +149 -149
  110. package/src/mcp-server/roots.js +124 -124
  111. package/src/ui/auto-spawn.js +113 -113
  112. package/src/ui/browser.js +78 -78
  113. package/src/ui/client.js +130 -130
  114. package/src/ui/events.js +65 -65
  115. package/src/ui/lockfile.js +191 -191
  116. package/src/ui/port.js +67 -67
  117. package/src/ui/server.js +547 -547
  118. package/src/ui/wrapper.js +129 -129
@@ -1,200 +1,200 @@
1
- ---
2
- name: instrumentar-fase
3
- description: Após /planejar-fase, gera INSTRUMENTATION.md por plano (spans, atributos canônicos, eventos, validação ODD). Aplica skill observability-driven-development.
4
- argument-hint: "[fase] [plano]"
5
- allowed-tools:
6
- - Read
7
- - Write
8
- - Bash
9
- - Grep
10
- - Glob
11
- - Task
12
- ---
13
-
14
- <objective>
15
- Após `/planejar-fase` produzir PLAN.md, este comando gera `INSTRUMENTATION.md` para cada plano da fase. Aplica a skill [observability-driven-development](../skills/observability-driven-development/SKILL.md) — bundle telemetria com a feature, valide as 4 perguntas pré-PR.
16
-
17
- **Cria/Atualiza:**
18
- - `.planning/phases/<N>/<padded>-PLAN-<NN>-INSTRUMENTATION.md` por plano
19
-
20
- **Após:** o user tem o contrato de instrumentação que o `executor` (e o `observability-instrumenter`) devem cumprir durante `/executar-fase`.
21
- </objective>
22
-
23
- <context>
24
- **Argumentos:** `$ARGUMENTS` — primeiro token é número da fase (ex.: `30`); segundo opcional é número do plano (ex.: `01`); se omitido, processa todos os planos da fase.
25
-
26
- **Pré-requisito:** `/planejar-fase <N>` já rodou. Existem `<padded>-PLAN-<NN>-*.md` em `.planning/phases/<N>/`.
27
-
28
- **Skill consultada:** [`observability-driven-development`](../skills/observability-driven-development/SKILL.md) — 4 perguntas pré-PR canônicas.
29
- </context>
30
-
31
- <process>
32
-
33
- ## 1. Parsear argumentos
34
-
35
- ```bash
36
- PHASE_NUM=$(echo "$ARGUMENTS" | awk '{print $1}')
37
- PLAN_NUM=$(echo "$ARGUMENTS" | awk '{print $2}')
38
-
39
- if [ -z "$PHASE_NUM" ]; then
40
- echo "Uso: /instrumentar-fase <N> [<NN>]"
41
- echo "Ex.: /instrumentar-fase 30 # todos os planos da Phase 30"
42
- echo "Ex.: /instrumentar-fase 30 01 # só Plano 01 da Phase 30"
43
- exit 1
44
- fi
45
- ```
46
-
47
- ## 2. Detectar phase_dir + planos
48
-
49
- ```bash
50
- PHASE_STATE=$(node "./.claude/framework/bin/tools.cjs" init phase-op "$PHASE_NUM")
51
- PHASE_DIR=$(echo "$PHASE_STATE" | jq -r .phase_dir)
52
-
53
- if [ "$PHASE_DIR" = "null" ] || [ ! -d "$PHASE_DIR" ]; then
54
- echo "Fase $PHASE_NUM ainda não foi planejada. Rode /planejar-fase $PHASE_NUM primeiro."
55
- exit 1
56
- fi
57
-
58
- # PT-BR: descobrir PLAN.md(s) — exclui já-instrumentados
59
- if [ -n "$PLAN_NUM" ]; then
60
- PLANS=("$PHASE_DIR"/*-PLAN-${PLAN_NUM}-*.md)
61
- else
62
- PLANS=("$PHASE_DIR"/*-PLAN-*.md)
63
- fi
64
- ```
65
-
66
- ## 3. Para cada plano, gerar INSTRUMENTATION.md
67
-
68
- Para cada `PLAN_FILE`:
69
-
70
- ```bash
71
- PADDED=$(basename "$PLAN_FILE" | grep -oE '^[0-9]+')
72
- NN=$(basename "$PLAN_FILE" | grep -oE 'PLAN-[0-9]+' | grep -oE '[0-9]+')
73
- OUT_FILE="$PHASE_DIR/${PADDED}-PLAN-${NN}-INSTRUMENTATION.md"
74
-
75
- # PT-BR: não sobrescrever se já existe
76
- if [ -f "$OUT_FILE" ]; then
77
- echo "Já existe: $OUT_FILE — pulando"
78
- continue
79
- fi
80
- ```
81
-
82
- Ler `PLAN_FILE` para extrair:
83
- - Goal/objetivo
84
- - Tarefas (especialmente as que adicionam novos handlers/funções/endpoints)
85
- - Componentes/serviços tocados
86
-
87
- Gerar `INSTRUMENTATION.md` com seções canônicas (consultar [`observability-driven-development`](../skills/observability-driven-development/SKILL.md)):
88
-
89
- ```markdown
90
- ---
91
- phase: {N}
92
- plan: {NN}
93
- title: Instrumentation Plan for Plan {NN}
94
- status: pending
95
- ---
96
-
97
- # Instrumentation Plan — Phase {N}, Plan {NN}: {plan_title}
98
-
99
- ## Spans
100
-
101
- Spans a adicionar em arquivos modificados/criados pelo plano.
102
-
103
- | Name | Kind | Service | Atributos canônicos | Notas |
104
- |------|------|---------|---------------------|-------|
105
- | `{handler_name}` | SERVER | `{service}` | `user.id`, `tenant_id`, `request.id`, `endpoint`, `http.method`, `result.success`, `error.type`, `build_id` | inbound HTTP |
106
-
107
- ## Eventos críticos
108
-
109
- Eventos com semantic significance que merecem `result.success` discreto.
110
-
111
- | Event | Quando emitir | result.success | error.type enum (catch) |
112
- |-------|---------------|----------------|--------------------------|
113
- | `{event_name}` | {momento} | true se {happy path} | `validation` \| `auth` \| `rate_limit` \| `timeout` \| `unknown` |
114
-
115
- ## Métricas (opcional, se há valores numéricos críticos)
116
-
117
- | Name | Type | Unit | Labels |
118
- |------|------|------|--------|
119
- | `{metric_name}` | counter \| histogram | `ms` \| `bytes` \| `count` | `tenant_id`, `endpoint` |
120
-
121
- ## Validação ODD — 4 perguntas pré-PR
122
-
123
- | # | Pergunta | Como verificar |
124
- |---|----------|----------------|
125
- | 1 | **Faz o que esperei?** | Span tem `result.success = true` no happy path. Smoke: enviar request, query `WHERE result_success = true` retorna |
126
- | 2 | **Compara à versão anterior?** | `build_id` setado em todo span. Query: `SELECT build_id, ..., AVG(duration_ms) GROUP BY build_id` |
127
- | 3 | **Usuários estão usando?** | `user.id` ou `tenant_id` ou `customer.tier` em todo span. Query: `SELECT customer.tier, COUNT(*) GROUP BY 1` |
128
- | 4 | **Anomalias emergem?** | Cada `catch` emite `error.type` enum (não message livre). Cada if/else significativo emite `branch_taken`. Query: `SELECT error.type, COUNT(*) GROUP BY 1` |
129
-
130
- ## Sampling (head-based, default)
131
-
132
- ```ts
133
- // PT-BR: errors sempre, success sample 10% — ajuste conforme volume
134
- const shouldSample = (event: SpanLike): boolean => {
135
- if (event.attributes['result.success'] === false) return true // 100% errors
136
- if (event.attributes['customer.tier'] === 'enterprise') return true // 100% enterprise
137
- return Math.random() < 0.1 // 10% baseline
138
- }
139
- ```
140
-
141
- ## Referências cruzadas
142
-
143
- - Skill [`structured-events`](../../../../kit/skills/structured-events/SKILL.md) — campos canônicos
144
- - Skill [`distributed-tracing`](../../../../kit/skills/distributed-tracing/SKILL.md) — propagação cross-service
145
- - Skill [`opentelemetry-standard`](../../../../kit/skills/opentelemetry-standard/SKILL.md) — SDK setup
146
- - Skill [`observability-driven-development`](../../../../kit/skills/observability-driven-development/SKILL.md) — 4 perguntas
147
- - Agente [`observability-instrumenter`](../../../../kit/agents/observability-instrumenter.md) — gera os patches durante `/executar-fase`
148
-
149
- ## Aceitação
150
-
151
- - [ ] Cada handler do plano tem span com 8 atributos canônicos mínimos
152
- - [ ] Cada `catch` emite `error.type` enum
153
- - [ ] Cada branch significativo emite `branch_taken`
154
- - [ ] Outbound calls propagam contexto via `propagation.inject`
155
- - [ ] Smoke: 100 requests sintéticos → spans queryables com filtragem por `tenant_id`/`user.id`
156
- ```
157
-
158
- ## 4. Plan-checker hook
159
-
160
- Se `plan-checker` está ativo no fluxo, este comando atualiza checkpoint do plan-checker:
161
-
162
- ```bash
163
- # PT-BR: registrar que plano agora tem ODD-spec acoplada
164
- echo "instrumentation:$NN:ready" >> "$PHASE_DIR/.plan-checker-state"
165
- ```
166
-
167
- ## 5. Output
168
-
169
- ```
170
- ═══════════════════════════════════════════════════════════
171
- framework ► INSTRUMENTAR-FASE ▸ Phase {N}
172
- ═══════════════════════════════════════════════════════════
173
-
174
- Planos processados: {count}
175
- INSTRUMENTATION.md gerados:
176
- - {padded}-PLAN-01-INSTRUMENTATION.md
177
- - {padded}-PLAN-02-INSTRUMENTATION.md
178
- ...
179
-
180
- Próximo passo:
181
- - `/executar-fase {N}` — executor invocará observability-instrumenter automaticamente para aplicar os spans descritos
182
- - `/auditar-uat` antes do PR — valida que as 4 perguntas ODD têm resposta executável
183
- ```
184
-
185
- ## 6. Commit
186
-
187
- ```bash
188
- node "./.claude/framework/bin/tools.cjs" commit "docs(${PHASE_NUM}): instrumentation plans" --files "${PHASE_DIR}"/*-INSTRUMENTATION.md
189
- ```
190
-
191
- </process>
192
-
193
- <success_criteria>
194
- - [ ] Para cada `PLAN-NN-*.md` da fase, existe `PLAN-NN-INSTRUMENTATION.md`
195
- - [ ] INSTRUMENTATION.md tem 4 seções: Spans, Eventos críticos, Métricas, Validação ODD
196
- - [ ] Validação ODD com 4 perguntas explicitamente respondidas
197
- - [ ] Cross-references para skills `structured-events`, `distributed-tracing`, `opentelemetry-standard`, `observability-driven-development`
198
- - [ ] Não sobrescreve INSTRUMENTATION.md já existente (idempotente)
199
- - [ ] Commit atômico após geração
200
- </success_criteria>
1
+ ---
2
+ name: instrumentar-fase
3
+ description: Após /planejar-fase, gera INSTRUMENTATION.md por plano (spans, atributos canônicos, eventos, validação ODD). Aplica skill observability-driven-development.
4
+ argument-hint: "[fase] [plano]"
5
+ allowed-tools:
6
+ - Read
7
+ - Write
8
+ - Bash
9
+ - Grep
10
+ - Glob
11
+ - Task
12
+ ---
13
+
14
+ <objective>
15
+ Após `/planejar-fase` produzir PLAN.md, este comando gera `INSTRUMENTATION.md` para cada plano da fase. Aplica a skill [observability-driven-development](../skills/observability-driven-development/SKILL.md) — bundle telemetria com a feature, valide as 4 perguntas pré-PR.
16
+
17
+ **Cria/Atualiza:**
18
+ - `.planning/phases/<N>/<padded>-PLAN-<NN>-INSTRUMENTATION.md` por plano
19
+
20
+ **Após:** o user tem o contrato de instrumentação que o `executor` (e o `observability-instrumenter`) devem cumprir durante `/executar-fase`.
21
+ </objective>
22
+
23
+ <context>
24
+ **Argumentos:** `$ARGUMENTS` — primeiro token é número da fase (ex.: `30`); segundo opcional é número do plano (ex.: `01`); se omitido, processa todos os planos da fase.
25
+
26
+ **Pré-requisito:** `/planejar-fase <N>` já rodou. Existem `<padded>-PLAN-<NN>-*.md` em `.planning/phases/<N>/`.
27
+
28
+ **Skill consultada:** [`observability-driven-development`](../skills/observability-driven-development/SKILL.md) — 4 perguntas pré-PR canônicas.
29
+ </context>
30
+
31
+ <process>
32
+
33
+ ## 1. Parsear argumentos
34
+
35
+ ```bash
36
+ PHASE_NUM=$(echo "$ARGUMENTS" | awk '{print $1}')
37
+ PLAN_NUM=$(echo "$ARGUMENTS" | awk '{print $2}')
38
+
39
+ if [ -z "$PHASE_NUM" ]; then
40
+ echo "Uso: /instrumentar-fase <N> [<NN>]"
41
+ echo "Ex.: /instrumentar-fase 30 # todos os planos da Phase 30"
42
+ echo "Ex.: /instrumentar-fase 30 01 # só Plano 01 da Phase 30"
43
+ exit 1
44
+ fi
45
+ ```
46
+
47
+ ## 2. Detectar phase_dir + planos
48
+
49
+ ```bash
50
+ PHASE_STATE=$(node "./.claude/framework/bin/tools.cjs" init phase-op "$PHASE_NUM")
51
+ PHASE_DIR=$(echo "$PHASE_STATE" | jq -r .phase_dir)
52
+
53
+ if [ "$PHASE_DIR" = "null" ] || [ ! -d "$PHASE_DIR" ]; then
54
+ echo "Fase $PHASE_NUM ainda não foi planejada. Rode /planejar-fase $PHASE_NUM primeiro."
55
+ exit 1
56
+ fi
57
+
58
+ # PT-BR: descobrir PLAN.md(s) — exclui já-instrumentados
59
+ if [ -n "$PLAN_NUM" ]; then
60
+ PLANS=("$PHASE_DIR"/*-PLAN-${PLAN_NUM}-*.md)
61
+ else
62
+ PLANS=("$PHASE_DIR"/*-PLAN-*.md)
63
+ fi
64
+ ```
65
+
66
+ ## 3. Para cada plano, gerar INSTRUMENTATION.md
67
+
68
+ Para cada `PLAN_FILE`:
69
+
70
+ ```bash
71
+ PADDED=$(basename "$PLAN_FILE" | grep -oE '^[0-9]+')
72
+ NN=$(basename "$PLAN_FILE" | grep -oE 'PLAN-[0-9]+' | grep -oE '[0-9]+')
73
+ OUT_FILE="$PHASE_DIR/${PADDED}-PLAN-${NN}-INSTRUMENTATION.md"
74
+
75
+ # PT-BR: não sobrescrever se já existe
76
+ if [ -f "$OUT_FILE" ]; then
77
+ echo "Já existe: $OUT_FILE — pulando"
78
+ continue
79
+ fi
80
+ ```
81
+
82
+ Ler `PLAN_FILE` para extrair:
83
+ - Goal/objetivo
84
+ - Tarefas (especialmente as que adicionam novos handlers/funções/endpoints)
85
+ - Componentes/serviços tocados
86
+
87
+ Gerar `INSTRUMENTATION.md` com seções canônicas (consultar [`observability-driven-development`](../skills/observability-driven-development/SKILL.md)):
88
+
89
+ ```markdown
90
+ ---
91
+ phase: {N}
92
+ plan: {NN}
93
+ title: Instrumentation Plan for Plan {NN}
94
+ status: pending
95
+ ---
96
+
97
+ # Instrumentation Plan — Phase {N}, Plan {NN}: {plan_title}
98
+
99
+ ## Spans
100
+
101
+ Spans a adicionar em arquivos modificados/criados pelo plano.
102
+
103
+ | Name | Kind | Service | Atributos canônicos | Notas |
104
+ |------|------|---------|---------------------|-------|
105
+ | `{handler_name}` | SERVER | `{service}` | `user.id`, `tenant_id`, `request.id`, `endpoint`, `http.method`, `result.success`, `error.type`, `build_id` | inbound HTTP |
106
+
107
+ ## Eventos críticos
108
+
109
+ Eventos com semantic significance que merecem `result.success` discreto.
110
+
111
+ | Event | Quando emitir | result.success | error.type enum (catch) |
112
+ |-------|---------------|----------------|--------------------------|
113
+ | `{event_name}` | {momento} | true se {happy path} | `validation` \| `auth` \| `rate_limit` \| `timeout` \| `unknown` |
114
+
115
+ ## Métricas (opcional, se há valores numéricos críticos)
116
+
117
+ | Name | Type | Unit | Labels |
118
+ |------|------|------|--------|
119
+ | `{metric_name}` | counter \| histogram | `ms` \| `bytes` \| `count` | `tenant_id`, `endpoint` |
120
+
121
+ ## Validação ODD — 4 perguntas pré-PR
122
+
123
+ | # | Pergunta | Como verificar |
124
+ |---|----------|----------------|
125
+ | 1 | **Faz o que esperei?** | Span tem `result.success = true` no happy path. Smoke: enviar request, query `WHERE result_success = true` retorna |
126
+ | 2 | **Compara à versão anterior?** | `build_id` setado em todo span. Query: `SELECT build_id, ..., AVG(duration_ms) GROUP BY build_id` |
127
+ | 3 | **Usuários estão usando?** | `user.id` ou `tenant_id` ou `customer.tier` em todo span. Query: `SELECT customer.tier, COUNT(*) GROUP BY 1` |
128
+ | 4 | **Anomalias emergem?** | Cada `catch` emite `error.type` enum (não message livre). Cada if/else significativo emite `branch_taken`. Query: `SELECT error.type, COUNT(*) GROUP BY 1` |
129
+
130
+ ## Sampling (head-based, default)
131
+
132
+ ```ts
133
+ // PT-BR: errors sempre, success sample 10% — ajuste conforme volume
134
+ const shouldSample = (event: SpanLike): boolean => {
135
+ if (event.attributes['result.success'] === false) return true // 100% errors
136
+ if (event.attributes['customer.tier'] === 'enterprise') return true // 100% enterprise
137
+ return Math.random() < 0.1 // 10% baseline
138
+ }
139
+ ```
140
+
141
+ ## Referências cruzadas
142
+
143
+ - Skill [`structured-events`](../../../../kit/skills/structured-events/SKILL.md) — campos canônicos
144
+ - Skill [`distributed-tracing`](../../../../kit/skills/distributed-tracing/SKILL.md) — propagação cross-service
145
+ - Skill [`opentelemetry-standard`](../../../../kit/skills/opentelemetry-standard/SKILL.md) — SDK setup
146
+ - Skill [`observability-driven-development`](../../../../kit/skills/observability-driven-development/SKILL.md) — 4 perguntas
147
+ - Agente [`observability-instrumenter`](../../../../kit/agents/observability-instrumenter.md) — gera os patches durante `/executar-fase`
148
+
149
+ ## Aceitação
150
+
151
+ - [ ] Cada handler do plano tem span com 8 atributos canônicos mínimos
152
+ - [ ] Cada `catch` emite `error.type` enum
153
+ - [ ] Cada branch significativo emite `branch_taken`
154
+ - [ ] Outbound calls propagam contexto via `propagation.inject`
155
+ - [ ] Smoke: 100 requests sintéticos → spans queryables com filtragem por `tenant_id`/`user.id`
156
+ ```
157
+
158
+ ## 4. Plan-checker hook
159
+
160
+ Se `plan-checker` está ativo no fluxo, este comando atualiza checkpoint do plan-checker:
161
+
162
+ ```bash
163
+ # PT-BR: registrar que plano agora tem ODD-spec acoplada
164
+ echo "instrumentation:$NN:ready" >> "$PHASE_DIR/.plan-checker-state"
165
+ ```
166
+
167
+ ## 5. Output
168
+
169
+ ```
170
+ ═══════════════════════════════════════════════════════════
171
+ framework ► INSTRUMENTAR-FASE ▸ Phase {N}
172
+ ═══════════════════════════════════════════════════════════
173
+
174
+ Planos processados: {count}
175
+ INSTRUMENTATION.md gerados:
176
+ - {padded}-PLAN-01-INSTRUMENTATION.md
177
+ - {padded}-PLAN-02-INSTRUMENTATION.md
178
+ ...
179
+
180
+ Próximo passo:
181
+ - `/executar-fase {N}` — executor invocará observability-instrumenter automaticamente para aplicar os spans descritos
182
+ - `/auditar-uat` antes do PR — valida que as 4 perguntas ODD têm resposta executável
183
+ ```
184
+
185
+ ## 6. Commit
186
+
187
+ ```bash
188
+ node "./.claude/framework/bin/tools.cjs" commit "docs(${PHASE_NUM}): instrumentation plans" --files "${PHASE_DIR}"/*-INSTRUMENTATION.md
189
+ ```
190
+
191
+ </process>
192
+
193
+ <success_criteria>
194
+ - [ ] Para cada `PLAN-NN-*.md` da fase, existe `PLAN-NN-INSTRUMENTATION.md`
195
+ - [ ] INSTRUMENTATION.md tem 4 seções: Spans, Eventos críticos, Métricas, Validação ODD
196
+ - [ ] Validação ODD com 4 perguntas explicitamente respondidas
197
+ - [ ] Cross-references para skills `structured-events`, `distributed-tracing`, `opentelemetry-standard`, `observability-driven-development`
198
+ - [ ] Não sobrescreve INSTRUMENTATION.md já existente (idempotente)
199
+ - [ ] Commit atômico após geração
200
+ </success_criteria>