spec: close memory driver's persistence sub-shapes against unknown keys (#4001 batch B) - #7985
Conversation
…own keys (#4001 batch B) Convert the 5 remaining non-strict `z.object` sites in `data/driver/memory.zod.ts` to `strictObject` — `PersistenceAdapterSchema`, `FilePersistenceConfigSchema`, `LocalStoragePersistenceConfigSchema`, `CustomPersistenceConfigSchema`, `AutoPersistenceConfigSchema` — the persistence-adapter union nested under `datasource.config.persistence`. `.strict()` does not recurse, so these stayed open after #4410 closed the top-level `MemoryConfigSchema`. - Added unrecognised-key rejection tests for all 5 sites (reverse-verified: reverting the schema change turns them red). - Regenerated the strictness-ledger counts file and updated its prose to drop `driver/memory.zod.ts`'s now-empty remaining-strip row. - Removed `memory.test.ts`'s graduated entry from test-typecheck-debt.json (regenerated via `gen:test-typecheck-debt`, not hand-edited). Part of #4001. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ECjShwqVRAhLy15mgatGjV
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
📓 Docs Drift CheckThis PR changes 1 package(s): 106 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
⛔ 7 release-owned page(s) also reference the affected code. These are read-only:
|
…ged with batch B Second turn of the os-regen relay. `#7985` (batch B — the memory driver's five persistence sub-shapes) and `#7972` landed while this branch was in the queue, so the shared counts artifact met two batches that each decremented it correctly and independently. That is the exact arithmetic #5107 built this artifact to prevent: the rows do not overlap, git merges them without complaint, and the SUBTOTAL — which overlaps nothing — merges clean and wrong. The artifact carries `merge=os-regen` so the merge defers rather than splices, and the only correct resolution is to recompute from the merged tree. Regenerated, never hand-edited: still-open (strip) 149 → 144 (batch B's five) files carrying at least one 26 → 25 authorable — forced scope 9 → 4 data/ strip 107 → 102, data/ strict 57 → 62 total strict 283 → 288 Neither batch's own numbers moved; the combined ones did. `check:strictness-ledger` agrees with the merged tree in both directions (25 open files / 144 strip sites, no closed file still carrying a worklist row — batch B's `driver/memory.zod.ts` row left with their side of the prose). Merged tree verified: spec 382 files / 10109 tests, lint 71 / 1932, check:generated 13/13. Part of #4001 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012NLJ8PWLdwLSyi84LHzrAx
Part of #4001
What
Converts the 5 remaining non-strict
z.objectsites inpackages/spec/src/data/driver/memory.zod.tsto the campaign'sstrictObjectposture —
PersistenceAdapterSchema,FilePersistenceConfigSchema,LocalStoragePersistenceConfigSchema,CustomPersistenceConfigSchema,AutoPersistenceConfigSchema. These are the persistence-adapter union nestedunder
datasource.config.persistence..strict()does not recurse:MemoryConfigSchema(the top-levelconfigslot) was already closed as of #4410, but the five variant shapes nested
inside its
persistencefield stayed open, so a typo written insidepersistence(e.g.{ type: 'file', filepath: '/data.json' }) parsed cleanand the driver silently came up on its defaults.
Premise check
Verified against
origin/main@8d80e12e74before starting:git show origin/main:packages/spec/src/data/driver/memory.zod.tsstill has exactly 5bare
z.object(sites (the other 2z.object(matches were in an unrelatedJSDoc-adjacent context and don't count), and the ledger
(
docs/audits/2026-07-unknown-key-strictness-ledger.md:1185) still classedthe file
authorable, "persistence-adapter union underdatasource.config".Premise held — proceeded.
Changes
strictObject, each with its ownsurfacename(
.strict()doesn't recurse, so each nested variant needed its own gate).No aliases added — I don't have real-payload evidence for any specific
typo, and the helper's own docblock says curation is an upgrade, not a
precondition.
memory.test.ts.Reverse-verified: reverting
memory.zod.tsto theorigin/mainversion turns exactly these 5 new cases red (
expected true to be false—the unknown key was silently accepted), restoring the fix turns them green
again. Done via
git checkout origin/main -- <path>+ a saved patch, notgit stash.the new shared
PERSISTENCE_HISTORYdoc comment before the file's realmodule header.
findModuleDocBlock(两张公开参考页的正文被 #4001 的内部注释顶替(#3746 陷阱 1 已实际发生两次) #5059) takes the first top-level doccomment as the page description and returns
nullfor the whole fileif it's immediately followed by a declaration — no fallback search — so
that ordering would have silently dropped
memory.zod.ts's published docsdescription. Moved the new comment after the real header; confirmed with
findModuleDocBlockdirectly that the correct block is now selected.docs/audits/2026-07-unknown-key-strictness-ledger.counts.md(
gen:strictness-ledger— never hand-edited) and updated the ledger'sprose/table to drop
driver/memory.zod.ts's now-empty remaining-strip row(
check:strictness-ledgerwas red until this was fixed).memory.test.ts's graduated entry frompackages/spec/test-typecheck-debt.jsonviagen:test-typecheck-debt(not hand-edited) — the file now compiles cleanunder
tsconfig.test.json.@objectstack/specminor.Tests
pnpm --filter @objectstack/spec test -- --maxWorkers=2— 381 files /10037 tests, all passing (full package suite; ran clean both before and
after the ledger-doc fix).
pnpm --filter @objectstack/spec typecheck— clean (tsc --noEmit,check:scripts-typecheck,check:test-typecheckall green).pnpm --filter @objectstack/spec check:generated— all 13 generatedartifacts up to date (api-surface, strictness-ledger counts,
authorable-surface, docs, etc.).
pnpm --filter @objectstack/spec check:authorable-surface— green;authorable-surface.base.jsonanchor untouched (the "trails the baseline"note is the expected informational line, not an error).
check:merge-driver,check:nul-bytes,check:spec-parsed-alias,check:adr-anchors— all green....@objectstack/driver-memory— wait, thispackage has no in-repo consumers upstream of it other than
@objectstack/driver-memoryitself, which is the one that parses theseconfigs): built its dependency closure first
(
pnpm --workspace-concurrency=2 --filter '@objectstack/driver-memory^...' build),then
pnpm --filter @objectstack/driver-memory typecheck(clean) andpnpm --filter @objectstack/driver-memory test -- --maxWorkers=2— 24files / 732 tests, all passing.
Out of scope
Nothing found outside this card's 5 sites while working the file.
Generated by Claude Code