Skip to content

feat(db): enforce input-scaled chunking invariant + PR #55 deferred findings (#76)#185

Merged
edheltzel merged 2 commits into
mainfrom
worktree-feat+chunk-audit-deferred-76
Jun 25, 2026
Merged

feat(db): enforce input-scaled chunking invariant + PR #55 deferred findings (#76)#185
edheltzel merged 2 commits into
mainfrom
worktree-feat+chunk-audit-deferred-76

Conversation

@edheltzel

Copy link
Copy Markdown
Owner

Summary

Consolidates the non-blocking deferred findings from the PR #55 review (issue #76) into one surgical change set, and turns the chunk.ts audit 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-scaled id IN (...) list with Array.from(ids, () => '?') and never chunked it. A high---limit recall could push that bind count past the historical SQLite variable limit on stricter platforms. Brought it into line with the existing chunked() pattern (same as aging.ts / dedup.ts), inside the existing transaction so the bump stays all-or-nothing.

Findings addressed

  1. Guard test for the audit note (tests/lib/chunk-audit.test.ts) — scans src/ + hooks/ for the input-scaled placeholder idiom (() => '?', covering both .map(() => '?') and Array.from(x, () => '?')) and fails when a site bypasses chunked() 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.
  2. hooks/ carve-outchunk.ts audit 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 in AGENTS.md puts the invariant where the next SQL author will see it. consolidate-core.ts's fixed-column VALUES is the one allowlisted site.
  3. @throws {RangeError} JSDoc on chunked(), noting chunked([], 0) throws (size validates before the empty-input check).
  4. FOR_OPENCODE.md rule 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, and memory.ts — all routed through chunked() 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 missing results.length === 4 assertion, parent_loa_id cycle recursion) and the deleteSession end-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.
  • Proved the guard is not vacuous against real source: temporarily un-chunked bumpAccess and confirmed the guard test fails naming src/lib/memory.ts with a remediation message; passes once restored.

Closes #76

…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chunking: consolidated deferred findings from PR #55 review

1 participant