@luanpdd/kit-mcp 1.7.0 → 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/CHANGELOG.md +101 -0
- package/README.md +39 -1
- package/gates/agent-no-recursive-dispatch.md +48 -0
- package/gates/budget-description.md +68 -0
- package/gates/no-personal-uuid.md +72 -0
- 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 +71 -0
- package/gates/sync-idempotent.md +62 -0
- package/kit/agents/burn-rate-forecaster.md +160 -0
- package/kit/agents/codebase-mapper.md +1 -1
- package/kit/agents/executor.md +17 -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/planner.md +35 -0
- package/kit/agents/project-researcher.md +1 -1
- package/kit/agents/schema-checker.md +4 -4
- package/kit/agents/slo-engineer.md +224 -0
- package/kit/agents/supabase-architect.md +166 -0
- package/kit/agents/supabase-auth-bootstrapper.md +315 -0
- package/kit/agents/supabase-edge-fn-writer.md +207 -0
- package/kit/agents/supabase-migration-writer.md +174 -0
- package/kit/agents/supabase-realtime-implementer.md +275 -0
- package/kit/agents/supabase-rls-writer.md +235 -0
- package/kit/agents/supabase-storage-implementer.md +258 -0
- package/kit/agents/user-profiler.md +1 -1
- package/kit/agents/verifier.md +1 -1
- 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/depurar.md +17 -0
- package/kit/commands/discutir-fase.md +26 -0
- package/kit/commands/fazer.md +15 -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/supabase.md +148 -0
- package/kit/commands/verificar-trabalho.md +26 -0
- package/kit/framework/workflows/discuss-phase.md +19 -0
- package/kit/framework/workflows/plan-phase.md +25 -0
- package/kit/skills/_shared-observability/glossary.md +396 -0
- package/kit/skills/_shared-supabase/glossary.md +180 -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/supabase-auth-ssr/SKILL.md +260 -0
- package/kit/skills/supabase-cron-queues/SKILL.md +266 -0
- package/kit/skills/supabase-database-functions/SKILL.md +247 -0
- package/kit/skills/supabase-declarative-schema/SKILL.md +183 -0
- package/kit/skills/supabase-edge-functions/SKILL.md +242 -0
- package/kit/skills/supabase-migrations/SKILL.md +175 -0
- package/kit/skills/supabase-pgvector-rag/SKILL.md +253 -0
- package/kit/skills/supabase-postgres-style/SKILL.md +138 -0
- package/kit/skills/supabase-realtime/SKILL.md +236 -0
- package/kit/skills/supabase-rls-policies/SKILL.md +185 -0
- package/kit/skills/supabase-storage/SKILL.md +234 -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,180 @@
|
|
|
1
|
+
# Glossário Supabase — Termos, Comandos e Patterns Canônicos
|
|
2
|
+
|
|
3
|
+
> Arquivo de referência compartilhado pelas skills `supabase-*`. **NÃO é skill** — não tem `description:` triggerável; não aparece em `listKit`. Cross-referenciado pelas 11 skills via Markdown link relativo.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## (a) Termos PT-BR ↔ EN
|
|
8
|
+
|
|
9
|
+
### Authorization e Auth
|
|
10
|
+
|
|
11
|
+
| EN | PT-BR / Significado |
|
|
12
|
+
|---|---|
|
|
13
|
+
| **RLS** | Row Level Security — segurança em nível de linha. Filtra automaticamente quais linhas de uma tabela cada usuário vê/modifica baseado em policies. |
|
|
14
|
+
| **policy** | Política de RLS — regra `create policy ... on <table> for <op> ...`. Sempre granular por operação (SELECT/INSERT/UPDATE/DELETE). |
|
|
15
|
+
| **`auth.uid()`** | Função que retorna o UUID do usuário autenticado da sessão atual. **Sempre** usar em `(select auth.uid())` em policies. |
|
|
16
|
+
| **`auth.jwt()`** | Função que retorna o JWT decodificado da sessão. Acesso via `auth.jwt()->'app_metadata'` ou `auth.jwt()->>'aal'`. |
|
|
17
|
+
| **`app_metadata`** | Metadata controlado pelo backend (apenas service_role pode mutar). **Use para roles/permissions** em RLS. |
|
|
18
|
+
| **`user_metadata`** | Metadata controlado pelo cliente (`auth.updateUser({data: ...})`). **NUNCA** use em policy de autorização — privilege escalation. |
|
|
19
|
+
| **service_role** | Role do Postgres com bypass total de RLS. **NUNCA** expor ao cliente — vazamento = acesso total ao DB. |
|
|
20
|
+
| **anon** | Role para requests sem autenticação. RLS aplicado normalmente. |
|
|
21
|
+
| **authenticated** | Role para usuário autenticado. RLS aplicado normalmente. |
|
|
22
|
+
| **public** | Role default — equivale a anon + authenticated juntos. Evite — sempre use `to authenticated` ou `to anon` explícito. |
|
|
23
|
+
| **AAL** | Authentication Assurance Level. `aal1` = senha apenas; `aal2` = senha + 2FA. Verifica via `(auth.jwt()->>'aal')::text`. |
|
|
24
|
+
|
|
25
|
+
### Database e Schema
|
|
26
|
+
|
|
27
|
+
| EN | PT-BR / Significado |
|
|
28
|
+
|---|---|
|
|
29
|
+
| **`schemas/`** | Pasta `supabase/schemas/` — fonte da verdade declarative do schema. Editar aqui, depois `db diff` gera migration. |
|
|
30
|
+
| **`migrations/`** | Pasta `supabase/migrations/` — arquivos `YYYYMMDDHHmmss_<name>.sql` versionados em git. |
|
|
31
|
+
| **`db diff`** | `supabase db diff -f <name>` — gera migration a partir do diff entre schemas/ declarado e DB local atual. |
|
|
32
|
+
| **`db reset`** | `supabase db reset` — recria DB local do zero + reaplica todas as migrations + seeds. |
|
|
33
|
+
| **`search_path`** | Caminho de busca de schema do Postgres. **Sempre** `set search_path = ''` em funções. |
|
|
34
|
+
| **schema-qualified** | Referência a objeto com schema explícito: `public.tasks` em vez de só `tasks`. Obrigatório quando `search_path = ''`. |
|
|
35
|
+
| **`SECURITY INVOKER`** | Função executa com permissões de quem chamou. Default obrigatório. |
|
|
36
|
+
| **`SECURITY DEFINER`** | Função executa com permissões do owner. Apenas com justificativa documentada. |
|
|
37
|
+
| **`IMMUTABLE`** | Função sempre retorna o mesmo para os mesmos inputs (sem consultar DB). |
|
|
38
|
+
| **`STABLE`** | Função consulta DB mas não modifica — mesmo resultado dentro de uma transação. |
|
|
39
|
+
| **`VOLATILE`** | Default. Função pode retornar valores diferentes ou ter side effects. |
|
|
40
|
+
|
|
41
|
+
### Realtime
|
|
42
|
+
|
|
43
|
+
| EN | PT-BR / Significado |
|
|
44
|
+
|---|---|
|
|
45
|
+
| **broadcast** | Mensagens custom via WebSocket — tipo recomendado em 2026 (substitui `postgres_changes` em apps novos). |
|
|
46
|
+
| **postgres_changes** | Pattern legado de receber mudanças do DB via stream. Single-threaded — não escala. **Migrar para broadcast.** |
|
|
47
|
+
| **presence** | Tracking de "quem está online". Usar **com moderação** — só para presence real (online status, cursor de colaboração). |
|
|
48
|
+
| **channel** | Canal de comunicação — naming canônico `scope:entity:id` (ex: `room:123:messages`). |
|
|
49
|
+
| **private channel** | Canal autenticado — `private: true` + RLS sobre `realtime.messages`. **Default em produção.** |
|
|
50
|
+
| **`realtime.broadcast_changes`** | Função SQL para emitir broadcast de dentro do Postgres (de trigger). |
|
|
51
|
+
| **`realtime.send`** | Função SQL para emitir mensagem custom (não amarrada a tabela). |
|
|
52
|
+
|
|
53
|
+
### Edge Functions
|
|
54
|
+
|
|
55
|
+
| EN | PT-BR / Significado |
|
|
56
|
+
|---|---|
|
|
57
|
+
| **Edge Function** | Função serverless Deno hospedada por Supabase. Roda perto do usuário. |
|
|
58
|
+
| **`Deno.serve`** | Built-in para HTTP server em Edge Functions (NÃO usar `serve` de `deno.land/std`). |
|
|
59
|
+
| **`EdgeRuntime.waitUntil`** | Permite tarefa background continuar após response retornar. |
|
|
60
|
+
| **`npm:` / `jsr:`** | Specifiers de import obrigatórios (sem bare specifiers). Ex: `import x from "npm:hono@4.6.7"`. |
|
|
61
|
+
|
|
62
|
+
### Storage e Vector
|
|
63
|
+
|
|
64
|
+
| EN | PT-BR / Significado |
|
|
65
|
+
|---|---|
|
|
66
|
+
| **bucket** | Container de arquivos — público ou privado. Privado por default. |
|
|
67
|
+
| **signed URL** | URL temporária com expiration para download de arquivo privado. |
|
|
68
|
+
| **`storage.objects`** | Tabela onde Storage grava metadados — RLS aplicado aqui controla acesso. |
|
|
69
|
+
| **multi-tenant path isolation** | Pattern: prefixar path do arquivo com `auth.uid()` (`{user_id}/file.png`) para isolar por tenant via RLS. |
|
|
70
|
+
| **TUS** | Tus Resumable Upload protocol — upload em chunks resumable. |
|
|
71
|
+
| **pgvector** | Extensão Postgres para embeddings/similarity search. |
|
|
72
|
+
| **HNSW** | Hierarchical Navigable Small World — index para vector. **Recall melhor.** Default em 2026. |
|
|
73
|
+
| **IVFFlat** | Inverted File Flat — index alternativo. Mais rápido com volumes grandes mas recall menor. |
|
|
74
|
+
| **`<=>`** | Operador cosine distance em pgvector. |
|
|
75
|
+
| **`<#>`** | Operador inner product em pgvector. |
|
|
76
|
+
| **`<->`** | Operador L2 (euclidean) distance em pgvector. |
|
|
77
|
+
|
|
78
|
+
### Background Jobs
|
|
79
|
+
|
|
80
|
+
| EN | PT-BR / Significado |
|
|
81
|
+
|---|---|
|
|
82
|
+
| **`pg_cron`** | Extensão para jobs cron dentro do Postgres. Schedule SQL/funções. |
|
|
83
|
+
| **`pgmq`** | Postgres Message Queue — extensão de queues. Requer Postgres 15.6.1.143+. |
|
|
84
|
+
| **`pg_net`** | Extensão para requests HTTP de dentro do Postgres. v0.10.0+. |
|
|
85
|
+
|
|
86
|
+
### Branching
|
|
87
|
+
|
|
88
|
+
| EN | PT-BR / Significado |
|
|
89
|
+
|---|---|
|
|
90
|
+
| **branch database** | Cópia preview do DB de produção para feature branches. |
|
|
91
|
+
| **persistent branch** | Branch que sobrevive entre PRs (staging long-lived). |
|
|
92
|
+
| **preview branch** | Branch criado para PR específico — destruído ao merge. |
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## (b) Comandos CLI canônicos
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
# Schema declarative
|
|
100
|
+
supabase stop # parar containers (necessário antes de db diff)
|
|
101
|
+
supabase db diff -f <name> # gera migration de schemas/ → migrations/
|
|
102
|
+
supabase db reset # reset local + reaplica migrations + seeds
|
|
103
|
+
supabase db push # aplica migrations não aplicadas no DB remote
|
|
104
|
+
supabase db pull # pulla mudanças remote → cria migration local
|
|
105
|
+
|
|
106
|
+
# Migrations
|
|
107
|
+
supabase migration new <name> # cria migration vazia com timestamp UTC
|
|
108
|
+
|
|
109
|
+
# Edge Functions
|
|
110
|
+
supabase functions new <name> # cria boilerplate de Edge Function
|
|
111
|
+
supabase functions deploy <name> # deploy para Supabase
|
|
112
|
+
supabase functions invoke <name> --body '{}' # invoca localmente
|
|
113
|
+
|
|
114
|
+
# Tipos
|
|
115
|
+
supabase gen types typescript --local > types/db.ts # gera tipos do schema local
|
|
116
|
+
supabase gen types typescript --linked > types/db.ts # gera tipos do remote linked
|
|
117
|
+
|
|
118
|
+
# Project lifecycle
|
|
119
|
+
supabase init # inicializa supabase/ no projeto
|
|
120
|
+
supabase start # sobe stack local (Postgres + Studio + Auth + ...)
|
|
121
|
+
supabase stop # derruba stack local
|
|
122
|
+
supabase status # status dos containers locais
|
|
123
|
+
supabase link --project-ref <ref> # linka projeto local com remote
|
|
124
|
+
|
|
125
|
+
# Branching
|
|
126
|
+
supabase branches create <name> # cria preview branch
|
|
127
|
+
supabase branches list # lista branches
|
|
128
|
+
supabase branches delete <name> # deleta branch (importante para custo!)
|
|
129
|
+
|
|
130
|
+
# Secrets
|
|
131
|
+
supabase secrets set --env-file .env.production # setar secrets em remote
|
|
132
|
+
supabase secrets list # listar (sem revelar valores)
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## (c) Patterns canônicos consolidados
|
|
138
|
+
|
|
139
|
+
### Pattern: `(select auth.uid())` wrapper em RLS
|
|
140
|
+
- Sem `(select)`: degradação até **1000×** em queries com filtro RLS
|
|
141
|
+
- Detalhes: [supabase-rls-policies](../supabase-rls-policies/SKILL.md)
|
|
142
|
+
|
|
143
|
+
### Pattern: `set search_path = ''` em funções
|
|
144
|
+
- Sem isso: vulnerável a hijack de schema via `search_path` manipulation
|
|
145
|
+
- Detalhes: [supabase-database-functions](../supabase-database-functions/SKILL.md)
|
|
146
|
+
|
|
147
|
+
### Pattern: `getAll`/`setAll` cookies em SSR (Next.js)
|
|
148
|
+
- Pacote `@supabase/ssr` — **NUNCA** `@supabase/auth-helpers-nextjs` (deprecated)
|
|
149
|
+
- Detalhes: [supabase-auth-ssr](../supabase-auth-ssr/SKILL.md)
|
|
150
|
+
|
|
151
|
+
### Pattern: `cron → pgmq → Edge Function` (background jobs)
|
|
152
|
+
- Schedule via `pg_cron` → enqueue em `pgmq` → consumir e disparar `pg_net.http_post()` para Edge Function
|
|
153
|
+
- Sem dep externa (Inngest/Trigger.dev) — tudo dentro de Supabase
|
|
154
|
+
- Detalhes: [supabase-cron-queues](../supabase-cron-queues/SKILL.md)
|
|
155
|
+
|
|
156
|
+
### Pattern: RAG with permissions (similarity + RLS)
|
|
157
|
+
- Embeddings em coluna vector + RLS policy filtrando por `user_id` ou `org_id`
|
|
158
|
+
- Sem RLS, qualquer cliente vê embeddings de todos os tenants
|
|
159
|
+
- Detalhes: [supabase-pgvector-rag](../supabase-pgvector-rag/SKILL.md)
|
|
160
|
+
|
|
161
|
+
### Pattern: multi-tenant path isolation em Storage
|
|
162
|
+
- Path do arquivo prefixado com `auth.uid()` ou `org_id`: `{user_id}/avatar.png`, `{org_id}/docs/file.pdf`
|
|
163
|
+
- RLS sobre `storage.objects` valida que o cliente acessa apenas o próprio prefixo
|
|
164
|
+
- Detalhes: [supabase-storage](../supabase-storage/SKILL.md)
|
|
165
|
+
|
|
166
|
+
### Pattern: declarative-first → diff → migration
|
|
167
|
+
- Editar schemas em `supabase/schemas/*.sql`
|
|
168
|
+
- Rodar `supabase stop && supabase db diff -f <name>` para gerar migration em `supabase/migrations/`
|
|
169
|
+
- Revisar migration manualmente antes de aplicar
|
|
170
|
+
- Detalhes: [supabase-declarative-schema](../supabase-declarative-schema/SKILL.md)
|
|
171
|
+
|
|
172
|
+
### Pattern: `private: true` em Realtime channels
|
|
173
|
+
- Default em produção (2026) — desabilita acesso anônimo
|
|
174
|
+
- Requer RLS sobre `realtime.messages` para SELECT (read) e INSERT (write)
|
|
175
|
+
- Detalhes: [supabase-realtime](../supabase-realtime/SKILL.md)
|
|
176
|
+
|
|
177
|
+
### Pattern: schema-qualified em Edge Functions chamando Supabase
|
|
178
|
+
- Function consulta `public.tasks` (não `tasks`) quando usar service-role client
|
|
179
|
+
- Combina com `set search_path = ''` em DB functions chamadas via RPC
|
|
180
|
+
- Detalhes: [supabase-edge-functions](../supabase-edge-functions/SKILL.md)
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: burn-rate-alerting
|
|
3
|
+
description: Use ao calcular burn rate predictive — lookahead/baseline window com fator 4×, context-aware vs short-term, fórmula de extrapolação para alert page vs ticket.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Observabilidade — Burn Rate Alerting
|
|
7
|
+
|
|
8
|
+
## Quando usar
|
|
9
|
+
|
|
10
|
+
LLM carrega esta skill ao configurar alertas SLO ou avaliar burn rate. Trigger phrases:
|
|
11
|
+
|
|
12
|
+
- "burn rate alert", "burn rate forecast"
|
|
13
|
+
- "lookahead window", "baseline window"
|
|
14
|
+
- "predictive vs context-aware"
|
|
15
|
+
- "quando paginar vs quando criar ticket"
|
|
16
|
+
- "extrapolar exhaustão de budget"
|
|
17
|
+
|
|
18
|
+
## Fórmula canônica
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
burn_rate = error_rate / (1 - SLO_target)
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
| Burn rate | Significado |
|
|
25
|
+
|---|---|
|
|
26
|
+
| 1× | Budget durará exatamente a janela do SLO |
|
|
27
|
+
| 2× | Budget acabará em metade da janela |
|
|
28
|
+
| 10× | Budget acabará em 1/10 da janela |
|
|
29
|
+
| 100× | Budget esgotado em horas, não dias |
|
|
30
|
+
|
|
31
|
+
**Predictive forecast (Cap 13 p145):**
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
projected_remaining_at_lookahead = current_remaining - (burn_rate_now × lookahead_window)
|
|
35
|
+
ALERT iff projected_remaining_at_lookahead < 0
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Regras absolutas
|
|
39
|
+
|
|
40
|
+
- **Lookahead ≤ 4× baseline** — extrapolar 4 horas a partir de baseline 1h é confiável; extrapolar 1 dia a partir de 1h é flappy. (Sem ajuste de seasonality)
|
|
41
|
+
- **Sliding window 30d** para o SLO — alinha com customer memory (skill [`event-based-slos`](../skills/event-based-slos/SKILL.md))
|
|
42
|
+
- **2 alertas por SLO** — short-term (page) + long-term (ticket). Não 1 só, não 5+.
|
|
43
|
+
- **Short-term: lookahead 4h, baseline 1h** — paga on-call em horas
|
|
44
|
+
- **Long-term: lookahead 3d, baseline 18h** — abre ticket, não acorda alguém
|
|
45
|
+
- **Context-aware vs short-term** — escolher por trade-off de custo vs sensibilidade. Default short-term para a maioria; context-aware se "10% restante = mais urgente que 90%".
|
|
46
|
+
- **Não alertar zero-level** — se você só alerta quando budget = 0, não há tempo de reagir. Use predictive sempre.
|
|
47
|
+
|
|
48
|
+
## Patterns canônicos
|
|
49
|
+
|
|
50
|
+
### Pattern: 2 alertas canônicos por SLO
|
|
51
|
+
|
|
52
|
+
```yaml
|
|
53
|
+
# PT-BR: para SLO 99.9% checkout_success com window 30d
|
|
54
|
+
slo: checkout_success
|
|
55
|
+
target: 0.999
|
|
56
|
+
window: 30d_sliding
|
|
57
|
+
|
|
58
|
+
alerts:
|
|
59
|
+
# PT-BR: PAGE — paginar on-call (urgent)
|
|
60
|
+
- name: short_term_burn
|
|
61
|
+
type: predictive
|
|
62
|
+
lookahead: 4h # PT-BR: forecast 4h à frente
|
|
63
|
+
baseline: 1h # PT-BR: 4× regra (4h ≤ 4× 1h ✓)
|
|
64
|
+
severity: page
|
|
65
|
+
threshold_burn_rate: 14.4 # PT-BR: 4h × 14.4 = ~58h, esgota budget de 30d×0.001 = 43.2min em <4h
|
|
66
|
+
routing: pagerduty:on-call
|
|
67
|
+
|
|
68
|
+
# PT-BR: TICKET — criar ticket Jira/Linear (não-urgent)
|
|
69
|
+
- name: long_term_burn
|
|
70
|
+
type: predictive
|
|
71
|
+
lookahead: 3d
|
|
72
|
+
baseline: 18h # PT-BR: 4× regra (3d ≤ 4× 18h = 72h ✓)
|
|
73
|
+
severity: ticket
|
|
74
|
+
threshold_burn_rate: 1.0 # PT-BR: 1× = vai esgotar em 30d se continuar
|
|
75
|
+
routing: jira:engineering
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Pattern: query de burn rate atual (Postgres)
|
|
79
|
+
|
|
80
|
+
```sql
|
|
81
|
+
-- PT-BR: burn rate atual em janela baseline (último 1h)
|
|
82
|
+
-- Para SLO 99.9% checkout_success
|
|
83
|
+
with baseline as (
|
|
84
|
+
select
|
|
85
|
+
sum(good) as good,
|
|
86
|
+
sum(bad) as bad,
|
|
87
|
+
sum(total) as total
|
|
88
|
+
from obs.sli_checkout_success
|
|
89
|
+
where bucket > now() - interval '1 hour' -- baseline window
|
|
90
|
+
)
|
|
91
|
+
select
|
|
92
|
+
total,
|
|
93
|
+
bad,
|
|
94
|
+
bad::float / nullif(total, 0) as error_rate,
|
|
95
|
+
(bad::float / nullif(total, 0)) / (1 - 0.999) as burn_rate,
|
|
96
|
+
case
|
|
97
|
+
when bad::float / nullif(total, 0) >= 0.0144 then 'PAGE' -- burn_rate ≥ 14.4
|
|
98
|
+
when bad::float / nullif(total, 0) >= 0.001 then 'TICKET' -- burn_rate ≥ 1
|
|
99
|
+
else 'OK'
|
|
100
|
+
end as alert_status
|
|
101
|
+
from baseline;
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Pattern: predictive forecast — esgotamento
|
|
105
|
+
|
|
106
|
+
```sql
|
|
107
|
+
-- PT-BR: ETA exhaustão do budget em horas
|
|
108
|
+
with current_state as (
|
|
109
|
+
select
|
|
110
|
+
sum(case when bucket > now() - interval '30 days' then bad else 0 end) as bad_30d,
|
|
111
|
+
sum(case when bucket > now() - interval '30 days' then total else 0 end) as total_30d,
|
|
112
|
+
sum(case when bucket > now() - interval '1 hour' then bad else 0 end) as bad_1h,
|
|
113
|
+
sum(case when bucket > now() - interval '1 hour' then total else 0 end) as total_1h
|
|
114
|
+
from obs.sli_checkout_success
|
|
115
|
+
)
|
|
116
|
+
select
|
|
117
|
+
-- PT-BR: budget restante em eventos
|
|
118
|
+
(1 - 0.999) * total_30d - bad_30d as remaining_budget,
|
|
119
|
+
-- PT-BR: taxa atual de queima (eventos/hora)
|
|
120
|
+
bad_1h::float / 1 as burn_per_hour,
|
|
121
|
+
-- PT-BR: ETA = budget restante / taxa
|
|
122
|
+
case
|
|
123
|
+
when bad_1h = 0 then 'NO_BURN'
|
|
124
|
+
else round(((1 - 0.999) * total_30d - bad_30d) / nullif(bad_1h, 0))::text || 'h'
|
|
125
|
+
end as eta_to_exhaustion
|
|
126
|
+
from current_state;
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Pattern: context-aware vs short-term
|
|
130
|
+
|
|
131
|
+
```text
|
|
132
|
+
SHORT-TERM (cheap):
|
|
133
|
+
- Olha apenas baseline window (último 1h)
|
|
134
|
+
- Não considera quanto budget já foi gasto
|
|
135
|
+
- Mais barato; default para maioria
|
|
136
|
+
- Pode causar false positive se budget está cheio (90% restante)
|
|
137
|
+
|
|
138
|
+
CONTEXT-AWARE (expensive):
|
|
139
|
+
- Considera budget remanescente
|
|
140
|
+
- "Remaining budget × tolerable_burn_rate ≥ lookahead × current_burn_rate"
|
|
141
|
+
- Mais caro (query SLO total + recente)
|
|
142
|
+
- Recomendado para SLOs de alto risco onde 10% restante > 90% restante
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Pattern: dashboard de burn rate (Markdown gerado por `/burn-rate-status`)
|
|
146
|
+
|
|
147
|
+
```markdown
|
|
148
|
+
# Burn Rate Status — 2026-05-06 14:32 UTC
|
|
149
|
+
|
|
150
|
+
| SLO | Target | Window | Budget gasto | Burn rate atual | ETA exhaustão | Ação |
|
|
151
|
+
|---|---|---|---|---|---|---|
|
|
152
|
+
| checkout_success | 99.9% | 30d sliding | 23% | 1.4× | 12d | informativo |
|
|
153
|
+
| login_success | 99.95% | 30d sliding | 78% | 8.0× | 4h | **PAGE on-call** |
|
|
154
|
+
| search_latency | 99% | 30d sliding | 15% | 0.7× | — | OK |
|
|
155
|
+
| admin_panel | (sem SLO) | — | — | — | — | — |
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Pattern: tightening alerts gradualmente
|
|
159
|
+
|
|
160
|
+
```text
|
|
161
|
+
SEMANA 1: SLO + alerts em test channel (não real page)
|
|
162
|
+
SEMANA 2: SLO + alerts em low-priority email
|
|
163
|
+
SEMANA 3-4: validar que SLO detecta incidents reais
|
|
164
|
+
SEMANA 5+: alerts SLO viram primários, threshold antigos para test channel
|
|
165
|
+
SEMANA 8+: deletar threshold antigos completamente
|
|
166
|
+
|
|
167
|
+
PT-BR: case study Honeycomb (Cap 12 p135) — SLO detectou outage 8h antes
|
|
168
|
+
de threshold tradicional alertar. Confiança = deletar antigos.
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## Anti-patterns
|
|
172
|
+
|
|
173
|
+
### ANTI: 1 alerta apenas (zero-level)
|
|
174
|
+
|
|
175
|
+
```text
|
|
176
|
+
ANTI: alert dispara quando budget == 0 (totalmente exausto)
|
|
177
|
+
|
|
178
|
+
PROBLEMA: você não tem tempo de reagir. Budget zerou, SLO violado, cliente afetado.
|
|
179
|
+
|
|
180
|
+
CERTO: 2 alertas:
|
|
181
|
+
- Short-term: burn rate 14.4× → page (4h de runway)
|
|
182
|
+
- Long-term: burn rate 1× → ticket (3d de runway)
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### ANTI: lookahead >> baseline
|
|
186
|
+
|
|
187
|
+
```text
|
|
188
|
+
ANTI: lookahead 1d a partir de baseline 1h (24×)
|
|
189
|
+
|
|
190
|
+
PROBLEMA: extrapolação linear de janela curta para janela longa é inválida.
|
|
191
|
+
Ciclos diários, semanais, sazonalidades distorcem.
|
|
192
|
+
Alert flappa (entra/sai a cada hora).
|
|
193
|
+
|
|
194
|
+
CERTO: lookahead ≤ 4× baseline (regra empírica do livro p145)
|
|
195
|
+
Para alertar 1d à frente: baseline ≥ 6h
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### ANTI: burn rate threshold = 1×
|
|
199
|
+
|
|
200
|
+
```text
|
|
201
|
+
ANTI: page on-call quando burn rate >= 1× (igual à taxa que esgota a janela)
|
|
202
|
+
|
|
203
|
+
PROBLEMA: 1× sustained durante 1 mês = budget zerou ao final.
|
|
204
|
+
Time tem 30d para reagir. NÃO é page-worthy.
|
|
205
|
+
|
|
206
|
+
CERTO: page = 14.4× (esgota em 4h, ação imediata)
|
|
207
|
+
ticket = 1× (esgota em 30d, ação planejada)
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### ANTI: burn rate calculation com janela errada
|
|
211
|
+
|
|
212
|
+
```text
|
|
213
|
+
ANTI: calcular burn rate sobre janela inteira de SLO (30d)
|
|
214
|
+
|
|
215
|
+
PROBLEMA: smooth out spikes recentes. Você vê "compliance ok 99.7%" mesmo
|
|
216
|
+
quando última 1h queimou 30% do budget. Reage tarde.
|
|
217
|
+
|
|
218
|
+
CERTO: burn rate sobre baseline window (1h ou 18h), comparado ao SLO inteiro
|
|
219
|
+
para avaliar remaining budget.
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### ANTI: ignorar seasonality
|
|
223
|
+
|
|
224
|
+
```text
|
|
225
|
+
ANTI: alertar 1d à frente sem considerar que sábado tem 1/3 do tráfego
|
|
226
|
+
|
|
227
|
+
PROBLEMA: false positive sexta à noite (sábado vai ser baixo);
|
|
228
|
+
false negative segunda de manhã (sábado foi baixo, segunda explode).
|
|
229
|
+
|
|
230
|
+
CERTO: ou (a) usar baseline window grande o suficiente para capturar 1 ciclo
|
|
231
|
+
(≥ 24h cobre dia/noite; ≥ 7d cobre semana);
|
|
232
|
+
ou (b) modelar seasonality (cíclico) — context-aware burn alerts
|
|
233
|
+
que conhecem padrões.
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
## Verificação
|
|
237
|
+
|
|
238
|
+
Antes de promover burn alerts a produção:
|
|
239
|
+
|
|
240
|
+
1. **2 alertas por SLO** — short-term (page) + long-term (ticket)
|
|
241
|
+
2. **Lookahead ≤ 4× baseline** — verifique aritmética em cada
|
|
242
|
+
3. **Threshold burn rate calculado** — `target=99.9% → page=14.4×, ticket=1×`
|
|
243
|
+
4. **Routing nomeado** — `pagerduty:on-call` ou `jira:engineering`
|
|
244
|
+
5. **Test channel primeiro** — 1+ semana em low-priority antes de promover
|
|
245
|
+
6. **SLO já provou valor** — detectou incident antes de threshold antigo
|
|
246
|
+
7. **Documentação** — runbook de "o que fazer quando alert dispara"
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
## Ver também
|
|
251
|
+
|
|
252
|
+
- `kit/skills/_shared-observability/glossary.md` — burn rate, lookahead/baseline
|
|
253
|
+
- `kit/skills/event-based-slos/SKILL.md` — SLO definition
|
|
254
|
+
- `kit/skills/core-analysis-loop/SKILL.md` — investigar root cause após alert
|
|
255
|
+
- `kit/agents/burn-rate-forecaster.md` — agente que calcula via SQL
|
|
256
|
+
- `kit/commands/burn-rate-status.md` — comando que invoca forecaster
|
|
257
|
+
|
|
258
|
+
*Material-fonte: Observability Engineering (O'Reilly, 2022) — Cap 13: "Acting on and Debugging SLO-Based Alerts".*
|