mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-16 03:03:06 +00:00
2 KiB
2 KiB
Referência — escada de guardas determinísticas (passo 4b)
Classificação 1–6 por classe de achado; ledger em docs/GUARDRAILS.md — contrato do passo 4b em ../SKILL.md.
Step 4b — Recurrence prevention (deterministic guards)
A finding is not fully planned until its recurrence prevention is classified. The question for every finding class: "what deterministic mechanism makes this smell impossible — or at least a build failure — next time?" Rank the mechanisms by determinism:
- Type — the bad state becomes unrepresentable (single-source the type/value; a required prop; a schema transform). Strongest: it cannot compile.
- ESLint (
no-restricted-syntax,no-restricted-imports) — per-file, instant feedback. Precedents: theas neverban; thesrc/libboundary. - Convention unit spec (
tests/unit/codebaseConventions.unit.spec.ts, table-driven sweeps ofsrc/tests/scripts) — structural policies. Precedents: vocabulary guard (C13), formActions guard (W4d),campaignJsonMutationRouteguard (B32+),server-onlysweep. - CI static analysis — knip (dead code), madge (cycles). Already at error level.
- Behavioral pin — a unit/int spec locking the contract ("every curated alias resolves in every consumer"; "dossier aggregate === list aggregate").
- Doc/convention — rules files, codebase-map, rejected-with-reason lists. Last resort, and it must say so: judgment-only findings (abstraction-gate calls, bundle trade-offs) live here, declared as such.
Rules:
- If a guard is feasible, it ships in the same delivery as the fix — never as a follow-up. A guard that lands later is a guard that never lands.
- If an existing guard covers the class but is dodgeable, hardening it is its own plan item.
- If only judgment prevents recurrence, register the convention explicitly (rules/codebase-map) and mark the finding "judgment-only" — do not pretend a doc is a guard.
- Prefer one guard per class over N per-instance pins: the guard is what makes the fix the last time the smell is fixed.