Skip to content

test: deterministic seam for bounded-read growth paths (HACK-1483) - #108

Merged
roodboi merged 1 commit into
mainfrom
kit/hack-1483-deterministic-growth-seam
Oct 31, 2026
Merged

roodboi merged 1 commit into
mainfrom
kit/hack-1483-deterministic-growth-seam

Conversation

@roodboi

@roodboi roodboi commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Resolves HACK-1483. Follow-up to #97.

Problem

On main, four bounded-read growth-path tests relied on real file growth during the read:

  • report-persistence-adversarial.test.ts ("growing files with bounded reads") and two source-provenance.test.ts cases appended to the file from a before*ReadChunk hook. The append also changes size/mtime, so the metadata drift check could reject first. The tests accepted either message, so they never proved the growth branch ran.
  • manage.test.ts ("grows around bounded reads") spawned a detached process that appended in a loop while the reader ran. It accepted either the per-file error or the later "tree hash differs" fallback, because the outcome depended on timing.

Seam

Each bounded reader now takes an injectable chunk reader, marked @internal. The default behaves exactly as before:

  • loadVerifiedAuditReport({ readEnvelopeChunk }), AuditEnvelopeChunkReader, sync and readSync-shaped
  • new AuditSourceTracker({ readFileChunk }), AuditFileChunkReader, used by read and captureTree
  • setupCodexPlugin({ readPluginPayloadChunk }), CodexPluginPayloadChunkReader, passed into hashStrictDirectoryTree

The tests pass real reads through, but report one extra byte on the trailing end-of-file read while the file stays unchanged. Only the growth check can reject that. Each test asserts:

  • the exact "grew" error;
  • that the end-of-file read happened once, at the expected size;
  • that the file size did not change.

The detached mutator process and its ready/stop files are gone.

Verification

  • 20-run determinism: 20 back-to-back runs of bun test src/audit/report-persistence-adversarial.test.ts src/audit/source-provenance.test.ts src/manage.test.ts -t "growing|grows around bounded reads" gave 20 pass, 0 fail.
  • Mutation proof: I turned off each trailing growth check in turn (if (false && …)), and every matching test failed:
    • report-persistence.ts: the load resolved instead of rejecting.
    • source-provenance.ts: both tests' reads resolved instead of rejecting.
    • manage.ts: the error fell through to "installed tree hash differs". The old test accepted that error, so it would have passed this mutation.
  • Sandboxing: all touched tests run under test/setup.ts, which points HOME, XDG_* and TMPDIR at a temp root. They write nothing outside it and never touch the host fclt runtime or AI index.
  • Touched files: 116/116 pass.
  • Full suite: ./scripts/test-safe.sh, run by the pre-commit hook, passed 1357/1357.
  • Typecheck and lint: bun run type-check and bun run check are clean.

Note: on a heavily loaded host, the full suite often fails random unrelated subprocess tests on the 5s per-test timeout. main without this change failed the same way. Those failures are unrelated to this PR.

@codex review

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

…ACK-1483)

Replace real file growth (hook-driven appends and a detached appending
process) in the growth-path tests with injectable chunk-reader seams in
loadVerifiedAuditReport, AuditSourceTracker, and setupCodexPlugin. The
test reader reports one byte past EOF on the trailing sentinel read while
the file stays unchanged, so only the growth branch can reject it and
each test asserts that exact error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-31T03:51:52.528108Z a34e9ad Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: a34e9ad39e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@roodboi
roodboi merged commit a8cf600 into main Oct 31, 2026
4 checks passed
@roodboi
roodboi deleted the kit/hack-1483-deterministic-growth-seam branch October 31, 2026 04:38
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 2.33.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant