@luanpdd/kit-mcp 1.9.0 → 1.11.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/CHANGELOG.md +86 -0
- package/README.md +58 -0
- package/gates/ai-prompt-stability.md +120 -0
- package/gates/golden-signals-coverage.md +133 -0
- package/gates/legacy-refactor-safety.md +178 -0
- package/gates/observability-coverage.md +151 -0
- package/gates/postmortem-template-required.md +127 -0
- package/gates/prr-checklist-coverage.md +128 -0
- package/gates/release-pipeline-policy.md +132 -0
- package/kit/COMANDOS.md +15 -0
- package/kit/agents/ai-mutation-tester.md +298 -0
- package/kit/agents/cascading-failures-auditor.md +306 -0
- package/kit/agents/executor.md +13 -0
- package/kit/agents/golden-signals-instrumenter.md +241 -0
- package/kit/agents/legacy-characterizer.md +378 -0
- package/kit/agents/load-shedding-instrumenter.md +297 -0
- package/kit/agents/observability-coverage-auditor.md +325 -0
- package/kit/agents/omm-auditor.md +99 -0
- package/kit/agents/payload-capture-instrumenter.md +283 -0
- package/kit/agents/planner.md +29 -0
- package/kit/agents/postmortem-writer.md +282 -0
- package/kit/agents/prr-conductor.md +296 -0
- package/kit/agents/refactor-safety-auditor.md +414 -0
- package/kit/agents/release-pipeline-auditor.md +360 -0
- package/kit/agents/seam-finder.md +367 -0
- package/kit/agents/shotgun-surgery-detector.md +359 -0
- package/kit/agents/storytelling-analyst.md +309 -0
- package/kit/agents/supabase-architect.md +49 -0
- package/kit/agents/supabase-edge-fn-writer.md +114 -0
- package/kit/agents/supabase-migration-writer.md +80 -0
- package/kit/agents/supabase-storage-implementer.md +156 -0
- package/kit/agents/toil-auditor.md +277 -0
- package/kit/agents/verifier.md +30 -0
- package/kit/commands/auditar-cascading.md +111 -0
- package/kit/commands/auditar-marco.md +124 -1
- package/kit/commands/auditar-observabilidade-cobertura.md +183 -0
- package/kit/commands/auditar-refactor.md +219 -0
- package/kit/commands/auditar-release.md +109 -0
- package/kit/commands/auditar-toil.md +129 -0
- package/kit/commands/capturar-payloads.md +193 -0
- package/kit/commands/caracterizar-prompt.md +195 -0
- package/kit/commands/caracterizar.md +212 -0
- package/kit/commands/concluir-marco.md +95 -1
- package/kit/commands/detectar-duplicacao.md +197 -0
- package/kit/commands/discutir-fase.md +41 -0
- package/kit/commands/encontrar-seams.md +136 -0
- package/kit/commands/forense.md +103 -1
- package/kit/commands/golden-signals.md +142 -0
- package/kit/commands/legacy.md +263 -0
- package/kit/commands/load-shedding.md +117 -0
- package/kit/commands/observabilidade.md +2 -0
- package/kit/commands/postmortem.md +179 -0
- package/kit/commands/prr.md +205 -0
- package/kit/commands/refactor-seguro.md +321 -0
- package/kit/commands/risk-budget.md +220 -0
- package/kit/commands/sre.md +230 -0
- package/kit/commands/storytelling.md +179 -0
- package/kit/skills/_shared-legacy/glossary.md +389 -0
- package/kit/skills/_shared-sre/glossary.md +712 -0
- package/kit/skills/ai-prompt-characterization/SKILL.md +335 -0
- package/kit/skills/blameless-postmortems/SKILL.md +340 -0
- package/kit/skills/cascading-failures/SKILL.md +307 -0
- package/kit/skills/eliminating-toil/SKILL.md +243 -0
- package/kit/skills/event-based-slos/SKILL.md +22 -0
- package/kit/skills/four-golden-signals/SKILL.md +314 -0
- package/kit/skills/hermetic-builds/SKILL.md +323 -0
- package/kit/skills/legacy-api-only-applications/SKILL.md +358 -0
- package/kit/skills/legacy-characterization-tests/SKILL.md +330 -0
- package/kit/skills/legacy-effect-analysis/SKILL.md +331 -0
- package/kit/skills/legacy-extract-class/SKILL.md +203 -0
- package/kit/skills/legacy-monster-methods/SKILL.md +444 -0
- package/kit/skills/legacy-programming-by-difference/SKILL.md +252 -0
- package/kit/skills/legacy-seams-and-test-harness/SKILL.md +460 -0
- package/kit/skills/legacy-shotgun-surgery/SKILL.md +286 -0
- package/kit/skills/legacy-sprout-wrap-techniques/SKILL.md +434 -0
- package/kit/skills/legacy-storytelling-naked-crc/SKILL.md +270 -0
- package/kit/skills/llm-as-dependency/SKILL.md +436 -0
- package/kit/skills/load-shedding-graceful-degradation/SKILL.md +396 -0
- package/kit/skills/pre-refactor-characterization/SKILL.md +421 -0
- package/kit/skills/production-readiness-review/SKILL.md +305 -0
- package/kit/skills/release-engineering/SKILL.md +367 -0
- package/kit/skills/retry-strategies/SKILL.md +372 -0
- package/kit/skills/sre-risk-management/SKILL.md +221 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,92 @@ Format: [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) · Versioning:
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [1.10.0] - 2026-05-07
|
|
10
|
+
|
|
11
|
+
Milestone v1.10 — Suíte SRE Engagement: incorpora técnicas do livro *Site Reliability Engineering: How Google Runs Production Systems* (Beyer, Jones, Petoff, Murphy — Google/O'Reilly, 2016) ao kit-mcp. 32 REQs em 6 fases (Phases 36-41), distribuídos em 3 ondas: Núcleo SRE (Phases 36-38), Integração com suítes existentes (Phases 39-40), Gates QA + docs (Phase 41). Complementa a Suíte Observabilidade v1.9.0 (publicada 2026-05-06) e a Suíte Supabase v1.8.0 — juntas formam o stack production engineering do kit.
|
|
12
|
+
|
|
13
|
+
### Adicionado — 6 skills SRE foundationais (Phase 36)
|
|
14
|
+
|
|
15
|
+
Cada skill é auto-contida (sem `references/`), com frontmatter `description ≤ 200 chars`, template canônico de 5 seções (Quando usar / Regras absolutas / Patterns canônicos / Anti-patterns / Ver também), e cross-refs via Markdown link relativo.
|
|
16
|
+
|
|
17
|
+
- `_shared-sre/glossary.md` — vocabulário canônico bilíngue (PT-BR↔EN): SLI, SLO, SLA, error budget, burn rate, toil, postmortem, blameless, PRR, golden signals (latency/traffic/errors/saturation), risk continuum, MTTR, MTBF. Lista anti-patterns explícitos (alert fatigue, hero culture, SLO 99.99%+, fixed-window error budget, blame culture, mean-only latency, monitoring causes não symptoms).
|
|
18
|
+
- `sre-risk-management` — risk continuum (cap 3 livro Google SRE), 99.99% wisdom (user em 99% smartphone não distingue 99.99% vs 99.999%), error budget como balanço explícito risk × innovation, "as reliable as needs to be, no more".
|
|
19
|
+
- `four-golden-signals` — Latency + Traffic + Errors + Saturation (cap 6), black-box vs white-box monitoring, distinção de latência success vs error, percentis vs mean (long tail), histograms com bucketing exponencial.
|
|
20
|
+
- `eliminating-toil` — definição canônica de toil (manual, repetitivo, automatizável, tático, sem valor durável, escala linear), regra ≤ 50% (cap 5), padrões de automação, distinção toil vs overhead vs grungy work.
|
|
21
|
+
- `blameless-postmortems` — template canônico 9 seções (Summary, Impact, Root Causes, Trigger, Resolution, Detection, Action Items, Lessons Learned, Timeline UTC), cultura blameless (cap 15), "no postmortem left unreviewed", Wheel of Misfortune para training.
|
|
22
|
+
- `production-readiness-review` — checklist PRR (cap 32) — 6 axes: System architecture, Instrumentation/Metrics/Monitoring, Emergency response, Capacity planning, Change management, Performance — com 3 modelos de engagement: Simple PRR, Early Engagement, Frameworks/SRE Platform.
|
|
23
|
+
|
|
24
|
+
### Adicionado — 4 agents SRE core (Phase 37)
|
|
25
|
+
|
|
26
|
+
Cada agent inclui tabela `## Compatibilidade` por IDE (Full / Partial / Offline-only), preflight detection MCP no Step 0 quando aplicável, e frontmatter `tools:` com nomes canônicos.
|
|
27
|
+
|
|
28
|
+
- `golden-signals-instrumenter` — especialização de `observability-instrumenter` (v1.9). Recebe código de serviço/Edge Function e retorna patches OTel com Latency=histogram bucketed exponencial, Traffic=counter por endpoint × method, Errors=counter por `error.type` enum 5-15 valores fechado (NUNCA `error.message`), Saturation=gauge resource-specific identificado explicitamente.
|
|
29
|
+
- `toil-auditor` — analisa repo + git log ≤ 90d + scripts shell + comandos manuais documentados em README/runbooks. Retorna `.planning/TOIL-AUDIT.md` listando candidatos a automação com priorização P0/P1/P2 e ROI = freq × tempo / esforço.
|
|
30
|
+
- `postmortem-writer` — recebe `--from-investigation <id>` (continuação de `incident-investigator` v1.9 — lê `.planning/investigations/<id>.md`) ou `--incident "<descrição>"` (standalone). Gera postmortem blameless seguindo template canônico de 9 seções em `.planning/postmortems/<id>.md`.
|
|
31
|
+
- `prr-conductor` — conduz Production Readiness Review para serviço/feature. Lê schema (Supabase MCP), Edge Functions code, SLOs definidos (`.planning/slos/`), audit logs. Produz `PRR-REPORT.md` scored em 6 axes com gaps e action items priorizados (P0 blocker / P1 scheduled).
|
|
32
|
+
|
|
33
|
+
### Adicionado — 6 commands SRE (Phase 38)
|
|
34
|
+
|
|
35
|
+
- `/sre <subcommand>` — orquestrador único (análogo a `/supabase` v1.8 e `/observabilidade` v1.9); dispatch via `Task(subagent_type=...)` com sinônimos PT/EN para os 5 comandos abaixo.
|
|
36
|
+
- `/golden-signals` — invoca `golden-signals-instrumenter` para serviço/Edge Function/fase; gera `GOLDEN-SIGNALS.md` por target com instrumentação OTel pronta.
|
|
37
|
+
- `/auditar-toil` — invoca `toil-auditor`; gera `.planning/TOIL-AUDIT.md`.
|
|
38
|
+
- `/postmortem` — invoca `postmortem-writer`; suporta flag `--from-investigation <id>` (continuar de investigation v1.9) ou `--incident "<descrição>"` (postmortem standalone).
|
|
39
|
+
- `/prr` — invoca `prr-conductor` para serviço/feature; usa flag `--service <name>` ou `--feature <description>`; gera `PRR-REPORT.md`.
|
|
40
|
+
- `/risk-budget` — exibe state atual de error budget vs risk continuum, citando SLOs definidos em v1.9 (lê `.planning/slos/`); aplica skill `sre-risk-management`.
|
|
41
|
+
|
|
42
|
+
### Adicionado — 3 audit gates novos (Phase 41)
|
|
43
|
+
|
|
44
|
+
Markdown specs em `gates/` com `## Check` em bash 3.2-portable (macOS default):
|
|
45
|
+
|
|
46
|
+
- `gates/golden-signals-coverage.md` (blocking, pre-verify) — verifica código de serviço/Edge Function tocado em fase tem os 4 golden signals presentes (regex sobre `histogram | counter | gauge | saturation`). Skip gracefully em projetos content-only (sem `supabase/functions/` / `src/` / `lib/`).
|
|
47
|
+
- `gates/postmortem-template-required.md` (blocking, pre-conclude) — em `/concluir-marco`, bloqueia se houve incident em `.planning/investigations/` sem `.planning/postmortems/` correspondente. `Status: INCONCLUSIVE` reconhecido como exceção (sem root cause = sem aprendizado a documentar). Princípio canônico: "no postmortem left unreviewed" (cap 15).
|
|
48
|
+
- `gates/prr-checklist-coverage.md` (blocking, pre-verify) — verifica que `PRR-REPORT.md` em `.planning/prr/**/*.md` cobre os 6 axes do PRR (System architecture, Instrumentation, Emergency response, Capacity planning, Change management, Performance) — pular um axe = aprovação inválida (regra absoluta da skill `production-readiness-review`).
|
|
49
|
+
|
|
50
|
+
### Adicionado — integração com Suíte Observabilidade v1.9 (Phase 39)
|
|
51
|
+
|
|
52
|
+
- **Skill `event-based-slos` (v1.9)** ganha bloco "Risk continuum" cross-referenciando `sre-risk-management`; explica que target SLO é escolha explícita no continuum risk × innovation, não meta arbitrária.
|
|
53
|
+
- **Agent `omm-auditor` (v1.9)** consulta `toil-auditor` para Capacidade 3 (Complexidade/Tech Debt). Score OMM-3 considera % de tempo em toil pelo time. Tabela 5-row Cap 3 (`< 15%` → 5 / `15-30%` → 4 / `30-50%` → 3 / `50-60%` → 2 / `> 60%` → 1) replicada como single source of truth distribuída.
|
|
54
|
+
|
|
55
|
+
### Adicionado — integração com Suíte Supabase v1.8 (Phase 39)
|
|
56
|
+
|
|
57
|
+
- **`supabase-edge-fn-writer`** ganha seção "Four Golden Signals" — template canônico de Edge Function inclui histogram de latência, counter de tráfego, counter de erros por error.type enum, gauge de saturação (recurso identificado explicitamente: pg_pool / concurrency_limit / pgmq.queue_length / egress_bandwidth conforme tipo de função).
|
|
58
|
+
- **`supabase-architect`** ganha menção a PRR — plano arquitetural sugere PRR antes de production; cross-ref para `production-readiness-review`. Tabela 6 axes adaptada ao contexto Supabase (single project = SPOF mitigado por branches Pro; Spend Cap; RLS git-versioned; declarative schema; load test com p99 baseline).
|
|
59
|
+
- **`supabase-migration-writer`** ganha alerta sobre toil — scripts SQL repetitivos (rebuild de índices manuais, vacuums recorrentes) são candidatos a automação via pg_cron; cross-ref para `eliminating-toil`.
|
|
60
|
+
- **`supabase-storage-implementer`** ganha saturation signal — uploads emitem gauge de bucket size + counter de quota near-exhaustion (thresholds 80% yellow / 95% red por plan: Free 1 GB / Pro 100 GB / Team 1 TB / Enterprise custom); cross-ref para `four-golden-signals`.
|
|
61
|
+
|
|
62
|
+
### Mudado — lifecycle hooks no fluxo framework (Phase 40)
|
|
63
|
+
|
|
64
|
+
Patches editoriais puramente aditivos em 3 commands de fluxo framework — frontmatter (`description`, `allowed-tools`) preservado byte-a-byte (anti-pitfall A2), workflows em `.claude/framework/workflows/*.md` continuam funcionais como antes.
|
|
65
|
+
|
|
66
|
+
- **`/forense`** ganha bloco `<sre_integration>` que sugere chain `/postmortem` automaticamente após Core Analysis Loop fechar com root cause `VALIDATED`. Distinção fundamental: forense diagnostica (read-only, evidence-based, científico — output em `.planning/forensics/`); postmortem documenta blameless para aprendizado organizacional (cap 15 — output em `.planning/postmortems/`). 3 condições de trigger sugerido + 3 exceções explícitas de não-trigger (INT-FW-V2-01).
|
|
67
|
+
- **`/concluir-marco`** ganha gate PRR opcional — quando `workflow.complete_milestone_prr_gate=true` (default `false`, opt-in até maturidade SRE), exige `PRR-REPORT.md` com status `passed` para features production-bound antes de arquivar. Status table 3-row (`passed` 6/6 axes ≥ 3/5 = arquivável / `passed-with-warnings` P1 pendente = arquivável com warnings / `failed` P0 reprovado = BLOQUEIA). Coexiste ortogonalmente com gate OMM regression v1.9 — OMM mede observability maturity, PRR mede production readiness (INT-FW-V2-02).
|
|
68
|
+
- **`/auditar-marco`** invoca `/auditar-toil` automaticamente quando `workflow.audit_milestone_toil=true` (default `true`); resultado `.planning/TOIL-AUDIT.md` alimenta scoring OMM Capacidade 3 via `omm-auditor`. Loop fechado canônico: `/auditar-marco` → `/auditar-toil` → `/auditar-observabilidade` → `omm-auditor` consulta `TOIL-AUDIT.md` → `OMM-REPORT.md` inclui Cap 3 → `MILESTONE-AUDIT.md` (INT-FW-V2-03).
|
|
69
|
+
|
|
70
|
+
### Mudado — README ganha seção "SRE Engagement suite (v1.10)"
|
|
71
|
+
|
|
72
|
+
`README.md` adiciona nova seção entre "Observability suite (v1.9)" e o separador `---` listando 6 skills + 4 agents + 6 commands + 3 audit gates + lifecycle integration + quick start example end-to-end (PRR antes de produção → instrumentação golden signals → após incident, postmortem chain). Citação canônica ao livro Google SRE 2016 em paridade com a citação a *Observability Engineering* na seção v1.9 (QA-SRE-04).
|
|
73
|
+
|
|
74
|
+
### Sem mudanças de API runtime
|
|
75
|
+
|
|
76
|
+
v1.10 é **content-only por design** — zero alterações em `src/core/`, `registry.js`, `sync.js`, ou no MCP server. Stable API v1.0+ totalmente preservada. CI passa sem mudança em `.github/workflows/`. Deps budget mantido em 6/6 (zero deps novas — todo o conteúdo é Markdown).
|
|
77
|
+
|
|
78
|
+
### Tests
|
|
79
|
+
|
|
80
|
+
Tests existentes (115 unit + 67 integration acumulados de v1.7) continuam verde. Novos gates não têm tests dedicados (são bash em markdown, executados via `runGate` no framework de gates já testado em `test/unit/gates.test.js`). Smoke validation por gate: PASS na codebase atual (kit-mcp content-only) + FAIL em fixture sintético com gaps + PASS em fixture sintético com cobertura completa — todos os 3 gates novos validados.
|
|
81
|
+
|
|
82
|
+
### Decisões arquiteturais
|
|
83
|
+
|
|
84
|
+
- **Conteúdo-only milestone** — zero alterações em `src/core/`. Toda integração com fluxo framework via patches editoriais nos commands `kit/commands/{forense,concluir-marco,auditar-marco}.md` (paridade com pattern v1.9 que adicionou bloco `<observability_integration>` aos mesmos commands).
|
|
85
|
+
- **Specialização sobre overlap** — `golden-signals-instrumenter` é especialização de `observability-instrumenter` (v1.9), não substituto: aquele cuida de spans/atributos canônicos, este cuida de métricas dos 4 signals; ambos podem coexistir num mesmo PR (chain canônica: `observability-instrumenter` primeiro → `golden-signals-instrumenter` segundo).
|
|
86
|
+
- **Chain v1.9 → v1.10** — `incident-investigator` (v1.9) fecha Core Analysis Loop com root cause `VALIDATED` em `.planning/investigations/<id>.md`; `postmortem-writer` (v1.10) consome via `--from-investigation <id>` para gerar `.planning/postmortems/<id>.md`. Handoff é state-based via filesystem (não API).
|
|
87
|
+
- **Gates blocking pre-verify** — `golden-signals-coverage` e `prr-checklist-coverage` são blocking (cobertura mínima é regra absoluta). `postmortem-template-required` é blocking pre-conclude (regra cap 15 "no postmortem left unreviewed" não admite warn-only após adoption).
|
|
88
|
+
- **PRR gate em `/concluir-marco` é opt-in** — diferente do gate OMM regression v1.9 (default `true`, estabelecido), o gate PRR v1.10 é default `false` até time amadurecer cultura SRE. Toggle via `workflow.complete_milestone_prr_gate=true`. Critério de "ligar gate": ≥ 2 dos 4 indicadores (paid feature, SLO definido, on-call rotation, postmortem culture).
|
|
89
|
+
- **Vendor-neutral** — gate `golden-signals-coverage` aceita qualquer pattern com `histogram` / `counter` / `gauge` (OTel, Prometheus, StatsD, Borgmon-like). Livro Google SRE descreve Borgmon mas é proprietário; gate é genérico.
|
|
90
|
+
|
|
91
|
+
### Detalhes
|
|
92
|
+
|
|
93
|
+
`.planning/milestones/v1.10.0/` (após `/concluir-marco`).
|
|
94
|
+
|
|
9
95
|
## [1.8.1] - 2026-05-06
|
|
10
96
|
|
|
11
97
|
Patch de integração da Suíte Supabase v1.8.0 — fecha 7 lacunas onde o conteúdo novo não estava "wired" nos pontos de entrada existentes do framework.
|
package/README.md
CHANGED
|
@@ -101,6 +101,64 @@ A complete observability layer derived from *Observability Engineering* (Charity
|
|
|
101
101
|
/observabilidade omm
|
|
102
102
|
```
|
|
103
103
|
|
|
104
|
+
### SRE Engagement suite (v1.10)
|
|
105
|
+
|
|
106
|
+
A production engineering layer derived from *Site Reliability Engineering: How Google Runs Production Systems* (Beyer, Jones, Petoff, Murphy — Google/O'Reilly, 2016) ships in the kit. It composes with the Supabase suite (v1.8) and the Observability suite (v1.9) into a coherent production engineering stack — Supabase agents now suggest PRR before launch, every Edge Function template includes the **4 golden signals**, and `incident-investigator` outputs feed directly into blameless postmortems via `/postmortem --from-investigation <id>`.
|
|
107
|
+
|
|
108
|
+
**6 skills** in `kit/skills/`:
|
|
109
|
+
- `_shared-sre/glossary.md` — canonical bilingual vocabulary (PT-BR↔EN) — SLI/SLO/SLA, error budget, burn rate, toil, postmortem, blameless, PRR, golden signals, risk continuum, MTTR/MTBF
|
|
110
|
+
- `sre-risk-management` — risk continuum (cap 3), 99.99% wisdom ("as reliable as needs to be, no more"), error budget as explicit risk × innovation balance
|
|
111
|
+
- `four-golden-signals` — Latency + Traffic + Errors + Saturation (cap 6), histograms with exponential bucketing, success vs error latency separated, percentiles vs mean (long tail)
|
|
112
|
+
- `eliminating-toil` — canonical toil definition (manual + repetitive + automatable + tactical + no enduring value + scales linearly), ≤ 50% rule (cap 5), automation patterns
|
|
113
|
+
- `blameless-postmortems` — canonical 9-section template (cap 15), "no postmortem left unreviewed", blame culture as anti-pattern, Wheel of Misfortune
|
|
114
|
+
- `production-readiness-review` — PRR checklist (cap 32) — 6 axes (System architecture, Instrumentation, Emergency response, Capacity planning, Change management, Performance), 3 engagement models
|
|
115
|
+
|
|
116
|
+
**4 agents** in `kit/agents/`:
|
|
117
|
+
- `golden-signals-instrumenter` — specialization of `observability-instrumenter` (v1.9); generates OTel patches with the 4 golden signals (Latency=histogram, Traffic=counter, Errors=counter by `error.type`, Saturation=gauge)
|
|
118
|
+
- `toil-auditor` — analyzes git log + shell scripts + manual commands in README/runbooks; produces `TOIL-AUDIT.md` with P0/P1/P2 priority + estimated effort
|
|
119
|
+
- `postmortem-writer` — natural continuation of `incident-investigator` (v1.9); reads `.planning/investigations/<id>.md` and produces blameless postmortem (Summary, Impact, Root Causes, Trigger, Resolution, Detection, Action Items, Lessons Learned, Timeline UTC)
|
|
120
|
+
- `prr-conductor` — conducts Production Readiness Review for service/feature; reads schema (Supabase MCP), Edge Functions, `.planning/slos/`, audit logs; produces `PRR-REPORT.md` scored across the 6 axes
|
|
121
|
+
|
|
122
|
+
**6 commands**:
|
|
123
|
+
- `/sre <subcommand>` — single orchestrator (analog to `/supabase` v1.8 and `/observabilidade` v1.9) — dispatches to the 4 agents with PT/EN synonyms
|
|
124
|
+
- `/golden-signals` — invokes `golden-signals-instrumenter` for service/Edge Function/phase; generates `GOLDEN-SIGNALS.md` with OTel-ready instrumentation
|
|
125
|
+
- `/auditar-toil` — invokes `toil-auditor`; generates `.planning/TOIL-AUDIT.md`
|
|
126
|
+
- `/postmortem` — invokes `postmortem-writer`; supports `--from-investigation <id>` (continue from v1.9 investigation) or `--incident "<description>"` (standalone)
|
|
127
|
+
- `/prr` — invokes `prr-conductor`; supports `--service <name>` or `--feature <description>`; generates `PRR-REPORT.md`
|
|
128
|
+
- `/risk-budget` — displays current error budget vs risk continuum, citing SLOs from v1.9 (`.planning/slos/`); applies `sre-risk-management` skill
|
|
129
|
+
|
|
130
|
+
**3 audit gates** in `gates/`:
|
|
131
|
+
- `golden-signals-coverage` (blocking, pre-verify) — verifies code in `supabase/functions/**`, `src/**`, `lib/**` covers the 4 golden signals (skips gracefully on content-only phases)
|
|
132
|
+
- `postmortem-template-required` (blocking, pre-conclude) — blocks `/concluir-marco` if any `.planning/investigations/<id>.md` lacks a corresponding `.planning/postmortems/<id>.md` (`Status: INCONCLUSIVE` is the only exception)
|
|
133
|
+
- `prr-checklist-coverage` (blocking, pre-verify) — verifies every `PRR-REPORT.md` in `.planning/prr/**/*.md` covers the 6 canonical axes; "skipping an axe = invalid approval"
|
|
134
|
+
|
|
135
|
+
**Lifecycle integration:**
|
|
136
|
+
- `/forense` — after Core Analysis Loop closes with VALIDATED root cause, suggests chain `/postmortem --from-investigation <id>` (Phase 40 / INT-FW-V2-01)
|
|
137
|
+
- `/concluir-marco` — opt-in gate `workflow.complete_milestone_prr_gate=true` requires `PRR-REPORT.md` with status `passed` for production-bound features before archive (Phase 40 / INT-FW-V2-02)
|
|
138
|
+
- `/auditar-marco` — auto-invokes `/auditar-toil` when `workflow.audit_milestone_toil=true` (default); result feeds OMM Capacidade 3 scoring via `omm-auditor` (Phase 40 / INT-FW-V2-03)
|
|
139
|
+
|
|
140
|
+
**Quick start example — end-to-end SRE workflow:**
|
|
141
|
+
```bash
|
|
142
|
+
# Before launching a new feature in production — PRR
|
|
143
|
+
/sre prr --feature "checkout v2"
|
|
144
|
+
|
|
145
|
+
# While instrumenting service — apply 4 golden signals
|
|
146
|
+
/sre golden-signals supabase/functions/orders/index.ts
|
|
147
|
+
|
|
148
|
+
# Audit team toil quarterly
|
|
149
|
+
/sre toil
|
|
150
|
+
|
|
151
|
+
# When SLO burn alert fires — investigate (v1.9 deep loop), then postmortem (v1.10)
|
|
152
|
+
/investigar-producao "checkout SLO burn rate = 8 às 14:32"
|
|
153
|
+
/sre postmortem --from-investigation checkout-2026-05-07
|
|
154
|
+
# Or for framework-level failures:
|
|
155
|
+
/forense "framework workflow X falhou em produção"
|
|
156
|
+
/sre postmortem --incident "framework workflow X failed (see .planning/forensics/report-*)"
|
|
157
|
+
|
|
158
|
+
# Risk dashboard against SLO budgets
|
|
159
|
+
/sre risk-budget
|
|
160
|
+
```
|
|
161
|
+
|
|
104
162
|
---
|
|
105
163
|
|
|
106
164
|
## Prerequisites
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: ai-prompt-stability
|
|
3
|
+
stage: pre-execute
|
|
4
|
+
blocking: false
|
|
5
|
+
description: Valida que prompts/tools LLM em produção (qualquer arquivo em `prompts/` ou referenciado por código de produção como prompt) têm characterization tests linkados. Skip se projeto não usa LLM. Opt-in via workflow.ai_prompt_gate.
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# AI prompt stability gate
|
|
9
|
+
|
|
10
|
+
**When to run:** pre-execute (consultive default; blocking se `workflow.ai_prompt_gate=true`).
|
|
11
|
+
|
|
12
|
+
**Skill canônica:** [`ai-prompt-characterization`](../kit/skills/ai-prompt-characterization/SKILL.md)
|
|
13
|
+
|
|
14
|
+
**Agent invocado:** [`legacy-characterizer`](../kit/agents/legacy-characterizer.md) (modo prompt)
|
|
15
|
+
|
|
16
|
+
## Check
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
#!/usr/bin/env bash
|
|
20
|
+
# PT-BR: validar que prompts em prod têm characterization tests
|
|
21
|
+
set -e
|
|
22
|
+
|
|
23
|
+
# detectar prompts em prod (heurística — paths canônicos)
|
|
24
|
+
PROMPT_FILES=""
|
|
25
|
+
for d in prompts src/prompts supabase/functions/*/prompts; do
|
|
26
|
+
[ -d "$d" ] && PROMPT_FILES="$PROMPT_FILES $(find "$d" -type f \( -name "*.md" -o -name "*.txt" -o -name "*.prompt" \) 2>/dev/null)"
|
|
27
|
+
done
|
|
28
|
+
|
|
29
|
+
if [ -z "$PROMPT_FILES" ]; then
|
|
30
|
+
echo "INFO: nenhum prompt em prod detectado — gate skip."
|
|
31
|
+
exit 0
|
|
32
|
+
fi
|
|
33
|
+
|
|
34
|
+
# detectar gate mode
|
|
35
|
+
GATE_BLOCKING=false
|
|
36
|
+
if [ -f ".planning/config.json" ] && command -v jq >/dev/null; then
|
|
37
|
+
CFG=$(jq -r '.workflow.ai_prompt_gate // empty' .planning/config.json 2>/dev/null)
|
|
38
|
+
[ "$CFG" = "true" ] && GATE_BLOCKING=true
|
|
39
|
+
fi
|
|
40
|
+
|
|
41
|
+
# para cada prompt, verificar characterization tests
|
|
42
|
+
PROMPTS_OK=()
|
|
43
|
+
PROMPTS_MISSING=()
|
|
44
|
+
|
|
45
|
+
for prompt in $PROMPT_FILES; do
|
|
46
|
+
STEM=$(basename "$prompt" | sed 's/\.[^.]*$//')
|
|
47
|
+
HAS_CHAR=false
|
|
48
|
+
for chardir in tests/characterization/prompts test/characterization/prompts __tests__/characterization/prompts; do
|
|
49
|
+
if find "$chardir" -path "*${STEM}*" 2>/dev/null | head -1 | grep -q . ; then
|
|
50
|
+
HAS_CHAR=true
|
|
51
|
+
break
|
|
52
|
+
fi
|
|
53
|
+
done
|
|
54
|
+
|
|
55
|
+
if [ "$HAS_CHAR" = "true" ]; then
|
|
56
|
+
PROMPTS_OK+=("$prompt")
|
|
57
|
+
else
|
|
58
|
+
LINES=$(wc -l < "$prompt" 2>/dev/null | tr -d ' ')
|
|
59
|
+
if [ "${LINES:-0}" -gt 50 ]; then # threshold: prompts > 50 linhas requerem char
|
|
60
|
+
PROMPTS_MISSING+=("$prompt (lines=$LINES)")
|
|
61
|
+
fi
|
|
62
|
+
fi
|
|
63
|
+
done
|
|
64
|
+
|
|
65
|
+
if [ ${#PROMPTS_MISSING[@]} -eq 0 ]; then
|
|
66
|
+
echo "✓ ai-prompt-stability — todos os prompts > 50 linhas têm characterization tests."
|
|
67
|
+
exit 0
|
|
68
|
+
fi
|
|
69
|
+
|
|
70
|
+
echo ""
|
|
71
|
+
echo "⚠ ai-prompt-stability — prompts sem characterization detectados:"
|
|
72
|
+
echo ""
|
|
73
|
+
for p in "${PROMPTS_MISSING[@]}"; do
|
|
74
|
+
echo " - $p"
|
|
75
|
+
done
|
|
76
|
+
echo ""
|
|
77
|
+
echo "Skill canônica: kit/skills/ai-prompt-characterization/SKILL.md"
|
|
78
|
+
echo ""
|
|
79
|
+
echo "Caminhos para resolver:"
|
|
80
|
+
echo " /caracterizar-prompt <prompt-file> (gera characterization tests)"
|
|
81
|
+
echo " /caracterizar-prompt <prompt> --num-intents 5 (5 intents canônicas)"
|
|
82
|
+
echo ""
|
|
83
|
+
|
|
84
|
+
if [ "$GATE_BLOCKING" = "true" ]; then
|
|
85
|
+
echo "MODE: blocking (workflow.ai_prompt_gate=true)"
|
|
86
|
+
echo "Resolve antes de prosseguir."
|
|
87
|
+
exit 1
|
|
88
|
+
else
|
|
89
|
+
echo "MODE: consultive (warning apenas)"
|
|
90
|
+
echo "Para tornar blocking: setar workflow.ai_prompt_gate=true em .planning/config.json"
|
|
91
|
+
exit 0
|
|
92
|
+
fi
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Configuração
|
|
96
|
+
|
|
97
|
+
```json
|
|
98
|
+
{
|
|
99
|
+
"workflow": {
|
|
100
|
+
"ai_prompt_gate": false,
|
|
101
|
+
"ai_prompt_min_lines": 50,
|
|
102
|
+
"ai_prompt_paths": ["prompts/**", "src/prompts/**", "supabase/functions/*/prompts/**"]
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
**Default:** `ai_prompt_gate` = false (consultive). Promove para blocking se projeto tem ≥ 5 prompts em prod.
|
|
108
|
+
|
|
109
|
+
## Quando NÃO rodar
|
|
110
|
+
|
|
111
|
+
- Projeto não usa LLM em produção
|
|
112
|
+
- Prompts são apenas para dev tooling (não prod)
|
|
113
|
+
- Prompts < 50 linhas (threshold default)
|
|
114
|
+
|
|
115
|
+
## Ver também
|
|
116
|
+
|
|
117
|
+
- [`ai-prompt-characterization`](../kit/skills/ai-prompt-characterization/SKILL.md) — knowledge base
|
|
118
|
+
- [`legacy-characterization-tests`](../kit/skills/legacy-characterization-tests/SKILL.md) — characterization clássico
|
|
119
|
+
- [`legacy-refactor-safety`](./legacy-refactor-safety.md) — gate análogo para refactor de código
|
|
120
|
+
- [`llm-as-dependency`](../kit/skills/llm-as-dependency/SKILL.md) — fakear LLM em business logic tests
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: golden-signals-coverage
|
|
3
|
+
stage: pre-verify
|
|
4
|
+
blocking: true
|
|
5
|
+
description: Valida que código de serviço/Edge Function tocado em fase contém os 4 golden signals (Latency=histogram, Traffic=counter, Errors=counter, Saturation=gauge). Skip se fase só toca markdown.
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Golden signals coverage gate
|
|
9
|
+
|
|
10
|
+
**When to run:** pre-verify (blocking — fase não verifica até cobertura completa).
|
|
11
|
+
|
|
12
|
+
## Check
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
#!/usr/bin/env bash
|
|
16
|
+
# PT-BR: validar que código de serviço/Edge Function tocado em fase tem 4 golden signals.
|
|
17
|
+
# Estratégia: descobrir arquivos tocados (supabase/functions/** ou STATE.md current_phase code paths),
|
|
18
|
+
# rodar grep por histogram/counter/gauge/saturation, contar matches por sinal.
|
|
19
|
+
# Bash 3.2-portable (macOS default).
|
|
20
|
+
set -e
|
|
21
|
+
|
|
22
|
+
# PT-BR: identificar fase atual via STATE.md
|
|
23
|
+
STATE_FILE=".planning/STATE.md"
|
|
24
|
+
CURRENT_PHASE=""
|
|
25
|
+
if [ -f "$STATE_FILE" ]; then
|
|
26
|
+
CURRENT_PHASE=$(grep -E "^Fase:" "$STATE_FILE" 2>/dev/null | head -1 | sed -E 's/^Fase: *([0-9]+).*/\1/')
|
|
27
|
+
fi
|
|
28
|
+
|
|
29
|
+
# PT-BR: candidatos a arquivos de código tocados — escopo principal Supabase Edge + qualquer .ts/.js/.py
|
|
30
|
+
# em paths declarados pela fase (heurística: supabase/functions/** SEMPRE inspecionado).
|
|
31
|
+
CODE_FILES=""
|
|
32
|
+
if [ -d "supabase/functions" ]; then
|
|
33
|
+
CODE_FILES=$(find supabase/functions -type f \( -name "*.ts" -o -name "*.js" -o -name "*.mjs" \) 2>/dev/null)
|
|
34
|
+
fi
|
|
35
|
+
|
|
36
|
+
# PT-BR: também inspecionar lib/ e src/ se existirem (apps Node/Deno fora de Supabase)
|
|
37
|
+
if [ -d "src" ]; then
|
|
38
|
+
ADDITIONAL=$(find src -type f \( -name "*.ts" -o -name "*.js" -o -name "*.mjs" -o -name "*.py" \) 2>/dev/null)
|
|
39
|
+
CODE_FILES="$CODE_FILES
|
|
40
|
+
$ADDITIONAL"
|
|
41
|
+
fi
|
|
42
|
+
if [ -d "lib" ]; then
|
|
43
|
+
ADDITIONAL=$(find lib -type f \( -name "*.ts" -o -name "*.js" -o -name "*.mjs" -o -name "*.py" \) 2>/dev/null)
|
|
44
|
+
CODE_FILES="$CODE_FILES
|
|
45
|
+
$ADDITIONAL"
|
|
46
|
+
fi
|
|
47
|
+
|
|
48
|
+
# PT-BR: filtrar linhas vazias
|
|
49
|
+
CODE_FILES=$(echo "$CODE_FILES" | grep -v "^$" || true)
|
|
50
|
+
|
|
51
|
+
# PT-BR: se fase não toca código (só markdown/docs), pular gate
|
|
52
|
+
if [ -z "$CODE_FILES" ]; then
|
|
53
|
+
echo "INFO: nenhum arquivo de código (.ts/.js/.py) encontrado em supabase/functions/** | src/** | lib/** — fase parece content-only. Gate skipped."
|
|
54
|
+
exit 0
|
|
55
|
+
fi
|
|
56
|
+
|
|
57
|
+
# PT-BR: contar matches por signal
|
|
58
|
+
LATENCY_HITS=0
|
|
59
|
+
TRAFFIC_HITS=0
|
|
60
|
+
ERRORS_HITS=0
|
|
61
|
+
SATURATION_HITS=0
|
|
62
|
+
|
|
63
|
+
# PT-BR: process file list line-by-line para portabilidade bash 3.2
|
|
64
|
+
OLDIFS="$IFS"
|
|
65
|
+
IFS='
|
|
66
|
+
'
|
|
67
|
+
for f in $CODE_FILES; do
|
|
68
|
+
[ -z "$f" ] && continue
|
|
69
|
+
[ ! -f "$f" ] && continue
|
|
70
|
+
|
|
71
|
+
# PT-BR: Latency = histogram (createHistogram, recordHistogram, histogram.record)
|
|
72
|
+
if grep -qE "histogram|Histogram" "$f" 2>/dev/null; then
|
|
73
|
+
LATENCY_HITS=$((LATENCY_HITS + 1))
|
|
74
|
+
fi
|
|
75
|
+
|
|
76
|
+
# PT-BR: Traffic + Errors = counter (Errors counter dimensionado por error.type)
|
|
77
|
+
if grep -qE "counter|Counter|createCounter" "$f" 2>/dev/null; then
|
|
78
|
+
TRAFFIC_HITS=$((TRAFFIC_HITS + 1))
|
|
79
|
+
ERRORS_HITS=$((ERRORS_HITS + 1))
|
|
80
|
+
fi
|
|
81
|
+
|
|
82
|
+
# PT-BR: Saturation = gauge (createObservableGauge, gauge.record) ou string saturation
|
|
83
|
+
if grep -qE "gauge|Gauge|saturation|Saturation" "$f" 2>/dev/null; then
|
|
84
|
+
SATURATION_HITS=$((SATURATION_HITS + 1))
|
|
85
|
+
fi
|
|
86
|
+
done
|
|
87
|
+
IFS="$OLDIFS"
|
|
88
|
+
|
|
89
|
+
# PT-BR: gate passa se TODOS os 4 signals têm pelo menos 1 hit em algum arquivo de código
|
|
90
|
+
MISSING=""
|
|
91
|
+
[ "$LATENCY_HITS" -eq 0 ] && MISSING="$MISSING Latency(histogram)"
|
|
92
|
+
[ "$TRAFFIC_HITS" -eq 0 ] && MISSING="$MISSING Traffic(counter)"
|
|
93
|
+
[ "$ERRORS_HITS" -eq 0 ] && MISSING="$MISSING Errors(counter)"
|
|
94
|
+
[ "$SATURATION_HITS" -eq 0 ] && MISSING="$MISSING Saturation(gauge)"
|
|
95
|
+
|
|
96
|
+
if [ -z "$MISSING" ]; then
|
|
97
|
+
echo "PASS: 4 golden signals cobertos em código (Latency=$LATENCY_HITS files / Traffic=$TRAFFIC_HITS / Errors=$ERRORS_HITS / Saturation=$SATURATION_HITS)"
|
|
98
|
+
exit 0
|
|
99
|
+
else
|
|
100
|
+
echo "FAIL: golden signals ausentes em código tocado:$MISSING"
|
|
101
|
+
echo "Sugestão: rodar /sre golden-signals <service> ou /golden-signals para gerar instrumentação OTel canônica."
|
|
102
|
+
echo "Cross-ref: kit/skills/four-golden-signals/SKILL.md + kit/agents/golden-signals-instrumenter.md"
|
|
103
|
+
exit 1
|
|
104
|
+
fi
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Verdict
|
|
108
|
+
|
|
109
|
+
- **passed** — todos 4 signals (Latency / Traffic / Errors / Saturation) presentes em pelo menos 1 arquivo de código no projeto
|
|
110
|
+
- **passed (skip)** — projeto não tem código (apenas markdown / docs); gate não aplicável
|
|
111
|
+
- **block** — pelo menos 1 signal ausente em código tocado pela fase
|
|
112
|
+
|
|
113
|
+
## Why
|
|
114
|
+
|
|
115
|
+
O livro Google SRE (cap 6 — *Monitoring Distributed Systems*) define os **4 golden signals** como cobertura mínima universal de saúde operacional para serviços user-facing — Latency (histogram com percentis, success vs error separados), Traffic (counter por endpoint × method), Errors (counter por `error.type` enum 5-15 valores, NUNCA `error.message`), Saturation (gauge do recurso mais escasso identificado explicitamente).
|
|
116
|
+
|
|
117
|
+
Sem esse gate, fases entregam Edge Functions / serviços sem instrumentação básica e dashboards crescem ad-hoc (CPU, memory, threads — *causes* não *symptoms*). Gate força padrão canônico: cada PR de código deve cobrir os 4 signals, ou explicar a ausência via skip (fase só altera markdown).
|
|
118
|
+
|
|
119
|
+
Cross-ref agent canônico: [`golden-signals-instrumenter`](../kit/agents/golden-signals-instrumenter.md) (Phase 37 / AGCORE-SRE-01). Skill: [`four-golden-signals`](../kit/skills/four-golden-signals/SKILL.md) (Phase 36 / SKFD-SRE-02).
|
|
120
|
+
|
|
121
|
+
## REQ
|
|
122
|
+
|
|
123
|
+
QA-SRE-01.
|
|
124
|
+
|
|
125
|
+
## Configuração
|
|
126
|
+
|
|
127
|
+
Gate é **blocking** por default. Para tornar warn-only (durante adoption inicial em legado):
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
node ./.claude/framework/bin/tools.cjs config-set workflow.golden_signals_coverage_warn true
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
(Nota: implementação do toggle warn-only é deferida — gate atual lê apenas presença/ausência de regex, não consulta config.)
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: legacy-refactor-safety
|
|
3
|
+
stage: pre-execute
|
|
4
|
+
blocking: false
|
|
5
|
+
description: Valida que tasks com kind=refactor em arquivos > 500 linhas OU com contrato externo têm characterization tests linkados. Skip se fase só toca markdown OR fase é greenfield. Opt-in via workflow.legacy_refactor_gate_blocking=true.
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Legacy refactor safety gate
|
|
9
|
+
|
|
10
|
+
**When to run:** pre-execute (consultive por default; blocking se `workflow.legacy_refactor_gate_blocking=true` E `omm.capacidade_1_resilience >= 3`).
|
|
11
|
+
|
|
12
|
+
**Skill canônica:** [`pre-refactor-characterization`](../kit/skills/pre-refactor-characterization/SKILL.md)
|
|
13
|
+
|
|
14
|
+
**Agent invocado:** [`refactor-safety-auditor`](../kit/agents/refactor-safety-auditor.md)
|
|
15
|
+
|
|
16
|
+
## Check
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
#!/usr/bin/env bash
|
|
20
|
+
# PT-BR: validar que tasks com kind=refactor em arquivos arriscados têm safety net.
|
|
21
|
+
# Estratégia: descobrir tasks da fase atual, identificar refactor + arquivos flagged,
|
|
22
|
+
# verificar characterization tests linkados, gerar warning ou block conforme mode.
|
|
23
|
+
# Bash 3.2-portable (macOS default).
|
|
24
|
+
set -e
|
|
25
|
+
|
|
26
|
+
# PT-BR: identificar fase atual via STATE.md
|
|
27
|
+
STATE_FILE=".planning/STATE.md"
|
|
28
|
+
CURRENT_PHASE=""
|
|
29
|
+
if [ -f "$STATE_FILE" ]; then
|
|
30
|
+
CURRENT_PHASE=$(grep -E "^Fase:" "$STATE_FILE" 2>/dev/null | head -1 | sed -E 's/^Fase: *([0-9]+).*/\1/')
|
|
31
|
+
fi
|
|
32
|
+
|
|
33
|
+
if [ -z "$CURRENT_PHASE" ]; then
|
|
34
|
+
echo "INFO: nenhuma fase ativa — gate skip."
|
|
35
|
+
exit 0
|
|
36
|
+
fi
|
|
37
|
+
|
|
38
|
+
PHASE_DIR=".planning/phases/phase-${CURRENT_PHASE}"
|
|
39
|
+
[ ! -d "$PHASE_DIR" ] && exit 0
|
|
40
|
+
|
|
41
|
+
# PT-BR: ler config para mode
|
|
42
|
+
GATE_BLOCKING=false
|
|
43
|
+
if [ -f ".planning/config.json" ] && command -v jq >/dev/null; then
|
|
44
|
+
CFG=$(jq -r '.workflow.legacy_refactor_gate_blocking // empty' .planning/config.json 2>/dev/null)
|
|
45
|
+
[ "$CFG" = "true" ] && GATE_BLOCKING=true
|
|
46
|
+
fi
|
|
47
|
+
|
|
48
|
+
# PT-BR: ler omm — Capacidade 1 (Resilience) calibra mode default
|
|
49
|
+
if [ "$GATE_BLOCKING" = "false" ] && [ -f ".planning/OMM-REPORT.md" ]; then
|
|
50
|
+
OMM_RES=$(grep -oE 'Capacidade 1.*Resilience.*[0-9]/5' .planning/OMM-REPORT.md 2>/dev/null \
|
|
51
|
+
| grep -oE '[0-9]/5' | head -1 | sed 's|/5||')
|
|
52
|
+
if [ -n "$OMM_RES" ] && [ "$OMM_RES" -ge 3 ]; then
|
|
53
|
+
GATE_BLOCKING=true
|
|
54
|
+
fi
|
|
55
|
+
fi
|
|
56
|
+
|
|
57
|
+
# PT-BR: identificar PLAN.md da fase atual
|
|
58
|
+
PLAN_FILES=$(find "$PHASE_DIR" -name "PLAN.md" 2>/dev/null)
|
|
59
|
+
|
|
60
|
+
REFACTOR_TASKS_RISKY=()
|
|
61
|
+
REFACTOR_TASKS_OK=()
|
|
62
|
+
TOTAL_REFACTOR=0
|
|
63
|
+
|
|
64
|
+
for plan_file in $PLAN_FILES; do
|
|
65
|
+
# PT-BR: detectar tasks com kind=refactor (heurística — frase canônica)
|
|
66
|
+
if grep -qiE "(refactor|refator|extract method|extract class|move method|reorganizar|limpar)" "$plan_file"; then
|
|
67
|
+
# extrair arquivos mencionados em tasks de refactor
|
|
68
|
+
AFFECTED_FILES=$(grep -oE "(src|lib|app|supabase|tests)/[a-zA-Z0-9_./-]+\.(ts|tsx|js|jsx|mjs|py|java|go|rb|cs|rs|cpp|c|h)" "$plan_file" 2>/dev/null | sort -u)
|
|
69
|
+
|
|
70
|
+
for f in $AFFECTED_FILES; do
|
|
71
|
+
[ ! -f "$f" ] && continue
|
|
72
|
+
|
|
73
|
+
# PT-BR: critérios de risco
|
|
74
|
+
LINES=$(wc -l < "$f" 2>/dev/null | tr -d ' ')
|
|
75
|
+
EXTERNAL=false
|
|
76
|
+
if echo "$f" | grep -qE "(supabase/functions|src/api|/handlers/webhooks|pages/api|integrations)"; then
|
|
77
|
+
EXTERNAL=true
|
|
78
|
+
fi
|
|
79
|
+
|
|
80
|
+
RISK_HIGH=false
|
|
81
|
+
[ "${LINES:-0}" -gt 500 ] && RISK_HIGH=true
|
|
82
|
+
[ "$EXTERNAL" = "true" ] && RISK_HIGH=true
|
|
83
|
+
|
|
84
|
+
if [ "$RISK_HIGH" = "true" ]; then
|
|
85
|
+
TOTAL_REFACTOR=$((TOTAL_REFACTOR + 1))
|
|
86
|
+
|
|
87
|
+
# PT-BR: verificar characterization tests linkados
|
|
88
|
+
STEM=$(basename "$f" | sed 's/\.[^.]*$//')
|
|
89
|
+
HAS_CHAR=false
|
|
90
|
+
for chardir in tests test __tests__; do
|
|
91
|
+
if find "$chardir" -path "*characterization*$STEM*" 2>/dev/null | head -1 | grep -q . ; then
|
|
92
|
+
HAS_CHAR=true
|
|
93
|
+
break
|
|
94
|
+
fi
|
|
95
|
+
done
|
|
96
|
+
|
|
97
|
+
if [ "$HAS_CHAR" = "true" ]; then
|
|
98
|
+
REFACTOR_TASKS_OK+=("$f")
|
|
99
|
+
else
|
|
100
|
+
REFACTOR_TASKS_RISKY+=("$f (lines=$LINES, external=$EXTERNAL)")
|
|
101
|
+
fi
|
|
102
|
+
fi
|
|
103
|
+
done
|
|
104
|
+
fi
|
|
105
|
+
done
|
|
106
|
+
|
|
107
|
+
# PT-BR: relatório
|
|
108
|
+
if [ ${#REFACTOR_TASKS_RISKY[@]} -eq 0 ]; then
|
|
109
|
+
echo "✓ legacy-refactor-safety — sem refactors arriscados sem characterization."
|
|
110
|
+
if [ ${#REFACTOR_TASKS_OK[@]} -gt 0 ]; then
|
|
111
|
+
echo " ${#REFACTOR_TASKS_OK[@]} refactor(s) com characterization linkados."
|
|
112
|
+
fi
|
|
113
|
+
exit 0
|
|
114
|
+
fi
|
|
115
|
+
|
|
116
|
+
# PT-BR: há refactors arriscados sem char
|
|
117
|
+
echo ""
|
|
118
|
+
echo "⚠ legacy-refactor-safety — refactor(s) sem characterization detectado(s):"
|
|
119
|
+
echo ""
|
|
120
|
+
for item in "${REFACTOR_TASKS_RISKY[@]}"; do
|
|
121
|
+
echo " - $item"
|
|
122
|
+
done
|
|
123
|
+
echo ""
|
|
124
|
+
echo "Skill canônica: kit/skills/pre-refactor-characterization/SKILL.md"
|
|
125
|
+
echo ""
|
|
126
|
+
echo "Caminhos para resolver:"
|
|
127
|
+
echo " 1. /caracterizar <file> (full chain — preferido)"
|
|
128
|
+
echo " 2. /refactor-seguro --mode=sprout <file> (não toca legado, ADICIONA via sprout)"
|
|
129
|
+
echo " 3. /refactor-seguro --mode=safe-extract <file> (apenas refactor mecânico)"
|
|
130
|
+
echo " 4. /refactor-seguro --mode=override --ticket REQ-N --reason \"...\" (último recurso)"
|
|
131
|
+
echo ""
|
|
132
|
+
|
|
133
|
+
if [ "$GATE_BLOCKING" = "true" ]; then
|
|
134
|
+
echo "MODE: blocking (workflow.legacy_refactor_gate_blocking=true OR OMM Capacidade 1 ≥ 3)"
|
|
135
|
+
echo "Resolve antes de prosseguir com /executar-fase."
|
|
136
|
+
exit 1
|
|
137
|
+
else
|
|
138
|
+
echo "MODE: consultive (warning apenas)"
|
|
139
|
+
echo "Para tornar blocking: setar workflow.legacy_refactor_gate_blocking=true em .planning/config.json"
|
|
140
|
+
exit 0
|
|
141
|
+
fi
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Configuração
|
|
145
|
+
|
|
146
|
+
```json
|
|
147
|
+
// .planning/config.json
|
|
148
|
+
{
|
|
149
|
+
"workflow": {
|
|
150
|
+
"legacy_refactor_gate_blocking": true,
|
|
151
|
+
"legacy_refactor_min_lines": 500,
|
|
152
|
+
"legacy_refactor_external_paths": [
|
|
153
|
+
"supabase/functions/**",
|
|
154
|
+
"src/api/**",
|
|
155
|
+
"src/handlers/webhooks/**",
|
|
156
|
+
"pages/api/**"
|
|
157
|
+
]
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
**Default:** `legacy_refactor_gate_blocking` = false (consultive). Auto-promove para `true` se `omm-auditor` (v1.9) reportar Capacidade 1 (Resilience) ≥ 3 — sinal de que projeto tem maturity de safety.
|
|
163
|
+
|
|
164
|
+
## Quando NÃO rodar
|
|
165
|
+
|
|
166
|
+
- Fase só toca markdown/docs — sem código a refactor
|
|
167
|
+
- Projeto < 1 mês de idade — código novo não é "legacy" no sentido Feathers
|
|
168
|
+
- Projeto sem `omm-auditor` rodado E sem flag explícita — skip silencioso (consultive)
|
|
169
|
+
- Tasks são `bug-fix` ou `feature` (não refactor) — gate só roda em refactor
|
|
170
|
+
|
|
171
|
+
## Ver também
|
|
172
|
+
|
|
173
|
+
- [`pre-refactor-characterization`](../kit/skills/pre-refactor-characterization/SKILL.md) — knowledge base do gate
|
|
174
|
+
- [`refactor-safety-auditor`](../kit/agents/refactor-safety-auditor.md) — agent invocado em runtime
|
|
175
|
+
- [`legacy-characterizer`](../kit/agents/legacy-characterizer.md) — agent que gera safety net
|
|
176
|
+
- [`golden-signals-coverage`](./golden-signals-coverage.md) — gate análogo da Suíte SRE
|
|
177
|
+
- [`prr-checklist-coverage`](./prr-checklist-coverage.md) — gate análogo da Suíte SRE para PRR
|
|
178
|
+
- [`omm-no-regression`](./omm-no-regression.md) — gate análogo da Suíte Observabilidade para OMM
|