@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.
Files changed (84) hide show
  1. package/CHANGELOG.md +86 -0
  2. package/README.md +58 -0
  3. package/gates/ai-prompt-stability.md +120 -0
  4. package/gates/golden-signals-coverage.md +133 -0
  5. package/gates/legacy-refactor-safety.md +178 -0
  6. package/gates/observability-coverage.md +151 -0
  7. package/gates/postmortem-template-required.md +127 -0
  8. package/gates/prr-checklist-coverage.md +128 -0
  9. package/gates/release-pipeline-policy.md +132 -0
  10. package/kit/COMANDOS.md +15 -0
  11. package/kit/agents/ai-mutation-tester.md +298 -0
  12. package/kit/agents/cascading-failures-auditor.md +306 -0
  13. package/kit/agents/executor.md +13 -0
  14. package/kit/agents/golden-signals-instrumenter.md +241 -0
  15. package/kit/agents/legacy-characterizer.md +378 -0
  16. package/kit/agents/load-shedding-instrumenter.md +297 -0
  17. package/kit/agents/observability-coverage-auditor.md +325 -0
  18. package/kit/agents/omm-auditor.md +99 -0
  19. package/kit/agents/payload-capture-instrumenter.md +283 -0
  20. package/kit/agents/planner.md +29 -0
  21. package/kit/agents/postmortem-writer.md +282 -0
  22. package/kit/agents/prr-conductor.md +296 -0
  23. package/kit/agents/refactor-safety-auditor.md +414 -0
  24. package/kit/agents/release-pipeline-auditor.md +360 -0
  25. package/kit/agents/seam-finder.md +367 -0
  26. package/kit/agents/shotgun-surgery-detector.md +359 -0
  27. package/kit/agents/storytelling-analyst.md +309 -0
  28. package/kit/agents/supabase-architect.md +49 -0
  29. package/kit/agents/supabase-edge-fn-writer.md +114 -0
  30. package/kit/agents/supabase-migration-writer.md +80 -0
  31. package/kit/agents/supabase-storage-implementer.md +156 -0
  32. package/kit/agents/toil-auditor.md +277 -0
  33. package/kit/agents/verifier.md +30 -0
  34. package/kit/commands/auditar-cascading.md +111 -0
  35. package/kit/commands/auditar-marco.md +124 -1
  36. package/kit/commands/auditar-observabilidade-cobertura.md +183 -0
  37. package/kit/commands/auditar-refactor.md +219 -0
  38. package/kit/commands/auditar-release.md +109 -0
  39. package/kit/commands/auditar-toil.md +129 -0
  40. package/kit/commands/capturar-payloads.md +193 -0
  41. package/kit/commands/caracterizar-prompt.md +195 -0
  42. package/kit/commands/caracterizar.md +212 -0
  43. package/kit/commands/concluir-marco.md +95 -1
  44. package/kit/commands/detectar-duplicacao.md +197 -0
  45. package/kit/commands/discutir-fase.md +41 -0
  46. package/kit/commands/encontrar-seams.md +136 -0
  47. package/kit/commands/forense.md +103 -1
  48. package/kit/commands/golden-signals.md +142 -0
  49. package/kit/commands/legacy.md +263 -0
  50. package/kit/commands/load-shedding.md +117 -0
  51. package/kit/commands/observabilidade.md +2 -0
  52. package/kit/commands/postmortem.md +179 -0
  53. package/kit/commands/prr.md +205 -0
  54. package/kit/commands/refactor-seguro.md +321 -0
  55. package/kit/commands/risk-budget.md +220 -0
  56. package/kit/commands/sre.md +230 -0
  57. package/kit/commands/storytelling.md +179 -0
  58. package/kit/skills/_shared-legacy/glossary.md +389 -0
  59. package/kit/skills/_shared-sre/glossary.md +712 -0
  60. package/kit/skills/ai-prompt-characterization/SKILL.md +335 -0
  61. package/kit/skills/blameless-postmortems/SKILL.md +340 -0
  62. package/kit/skills/cascading-failures/SKILL.md +307 -0
  63. package/kit/skills/eliminating-toil/SKILL.md +243 -0
  64. package/kit/skills/event-based-slos/SKILL.md +22 -0
  65. package/kit/skills/four-golden-signals/SKILL.md +314 -0
  66. package/kit/skills/hermetic-builds/SKILL.md +323 -0
  67. package/kit/skills/legacy-api-only-applications/SKILL.md +358 -0
  68. package/kit/skills/legacy-characterization-tests/SKILL.md +330 -0
  69. package/kit/skills/legacy-effect-analysis/SKILL.md +331 -0
  70. package/kit/skills/legacy-extract-class/SKILL.md +203 -0
  71. package/kit/skills/legacy-monster-methods/SKILL.md +444 -0
  72. package/kit/skills/legacy-programming-by-difference/SKILL.md +252 -0
  73. package/kit/skills/legacy-seams-and-test-harness/SKILL.md +460 -0
  74. package/kit/skills/legacy-shotgun-surgery/SKILL.md +286 -0
  75. package/kit/skills/legacy-sprout-wrap-techniques/SKILL.md +434 -0
  76. package/kit/skills/legacy-storytelling-naked-crc/SKILL.md +270 -0
  77. package/kit/skills/llm-as-dependency/SKILL.md +436 -0
  78. package/kit/skills/load-shedding-graceful-degradation/SKILL.md +396 -0
  79. package/kit/skills/pre-refactor-characterization/SKILL.md +421 -0
  80. package/kit/skills/production-readiness-review/SKILL.md +305 -0
  81. package/kit/skills/release-engineering/SKILL.md +367 -0
  82. package/kit/skills/retry-strategies/SKILL.md +372 -0
  83. package/kit/skills/sre-risk-management/SKILL.md +221 -0
  84. package/package.json +2 -2
@@ -0,0 +1,372 @@
1
+ ---
2
+ name: retry-strategies
3
+ description: Use ao implementar retry — full/equal/decorrelated jitter, exponential backoff cap, retry budget, idempotency keys, when NOT to retry. Cap 22 livro Google SRE.
4
+ ---
5
+
6
+ # SRE — Retry Strategies
7
+
8
+ ## Quando usar
9
+
10
+ LLM carrega esta skill ao escrever código que chama dep externa e precisa lidar com failure transient. Trigger phrases:
11
+
12
+ - "retry", "exponential backoff"
13
+ - "jitter", "thundering herd"
14
+ - "retry budget"
15
+ - "idempotency key", "safe to retry?"
16
+ - "quando NÃO retentar?"
17
+ - "retry storm"
18
+
19
+ ## Regras absolutas
20
+
21
+ - **Retry SEM jitter = retry storm garantido.** Sempre adicione jitter (full por default).
22
+ - **Retry SEM deadline = work zumbi.** Cada retry respeita deadline propagation; após deadline aborta.
23
+ - **Retry SOMENTE em erros retentáveis.** 5xx, timeout, connection reset = retry. 4xx (validation, auth, not_found) = NÃO retry.
24
+ - **Idempotency key OBRIGATÓRIA em retry de write operation.** Sem idempotency, retry pode duplicar (charge double, send email twice, etc.).
25
+ - **Retry budget global limita amplificação.** Sem budget, retry total = N clients × M retries × cascading.
26
+ - **Max retries ≤ 3-5.** Mais que isso = bug não-transient mascarado.
27
+ - **Backoff cap obrigatório.** Sem cap, último retry pode ser horas. `min(base × 2^attempt, cap)`.
28
+ - **Não retry em rate limit a menos que respeite Retry-After.** 429 sem header → wait default; com header → respeita.
29
+
30
+ ## Patterns canônicos
31
+
32
+ ### Pattern 1: Tipos de jitter (cap 22)
33
+
34
+ ```ts
35
+ // Full jitter — DEFAULT canônico (Google SRE recomenda)
36
+ function fullJitter(baseMs: number, attempt: number, capMs = 30000): number {
37
+ const expBase = Math.min(baseMs * Math.pow(2, attempt), capMs)
38
+ return Math.random() * expBase // [0, expBase)
39
+ }
40
+
41
+ // Equal jitter — variação; metade fixa, metade jitter
42
+ function equalJitter(baseMs: number, attempt: number, capMs = 30000): number {
43
+ const expBase = Math.min(baseMs * Math.pow(2, attempt), capMs)
44
+ return expBase / 2 + Math.random() * (expBase / 2)
45
+ }
46
+
47
+ // Decorrelated jitter — para bursty load (AWS recomenda)
48
+ function decorrelatedJitter(baseMs: number, lastDelayMs: number, capMs = 30000): number {
49
+ return Math.min(capMs, Math.random() * (lastDelayMs * 3 - baseMs) + baseMs)
50
+ }
51
+
52
+ // Comparação:
53
+ // FULL JITTER: spread máximo, simples, default canônico
54
+ // EQUAL JITTER: spread parcial, predictable mínimo
55
+ // DECORRELATED: spread depende do último; melhor pra long outages
56
+ ```
57
+
58
+ ### Pattern 2: Retry com deadline propagation
59
+
60
+ ```ts
61
+ async function callWithRetry<T>(
62
+ call: () => Promise<T>,
63
+ opts: {
64
+ maxRetries: number
65
+ baseMs: number
66
+ capMs?: number
67
+ deadlineMs: number // unix ms; retry só se ainda há tempo
68
+ isRetryable?: (e: Error) => boolean
69
+ retryBudget?: RetryBudget
70
+ }
71
+ ): Promise<T> {
72
+ const startMs = performance.now()
73
+ let lastError: Error | undefined
74
+
75
+ for (let attempt = 0; attempt <= opts.maxRetries; attempt++) {
76
+ // Check deadline antes de cada attempt
77
+ if (Date.now() > opts.deadlineMs) {
78
+ throw new DeadlineExceededError(lastError)
79
+ }
80
+
81
+ try {
82
+ return await call()
83
+ } catch (e) {
84
+ lastError = e as Error
85
+
86
+ // Não-retentável → throw imediato
87
+ if (opts.isRetryable && !opts.isRetryable(lastError)) throw lastError
88
+
89
+ // Retry budget global
90
+ if (opts.retryBudget && !opts.retryBudget.tryAcquire()) {
91
+ throw new RetryBudgetExhaustedError(lastError)
92
+ }
93
+
94
+ // Last attempt — não delay
95
+ if (attempt >= opts.maxRetries) throw lastError
96
+
97
+ // Calcula delay com full jitter
98
+ const delayMs = fullJitter(opts.baseMs, attempt, opts.capMs)
99
+
100
+ // Não exceder deadline
101
+ const remainingMs = opts.deadlineMs - Date.now()
102
+ if (delayMs >= remainingMs) {
103
+ throw new DeadlineExceededError(lastError)
104
+ }
105
+
106
+ await sleep(delayMs)
107
+ }
108
+ }
109
+ throw lastError!
110
+ }
111
+ ```
112
+
113
+ ### Pattern 3: When NOT to retry — decision tree
114
+
115
+ ```text
116
+ Erro recebido. Retry?
117
+
118
+ 1. HTTP status 4xx (excluding 408, 429)?
119
+ → NÃO retry. Validation/auth/not_found.
120
+ 400, 401, 403, 404, 422 → throw imediato.
121
+
122
+ 2. HTTP status 408 (Request Timeout)?
123
+ → SIM retry. Servidor pediu (request expirou no servidor).
124
+
125
+ 3. HTTP status 429 (Too Many Requests)?
126
+ → SIM retry, COM Retry-After header se presente.
127
+ Sem Retry-After → backoff default + retry budget.
128
+
129
+ 4. HTTP status 5xx?
130
+ → SIM retry. Server error transient.
131
+
132
+ 5. Network error (connection reset, DNS failure)?
133
+ → SIM retry. Network transient.
134
+
135
+ 6. Timeout local (AbortSignal.timeout estourou)?
136
+ → SIM retry, mas check deadline global.
137
+
138
+ 7. Custom error (validation interna, business rule)?
139
+ → NÃO retry. Bug; retry não resolve.
140
+
141
+ 8. OperationCancelled (deadline upstream)?
142
+ → NÃO retry. Caller já desistiu.
143
+ ```
144
+
145
+ ```ts
146
+ function isRetryable(e: any): boolean {
147
+ // 4xx geralmente não retry
148
+ if (e.statusCode >= 400 && e.statusCode < 500) {
149
+ if (e.statusCode === 408) return true
150
+ if (e.statusCode === 429) return true
151
+ return false
152
+ }
153
+
154
+ // 5xx retry
155
+ if (e.statusCode >= 500 && e.statusCode < 600) return true
156
+
157
+ // Network errors
158
+ if (e.code === 'ECONNRESET' || e.code === 'ETIMEDOUT' || e.code === 'EAI_AGAIN') return true
159
+
160
+ // Aborts não retry (caller desistiu)
161
+ if (e.name === 'AbortError' || e instanceof DeadlineExceededError) return false
162
+
163
+ // Default: não retry
164
+ return false
165
+ }
166
+ ```
167
+
168
+ ### Pattern 4: Idempotency key em writes
169
+
170
+ ```ts
171
+ // PT-BR: idempotency key permite retry seguro de writes
172
+ import { randomUUID } from 'crypto'
173
+
174
+ interface CreateOrderInput {
175
+ customerId: string
176
+ items: OrderItem[]
177
+ idempotencyKey?: string // gerado se não fornecido
178
+ }
179
+
180
+ async function createOrderSafe(client: PaymentClient, input: CreateOrderInput): Promise<Order> {
181
+ const key = input.idempotencyKey ?? randomUUID()
182
+
183
+ return callWithRetry(
184
+ () => client.createOrder({ ...input, idempotencyKey: key }), // ← SAME KEY em retry
185
+ {
186
+ maxRetries: 3,
187
+ baseMs: 500,
188
+ capMs: 30000,
189
+ deadlineMs: Date.now() + 30000,
190
+ isRetryable,
191
+ }
192
+ )
193
+ }
194
+
195
+ // Server-side
196
+ async function createOrderHandler(input: CreateOrderInput): Promise<Order> {
197
+ // Check se já processamos esta key
198
+ const existing = await db.findByIdempotencyKey(input.idempotencyKey)
199
+ if (existing) return existing // retorna mesmo result; safe to retry
200
+
201
+ // Process; record com idempotency_key (UNIQUE constraint)
202
+ return await db.transaction(async (tx) => {
203
+ const order = await tx.orders.insert({
204
+ ...input,
205
+ idempotency_key: input.idempotencyKey, // UNIQUE constraint catches duplicate
206
+ created_at: new Date(),
207
+ })
208
+ return order
209
+ })
210
+ }
211
+ ```
212
+
213
+ **Anti-corruption:** idempotency keys SEMPRE em writes. Stripe, AWS S3, todos suportam. Se sua API não suporta, adicione (1 column UNIQUE).
214
+
215
+ ### Pattern 5: Retry budget (cap 22)
216
+
217
+ ```ts
218
+ // PT-BR: retry budget global limita amplificação
219
+ class RetryBudget {
220
+ private tokens: number
221
+ private readonly maxTokens: number
222
+ private readonly refillRate: number // tokens per second
223
+ private lastRefillMs: number
224
+
225
+ constructor(opts: { maxTokens: number; refillPerSec: number }) {
226
+ this.tokens = opts.maxTokens
227
+ this.maxTokens = opts.maxTokens
228
+ this.refillRate = opts.refillPerSec
229
+ this.lastRefillMs = Date.now()
230
+ }
231
+
232
+ tryAcquire(): boolean {
233
+ this.refill()
234
+ if (this.tokens < 1) return false
235
+ this.tokens--
236
+ return true
237
+ }
238
+
239
+ private refill(): void {
240
+ const now = Date.now()
241
+ const elapsed = (now - this.lastRefillMs) / 1000
242
+ const refill = elapsed * this.refillRate
243
+ this.tokens = Math.min(this.maxTokens, this.tokens + refill)
244
+ this.lastRefillMs = now
245
+ }
246
+ }
247
+
248
+ // Configuração canônica:
249
+ // - maxTokens = 10% da capacidade normal de calls/sec
250
+ // - refillPerSec = mesmo
251
+ // Se sua dep aguenta 1000 RPS, retry budget = 100 RPS de retries.
252
+ // Excede = circuit breaker abre OR caller falha rápido.
253
+
254
+ const retryBudget = new RetryBudget({ maxTokens: 100, refillPerSec: 100 })
255
+ ```
256
+
257
+ ### Pattern 6: Configuração canônica por tipo de call
258
+
259
+ | Tipo de call | Max retries | Base | Cap | Jitter |
260
+ |---|---|---|---|---|
261
+ | **Read DB query** | 3 | 50ms | 1000ms | full |
262
+ | **Write DB transaction** | 3 (com idempotency key) | 100ms | 5000ms | full |
263
+ | **HTTP API third-party** | 3 | 500ms | 30000ms | full |
264
+ | **Webhook delivery** | 5 | 1000ms | 60000ms | decorrelated |
265
+ | **Background job** | 5+ | 5000ms | 600000ms (10min) | decorrelated |
266
+ | **Real-time message** | 0-1 | — | — | — (deadline tight) |
267
+
268
+ ### Pattern 7: Observability de retry
269
+
270
+ Métricas a instrumentar:
271
+
272
+ ```ts
273
+ // Counter de retries por (dep, attempt)
274
+ metrics.counter('retries_total', { dep: 'stripe', attempt: '1' }) // attempt 1, 2, 3
275
+
276
+ // Counter de outcomes finais
277
+ metrics.counter('retry_outcomes_total', { dep: 'stripe', outcome: 'success_after_retry' })
278
+ metrics.counter('retry_outcomes_total', { dep: 'stripe', outcome: 'exhausted_max' })
279
+ metrics.counter('retry_outcomes_total', { dep: 'stripe', outcome: 'budget_exhausted' })
280
+ metrics.counter('retry_outcomes_total', { dep: 'stripe', outcome: 'deadline_exceeded' })
281
+
282
+ // Histogram de delay total adicionado por retry
283
+ metrics.histogram('retry_delay_added_ms', delayMs, { dep: 'stripe' })
284
+ ```
285
+
286
+ Alertas:
287
+ - `rate(retries_total) > 10% × rate(requests_total)` → dep degradada; investigate
288
+ - `retry_outcomes{outcome="budget_exhausted"} > 0` → sistema sob storm; load shedding pode ajudar
289
+ - `histogram retry_delay_added_ms > p99 baseline × 5` → delays inflados; deps lentas
290
+
291
+ ## Anti-patterns
292
+
293
+ ### ANTI: retry sem jitter
294
+
295
+ ```text
296
+ ANTI: setTimeout(call, 1000 * 2^attempt) — fixed exponential.
297
+
298
+ PROBLEMA: 1000 clients sincroniza retries. Storm na recovery.
299
+
300
+ CERTO: Math.random() * 1000 * 2^attempt — full jitter.
301
+ ```
302
+
303
+ ### ANTI: retry em 4xx
304
+
305
+ ```text
306
+ ANTI: catch (e) { return retry(call) } sem checar status.
307
+
308
+ PROBLEMA: 400/422/404 retentado infinitamente. Bug não corrige sozinho.
309
+
310
+ CERTO: isRetryable(e) check antes de retry. 4xx (excluding 408, 429)
311
+ throw imediato.
312
+ ```
313
+
314
+ ### ANTI: retry sem deadline
315
+
316
+ ```text
317
+ ANTI: retry com max=5, base=1s. Worst case: 1+2+4+8+16=31s de delays.
318
+ Plus call time. Cliente já desistiu.
319
+
320
+ PROBLEMA: work zumbi. Recursos consumidos sem benefit.
321
+
322
+ CERTO: deadline propagation. Cada attempt checa Date.now() vs deadline.
323
+ Aborta cedo.
324
+ ```
325
+
326
+ ### ANTI: idempotency key per-attempt
327
+
328
+ ```text
329
+ ANTI: retry gera NEW idempotency key cada attempt.
330
+
331
+ PROBLEMA: cada attempt vira write distinta. Charge double, email
332
+ duplicado.
333
+
334
+ CERTO: idempotency key gerada UMA vez por call lógica. Mesma key
335
+ em todos os attempts.
336
+ ```
337
+
338
+ ### ANTI: max retries muito alto
339
+
340
+ ```text
341
+ ANTI: maxRetries = 20.
342
+
343
+ PROBLEMA: bug não-transient mascarado. Erro real demora pra aparecer.
344
+ Logs de retry inundam observability.
345
+
346
+ CERTO: max 3-5. Mais que isso = error real, não transient. Falha
347
+ rápido + alert > retry esperançoso.
348
+ ```
349
+
350
+ ## Verificação
351
+
352
+ 1. Toda retry tem jitter (full por default)
353
+ 2. Toda retry respeita deadline propagation
354
+ 3. isRetryable() check em cada attempt
355
+ 4. Idempotency key em writes
356
+ 5. Retry budget global ativo
357
+ 6. Max retries ≤ 5
358
+ 7. Backoff cap ≤ 60s para user-facing
359
+ 8. Métricas instrumentadas (counter retries, outcome, histogram delay)
360
+
361
+ ---
362
+
363
+ ## Ver também
364
+
365
+ - [`_shared-sre/glossary.md`](../_shared-sre/glossary.md) — vocabulário (jitter types, retry storm, etc.)
366
+ - [`cascading-failures`](../cascading-failures/SKILL.md) (v1.11) — retry sem jitter é trigger principal de cascade
367
+ - [`load-shedding-graceful-degradation`](../load-shedding-graceful-degradation/SKILL.md) (v1.11) — server-side coopera (503 + Retry-After)
368
+ - [`four-golden-signals`](../four-golden-signals/SKILL.md) (v1.10) — métricas de retry instrumentadas seguindo padrão
369
+ - [`supabase-edge-fn-writer`](../../agents/supabase-edge-fn-writer.md) (v1.8 + patch v1.11) — Edge Functions ganham retry-with-jitter built-in
370
+ - [`cascading-failures-auditor`](../../agents/cascading-failures-auditor.md) (v1.11) — agent detecta retry sem jitter
371
+
372
+ *Material-fonte: Site Reliability Engineering — Beyer/Jones/Petoff/Murphy (Google/O'Reilly, 2016) — Cap 22 (subsections sobre retry, jitter, deadline propagation).*
@@ -0,0 +1,221 @@
1
+ ---
2
+ name: sre-risk-management
3
+ description: Use ao escolher SLO target — risk continuum, error budget como balanço explícito risk × innovation, "as reliable as needs to be, no more", sabedoria 99.99%.
4
+ ---
5
+
6
+ # SRE — Risk Management
7
+
8
+ ## Quando usar
9
+
10
+ LLM carrega esta skill ao definir SLO target, debater "qual disponibilidade precisamos?", ou justificar trade-off entre velocidade de release e estabilidade. Trigger phrases:
11
+
12
+ - "SLO target", "qual disponibilidade?"
13
+ - "99.9% vs 99.99%", "quantos noves?"
14
+ - "error budget", "risk budget"
15
+ - "risk continuum"
16
+ - "as reliable as needs to be"
17
+ - "sabedoria 99.99%", "smartphone dilui SLO"
18
+ - "embracing risk", "Google SRE cap 3"
19
+
20
+ ## Regras absolutas
21
+
22
+ - **100% disponibilidade NÃO é o objetivo** — custo cresce não-linearmente acima de 99.95%; benefício marginal cai a zero porque outros componentes (ISP do usuário, smartphone, ar do ambiente) já têm < 99.99% de disponibilidade. Esforço além disso é desperdício.
23
+ - **"As reliable as needs to be, no more"** — disponibilidade é decisão de produto, não de engenharia. Pergunta: "qual nível o usuário percebe como aceitável e está disposto a pagar?" — não "qual o máximo que conseguimos?".
24
+ - **Sabedoria 99.99%** — smartphone tem ~99% de disponibilidade (sinal cai, bateria acaba, app trava). Usuário em 99% smartphone NÃO distingue serviço 99.99% vs 99.999% — ambos parecem "sempre funcionando" no contexto dele.
25
+ - **Error budget é balanço explícito risk × innovation** — `(1 - SLO_target) × total_events` é orçamento de "bad" que pode ser gasto em deploys arriscados, experimentos, refactors. Se budget esgota, freeze releases até regenerar.
26
+ - **Target ≤ 99.95% para SLO real** — 99.99% = 4.3 min de tolerância em 30d; sem tempo de reagir antes do budget esgotar; alerts viram zero-level. Para 99.99%+, use métricas/dashboards informativos, NÃO SLO acionável.
27
+ - **SLI deve refletir customer perception** — meça o que o usuário sente ("checkout completou em < 800ms"), não estado interno ("threads ativas"). Risk é sobre consequência do customer, não engenharia.
28
+ - **Diferentes tiers, diferentes targets** — `customer.tier='enterprise'` pode ter SLO 99.95%; `tier='free'` pode ter 99.5%. Risk é gradual; tratar todos clientes como tier-1 desperdiça budget.
29
+
30
+ ## Patterns canônicos
31
+
32
+ ### Pattern: risk continuum como decisão explícita
33
+
34
+ | Target | Tolerância 30d | User-perceptible? | Recomendação | Custo relativo |
35
+ |---|---|---|---|---|
36
+ | 99% | 7.2 h | Sim (notável) | Tier free, beta features, internal tools | 1× |
37
+ | 99.5% | 3.6 h | Notável em paths críticos | Tier free de produção | 2× |
38
+ | 99.9% | 43.2 min | Aceitável para maior parte de UX | Tier paid default | 5× |
39
+ | 99.95% | 21.6 min | Quase imperceptível | Tier enterprise / mission-critical | 10× |
40
+ | 99.99% | 4.3 min | Imperceptível em smartphone | Apenas se justificado por user perception (raro) | 50×+ |
41
+ | 99.999% | 26 s | NÃO perceptível | NUNCA para serviço user-facing | 100×+ |
42
+
43
+ Cada nove adicional **multiplica custo** mas **divide benefício marginal**. Cliente final (humano em smartphone com ISP residencial ~99%) tem disponibilidade no canal de comunicação inferior à do seu serviço 99.99%. Essa é a sabedoria 99.99%.
44
+
45
+ ### Pattern: error budget como decisão de release
46
+
47
+ ```yaml
48
+ # PT-BR: SLO documenta target + política de budget
49
+ slo:
50
+ name: checkout_success
51
+ target: 0.999 # 99.9% — escolha explícita no risk continuum
52
+ window: 30d_sliding
53
+
54
+ # PT-BR: política de budget — o que fazer quando queima
55
+ budget_policy:
56
+ green: # > 50% restante
57
+ action: "Releases livres; experimentos OK"
58
+ yellow: # 10-50% restante
59
+ action: "Aumentar canary % menor; review extra de PRs riscados"
60
+ red: # < 10% restante
61
+ action: "Freeze de features; foco em stability; postmortems revisitados"
62
+ exhausted: # 0%
63
+ action: "Freeze total; rollback de releases recentes; SEV1 incident review"
64
+ ```
65
+
66
+ Budget esgotado **não é punição** — é sinal de que o time gastou risk em demais releases arriscadas e precisa pausar para investir em stability. Restaurar budget = entregar trabalho que reduz erro, não pular o reset.
67
+
68
+ ### Pattern: target diferenciado por customer.tier
69
+
70
+ ```sql
71
+ -- PT-BR: SLO compliance por tier — diferentes targets, diferentes alarmes
72
+ select
73
+ customer_tier,
74
+ count(*) as total,
75
+ count(*) filter (where result_success = true and duration_ms < 800) as good,
76
+ count(*) filter (where result_success = true and duration_ms < 800)::float / count(*) as compliance,
77
+ case customer_tier
78
+ when 'enterprise' then 0.9995 -- PT-BR: 99.95% — paga por SLO rigoroso
79
+ when 'pro' then 0.999 -- PT-BR: 99.9%
80
+ when 'free' then 0.995 -- PT-BR: 99.5% — best effort
81
+ end as target,
82
+ case
83
+ when count(*) filter (where result_success = true and duration_ms < 800)::float / count(*) >= (
84
+ case customer_tier
85
+ when 'enterprise' then 0.9995
86
+ when 'pro' then 0.999
87
+ when 'free' then 0.995
88
+ end
89
+ ) then 'IN_BUDGET'
90
+ else 'OUT_OF_BUDGET'
91
+ end as status
92
+ from observability.events
93
+ where service = 'orders-api' and timestamp > now() - interval '30 days'
94
+ group by customer_tier;
95
+ ```
96
+
97
+ ### Pattern: justificar 99.99%+ excepcional
98
+
99
+ ```text
100
+ Para SLO ≥ 99.99%, o time DEVE responder afirmativamente a TODAS as perguntas:
101
+
102
+ 1. User percebe diretamente a falha? (não apenas erro 500 — UX colapsa, dados perdidos)
103
+ Ex: trading platform de high-frequency, controle de fluxo industrial, healthcare critical
104
+
105
+ 2. Custo de outage > 10× custo de engineering p/ atingir target?
106
+ (calcular: 4.3 min outage por mês × revenue/min impactado)
107
+
108
+ 3. Sistema componentes downstream também são ≥ 99.99%?
109
+ (cliente em ISP 99% — investir aqui é desperdício; trocar de ISP/CDN primeiro)
110
+
111
+ 4. Time tem cultura para sustentar (canary obrigatório, rollback < 60s, on-call < 30s page)?
112
+ (sem isso, 99.99% é aspiracional — real será 99.5%)
113
+
114
+ Se QUALQUER resposta = NÃO → use 99.95% ou menos. Justificar em SLO.md comentário inline.
115
+ ```
116
+
117
+ ## Anti-patterns
118
+
119
+ ### ANTI: pursuit of 100% availability
120
+
121
+ ```text
122
+ ANTI: perseguir 100% como meta de disponibilidade — rejeitar qualquer outage como
123
+ falha de engenharia; medir sucesso por "zero downtime"
124
+
125
+ PROBLEMA: custo cresce assintoticamente perto de 100%; benefício marginal cai a zero
126
+ porque downstream (ISP do usuário, smartphone, ar do ambiente) já tem
127
+ < 99.99%; time burns out perseguindo target inalcançável; budget de
128
+ inovação some — toda capacidade vai para reliability sem ganho real.
129
+
130
+ CERTO: aceitar imperfeição como design — error budget existe PARA SER GASTO em
131
+ deploys arriscados, experimentos, refactors. Reliability é trade-off
132
+ contra velocity, não absoluto.
133
+ ```
134
+
135
+ ### ANTI: SLO 99.99% sem justificativa
136
+
137
+ ```text
138
+ ANTI: definir 99.99% como target por default — "queremos o melhor possível";
139
+ copiar número do AWS SLA; impor 99.99% sem checklist de justificação
140
+
141
+ PROBLEMA: 4.3 min de tolerância em 30d é zero margem de manobra; alerts disparam
142
+ após budget esgotar (zero-level — tarde demais para ação preventiva);
143
+ comportamentos perversos (esconder outages para preservar number);
144
+ time-pressure compulsiva; aspiração ≠ realidade — real será 99.5%
145
+ por falta de cultura para sustentar.
146
+
147
+ CERTO: ≤ 99.95% por default; 99.99%+ exige passar checklist de 4 perguntas
148
+ (ver Pattern: justificar 99.99%+ excepcional). Documentar racional em
149
+ SLO.md como comentário inline auditável.
150
+ ```
151
+
152
+ ### ANTI: SLO global "site availability"
153
+
154
+ ```text
155
+ ANTI: 1 SLO genérico "site availability 99.9%" cobrindo tudo — /admin, /api,
156
+ /checkout, /search, /docs com mesmo target
157
+
158
+ PROBLEMA: falha em /admin (uso 1×/dia por staff) não importa para customer;
159
+ falha em /checkout (uso 100×/min com revenue impact) é catastrófico;
160
+ mistura tudo no mesmo budget — alerts confusos, ações vagas; quando
161
+ burn dispara, time não sabe o que priorizar.
162
+
163
+ CERTO: 1 SLO por jornada crítica do user (`checkout_success: 99.9%`,
164
+ `login_success: 99.95%`, `search_p95: 99% < 200ms`); cada um com target
165
+ apropriado ao seu risk; admin/docs SEM SLO formal (só metric informativo).
166
+ ```
167
+
168
+ ### ANTI: budget como score de "performance"
169
+
170
+ ```text
171
+ ANTI: celebrar "atingimos SLO 99.99% este mês!" como vitória; KPIs comparam
172
+ times por % budget intacto; pressão de leadership para subir target
173
+
174
+ PROBLEMA: budget vira métrica de vaidade; budget intacto significa SUBUTILIZAÇÃO
175
+ (não shippamos suficientes deploys arriscados/experimentos); leadership
176
+ pressiona por mais features sem reconhecer trade-off; quando budget
177
+ esgota uma vez, vira "fracasso" — time esconde problemas no próximo mês.
178
+
179
+ CERTO: budget é orçamento — gastá-lo é OK e esperado. KPI é "shippamos N deploys
180
+ de valor sem queimar budget", não "budget alto". Budget esgotado = sinal
181
+ de aprender (quais releases custaram caro?), não punição.
182
+ ```
183
+
184
+ ### ANTI: SLA == SLO
185
+
186
+ ```text
187
+ ANTI: usar SLA do contrato (99.9%) como SLO interno — "se prometemos 99.9% no
188
+ contrato, basta atingir 99.9% internamente"
189
+
190
+ PROBLEMA: 0 margem de segurança entre compromisso comercial e meta interna;
191
+ primeira anomalia operacional quebra contrato; sem buffer para reagir;
192
+ SEV1 vira liability legal; cliente perde confiança no primeiro burn.
193
+
194
+ CERTO: SLO interno mais rígido que SLA externo — fator de margem 5×.
195
+ SLA externo: 99.9% (compromisso ao cliente);
196
+ SLO interno: 99.95% (meta de engenharia com folga para reagir).
197
+ ```
198
+
199
+ ## Verificação
200
+
201
+ Antes de marcar SLO target como decidido:
202
+
203
+ 1. **Target justificado por customer perception** — não "queremos 99.99%" mas "usuário em smartphone percebe falha acima de X%"
204
+ 2. **Target ≤ 99.95%** OU passou checklist de 99.99%+ (ver Pattern: justificar 99.99%+ excepcional)
205
+ 3. **Tier-aware** — diferentes targets para `customer.tier` quando aplicável (enterprise/pro/free)
206
+ 4. **Budget policy documentada** — 4 estados (green/yellow/red/exhausted) com ações claras
207
+ 5. **Owner nomeado** — SLO sem dono = sem ação = sem valor
208
+ 6. **SLI customer-facing** — mede o que cliente sente, não estado interno
209
+ 7. **SLA externo > SLO interno** — margem entre compromisso comercial e meta interna
210
+
211
+ ## Ver também
212
+
213
+ - [`_shared-sre/glossary.md`](../_shared-sre/glossary.md) — termos canônicos risk continuum, error budget, MTTR/MTBF
214
+ - [`event-based-slos`](../event-based-slos/SKILL.md) (v1.9) — definir SLO event-based com sliding window
215
+ - [`burn-rate-alerting`](../burn-rate-alerting/SKILL.md) (v1.9) — alertas predictive sobre error budget
216
+ - [`production-readiness-review`](../production-readiness-review/SKILL.md) — PRR axis "Performance" usa risk continuum
217
+ - [`blameless-postmortems`](../blameless-postmortems/SKILL.md) — postmortem documenta budget consumido
218
+
219
+ ---
220
+
221
+ *Material-fonte: Site Reliability Engineering — Beyer, Jones, Petoff, Murphy (Google/O'Reilly, 2016) — Cap 3: "Embracing Risk".*
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luanpdd/kit-mcp",
3
- "version": "1.9.0",
3
+ "version": "1.11.0",
4
4
  "description": "Generic infrastructure to ship YOUR personal kit of agents/commands/skills as an MCP server, with cross-IDE sync (Claude Code, Cursor, Codex, Gemini, Windsurf, Antigravity, Copilot, Trae).",
5
5
  "type": "module",
6
6
  "bin": {
@@ -51,7 +51,7 @@
51
51
  "@inquirer/prompts": "^8.4.2",
52
52
  "@modelcontextprotocol/sdk": "^1.0.0",
53
53
  "chokidar": "^5.0.0",
54
- "commander": "^12.1.0",
54
+ "commander": "^14.0.3",
55
55
  "open": "^11.0.0",
56
56
  "picocolors": "^1.1.1"
57
57
  }