feat(db): enforce input-scaled chunking invariant + PR #55 deferred findings (#76)#185
Merged
Merged
Conversation
…indings Add tests/lib/chunk-audit.test.ts guarding the chunk.ts audit note, route bumpAccess's input-scaled IN (...) list through chunked(), document the hooks/ carve-out (chunk.ts note + AGENTS.md), add @throws JSDoc to chunked(), and restore the credential-confirm clause in FOR_OPENCODE.md. Closes #76
This was referenced Jun 25, 2026
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Consolidates the non-blocking deferred findings from the PR #55 review (issue #76) into one surgical change set, and turns the
chunk.tsaudit note from prose into an enforced invariant.The guard test surfaced a real, latent post-audit bypass:
bumpAccess(frecency, issue #153, added after the 2026-06-10 audit) built an input-scaledid IN (...)list withArray.from(ids, () => '?')and never chunked it. A high---limitrecall could push that bind count past the historical SQLite variable limit on stricter platforms. Brought it into line with the existingchunked()pattern (same asaging.ts/dedup.ts), inside the existing transaction so the bump stays all-or-nothing.Findings addressed
tests/lib/chunk-audit.test.ts) — scanssrc/+hooks/for the input-scaled placeholder idiom (() => '?', covering both.map(() => '?')andArray.from(x, () => '?')) and fails when a site bypasseschunked()outside a fixed-size allowlist. Comments are stripped first so doc mentions of the idiom don't self-trigger. Includes a non-vacuous-detection test.chunk.tsaudit note now documents that hooks can't import the helper (self-contained-hooks rule) and must inline a local equivalent; a one-line Key Conventions entry inAGENTS.mdputs the invariant where the next SQL author will see it.consolidate-core.ts's fixed-columnVALUESis the one allowlisted site.@throws {RangeError}JSDoc onchunked(), notingchunked([], 0)throws (size validates before the empty-input check).FOR_OPENCODE.mdrule 5 drift — restores the "confirm with the user before dumping credentials" clause the other three guides carry.Audit note also refreshed: the input-scaled paths are now
dump.ts,aging.ts,dedup.ts, andmemory.ts— all routed throughchunked()and enforced by the new test.Out of scope (flagged for follow-up issues)
The review's "follow-up issue candidates" (production
busy_timeout, the 4-worker race test's missingresults.length === 4assertion,parent_loa_idcycle recursion) and thedeleteSessionend-to-end test are pre-existing, larger concerns — left for their own tracked issues rather than expanding this change set. (The embeddings-orphan item already shipped via #46.)Verification
bun run lint(tsc --noEmit) clean.bun test— full suite 1178 pass / 0 fail.bumpAccessand confirmed the guard test fails namingsrc/lib/memory.tswith a remediation message; passes once restored.Closes #76