diff --git a/skills/engineering/background-work/SKILL.md b/skills/engineering/background-work/SKILL.md index 3a5dc4a..8818e18 100644 --- a/skills/engineering/background-work/SKILL.md +++ b/skills/engineering/background-work/SKILL.md @@ -11,8 +11,8 @@ description: Hard-won rules for writing a service with a background thread, a ch - A **lock** will guard a resource several callers touch. - A service answers requests whose data is built **asynchronously**. - Read this *before* writing the thread — these are the bugs a green, - scenario-driven unit suite does not catch (see rule 13 in - [`../bdd/SKILL.md`](../bdd/SKILL.md)). + scenario-driven unit suite does not catch (see + [`../bdd/SKILL.md`](../bdd/SKILL.md) *"After green"*). ## Core principle **A background thread that dies takes its silence with it.** The process @@ -20,39 +20,39 @@ keeps serving, health keeps answering, and the loop's job silently never happens again. Everything below defends against that one failure shape. ## Before you spawn the thread -- **Parse configuration first (rule 3).** A malformed env var must crash the +- **Parse configuration first.** A malformed env var must crash the *container at startup*, where it is visible — not inside a daemon thread minutes later, after health already said ok. -- **Arm the trigger before the work it observes (rule 8).** Priming a change +- **Arm the trigger before the work it observes.** Priming a change detector *after* a long initial pass absorbs everything that changed during the pass into the baseline — never processed. Fingerprint first, then index; the first check after startup catches the window. ## Inside the loop -- **Nothing may raise (rule 1).** Wrap every pass; log; retry. Treat "first +- **Nothing may raise.** Wrap every pass; log; retry. Treat "first iteration fails because a dependency is still booting" as the *expected* startup path, not an edge case. -- **A retry must not consume the signal that scheduled it (rule 2).** Keep a +- **A retry must not consume the signal that scheduled it.** Keep a `pending` flag that *only a successful pass* clears — otherwise a transient error eats the trigger fire and the change is never processed. ## Locks -- **Never hold a lock across a network (or LLM) round-trip (rule 4).** Scope +- **Never hold a lock across a network (or LLM) round-trip.** Scope the lock to the shared resource itself — per statement, rows materialised before release — so a minutes-long call cannot block a millisecond lookup. State the isolation trade-off in the lock owner's docstring. -- **Put the lock where the resource is, not where the callers are (rule 5).** +- **Put the lock where the resource is, not where the callers are.** `with lock:` copy-pasted into every caller is an invariant enforced by author discipline; the next caller forgets it and no test notices. A guarded wrapper around the resource makes unlocked access *unrepresentable*. ## Cost and surface -- **An always-firing trigger is a busy loop with extra steps (rule 12).** +- **An always-firing trigger is a busy loop with extra steps.** "Fire every interval, let the differ decide" is harmless until the differ is a full content-hash pass holding the shared lock. Check the steady-state cost on a *quiet* system — that's the number that matters. -- **Readiness is part of the API, not just the health endpoint (rule 9).** +- **Readiness is part of the API, not just the health endpoint.** If the service answers before its data exists, "not found" becomes a confident lie. Gate the answering surface on the same status health reports, and keep that vocabulary in one module. @@ -64,8 +64,8 @@ happens again. Everything below defends against that one failure shape. - **Never** answer a query the underlying data can't yet satisfy — gate it. ## See also -- [`../bdd/SKILL.md`](../bdd/SKILL.md) — rule 13: green is necessary, - not sufficient; budget a recall-biased review after the thread is written. +- [`../bdd/SKILL.md`](../bdd/SKILL.md) — green is necessary, not + sufficient; budget a recall-biased review after the thread is written. - [`../review-angles/SKILL.md`](../review-angles/SKILL.md) — EAFP, stale references, readiness — the correctness angles these loops trip over. - [`../diagnose/SKILL.md`](../diagnose/SKILL.md) — when a background loop is diff --git a/skills/engineering/review-angles/SKILL.md b/skills/engineering/review-angles/SKILL.md index 242dbb9..c6f7bfa 100644 --- a/skills/engineering/review-angles/SKILL.md +++ b/skills/engineering/review-angles/SKILL.md @@ -9,7 +9,7 @@ description: A recall-biased correctness checklist for the review pass that runs - A feature is **green** and you want the review pass that finds what tests don't — run after `/bdd`, before calling a phase done. - A `/diagnose` post-mortem, or `/code-review`, wants concrete finder angles. -- **Why this exists (rule 13):** TDD green is *necessary, not sufficient*. +- **Why this exists:** TDD green is *necessary, not sufficient*. Findings live in code with 100% passing, scenario-driven tests, because unit scenarios don't exercise thread death, lock contention, caller ordering, hostile filesystem layouts, or stale stored data. Run each angle @@ -20,37 +20,37 @@ description: A recall-biased correctness checklist for the review pass that runs Each is a question to interrogate the change with. One real finding per angle is worth more than a green suite. -1. **Ordering-sensitive state — derive, don't relay (rule 6).** A return flag +1. **Ordering-sensitive state — derive, don't relay.** A return flag ("rebuilt") reported only by the call that rebuilds is lost the moment a second caller runs first. When consistency matters, cross-check the *artifacts themselves* (sidecar claims a build + graph has zero nodes → sidecar is stale) so no calling order can desync them. -2. **EAFP over check-then-read — TOCTOU (rule 10).** `is_file()` then +2. **EAFP over check-then-read — TOCTOU.** `is_file()` then `read_bytes()` is a crash window against git gc, branch deletes, log rotation. Read and catch the exception; the check just reopens the race. Applies *everywhere another process writes* the same path. -3. **"Is it a directory" is not "is it absent" (rule 11).** `.git` can be a +3. **"Is it a directory" is not "is it absent".** `.git` can be a *file* (worktrees, submodules: a `gitdir:` pointer). Treating an unfamiliar layout as "feature not present" silently selects the degraded path. Resolve the pointer, *then* fall back — and keep the fallback cheap (stat fingerprints, not content hashes). -4. **Write-time validation is a point-in-time fact, not an invariant - (rule 15).** Validating a reference when written says nothing about the +4. **Write-time validation is a point-in-time fact, not an invariant.** + Validating a reference when written says nothing about the world when it is read — anything deletable out from under stored data eventually will be. Every reader of a long-lived reference must own the stale case explicitly: skip, mark, or resolve — never index unguarded. -5. **A file's load path is half its durability contract (rule 16).** Atomic +5. **A file's load path is half its durability contract.** Atomic saves aren't enough. Load must default keys absent from *older* files, raise loudly on corruption (a silent empty-default is worse than a crash — the next save persists the loss), and save must create its directory. Test load against files your current save never writes; the disk remembers every version you shipped. -6. **A stored derived edge is signing up to invalidate it (rule 19).** Moving +6. **A stored derived edge is signing up to invalidate it.** Moving a cross-entity fact from a read-time join to a stored edge looks like cleanup, but a `DETACH DELETE` of a changed entity severs edges pointing *into* it from neighbours that didn't change — staling them silently. diff --git a/skills/engineering/review-angles/refute.md b/skills/engineering/review-angles/refute.md index 8fa60f0..51207bc 100644 --- a/skills/engineering/review-angles/refute.md +++ b/skills/engineering/review-angles/refute.md @@ -28,7 +28,7 @@ uses for keeping vs cutting, pointed at *believing* vs acting. - [`SKILL.md`](SKILL.md) — refute each review-angle candidate before emitting. - [`../winnow/SKILL.md`](../winnow/SKILL.md) — refute "it's redundant" before cutting; the type-checker is one skeptic. -- [`../bdd/SKILL.md`](../bdd/SKILL.md) — rule 13: a green suite is a claim, - not a proof; the post-green pass refutes it. +- [`../bdd/SKILL.md`](../bdd/SKILL.md) — a green suite is a claim, not a + proof; the post-green pass refutes it. - [`../sieve/SKILL.md`](../sieve/SKILL.md) — Good-with-receipts refutes the merely-cosmetic change. diff --git a/skills/engineering/sieve/SKILL.md b/skills/engineering/sieve/SKILL.md index 820355c..52c6a98 100644 --- a/skills/engineering/sieve/SKILL.md +++ b/skills/engineering/sieve/SKILL.md @@ -11,7 +11,7 @@ description: A Socratic gate that decides whether a change earns its place befor - About to **add** — a feature, file, dependency, abstraction, parameter. - About to **prune** — and a deletion is being defended ("but it's clearer"). - A backlog item says "do X properly" — is the current way wrong, or just - cheaper-to-improve? (rule 20) + cheaper-to-improve? ## Core principle **The burden is on keeping, not cutting.** A line does not get to exist by @@ -29,7 +29,7 @@ Each surviving line must pass **all three**: abstraction, a config nobody configures, a flag with one value — fails Real. Before taking on a "do it properly" change, prove the current way is actually *wrong*, not merely improvable — that sets the bar the change - must clear (rule 20). + must clear. 2. **Good** — *Does it leave the code better than you found it — clearer to the next reader, sounder in shape — not merely shorter?* This sieve faces diff --git a/skills/engineering/winnow/SKILL.md b/skills/engineering/winnow/SKILL.md index a600340..b2418d8 100644 --- a/skills/engineering/winnow/SKILL.md +++ b/skills/engineering/winnow/SKILL.md @@ -46,7 +46,7 @@ Close with: `net: - lines possible.` - A retry wrapper around an idempotent local operation. - A manual loop where a built-in (`map`, `sum`, comprehension) applies. -## The brake — prove redundant before you cut (rule 18) +## The brake — prove redundant before you cut A "redundant" idiom may be **load-bearing**. Every `delete`/`shrink` is the claim *"this is redundant"* — refute it before you act