Skip to content

chore: honest chunk-audit guard docs + >cap bumpAccess test (#189)#190

Merged
edheltzel merged 1 commit into
mainfrom
harden/chunk-audit-docs-189
Jun 25, 2026
Merged

chore: honest chunk-audit guard docs + >cap bumpAccess test (#189)#190
edheltzel merged 1 commit into
mainfrom
harden/chunk-audit-docs-189

Conversation

@edheltzel

Copy link
Copy Markdown
Owner

What

Hardening from the RedTeam gate on PR #185 (issue #189).

MED — chunk-audit guard is file-granular; docs oversell it.
tests/lib/chunk-audit.test.ts exempts an entire file from the input-scaled-placeholder check once that file contains any chunked( call. A new un-chunked IN (...) added to a file that already chunks (memory.ts, dump.ts, aging.ts, dedup.ts) is therefore not caught. Three descriptions (AGENTS.md Key-Conventions entry, the chunk.ts audit note, the test header) claimed a stronger invariant than the guard delivers.

Chose the issue's option 2 (honest docs) over tightening the guard. A per-statement guard robust enough to pass dump.ts — where the chunk var is bound two hops from chunked() (const chunks = chunked(loaIds)for (const chunk of chunks)chunk.map(() => '?')) — yet still flag a planted same-file bypass would require real data-flow analysis. That is overkill, and a CI-breaking false-positive risk, for a risk:low meta-test. So all three descriptions now state the file-granular limitation explicitly (kept DRY-consistent).

LOW — no >cap integration test for bumpAccess chunking.
Added a test that builds SQLITE_SAFE_CHUNK_SIZE * 2 + 1 rows (spans three chunks) and asserts every id lands at access_count === 1 — proving no id is dropped at a chunk boundary and the multi-chunk bump commits atomically within its single transaction.

Verification

  • bun run lint (tsc --noEmit) clean
  • bun test green: 1190 pass, 0 fail
  • Affected files: tests/lib/bump-access.test.ts + tests/lib/chunk-audit.test.ts pass (14 tests)

Closes #189

…mpAccess test (#189)

The chunk-audit guard exempts an entire file once it contains any
chunked() call, so a new un-chunked sibling IN(...) list in a file that
already chunks (memory.ts, dump.ts, aging.ts, dedup.ts) is not caught.
Three descriptions (AGENTS.md, chunk.ts note, test header) oversold this
as a full invariant.

Chosen the honest-docs option over tightening: a per-statement guard
robust enough to pass dump.ts (chunk var bound two hops from chunked())
yet catch a planted same-file bypass would need data-flow analysis —
overkill and a false-positive risk for a risk:low meta-test.

- Soften AGENTS.md / chunk.ts note / test header to state the
  file-granular limitation explicitly (DRY-consistent wording).
- LOW: add a >cap bumpAccess integration test asserting all ids are
  bumped across chunk boundaries within the single transaction.

Closes #189
@edheltzel edheltzel merged commit ee07e52 into main Jun 25, 2026
2 checks passed
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.

harden: chunk-audit guard is file-granular + docs oversell scope (from #185 gate)

1 participant