Skip to content
This repository was archived by the owner on Nov 16, 2026. It is now read-only.

Latest commit

 

History

History
923 lines (775 loc) · 53.6 KB

LESSONS.md

File metadata and controls

923 lines (775 loc) · 53.6 KB
title colada-db failure log
kind lessons
status active
updated 2026-08-02
owner danny
verified_by N/A — narrative

LESSONS.md — colada-db

Append-only failure log. Every recurring mistake gets encoded so the next agent never makes it again. Strongest-encoding rule: lint > test > skill > LESSONS entry (the entry then explains why the stronger encoding exists).

[2026-08-02] — GitHub silently dropped a workflow trigger, and under required checks that is an unmergeable PR with no error anywhere

Mistake: the first PR opened after main became protected sat at mergeable_state: blocked forever. Six checks are required; zero of them had run. Not failed — never started.

$ gh api "repos/.../actions/runs?branch=docs/agents-post-publish-state"
total: 0

Why it happened: nothing was misconfigured. Actions were enabled, the workflow was active, githubstatus.com reported Actions operational, the triggers were push: branches: ["**"] (which does match branch names containing /) plus an unfiltered pull_request:, there are no paths-ignore filters, and the remote branch head matched the PR head exactly. GitHub simply did not create the run for that push.

The reason this is worth an entry rather than a shrug is what full enforcement does to it. A dropped trigger used to be invisible and harmless — CI was advisory. With enforce_admins: true and six required contexts, a check that is never reported is indistinguishable from one still running: the PR shows "Expected — Waiting for status to be reported", forever. There is no error, no red X, and no log to open, because there is no run. The natural conclusion is "the required-checks setup is broken," and the natural next move is to start dismantling branch protection.

Fix: push again. An empty commit is enough and is the least destructive option:

git commit --allow-empty -m "chore: retrigger CI"
git push origin <branch>

Both the push and pull_request runs appeared within ~15 seconds of the retry, against an unchanged tree. Nothing else was touched.

For future agents: before concluding that branch protection or the workflow is misconfigured, check whether the run exists at all — gh api "repos/OWNER/REPO/actions/runs?branch=BRANCH" --jq .total_count. Zero runs and a failed run are completely different diagnoses that present the same way in the PR UI. Zero means retrigger; do not go edit the required-contexts list, and do not disable protection to "unblock" it.

[2026-08-02] — a scripted prepend is not an append, and no lint covers CHANGELOG.md

Mistake: the ## [Unreleased] section accumulated four separate ### Changed headings, two ### Fixed variants, and an intro paragraph shoved down into the middle of the bullet list. CodeRabbit caught one duplicate on a PR; the real count was worse.

Why it happened: each session's entry was added with

perl -0pi -e 's/(## \[Unreleased\]\n)/$1\n### Changed\n\n- ...\n/' CHANGELOG.md

which re-opens the section at the top every time instead of adding to the existing group of the right type. It looked correct after each individual run — the new bullet was there, in a heading with the right name — and the damage was only visible by reading the whole section at once, which nobody did because each edit was verified in isolation.

Note the family this belongs to. CHANGELOG.md has no lint, no schema and no gate; it is the one file in this repo where "it looked right" is the only check that ever runs. Every other recurring failure logged here is a mechanism that reported success without evaluating the question — this is the same shape with no mechanism at all.

Fix: consolidated to one heading per type in Keep a Changelog order, with the bullet count asserted before and after (15 → 15) and git diff checked for removed prose. .coderabbit.yaml now carries a path_instructions entry for CHANGELOG.md stating the one-heading-per-type rule, so the automated reviewer enforces it on every PR — the strongest encoding available for a file no linter covers.

For future agents: when adding a CHANGELOG entry, read the whole [Unreleased] section first and add the bullet to the existing heading of the right type. Do not script a prepend against the section header. If you do script it, re-read the section afterwards — the verification has to cover the result, not just the insertion.

[2026-08-02] — the same trap, mirrored: a gate that reported FAILURE on a question it never evaluated

Mistake: npm publish --dry-run — the rehearsal you run because the real thing is irreversible — failed on this repo with expected exactly 1 tarball in /tmp/…, found 0. The publish itself was fine.

Why it happened: npm exports npm_config_dry_run=true into the environment of every lifecycle script it runs, including prepublishOnly. That reaches check-pack-manifest.sh, whose nested pnpm pack inherits it, prints the file list it would have produced, and writes nothing. The script then counted zero tarballs and failed — correctly reporting what it saw, about a question it was never actually asked.

Note this repo has now hit this family six times, and this is the first in the safe direction. The other five reported success on an unevaluated question; this one reported failure. The mirror is worth naming, because a false red on the publish rehearsal has its own cost: the natural response is to skip the rehearsal, which is exactly the wrong lesson to learn right before an irreversible act.

Fix: env -u npm_config_dry_run -u NPM_CONFIG_DRY_RUN pnpm pack … in scripts/check-pack-manifest.sh, so the nested pack is always a real pack. Verified both ways: the script now passes with the variable set and without it, and npm publish --dry-run completes.

For future agents: a nested package-manager invocation inherits the outer one's npm_config_* environment, and those flags change behavior silently. If a script shells out to npm/pnpm inside a lifecycle hook, scrub the config it must not inherit — and test the script under the environment the hook actually provides, not the one your shell has.

[2026-08-01] — a mechanism can be built, tested, documented and ADR'd, and still never fire on the default path

Mistake: formatVersion — the persisted format's only escape hatch — was never written to disk by any consumer who didn't call setManifest. That is the default hydration: "all" path, and it is what the README quickstart teaches. Publishing would have put databases into the world carrying no version marker at all, which is ADR-022 line 1: a user pays, on their own disk, with no choice.

Why it happened: every individual piece was correct and had evidence behind it. ADR-018 decided the stamp. CDB_FORMAT_VERSION existed. The boot policy was implemented, and format-version.spec.ts covered absent / equal / higher with real assertions on real durable bytes. Both boot paths already parsed and skipped the index row. What nothing covered was whether the row was ever written outside manifest mode — because every test that asserted the stamp reached it through setManifest, which was also the only thing that set indexDirty. The tests and the feature shared a precondition, so the tests could not see the hole. A code comment even stated the gap as though it were a design choice: "any DB with no manifests (hence no index row), legitimately carry no version."

Fix: the row is stamped on the first flush that persists anything (src/persist.ts), plus four tests in src/format-version.spec.ts — including a negative control asserting a coordinator that persists nothing still writes nothing, so the suite cannot pass by simply always finding a row. Reverted the fix and watched 3 of 4 go red before trusting them.

For future agents: when a feature has a write side and a read side, test them against each other and ask "what reaches this on the path the README teaches?" — a test that reaches a mechanism through the same API that enables it is measuring the mechanism, not its coverage. Read the default path explicitly; it is the one no test author is forced to think about.

[2026-07-31] — a webServer with reuseExistingServer: true on a fixed port will happily test a STRANGER'S dev server

Mistake: the first run of the L4 browser lane (DAN-652) failed with six identical 30-second timeouts waiting for the fixture to boot. The fixture was fine. Port 5180 was already held by an unrelated project's dev server on this machine, and Playwright's reuseExistingServer: true attached to it — so the suite loaded a Sui testnet oracle app and waited for colada-db's fixture to appear on it.

Why it happened: Playwright's reuse check is "is anything listening on this URL". It cannot tell our fixture from any other program, and a dev machine runs several. The config asked a question that has no honest answer.

Fix: reuseExistingServer: false in playwright.config.ts, plus strictPort: true on the fixture's vite config, so a busy port is a loud startup failure instead of a silent misdirection. The specs also keep a fixture handshake — each waits for window.__cdb, a symbol only our page defines — which is what turned this into a visible failure rather than a green run against the wrong application.

For future agents: never let a test suite reuse a server it cannot identify; bind the port strictly and make the page prove it is yours before you assert anything about it.

[2026-07-23] — Node package SELF-REFERENCE resolves import("your-pkg") to the workspace, so a consumer smoke test that lives inside the package never opens the tarball

Mistake: the DAN-658 engines-floor CI job exists for exactly one purpose — prove the packed tarball installs and runs on Node 18, the version engines.node promises. It did this:

mkdir -p "$RUNNER_TEMP/floor" && cd "$RUNNER_TEMP/floor"
npm init -y
npm install "$RUNNER_TEMP"/colada-db-*.tgz "@vue/reactivity@$VUE_RANGE"
node "$GITHUB_WORKSPACE/scripts/smoke-consumer.mjs"    # ← the bug

The script does await import("colada-db"). Node's package self-reference rule resolves a bare specifier for a package's own name through the nearest enclosing package.json's exports map — based on the importing file's location, not the process's working directory, and without consulting any node_modules. scripts/smoke-consumer.mjs lives inside the colada-db package, so import("colada-db") loaded $GITHUB_WORKSPACE/dist/index.mjs: the local build. The cd into the consumer directory did nothing. The npm install was decorative.

Measured 2026-07-23, all three cases executed:

consumer dir contains script location result
a bare package.json, nothing installed inside the package exit 0 — every assertion green, including "✔ colada-db runs on the claimed engines floor"
a tarball built with files: ["LICENSE","README.md"] (ships no dist) inside the package exit 0
nothing installed copied into the consumer dir exit 1, ERR_MODULE_NOT_FOUND 'colada-db'
the real tarball copied into the consumer dir exit 0
the files-stripped tarball copied into the consumer dir exit 1, ERR_MODULE_NOT_FOUND .../dist/sqlite-worker.mjs

So the one job in the repo whose entire job was to open the tarball never opened it, and had never once executed against input it was supposed to reject.

Why it happened: the author reasoned carefully about the install location — there is a comment explaining why the consumer dir must be outside the workspace, so the repo .npmrc and pnpm's linked layout cannot contaminate the test — and did not consider that the script's location is what determines bare- specifier resolution. Self-reference is a real, spec'd, on-by-default Node feature that most people meet only as a convenience ("import my own package by name in my own tests"). Nothing about it is visible at the call site: the import looks identical whether it resolves to node_modules or to the workspace. And it fails in the flattering direction — it makes a broken artifact look fine.

Fix: the workflow now copies the script into the consumer directory before running it, so the importing file is no longer inside the package:

cp "$GITHUB_WORKSPACE/scripts/smoke-consumer.mjs" ./smoke-consumer.mjs
node ./smoke-consumer.mjs

And because a cp in a YAML file is easy to "simplify" away later, the script itself now fails closed before it asserts anything: it resolves colada-db/package.json via createRequire(import.meta.url) (works on Node 18, unlike import.meta.resolve) and refuses to continue unless the resolved path contains a node_modules segment. Run it in place and it exits 1 with an explanation, instead of silently testing the wrong artifact. dist/sqlite-worker.mjs — the second published entry point, previously ungated entirely — is imported there too.

For future agents: a "consumer" test must be run from a file that is not inside the package. If the importing file lives in the repo, import("your-pkg") is a self-reference and you are testing your working tree, not what you shipped. The general form of this trap is the one this repo has now hit five times in a day — a check that reports success on a question it never evaluated (grep -c exiting 1 on success; ! grep -q no-oping under set -e; a lint reporting clean on a scan that never opened the file; an absence assertion over a zero-byte file; and this). The defense is always the same and it is not code review: make the gate go red on purpose, against a deliberately broken subject, before you believe it went green. For an artifact gate specifically, the cheapest such subject is a tarball with files stripped — build it, install it, and watch the job fail.

[2026-07-23] — set -e is IGNORED for !-negated commands, so ! grep -q ... is a shell assertion that cannot fail

Mistake: the DAN-658 CI workflow cross-checked the publish surface with the obvious spelling of an absence assertion:

set -euo pipefail
! grep -q "pinia-colada-plugin-normalizer" dist/index.d.mts dist/index.mjs
grep -q "process\.env\.NODE_ENV" dist/index.mjs
! grep -q "process\.env?\.NODE_ENV" dist/index.mjs
! grep -q "@vue/reactivity" dist/index.d.mts

Three of those four lines were no-ops. POSIX: "The shell shall not exit if the command that fails ... has its return value inverted with !." set -e is explicitly disabled for !-negated commands, so a ! grep line reads as an assertion and behaves as a comment. Measured on the real artifact: injecting the forbidden plugin branding produced exit 0; injecting process.env?.NODE_ENV — the exact DAN-649 regression the line existed to catch — also produced exit 0. Only the bare (non-negated) grep -q actually gated, and the final ! grep appeared to work purely by accident of being the script's last command, where its status becomes the script's exit code.

Why it happened: the spelling is idiomatic, reads correctly in English, and was carried in verbatim from the ticket. It was never run against a violating artifact — the workflow was observed passing on a clean tree and on a red run where an earlier step failed first, so the cross-check step never once executed against input it was supposed to reject. A gate whose failure path has never executed is not a gate; it is decoration that suppresses suspicion.

Fix: scripts/cross-check-publish-surface.sh — explicit if ... ; then exit 1; fi helpers (assert_absent / assert_present), which have no interaction with set -e whatsoever, plus a self-test that runs both helpers against poisoned fixtures before any real assertion and aborts if either fails to fire. All four invariants were then re-verified by corrupting dist/ four different ways and confirming exit 1 each time.

For future agents: never write ! cmd and expect set -e to catch it — use if cmd; then exit 1; fi. More generally, this is the same family as DAN-657 (grep -c exits 1 on zero matches, so an "expect zero" check reads a PASS as a FAIL): in shell, an assertion's exit code frequently does not mean what it looks like it means. The only reliable defense is the one this repo already applies to its lint rules — make every gate demonstrate that it can FAIL, against a fixture engineered to trip it, before trusting that it passed. Copying an assertion from a ticket, an ADR, or a code review does not transfer that proof; run it red yourself.

[2026-07-23] — an environment guard can be runtime-CORRECT and build-time WRONG, and no semantic test can tell

Mistake: the guard shipped for the process fix was typeof process !== "undefined" && process.env?.NODE_ENV !== "production". It is safe. It never throws. It returns exactly the right boolean in every runtime. All 30 tests written to police it passed — and it silently broke dead-code elimination for literal-substitution definers. @rollup/plugin-replace substitutes the literal member expression process.env.NODE_ENV; a ?. between env and NODE_ENV leaves no literal to find. Measured on the canonical Rollup chain: the branch stopped folding, +1,106 bytes minified / +400 gzipped, and all five internal dev-warning strings leaked into consumers' production bundles. The shipped dist/index.mjs contained process.env?.NODE_ENV 5× and process.env.NODE_ENV 0× — a literal definer had nothing to replace.

Measured blast radius — record it honestly, it is narrower than it first looked. Five real production toolchains were built and grepped during the review, not reasoned about: @rollup/plugin-replace + terser leaked the warning strings; esbuild, Vite 8 app-mode, webpack 5 mode:"production", and Terser global_defs all stripped correctly, because their define is AST-aware and folds the ?. form. So most consumers — including this library's Vite-first audience — were never affected. Do not restate this as "every bundler"; the specific claim that survives measurement is literal/regex substituters break, AST-aware definers cope. (An earlier draft of this entry also named Vite and webpack as victims. They were measured clean. Corrected here rather than left to mislead a future agent — an unverified victim list in a knowledge base is worse than no list, because it gets trusted.)

Why it happened: every test we had was a SEMANTIC test — evaluate the expression, assert the value. process.env?.NODE_ENV and process.env && process.env.NODE_ENV are runtime-identical, so a semantic suite is structurally incapable of distinguishing them. The difference lives one layer down, in what a build tool can see in the source text, and nothing in the repo looked at that layer. The optional chaining also reads like the more careful choice, which is what got it past review.

Fix: the vB shape at all five sites — typeof process !== "undefined" && process.env && process.env.NODE_ENV !== "production" — which strips cleanly under a literal definer AND still tolerates a process shim with no .env (the plain conjunct evaluates falsy instead of throwing). The durable encoding is the strippability pin in src/process-guard.spec.ts: every guard extracted from shipped source must contain the literal substring process.env.NODE_ENV, plus a tree-wide check that nothing optional-chains between process.env and NODE_ENV, plus a positive control proving the detector fires on the broken shape. The lint's suggested-fix message — which had been prescribing the broken shape, steering every future fix into the same hole — now teaches the strippable form and states why in one sentence.

For future agents: when a value only exists because a build tool substitutes it, correctness has TWO axes — what it evaluates to, and what a definer can recognise. Semantic tests only cover the first. If a code shape exists to cooperate with a toolchain, pin the SHAPE, not just the behaviour: assert the literal text a define/replace pass keys on. And write to the strictest definer in the ecosystem, not the smartest — esbuild folds the ?. form happily, which is exactly why measuring against esbuild alone would have concluded "no problem".

Correction to the entry below (append-only, so stated here): it names Deno among the crashing runtimes. That is wrong — Deno 2.7.9 exposes process via Node compatibility (typeof process === "object"), verified 2026-07-23; it never threw, before or after. The real beneficiaries are browsers / CDN / <script type=module>, which WERE observed crashing pre-fix and degrading cleanly post-fix in real Chrome 149.

[2026-07-23] — a lint that tests CONTAINMENT instead of DOMINANCE is worse than no lint

Mistake: no-unguarded-process-env decided a read was safe by asking "does a typeof process check appear ANYWHERE in the left subtree of this &&". It does not follow that the check controlled the read. (typeof window !== "undefined" || typeof process !== "undefined") && process.env… passed the lint, passed the companion regression, and still throws ReferenceError in a real browser realm — executed under node:vm with window present and process genuinely undeclared. Two green gates over code that crashes is strictly worse than no gate: the next author trusts the tick.

Two sibling defects came from the same "close enough" posture. The rule exempted every identifier in a name position, which swallowed globalThis.process — the single most likely workaround, because the rule's OWN error message ("process is a Node global") is what invites it, and it fails identically with a TypeError. And the rule rejected both of this repo's house idioms for ambient globals (the inverted early return in persist.ts, the hoisted boolean in engines/idb.ts) while offering no suppression mechanism at all — so the only escape from a false positive was deleting the rule from package.json.

Why it happened: containment is the easy AST query and dominance is the correct one, and the fixtures written alongside the rule only exercised shapes the author already had in mind. A rule authored and tested by the same pass inherits that pass's blind spots wholesale.

Fix: real dominance — recurse through && only for positive guards and || only for negative ones (the exact dual: a && b truthy proves either conjunct; a || b falsy proves both disjuncts), never through the opposite connective, a ternary, a call, or a parenthesized disjunction. Plus early-exit dominance, same-file const propagation, globalThis/self/window/global member reads, and a mandatory-reason // lint-ok: <rule> — <reason> escape hatch. Every new capability carries a fixture AND a firing proof: the old rule and the new rule were run side by side over 13 shapes, 8 of which the new rule decides DIFFERENTLY.

For future agents: a guard licenses a read only when reaching that read proves the guard held. When writing any static check, state the dominance question explicitly and recurse only through connectives that preserve it. Two further rules earned here: (1) prove each capability by showing the verdict CHANGE — red before, green after — because a capability with no firing proof is not encoded, it is only claimed; (2) give every required gate an auditable escape hatch with a mandatory reason, because a gate that cannot be satisfied gets deleted, and a comment in the diff is reviewable where a package.json edit is not.

[2026-07-23] — a global your toolchain polyfills away is invisible until it reaches the one user who has no toolchain

Mistake: five dev-warning branches read process.env.NODE_ENV bare (matcher-view.ts, engines/sqlite.ts, persist.ts ×3). process is a Node global that does not exist in a browser loading dist/index.mjs from a CDN, in Deno, or in a plain <script type="module">. Every one of those reads sat on a DEGRADATION path — IndexedDB open failure, writeBatch failure, OPFS unavailable, foreign StoreBoundary — so a bundler-less consumer worked perfectly until persistence failed, at which point the graceful fallback threw ReferenceError: process is not defined instead. The crash landed exactly where the recovery code was supposed to run, and only for the framework-free audience the ADR-008 §4/§5 pillars specifically target (DAN-649/A1).

Why it happened: the entire development toolchain hides this defect. Vite/webpack/esbuild statically replace process.env.NODE_ENV at build time, so the identifier is gone before the code ever runs; tests run under Node, where process is real. Every environment the library is developed and tested in provides the global, and the one environment that doesn't is the one nobody was executing. Compounding it, the placement was maximally quiet: the happy path never touches process, so no smoke test, demo, or playground session could surface it — only an actual storage failure in an actual bundler-less page.

Fix: the guard typeof process !== "undefined" && process.env?.NODE_ENV !== "production" at all five sites (it still folds to false under a bundler's static replacement, so dead-code elimination of the warnings survives). The durable encoding is a LINT — no-unguarded-process-env (scripts/no-unguarded-process-env.mjs, wired into pnpm lint), AST-based, which bans any reference to the global process in shipped source unless dominated by a typeof guard, and whose error message states the reason rather than the rule name. Plus src/process-guard.spec.ts (30), which extracts the real guard expressions from source and evaluates them with process bound to undefined — asserting no throw, and (the anti-cheat) that the guard still returns true in Node/bundler dev, so "fix" can never mean "delete the warning". Verified failing pre-fix at both rungs, and the shipped dist/index.mjs was executed with the global deleted across three degradation paths.

For future agents: when a value only exists because a bundler injects it, your tests can never see its absence — the toolchain is the thing hiding the bug. Any ambient global (process, global, __dirname, Buffer, require) referenced in shipped library code needs a typeof guard AND a lint, because the failing runtime is by definition the one you are not running. Assume it doubly when the reference sits on an error path: degradation code is the least-exercised code you ship, so a crash there converts a graceful fallback into a hard failure precisely when the user was already in trouble.

[2026-07-22] — rebuilding an object key-by-key must never use obj[key] = v for __proto__

Mistake: encodeEntityRefs / decodeEntityRefs rebuilt objects with result[key] = value in a loop. When the source carried an OWN enumerable __proto__ key (JSON.parse and structured-clone both produce such keys from persisted data) alongside a sibling EntityRef forcing the rebuild path, the assignment invoked the __proto__ setter on the fresh {} — silently dropping the field AND reassigning the rebuilt object's prototype to the supplied payload (prototype-pollution-adjacent). Symmetric bug in both codecs; undetected because the common no-ref path short-circuits with an identity return and never rebuilds.

Why it happened: result[key] = value reads as an obviously-correct own -property write. It is — for every key EXCEPT __proto__, the one string key that is an accessor on Object.prototype. The hazard only surfaces with attacker-or-persisted data that has an own __proto__ key AND a sibling ref, so ordinary tests (object literals, ref-free data) never hit it.

Fix: assignOwn(target, key, value) — Object.defineProperty with a data descriptor for key === "__proto__", plain assignment otherwise. Regression: src/encode-decode-integrity.spec.ts (M1 cases incl. nested, array, and a constructor/prototype control proving those keys are already safe).

For future agents: any loop that rebuilds a plain object from untrusted or persisted key/value pairs (result[k] = v) is a __proto__ trap — route the assignment through a helper that special-cases __proto__ with Object.defineProperty. constructor/prototype are data properties and need no guard; __proto__ is the sole accessor and the sole hazard.

[2026-07-23] — a rename gate that greps for the retired token trips on tests asserting its absence

Mistake: DAN-654's DoD gate is ! grep -rn "__pcn_ref\|pcn_entities" src/ (prove no wire/disk position still emits the old identifier). The new round-trip test asserted the rename with expect(author).not.toHaveProperty("__pcn_ref") and an explanatory comment — both of which contain the literal retired token, so the gate flagged the test file even though the test is the opposite of a regression (it proves the old key is gone).

Why it happened: a plain grep can't tell an emitting occurrence (a wire constant, a db name) from a negative assertion about that same string. The gate's intent is "no code writes the old name"; a test proving the old name is absent has to name it.

Fix: assert the retired key's absence WITHOUT spelling it — pin the exact key set instead: expect(Object.keys(author).sort()).toEqual(["__cdb_ref", "entityType", "id", "key"]). Same guarantee (no stray heritage key rode along), zero literal occurrences of the retired token.

For future agents: when a rename ticket ships a ! grep "<old>" gate, write the regression's absence-assertions structurally (exact key set, snapshot shape) rather than not.toHaveProperty("<old>") — otherwise the test that proves you did the rename is what fails the gate that checks the rename.

[2026-07-23] — grep -c as a pass/fail gate inverts its exit code exactly when it passes

Mistake: DAN-656's DoD assertion is grep -c "@vue/reactivity" dist/index.d.mts # must be 0. It works — but "0 matches" is grep's failure exit (1). Chained after the other gates with &&, the whole DoD command aborts at the very moment the ticket succeeds, and the run reads as a red build. The inverse trap is worse: grep -c … && echo PASS reports PASS only when the leak IS present.

Why it happened: grep -c prints a count to stdout but still exits on match/no-match semantics, so the human-readable output (0) and the shell's verdict (failure) disagree. A gate whose success condition is "no output" has to either be negated (! grep -q …) or be a script that owns its own exit code.

Fix: encoded a rung up the ladder — scripts/check-public-types.mjs, wired into pnpm build, reads the emitted declarations, prints a specific diagnostic with file:line on a leak, and exits 1 only on violation. pnpm -r build now carries the assertion, so it composes correctly with every other gate and can't be forgotten. It also covers what the one-liner can't: leaks arriving through a different barrel-exported type, in a file nobody edited. Verified by executed negative control in both directions (fires on a reintroduced leak, silent when clean).

For future agents: never put a bare grep/grep -c in a &&-chained DoD command as an absence assertion. Use ! grep -q "<token>" <file> if it must stay a one-liner, and promote it to a script wired into build/test the moment the artifact it checks is a publish surface — the exit code is then yours, and so is the error message.

[2026-07-22] — a Symbol in-memory marker with a plain-string wire key reopens the collision the Symbol closed

Mistake: EntityRef uses a Symbol marker specifically to avoid colliding with user data (Issue #13), but the wire codec serializes it to the plain string key __pcn_ref and the decode guard accepted ANY {__pcn_ref:true, entityType, key}-shaped object as a ref — without requiring id or checking field types. Ordinary persisted data shaped that way (or malformed collisions like entityType:123) hydrated into broken / dangling EntityRefs.

Why it happened: the Symbol's collision-proofness lives only in memory; the moment you cross a JSON/structured-clone boundary you're back to a string key that user data can imitate, and the guard trusted the marker alone.

Fix: validate the FULL ref shape with correct types (entityType/id/key all string) on decode; non-conforming data passes through as plain data. The residual exact-shape-and-type collision is inherent to a string wire marker and is bounded honestly in a code comment rather than papered over.

For future agents: whenever an in-memory Symbol/branded marker is projected to a serializable string key, the decode side must re-validate the FULL structural shape+types — a string marker is a hint, never proof, and the collision the Symbol closed is wide open on the wire.

[2026-07-21] — snapshot-then-bulk-clear is never reentrant-safe when listeners can write

Mistake: clear() drained per-entity remove events (listeners run synchronously inside each emission — the H5 contract invites them to write) and then ran a trailing typeMap.clear() + refCounts.clear(). Any write or retain() a listener made during the drain was applied, evented... and silently erased by the bulk wipe, with no event for the erasure. Every event consumer (live views, history, persistence dirty-sets) permanently diverged from store truth (DAN-620; executed repro in the DAN-606 land gauntlet).

Why it happened: the bulk wipe read as a harmless belt-and-suspenders finish ("the loop already removed everything"). It wasn't redundant — it was a second, unevented mutation path racing everything the listeners did. The tell was already in the codebase: gc() handles the identical problem correctly with per-item refCounts.delete(key) before each evict emission, so drain-time retains survive. clear() just didn't follow its own sibling's pattern.

Fix: ADR-012 (semantics: clear() removes exactly its entry snapshot; reentrant writes survive) + src/clear-reentrancy.spec.ts (10 regression tests, 7 verified failing pre-fix — the strongest available encoding) + this entry.

For future agents: in any drain-that-delivers-events, every mutation must go through the evented per-item path — a trailing bulk .clear() (or any unevented cleanup) after a listener-visible loop is a silent divergence bug by construction; snapshot what you intend to destroy at entry and destroy exactly that, item by item.

[2026-07-21] — a cache-layer event must never cancel a truth-layer correction

Mistake: the persistence subscriber's evict branch dropped any pending save ("the last flushed value stands", ADR-004). After remove→set within one debounce window, that pending save was the ONLY thing correcting a durable row the remove had already invalidated — cancelling it resurrected the pre-remove value on next boot (DAN-621; found by the DAN-620 land gauntlet's adjacent-hole sweep).

Why it happened: the drop clause read as a harmless write-economy ("we'd only re-write what's already durable"). It carried a hidden soundness assumption nobody wrote down: dropping a queued write is valid only while the flushed state it falls back to is a prior confirmed value of a surviving entity. An intervening remove breaks the lineage — the fallback row is then dead state, and the queued write is a correction, not a redundancy. Cancellation-as-optimization in a write-behind pipeline is only safe when the cancelled write is provably redundant with flushed truth under EVERY event interleaving, not just the common one.

Fix: ADR-013 (eviction has no authority over the durability pipeline — evict never mutates the dirty sets; hydration honors the pending-truth overlay) + src/evict-resurrection.spec.ts (9 regression tests, 6 verified failing pre-fix — the strongest available encoding) + this entry.

For future agents: memory-projection events (evict, gc) may never cancel, reorder, or suppress queued confirmed writes — the durability pipeline must stay monotone in confirmed store truth; if an optimization drops a queued write, prove the fallback state is a surviving lineage first, and encode that proof as a test.

[2026-07-21] — an exclusion window keyed to a phase flag is a span bug waiting to happen

Mistake: the persistence subscriber excluded hydration-origin writes via a coordinator phase flag (isHydrating), and boot held that flag across every engine.loadAll()/loadMany() await. The exclusion of ONE write channel (hydration) thereby became the exclusion of ALL writes for the duration of engine I/O — an app set/remove racing boot was applied to memory, evented, and silently dropped from the durability pipeline (DAN-630; flagged by DAN-621's self-review, executed here).

Why it happened: the flag conflated two different claims — "this write IS hydration" (a property of the write) with "hydration is HAPPENING" (a property of time). The temporal claim is only correct while every edit preserves the exact span; boot's span had quietly widened to cover awaits. The tell was in the codebase twice over: hydrateScope scoped the same flag tightly around only its synchronous loop, and hydrateRow already stamped every hydration write origin: "hydration" through the privileged runWith channel — the exact per-event fact the flag was approximating.

Fix: ADR-014 (hydration exclusion by provenance: the subscriber skips exactly origin === "hydration" events; the flag is deleted; debounce/gc timers defer during boot so the ADR-013 overlay stays authoritative) + src/boot-hydration-writes.spec.ts (8 regression tests, 6 verified failing pre-fix — the strongest available encoding) + this entry.

For future agents: when excluding a write CHANNEL from a pipeline, key the exclusion to per-event provenance (origin stamps), never to a coordinator phase flag — any flag held across an await excludes everything that races the await, and the failure is silent by construction. If a phase flag and a provenance stamp both exist for the same concept, the flag is the redundant, drift-prone one: delete it.

[2026-07-21] — a residency-dependent guard is not a mask: eviction is exactly the case it can't cover

Mistake: ADR-015 gave optimistic DELETEs a hydration mask but gave optimistic PUTs none, on the premise "while the optimistic value stays resident, fresh-wins (store.has) blocks hydration." Eviction removes the resident value — so after tx.set(c1,"kept") → evict(c1) mid-tx, a hydrateScope paged the stale pre-tx engine row v1 over the optimistic projection. Worst of all it SURVIVED settlement: commit graduated "kept" to disk while memory kept v1 (DAN-635 flavor A; verified pre-existing at 71fdf82).

Why it happened: the argument "fresh-wins already blocks the put" quietly narrowed "the optimistic projection is protected" to "the optimistic VALUE is in memory." Those differ exactly when the key is evicted — a memory-only event that is a first-class part of this store (ADR-004). A guard that depends on a value being RESIDENT cannot protect the key's projection across an eviction; only a mask keyed to the tx BUFFER (which outlives residency) can. ADR-015 itself flagged the hole and filed it — the lesson is that a "fresh-wins covers this" hand-wave is a residency assumption in disguise, and residency is the one thing eviction breaks.

Fix: ADR-016 (the mask covers any buffered op — buffer.get(key)?.op === "delete" becomes buffer.has(key), so a PUT vetoes hydration of its evicted key just as a DELETE vetoes un-deletion) + src/tx-foreign-interference.spec.ts (5 regression tests, 2 verified failing pre-fix — the strongest available encoding) + this entry. The mask stays mask-first ON PURPOSE: yielding to a foreign confirmed write would diverge at commit (encoded as the flavor-B commit-leg pin), and the residual foreign-write hazard is bounded to the sync-rebase seam (ADR-006 §6).

For future agents: when you protect an optimistic projection, key the protection to the transaction BUFFER, not to the value's presence in memory — a residency check (store.has, fresh-wins) silently stops covering the projection the moment the key is evicted, and eviction is a first-class memory event here. "Fresh-wins already handles it" is a residency assumption; name it and test the evicted case before you rely on it.

[2026-07-21] — a drain before an await hides truth from every observer for the flight

Mistake: flush() drained the dirty sets into local arrays before await engine.writeBatch — correct for the write path, but the dirty sets were ALSO the pending-truth overlay that hydrateRow and readManifestRow consult. For the batch's whole flight (and, worse, after an ack that a stale load snapshot straddled), confirmed truth was invisible: removed entities resurrected into memory, evicted keys paged back stale, and boot's lifecycle-listener flush walked straight into the window (DAN-629; flavors executed across the DAN-621/DAN-630 gauntlets).

Why it happened: the drain read as a private handoff to the engine ("these are the batch's inputs now"). It wasn't private — the dirty sets were doing double duty as the readable record of un-durable truth, and the drain silently ended that duty a full await earlier than the durability it was standing in for. The tell: ADR-013 had just promoted the dirty sets from "write queue" to "overlay", and nobody re-audited who else depended on their lifetime.

Fix: ADR-015 (drain is a MOVE into inflightPuts/inflightDeletes; clearing is quiescence-gated — batch acked AND boot settled AND no hydration bracket open) + src/inflight-overlay.spec.ts (11 regression tests, 9 verified failing pre-fix — the strongest available encoding) + this entry.

For future agents: when a queue is both a work buffer AND a truth overlay, consuming it for one role must not blind the other — drain by moving entries to a visible in-flight stage, and retire that stage only at quiescence (acknowledged AND no reader that might predate the ack still running), never at hand-off. If you find yourself clearing shared state right before an await, list every reader of that state first.

[2026-07-22] — a teardown flag that stops NEW work must not also stop the in-flight work's own completion

Mistake: dispose() set disposed = true right after kicking off its final flush(). That flush, racing a prior batch still parked in await engine.writeBatch, took the re-entrant await inflightFlush; return flush() path — and the re-entrant flush() then bailed on the disposed guard that had flipped true in the meantime. The in-flight batch's own tail recovery (if (dirtySaves.size>0) scheduleFlush()) was defeated by the SAME flag. A set(Y)/remove(Y) that entered the dirty sets after the first drain parked was silently non-durable — the exact data-loss dispose()'s final flush exists to prevent (DAN-647; only real async engines expose it — a sync engine resolves the batch before dispose runs).

Why it happened: disposed conflated two jobs — "reject NEW work" (new subscriber events, new timers, new external flushes) and "this coordinator is torn down" — and the final flush is neither: it is the in-flight completion of work already acknowledged BEFORE teardown. A flag raised to stop the future also stopped the present from finishing. The tell was the async gap: the flag was read once at the flush's synchronous entry (false) and again at its post-await continuation (true), the same "state shifted across the await" shape as ADR-012–016.

Fix: ADR-017 (the final flush gets a single unforgeable exemption from the disposed guard via an internal final param threaded through the re-entrancy; disposed stays SYNCHRONOUS so the boot/hydration post-await guards keep firing; the public flush wrapper hides final so external callers still no-op post-dispose) + src/dispose-flush.spec.ts (4 tests, 3 verified failing pre-fix — the single-write test's residue is dropped by the same bug so it doubles as a failing repro; only the post-dispose-sneak-in test is a pure pin — the strongest available encoding) + this entry. Deferring the flag instead was rejected: it reopens the boot guards that stop retention/hydration from outliving the coordinator.

For future agents: a lifecycle flag that means "stop accepting new work" must never gate the completion of work already in flight. When a teardown/pause flag guards a code path, ask whether that path is starting NEW work or finishing ALREADY-ACCEPTED work — exempt the latter (thread an explicit final/draining token through it), and never solve it by deferring the flag, which un-guards everything else the flag protects.

[2026-08-02] — a deferral is not additive when the contract is public

Mistake: ADR-006 rev d was first drafted resolving 18 of 20 open points and leaving two — named-mutator rebase and priority-tiered hydration — open, on the stated grounds that they were "additive later, not one-way doors." Danny rejected that in review and was right.

Why it happened: the claim is true of the FIELDS and false of the CONTRACT. Adding a second way to express a write to a protocol that other people's servers already speak forces every adapter thereafter to handle both. The deferral does not avoid that cost; it buys the cost later at a worse price, which is precisely the calcification ADR-006 was frozen early to prevent. The reasoning was effort-shaped uncertainty dressed as prudence — and this workspace's standing rule is to filter by value, correctness and wisdom, never by effort.

The general form is worth keeping, because it is why the old instinct felt right: leaving a spec unfinished used to be rational because BUILDING TEACHES YOU THINGS, so learning beat guessing. When implementation is cheap and the thinking is the expensive part, that trade inverts. A hole in a spec stops being humility and becomes a decision handed to whoever implements it, who fills it by accident and makes it permanent.

Fix: both resolved (D19, D20) and ADR-006's Open Questions section is now empty by decision. Every rev-d resolution carries a falsification test — what would prove it wrong — instead of a hedge, which is what survives from the old instinct once the blank is removed. Encoded here, in the ADR's own D19/D20 prose, and in the now-empty Open Questions section of docs/specs/sync-adapter.allium, which is the file where the temptation recurs.

For future agents: before leaving a question open in a frozen contract, ask whether the eventual answer ADDS a field or adds a SECOND WAY TO DO THE SAME THING. The first is genuinely additive; the second is a permanent wart every future implementer pays for. If you cannot decide it, write the decision anyway with the test that would falsify it.

[2026-08-02] — a guard inside it passes; a guard outside it skips

Mistake: the first cut of the SyncAdapter conformance kit (src/sync-conformance.ts) guarded its limit and batching assertions with an early return INSIDE the it body when the optional seedRemote hook was absent. A red-proof run — deliberately pointing the kit at a broken adapter — showed honours limit as a ceiling reporting PASS against an adapter that over-serves limit, because it had returned before asserting anything.

Why it happened: an early return in a Vitest test body is indistinguishable from a successful test. The reporter prints a green tick either way, so a kit whose hooks are unsupplied reports full conformance against an adapter it never examined — the worst possible failure for an artifact whose entire purpose is telling third parties whether their backend is correct.

This is the false-green family again, one level up from the five instances in knowledge/verification-integrity-2026-07-23.md: a check that reports success on a question it never evaluated.

Fix: the guard moved to DESCRIBE level as an explicit it.skip with the reason in its name, so an unexercised property is visible in the reporter rather than counted as a pass. The kit is also shipped with src/sync-conformance.spec.ts, which runs every property against a deliberately broken mutant — that red-proof is what caught this, and it is the only reason it was caught before the kit reached an adapter author.

For future agents: in any test framework where a bare return ends a test successfully, never guard an assertion with one. Hoist the condition to the suite level and skip explicitly. And never ship a conformance kit that has not been watched to fail — a kit asserting nothing passes every implementation and reads as rigour.

[2026-08-02] — verify the PREMISE; a valid argument on a false fact passes every review

Mistake: ADR-018 made a clean break on the persisted format — __pcn_ref → __cdb_ref, pcn_entities → cdb_entities — with no migration and no dual-read, justified on two stated facts. Fact 2 was: "The Vue/Pinia adapter has never shipped persisted data either (the plugin-swap is chip 3, still gated on publish)."

That is false, and it was falsifiable in one command the whole time. pinia-colada-plugin-normalizer@0.3.0 is published on npm — releases back to 0.1.8 — and its shipped bundle contains enablePersistence, idbEngine, pcn_entities and __pcn_ref. So the CAPABILITY to create databases under the old names shipped to real users; whether any user enabled persistence is unknowable from outside, and 294 downloads in the last month bounds the population without establishing it. That asymmetry is the point: the premise was "never shipped persisted data", and shipping the capability is enough to falsify it. Chip 3 as planned would start, find nothing under the new names, and present an empty database with no error.

Why it happened: the parenthetical is the whole error. "The plugin-swap is chip 3, still gated on publish" is a true statement about the plugin depending on colada-db. It was used to support a different claim — that the plugin does not persist. The plugin has always persisted; it does so through its own frozen fork of the engine, which is the entire reason the fork exists.

Two propositions about one package got conflated because one sounds like it implies the other. Nothing was hidden and nobody was careless — the premise was simply never checked against the registry.

The reason it survived review: ADR-018's argument is valid. Its conclusion follows correctly from its stated facts. A reviewer checking whether the reasoning holds will pass a sound argument built on a false premise every single time, because the defect is not in the reasoning. This is also why the ADR reads as more rigorous than an ADR that had simply guessed — it showed its work.

Fix: ADR-024 amends ADR-018 (naming decision preserved, migration obligation added, chip 3 becomes a major version that must either read the legacy stores forward or refuse loudly — never start silently empty). ADR-018 gains one line of reciprocal metadata — an Amended by: pointer, so a lint can catch a one-directional supersession — and nothing else; its reasoning is untouched, because an accepted ADR records what was decided and why, not what turned out to be true. The correction lives in ADR-024. And the rule:

Before any ADR asserts what a package has or has not shipped, run npm view <pkg> versions, unpack the tarball, and paste the output into the ADR. It costs one command.

For future agents: when an argument depends on a fact about the outside world — what is published, what is deployed, what a vendor's licence says, what a spec requires — verify the fact, not the inference. Ask "is this still true?" before "does this follow?" A registry, a deployed artifact, or a raw source file is the system of record; a document that summarizes one is not.

[2026-08-02] — a hazard fixed on one verdict branch was left live on its sibling

Mistake: building the sync coordinator (DAN-776), handleVerdict's reject branch reverts a rejected write and then replays every OTHER still-outstanding outbox entry for the same key on top — because reverting first and stopping there would silently erase a second, still-unconfirmed writer's edit to that entity. The transform branch applies the server's corrected entity immediately (ADR-006 rev d / D2 requires this) but, as first written, never replayed the same siblings on top of it — an independent fresh-context review of the diff caught it before landing; self-review had not.

Why it happened: reject and transform are both "an authoritative write just landed on this key from outside the local writer" — the exact same hazard, arrived at from two different verdict types. The fix was written once, for the branch that prompted it (reject), and the structurally identical branch sitting right next to it in the same switch-shaped function was never re-asked "does this need the same fix?" A test suite built alongside the code has the same blind spot the code does — 31 tests passed with the bug present, because none of them put a second writer in flight during a transform, the same way the first-written reject test did.

Fix: the revert/replay logic was extracted into one shared replaySiblings() helper, called from both branches, so the fix can no longer exist in only one of them by construction. Two new watched-to-fail tests (coordinator-conformance.spec.ts, "found by independent review, DAN-776") pin each branch independently.

For future agents: when two code paths handle structurally symmetric cases of the same underlying event (two verdict types, two directions of a diff, two branches of an origin check), a hazard found and fixed on one is a standing question on every sibling, not a closed matter — literally re-ask "does this apply to the other branch(es) too?" the moment a fix like this lands, before moving on. And self-review is not a substitute for a second, differently-contexted reader: the reviewer that caught this had no attachment to the original design reasoning and was reading the diff cold against the spec, not against the author's own mental model of what the code does.