@luanpdd/kit-mcp 1.8.1 → 1.9.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.
- package/README.md +39 -1
- package/gates/obs-agents-mcp-supabase.md +86 -0
- package/gates/obs-skills-frontmatter.md +76 -0
- package/gates/omm-no-regression.md +83 -0
- package/gates/skill-must-include.md +21 -19
- package/kit/agents/burn-rate-forecaster.md +160 -0
- package/kit/agents/incident-investigator.md +245 -0
- package/kit/agents/observability-instrumenter.md +200 -0
- package/kit/agents/omm-auditor.md +199 -0
- package/kit/agents/slo-engineer.md +224 -0
- package/kit/agents/supabase-architect.md +13 -0
- package/kit/agents/supabase-auth-bootstrapper.md +17 -0
- package/kit/agents/supabase-edge-fn-writer.md +22 -0
- package/kit/agents/supabase-migration-writer.md +18 -0
- package/kit/agents/supabase-realtime-implementer.md +23 -0
- package/kit/agents/supabase-rls-writer.md +17 -0
- package/kit/agents/supabase-storage-implementer.md +18 -0
- package/kit/commands/auditar-marco.md +22 -1
- package/kit/commands/auditar-observabilidade.md +103 -0
- package/kit/commands/burn-rate-status.md +140 -0
- package/kit/commands/concluir-marco.md +19 -1
- package/kit/commands/definir-slo.md +108 -0
- package/kit/commands/discutir-fase.md +26 -0
- package/kit/commands/forense.md +20 -1
- package/kit/commands/instrumentar-fase.md +200 -0
- package/kit/commands/investigar-producao.md +162 -0
- package/kit/commands/observabilidade.md +116 -0
- package/kit/commands/planejar-fase.md +20 -0
- package/kit/commands/verificar-trabalho.md +26 -0
- package/kit/skills/_shared-observability/glossary.md +396 -0
- package/kit/skills/burn-rate-alerting/SKILL.md +258 -0
- package/kit/skills/core-analysis-loop/SKILL.md +352 -0
- package/kit/skills/distributed-tracing/SKILL.md +362 -0
- package/kit/skills/event-based-slos/SKILL.md +274 -0
- package/kit/skills/observability-driven-development/SKILL.md +315 -0
- package/kit/skills/observability-maturity-model/SKILL.md +222 -0
- package/kit/skills/opentelemetry-standard/SKILL.md +351 -0
- package/kit/skills/structured-events/SKILL.md +265 -0
- package/kit/skills/telemetry-pipelines/SKILL.md +259 -0
- package/kit/skills/telemetry-sampling/SKILL.md +256 -0
- package/package.json +1 -1
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: burn-rate-status
|
|
3
|
+
description: Tabela de burn rate por SLO — % budget gasto, ETA exhaustão, ação (page/ticket/warn/ok). Rodável manualmente ou em /loop. Aplica skill burn-rate-alerting.
|
|
4
|
+
argument-hint: "[<slo_name>] [--lookahead 4h] [--baseline 1h]"
|
|
5
|
+
allowed-tools:
|
|
6
|
+
- Read
|
|
7
|
+
- Bash
|
|
8
|
+
- Task
|
|
9
|
+
- Glob
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
<objective>
|
|
13
|
+
Snapshot de burn rate para 1 SLO (se especificado) ou TODOS os SLOs definidos. Aplica skill [`burn-rate-alerting`](../skills/burn-rate-alerting/SKILL.md) — fórmula `burn_rate = error_rate / (1 - target)`, lookahead ≤ 4× baseline.
|
|
14
|
+
|
|
15
|
+
**Cria/Atualiza:** nada — comando read-only.
|
|
16
|
+
|
|
17
|
+
**Após:** o user vê tabela com status (PAGE / TICKET / WARN / OK) e pode escolher invocar `/investigar-producao` se há burn ativo.
|
|
18
|
+
</objective>
|
|
19
|
+
|
|
20
|
+
<context>
|
|
21
|
+
**Argumentos:** `$ARGUMENTS` — opcional `<slo_name>` para 1 SLO; sem args = todos.
|
|
22
|
+
|
|
23
|
+
**Flags:**
|
|
24
|
+
- `--lookahead <duration>` — janela predictive (default: `4h` para short-term)
|
|
25
|
+
- `--baseline <duration>` — janela base (default: `1h`)
|
|
26
|
+
- `--format <table|json>` — output format (default: `table`)
|
|
27
|
+
|
|
28
|
+
**Combinações canônicas:**
|
|
29
|
+
- short-term: lookahead 4h, baseline 1h (page-tier)
|
|
30
|
+
- long-term: lookahead 3d, baseline 18h (ticket-tier)
|
|
31
|
+
|
|
32
|
+
**Loop pattern:** rodar este comando via skill `loop` com intervalo 5min para monitoramento contínuo.
|
|
33
|
+
|
|
34
|
+
```text
|
|
35
|
+
/loop 5m /burn-rate-status
|
|
36
|
+
```
|
|
37
|
+
</context>
|
|
38
|
+
|
|
39
|
+
<process>
|
|
40
|
+
|
|
41
|
+
## 1. Parsear argumentos
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
SLO_NAME=$(echo "$ARGUMENTS" | awk '{print $1}' | grep -v '^--' || true)
|
|
45
|
+
LOOKAHEAD=$(echo "$ARGUMENTS" | grep -oE -- '--lookahead [^ ]+' | awk '{print $2}')
|
|
46
|
+
BASELINE=$(echo "$ARGUMENTS" | grep -oE -- '--baseline [^ ]+' | awk '{print $2}')
|
|
47
|
+
FORMAT=$(echo "$ARGUMENTS" | grep -oE -- '--format [^ ]+' | awk '{print $2}')
|
|
48
|
+
|
|
49
|
+
[ -z "$LOOKAHEAD" ] && LOOKAHEAD="4h"
|
|
50
|
+
[ -z "$BASELINE" ] && BASELINE="1h"
|
|
51
|
+
[ -z "$FORMAT" ] && FORMAT="table"
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## 2. Listar SLOs
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
if [ -n "$SLO_NAME" ]; then
|
|
58
|
+
SLO_FILES=(".planning/slos/${SLO_NAME}.md")
|
|
59
|
+
else
|
|
60
|
+
SLO_FILES=(.planning/slos/*.md)
|
|
61
|
+
fi
|
|
62
|
+
|
|
63
|
+
if [ ${#SLO_FILES[@]} -eq 0 ] || [ ! -f "${SLO_FILES[0]}" ]; then
|
|
64
|
+
echo "Nenhum SLO definido. Rode /definir-slo <feature> primeiro."
|
|
65
|
+
exit 0
|
|
66
|
+
fi
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## 3. Para cada SLO, dispatch para `burn-rate-forecaster`
|
|
70
|
+
|
|
71
|
+
Para cada `SLO_FILE`:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
SLO_NAME=$(basename "$SLO_FILE" .md)
|
|
75
|
+
TARGET=$(grep -oE 'Target.*[0-9.]+' "$SLO_FILE" | head -1 | grep -oE '[0-9.]+')
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
```text
|
|
79
|
+
Task(
|
|
80
|
+
subagent_type="burn-rate-forecaster",
|
|
81
|
+
prompt="
|
|
82
|
+
slo_name: ${SLO_NAME}
|
|
83
|
+
target: ${TARGET}
|
|
84
|
+
lookahead: ${LOOKAHEAD}
|
|
85
|
+
baseline: ${BASELINE}
|
|
86
|
+
|
|
87
|
+
Calcular burn rate atual + ETA + status (PAGE/TICKET/WARN/OK).
|
|
88
|
+
Output formato compatível com tabela mestra.
|
|
89
|
+
"
|
|
90
|
+
)
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## 4. Agregar resultados em tabela
|
|
94
|
+
|
|
95
|
+
```
|
|
96
|
+
═══════════════════════════════════════════════════════════
|
|
97
|
+
framework ► BURN-RATE-STATUS ▸ {timestamp}
|
|
98
|
+
═══════════════════════════════════════════════════════════
|
|
99
|
+
|
|
100
|
+
| SLO | Target | Window | Budget gasto | Burn rate | ETA exhaustão | Status | Ação |
|
|
101
|
+
|---|---|---|---|---|---|---|---|
|
|
102
|
+
| checkout_success | 99.9% | 30d | 23% | 1.4× | 12d | OK | informativo |
|
|
103
|
+
| login_success | 99.95% | 30d | 78% | 8.0× | 4h | **PAGE** | invocar /investigar-producao |
|
|
104
|
+
| search_latency | 99% | 30d | 15% | 0.7× | — | OK | — |
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## 5. Sugerir próximas ações
|
|
108
|
+
|
|
109
|
+
Se algum SLO em status PAGE ou TICKET:
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
## ⚠ SLOs em alerta:
|
|
113
|
+
1. login_success — burn rate 8.0×, ETA 4h
|
|
114
|
+
→ /investigar-producao "login_success burn rate = 8.0× às {timestamp}"
|
|
115
|
+
|
|
116
|
+
## SLOs em WARN (>= 80% gasto):
|
|
117
|
+
- (nenhum)
|
|
118
|
+
|
|
119
|
+
## SLOs OK:
|
|
120
|
+
- 2 SLOs em compliance saudável
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## 6. Modo `/loop`
|
|
124
|
+
|
|
125
|
+
Se chamado dentro de `/loop`, comportamento idempotente:
|
|
126
|
+
- Não acumular state entre invocações (snapshot fresh)
|
|
127
|
+
- Output curto se nada mudou (apenas status; sem repetir tabela completa em todo loop)
|
|
128
|
+
- Acionar AskUserQuestion APENAS quando status muda de OK → WARN/TICKET/PAGE (transição)
|
|
129
|
+
|
|
130
|
+
</process>
|
|
131
|
+
|
|
132
|
+
<success_criteria>
|
|
133
|
+
- [ ] $ARGUMENTS parseados (SLO opcional + flags)
|
|
134
|
+
- [ ] SLOs descobertos via glob `.planning/slos/*.md`
|
|
135
|
+
- [ ] `burn-rate-forecaster` invocado para cada SLO
|
|
136
|
+
- [ ] Tabela agregada em formato consistente
|
|
137
|
+
- [ ] Status enum: PAGE / TICKET / WARN / OK
|
|
138
|
+
- [ ] Sugestões de próximas ações para SLOs em alerta
|
|
139
|
+
- [ ] Idempotente (rodável em /loop sem acúmulo)
|
|
140
|
+
</success_criteria>
|
|
@@ -133,4 +133,22 @@ Saída: Milestone arquivado (roadmap + requisitos), PROJECT.md evoluído, tag gi
|
|
|
133
133
|
- **Resumo de uma linha:** Milestone colapsado no ROADMAP.md deve ser uma única linha com link
|
|
134
134
|
- **Eficiência de contexto:** Arquivo mantém ROADMAP.md e REQUIREMENTS.md com tamanho constante por milestone
|
|
135
135
|
- **Novos requisitos:** Próximo milestone começa com `/novo-marco` que inclui definição de requisitos
|
|
136
|
-
</critical_rules>
|
|
136
|
+
</critical_rules>
|
|
137
|
+
|
|
138
|
+
<observability_integration>
|
|
139
|
+
**OMM no-regression gate (v1.9 — INT-FW-05):**
|
|
140
|
+
|
|
141
|
+
Quando `workflow.complete_milestone_omm_gate = true` (default), o workflow inclui passo OMM regression check antes de arquivar:
|
|
142
|
+
|
|
143
|
+
1. Procurar `.planning/OMM-REPORT.md` atual. Se ausente: rodar `/auditar-observabilidade` primeiro.
|
|
144
|
+
2. Comparar scores das 5 capacidades com `.planning/milestones/<previous>/OMM-REPORT.md`.
|
|
145
|
+
3. Se alguma capacidade regrediu E `workflow.omm_no_regression = true`: BLOQUEAR conclusion.
|
|
146
|
+
4. Se regression detectada mas `workflow.omm_no_regression = false`: WARN explícito; user decide entre aceitar ou pausar.
|
|
147
|
+
5. OMM-REPORT.md final é arquivado em `.planning/milestones/v<version>/OMM-REPORT.md`.
|
|
148
|
+
|
|
149
|
+
Gate executável: `gates/omm-no-regression.md`.
|
|
150
|
+
|
|
151
|
+
Skill consultada: [`observability-maturity-model`](../skills/observability-maturity-model/SKILL.md).
|
|
152
|
+
|
|
153
|
+
**REQ:** INT-FW-05.
|
|
154
|
+
</observability_integration>
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: definir-slo
|
|
3
|
+
description: Invoca slo-engineer para gerar SLO.md + SQL materialização SLI events. Aplica skill event-based-slos. Default 30d sliding window, target ≤ 99.95%.
|
|
4
|
+
argument-hint: "<feature> [--target 99.9] [--owner email]"
|
|
5
|
+
allowed-tools:
|
|
6
|
+
- Read
|
|
7
|
+
- Write
|
|
8
|
+
- Bash
|
|
9
|
+
- Task
|
|
10
|
+
- AskUserQuestion
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
<objective>
|
|
14
|
+
Definir um SLO event-based para uma feature/jornada do usuário. Invoca o agente [`slo-engineer`](../agents/slo-engineer.md) que aplica a skill [`event-based-slos`](../skills/event-based-slos/SKILL.md) — SLI event-based, sliding window 30d, target ≤ 99.95%, owner nomeado, materialização em Postgres.
|
|
15
|
+
|
|
16
|
+
**Cria/Atualiza:**
|
|
17
|
+
- `.planning/slos/<slo_name>.md` — definição canônica do SLO
|
|
18
|
+
- `supabase/migrations/<timestamp>_create_sli_<slo_name>.sql` — view materializada SLI
|
|
19
|
+
|
|
20
|
+
**Após:** SLO está em `draft` status. Próximo passo: `/burn-rate-status <slo_name>` para validar baseline; após 1+ semana, promover de `draft` → `test_channel` → `primary`.
|
|
21
|
+
</objective>
|
|
22
|
+
|
|
23
|
+
<context>
|
|
24
|
+
**Argumentos:** `$ARGUMENTS` — primeiro token é a feature/jornada (ex: `checkout`, `login`, `bulk-orders`); restante são flags.
|
|
25
|
+
|
|
26
|
+
**Flags:**
|
|
27
|
+
- `--target <percent>` — target % do SLO (default: agent sugere baseado em criticality, sempre ≤ 99.95%)
|
|
28
|
+
- `--owner <email>` — owner do SLO (default: AskUserQuestion)
|
|
29
|
+
- `--window <duration>` — sliding window (default: `30d`)
|
|
30
|
+
|
|
31
|
+
**Pré-requisito (Full mode):** projeto Supabase configurado, schema `observability` com tabela de events (Phase 31 supabase-architect projeta isso).
|
|
32
|
+
</context>
|
|
33
|
+
|
|
34
|
+
<process>
|
|
35
|
+
|
|
36
|
+
## 1. Parsear argumentos
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
FEATURE=$(echo "$ARGUMENTS" | awk '{print $1}')
|
|
40
|
+
TARGET=$(echo "$ARGUMENTS" | grep -oE -- '--target [0-9.]+' | awk '{print $2}')
|
|
41
|
+
OWNER=$(echo "$ARGUMENTS" | grep -oE -- '--owner [^ ]+' | awk '{print $2}')
|
|
42
|
+
WINDOW=$(echo "$ARGUMENTS" | grep -oE -- '--window [^ ]+' | awk '{print $2}')
|
|
43
|
+
|
|
44
|
+
[ -z "$FEATURE" ] && {
|
|
45
|
+
echo "Uso: /definir-slo <feature> [--target N] [--owner email]"
|
|
46
|
+
exit 1
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
[ -z "$WINDOW" ] && WINDOW="30d"
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## 2. Detectar `supabase/config.toml`
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
PROJECT_ID=""
|
|
56
|
+
if [ -f supabase/config.toml ]; then
|
|
57
|
+
PROJECT_ID=$(grep -E '^project_id\s*=' supabase/config.toml | sed 's/.*= *"\(.*\)".*/\1/' | head -1)
|
|
58
|
+
fi
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## 3. Dispatch para `slo-engineer`
|
|
62
|
+
|
|
63
|
+
```text
|
|
64
|
+
Task(
|
|
65
|
+
subagent_type="slo-engineer",
|
|
66
|
+
prompt="
|
|
67
|
+
feature: ${FEATURE}
|
|
68
|
+
${TARGET:+target: ${TARGET}}
|
|
69
|
+
${OWNER:+owner: ${OWNER}}
|
|
70
|
+
window: ${WINDOW}
|
|
71
|
+
${PROJECT_ID:+project_id: ${PROJECT_ID}}
|
|
72
|
+
|
|
73
|
+
Aplicar skill event-based-slos. Gerar:
|
|
74
|
+
1. .planning/slos/<slo_name>.md (SLO definition canônico)
|
|
75
|
+
2. supabase/migrations/<timestamp>_create_sli_<slo_name>.sql (materialized view + pg_cron refresh)
|
|
76
|
+
|
|
77
|
+
Se target > 99.95%, recusar e explicar — métrica informativa, não SLO.
|
|
78
|
+
Se Full mode (mcp__supabase disponível), apply_migration; senão, output text.
|
|
79
|
+
"
|
|
80
|
+
)
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## 4. Pós-output
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
═══════════════════════════════════════════════════════════
|
|
87
|
+
framework ► DEFINIR-SLO ▸ {slo_name}
|
|
88
|
+
═══════════════════════════════════════════════════════════
|
|
89
|
+
|
|
90
|
+
[output do slo-engineer — ver Step 8 do agent]
|
|
91
|
+
|
|
92
|
+
## Próximos passos
|
|
93
|
+
1. `/burn-rate-status {slo_name}` — checar baseline atual
|
|
94
|
+
2. Após 1+ semana validando que SLO detecta incidents reais:
|
|
95
|
+
- Editar `.planning/slos/{slo_name}.md` → status: `test_channel` → `primary`
|
|
96
|
+
3. Configurar alerts (page + ticket) — invocar `burn-rate-forecaster` ou config manual
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
</process>
|
|
100
|
+
|
|
101
|
+
<success_criteria>
|
|
102
|
+
- [ ] FEATURE parseado de $ARGUMENTS
|
|
103
|
+
- [ ] `slo-engineer` invocado via Task
|
|
104
|
+
- [ ] `.planning/slos/<slo_name>.md` criado
|
|
105
|
+
- [ ] Migration SQL criada (Full mode applied; Offline mode escrita)
|
|
106
|
+
- [ ] Target ≤ 99.95% enforced
|
|
107
|
+
- [ ] Owner registrado (via flag ou AskUserQuestion)
|
|
108
|
+
</success_criteria>
|
|
@@ -62,3 +62,29 @@ Se `DISCUSS_MODE` for `"discuss"` (ou não definido, ou qualquer outro valor): L
|
|
|
62
62
|
- CONTEXT.md captura decisões, não visão vaga
|
|
63
63
|
- Usuário conhece os próximos passos
|
|
64
64
|
</success_criteria>
|
|
65
|
+
|
|
66
|
+
<observability_integration>
|
|
67
|
+
**Integração com Observability-Driven Development (v1.9):**
|
|
68
|
+
|
|
69
|
+
Quando o workflow.observability_phase_questions = true (default), o workflow inclui pergunta canônica de ODD na sessão de discussão:
|
|
70
|
+
|
|
71
|
+
> "Quais SLIs essa fase impacta? O que precisa ser instrumentado para responder às 4 perguntas pré-PR?"
|
|
72
|
+
|
|
73
|
+
A pergunta é resolvida consultando a skill [`observability-driven-development`](../skills/observability-driven-development/SKILL.md) e o resultado é registrado na seção `<observability>` do CONTEXT.md gerado:
|
|
74
|
+
|
|
75
|
+
```markdown
|
|
76
|
+
<observability>
|
|
77
|
+
## SLIs impactados
|
|
78
|
+
- [SLI ou "nenhum — fase puramente interna"]
|
|
79
|
+
|
|
80
|
+
## Instrumentação necessária
|
|
81
|
+
- Spans novos: [lista]
|
|
82
|
+
- Atributos canônicos: [user.id, tenant_id, ...]
|
|
83
|
+
- error.type enum esperado: [validation, timeout, ...]
|
|
84
|
+
</observability>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
O `plan-checker` invocado pelo `/planejar-fase` (Phase 33 — INT-FW-02) lê esta seção e bloqueia o plano se ODD ausente para fases voltadas ao usuário (skip silenciosamente para fases de infraestrutura — ver detecção em `discuss-phase.md`).
|
|
88
|
+
|
|
89
|
+
**REQ:** INT-FW-01.
|
|
90
|
+
</observability_integration>
|
package/kit/commands/forense.md
CHANGED
|
@@ -53,4 +53,23 @@ Ler e executar o workflow forensics de @./.claude/framework/workflows/forensics.
|
|
|
53
53
|
- **Redigir dados sensíveis:** Remover caminhos absolutos, chaves de API, tokens de relatórios e issues.
|
|
54
54
|
- **Fundamentar descobertas em evidências:** Toda anomalia deve citar commits, arquivos ou dados de estado específicos.
|
|
55
55
|
- **Sem especulação sem evidência:** Se os dados forem insuficientes, diga isso — não fabrique causas raiz.
|
|
56
|
-
</critical_rules>
|
|
56
|
+
</critical_rules>
|
|
57
|
+
|
|
58
|
+
<observability_integration>
|
|
59
|
+
**Integração com Core Analysis Loop (v1.9):**
|
|
60
|
+
|
|
61
|
+
Forense usa skill [`core-analysis-loop`](../skills/core-analysis-loop/SKILL.md) — método científico iterativo (sintoma → hipótese de dados → validação → próxima iteração) em vez de inspeção ad hoc.
|
|
62
|
+
|
|
63
|
+
Cada anomalia detectada vira hipótese com query de validação:
|
|
64
|
+
|
|
65
|
+
| Tipo de anomalia | Hipótese formada | Query de validação |
|
|
66
|
+
|---|---|---|
|
|
67
|
+
| Loop travado | "phase X stuck há Yh" | `git log --since="Yh ago" --grep=phase` para confirmar zero commits |
|
|
68
|
+
| Artefatos ausentes | "PLAN.md ausente em phase X" | `ls .planning/phases/X-*/X-PLAN-*.md` |
|
|
69
|
+
| Trabalho abandonado | "branch sem merge nem commit recente" | `git log -1 <branch>` + `git status` |
|
|
70
|
+
| Crash/interrupção | "executor falhou em meio a fase" | grep no STATE.md por "in_progress" sem update recente |
|
|
71
|
+
|
|
72
|
+
**Skill consultada explicitamente:** abrir o arquivo `kit/skills/core-analysis-loop/SKILL.md` para padrão "documentação da trilha (formato canônico)" — o relatório forense em `.planning/forensics/report-<ts>.md` segue esse formato com cada hipótese tendo "Query / Resultado / Status (VALIDATED / REFUTED / INCONCLUSIVE)".
|
|
73
|
+
|
|
74
|
+
**REQ:** INT-FW-06.
|
|
75
|
+
</observability_integration>
|
|
@@ -0,0 +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>
|