Dark Gate Flip Readiness
Safely replace a hot computed/derived read with a cheaper persisted-or-SQL projection by shipping it DARK behind a flag, pinned by an automated source-of-truth parity check + a drift invariant + a bounded backfill, then flipping on a canary. Activates when optimizing a slow read path by moving derivation (status, scoring, rollups) into SQL or a persisted column, or any "make the hot read cheaper without changing results" rewrite.
Install this skill
git submodule add https://github.com/modh-labs/playbook.git .playbookOne submodule installs all 17 skills. Reference .playbook/skills/dark-gate-flip-readiness/SKILL.md from your AGENTS.md.
Dark-Gate Flip-Readiness
When you make an expensive read cheaper by changing how a value is computed — moving a TypeScript-derived status into SQL, persisting a projection, caching a rollup — you're trading correctness guarantees for speed. The risk isn't the speedup; it's that the new path silently disagrees with the old one for some rows. This skill is the apparatus that makes such a swap flip-a-flag safe.
When This Skill Activates
- Replacing an O(all-rows) in-memory derivation with a bounded SQL/persisted read.
- Persisting a projection of a rule that used to be computed at read time.
- Any "same results, much faster read" rewrite of a hot path.
The One Question
"If the new path silently disagrees with the old one for one row, what turns red?"
If the answer is "nothing", you're not flip-ready. Build the gates first.
Decision Tree
Rewriting how a hot read computes its result?
├─ Keep the OLD path as the runtime fallback, new path behind a flag (default OFF)
├─ Is the new result provably == the old single source of truth?
│ ├─ NO → build a PARITY check (new ≡ SSOT across N scenarios) — must be green
│ └─ YES → still add a DRIFT INVARIANT (persisted projection vs SSOT, ongoing)
├─ Does the new path read a persisted/backfilled value?
│ └─ YES → bounded (keyset-streamed) BACKFILL reconciler, dry-run first
├─ Flip on ONE canary → verify parity + latency → roll out → retire fallback
Core Rules
- One source of truth, two readers. The old computation stays the SSOT; the fast path must be pinned to it, never a re-implementation that can drift.
- Parity is automated, not eyeballed. A script asserts new-path ≡ SSOT across every branch/scenario (incl. the gnarly edge cases). It runs in CI and must be green before flip.
- Drift is monitored, not assumed. A read-only consistency invariant recomputes the SSOT on a bounded sample and flags any row whose persisted projection disagrees — so post-flip drift pages you instead of corrupting reads.
- Backfill is bounded + idempotent + dry-run-first. Reconcile existing rows
with keyset-paginated streaming (never load the whole table), guard each write
by the current stored value (concurrent-writer safe), dry-run on staging to
report the flip count before
--execute. - Ship dark, flip on a canary. Default-off flag; the unchanged old path is the fallback. Flip one tenant, verify parity + the latency win, then widen.
- Governance if you bend a rule. If the rewrite violates a standing rule (e.g. "no business logic in SQL"), document the scoped exception and name the gates that keep it honest (the parity script + the invariant) — the rule's intent (one testable source) is preserved, not abandoned.
Anti-Patterns
- Re-implementing the derivation in the new path (two sources → guaranteed drift).
- "We tested it once" instead of an enforced parity check.
- Unbounded backfill (
findManythe whole table) — OOM + lock risk; stream by keyset. - Flipping globally on day one instead of a canary.
- Deleting the fallback before the canary proves out.
Audit Checklist
- New path behind a default-off flag; old path intact as fallback.
- Parity script: new ≡ SSOT across all branches; green in CI.
- Drift invariant registered (read-only, bounded sample, recomputes via SSOT).
- Backfill: keyset-streamed, idempotent, guarded writes, dry-run reported.
- Canary flip plan + latency/parity verification before rollout.
- Scoped-exception governance written if a standing rule was bent.
Related Skills
Agent Disk Budget
Keep coding agents from filling a workstation's disk. Sort every agent output into evidence (keep) or scratch (delete when the task ends), enforce it with an age-based purge and a low-disk alert, and measure reclaimed space with df, never du. Activates when a disk is nearly full on a machine running coding agents, when writing a benchmark, build matrix, database restore or recurring automation, when an instruction says "re-run from clean", or when estimating how much a cleanup frees.
Workflow / ProcessAI Engineering Storytelling
Use whenever you finish a non-trivial fix, refactor, audit, or decomposition. Watches the live session for moments where AI-skill discipline produced an outcome that humans would have missed (catching a real bug during an unrelated audit, decomposing a 1300-line file via a documented pattern, composing skills to avoid a band-aid). Captures those moments as ready-to-publish content artifacts: a blog post, a lead magnet outline, social copy, and a video concept.
Workflow / ProcessBackground Job Right Sizing
Choose the LIGHTEST durable mechanism a background/async/side-effect job actually needs, instead of reaching for a full workflow engine by reflex. A four-rung ladder — in-process fire-and-forget → durable queue → workflow engine → dedicated orchestrator — routed by four axes: durability, step count, concurrency shape, and cross-app/bus membership. Activates when adding any background job, emitting a side-effect from a request handler, choosing between Vercel Queues / Workflows / Inngest / Temporal / SQS, or auditing an existing job fleet for over-engineering ("do we still need the orchestrator for this?").
Workflow / Process