Skip to content

🤖 refactor: add bounded raw history row scanning - #4214

Open
ThomasK33 wants to merge 1 commit into
mainfrom
codex/effect-history-row-scanner
Open

🤖 refactor: add bounded raw history row scanning#4214
ThomasK33 wants to merge 1 commit into
mainfrom
codex/effect-history-row-scanner

Conversation

@ThomasK33

@ThomasK33 ThomasK33 commented Sep 11, 2026

Copy link
Copy Markdown
Member

Adds a raw JSONL reader that streams large strings, keys and numbers without assembling a whole row. This is the inactive parsing prerequisite for the oversized-history witness finding in #4182; the runtime integration in #4182 consumes it through #4221.

The reader reports byte ranges, content digests, JSON/UTF-8 validity and duplicate decoded keys. Consumers receive provisional tokens, optional isolated raw chunks, and awaited row completion. Explicit replacement decoding supports legacy identity accounting while keeping strict raw validity separate. Abort, early exit and visitor errors close the file and parser.

Uses pinned stream-json 3.6.0 with scalar packing disabled. Retained memory depends on the read chunk plus nesting and object-key bookkeeping; this is not an absolute constant-memory guarantee for arbitrarily deep or wide objects. Callers must bound their own retention and revalidate file stamps before treating descriptors as evidence.

Validation: 58 tests / 266 assertions, including 12 MiB scalar fixtures, one-byte reads, malformed UTF-8/JSON, split escapes, duplicate keys, LF/EOF framing, backpressure and cleanup. A bundled Node 22 smoke run passed 17 checks; four additional abort-guard checks passed after fixing cancellation from beginRow; canonical make static-check passed. Deterministic held-open and held-stat tests on an empty file verify exact abort reasons and file-handle closure after awaited setup. Runtime compatibility was checked against the repository's Node 22 Docker runtime. No provider calls.

The Nix offline dependency-cache hash is updated to the value computed by CI for the added streaming parser dependency. A prior Flake Hash Check confirmed the generated value. Local Nix is unavailable.

Risk: the new dependency and streaming-token contract need careful review before activation.

Raw callbacks receive copies bounded by the read chunk, so mutation of the full backing buffer cannot corrupt parsed tokens, digests or later buffered rows. Cancellation remains observable after awaited visitor completion and asynchronous parser/file disposal. Nine adversarial regressions failed before these fixes and now pass; an additional bundled Node 22 run passed 16 mutation and late-cancellation checks. Canonical static checks passed on the final scanner fix.

Final integrated validation passes on #4191 052fc084517c1a6fd8cfbecdf08c05b635358a32 (4026 tests / 36442 assertions) and #4209 02651d365f63c9dc04d95744207f42f8065d6f35 (4095 tests / 36847 assertions), across 54 affected suites each. Full source/test TypeScript and make static-check pass on both exact commits.

The complete cancellation phase is ordered #4214#4215#4219#4221#4182#4187#4191#4209. The reader prerequisites and runtime changes merge together only after every member has current-head approval and green CI.


Generated with xum • Model: unavailable • Thinking: unavailable • Cost: $unavailable

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review


Generated with xum • Model: unavailable • Thinking: unavailable • Cost: $unavailable

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 11, 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-09-11T19:31:54.423670Z e9a86bd Manual request
🔒 Security Review Completed 2026-09-11T19:32:28.590741Z e9a86bd 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 Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: c4fd2b2972

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c4fd2b2972

ℹ️ 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".

Comment thread src/node/services/historyRowScanner.ts Outdated
@ThomasK33

Copy link
Copy Markdown
Member Author

Addressed the beginRow cancellation finding: push now checks the signal before hashing or delivering raw bytes. Both normal and false-returning raw visitors remain uncalled when beginRow aborts, and the scan rejects with the exact supplied reason. The two new cases fail before the fix and pass afterward. Raw47 tests/237 assertions, Node22 cancellation guards, canonical static and independent review pass.


Generated with xum • Model: unavailable • Thinking: unavailable • Cost: $unavailable

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review


Generated with xum • Model: unavailable • Thinking: unavailable • Cost: $unavailable

@ThomasK33
ThomasK33 added this pull request to stack #4216 September 11, 2026 12:38
@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: dec7d07f2d

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dec7d07f2d

ℹ️ 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".

Comment thread src/node/services/historyRowScanner.ts Outdated
@ThomasK33

Copy link
Copy Markdown
Member Author

Addressed 3989243370: the scanner now checks cancellation immediately after both awaited setup operations. Deterministic empty-file tests hold open and stat separately, abort with an object reason, then verify rejection with that exact reason, no row callback, and a closed file handle. Both cases failed before the fix and pass afterward. The complete reader/scalar composition passes 91 tests / 4,712 assertions; raw canonical static checks and independent review pass.

Generated with xum • Model: unavailable • Thinking: unavailable • Cost: $unavailable

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review


Generated with xum • Model: unavailable • Thinking: unavailable • Cost: $unavailable

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: 4a2dec6ab6

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4a2dec6ab6

ℹ️ 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".

Comment thread src/node/services/historyRowScanner.ts Outdated
@ThomasK33

Copy link
Copy Markdown
Member Author

Fixed the Flake Hash Check failure by applying the exact offline-cache hash computed in run 34602110408, job 103271747811. The completed dependency derivation reported sha256-5V2PO5L0AlCoSLgxjXYDRq/aCzmXYnCRiPss/IDOtYM=. This is the dependency update required by the streaming reader. Local Nix is unavailable, so the fresh-head CI check will verify the result; application code and the 91 passing reader/scalar tests are unchanged.

Generated with xum • Model: unavailable • Thinking: unavailable • Cost: $unavailable

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review


Generated with xum • Model: unavailable • Thinking: unavailable • Cost: $unavailable

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: cdacaafb31

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cdacaafb31

ℹ️ 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".

Comment thread src/node/services/historyRowScanner.ts Outdated
@ThomasK33

Copy link
Copy Markdown
Member Author

Addressed both current scanner findings:

  • 3989431027: raw visitors now receive an isolated Uint8Array with a backing buffer no larger than the input chunk. Mutating that whole buffer cannot change parser input, the recorded digest, or the next buffered row. The large-scalar fixture checks this bound while corrupting every callback buffer.
  • 3989494033: cancellation is checked before each row and after awaited push work; an outer finally checks again after parser and file disposal. Late finish reactions cannot start another row or return successful completion/early-stop after abort. Exact abort reasons and resource cleanup are preserved.

All nine new adversarial tests failed before the fixes and pass afterward. The complete scanner suite passes 58 tests / 266 assertions; Node 22 passes 16 new adversarial checks plus the previous 17 checks. Canonical static checks and independent review passed.


Generated with xum • Model: unavailable • Thinking: unavailable • Cost: $unavailable

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

Please review the current head. This remains part of the cancellation phase and will merge only with the completed, approved, green phase.


Generated with xum • Model: unavailable • Thinking: unavailable • Cost: $unavailable

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: 07752d54d0

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 07752d54d0

ℹ️ 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".

@ThomasK33
ThomasK33 force-pushed the codex/effect-history-row-scanner branch from 07752d5 to 1c9725b Compare September 11, 2026 14:23
@ThomasK33
ThomasK33 removed this pull request from stack #4216 September 11, 2026 14:24
@ThomasK33
ThomasK33 added this pull request to stack #4222 September 11, 2026 14:24
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

Please review the current head after the complete phase was composed on current main. All known findings have fixes and replies in their owning layers; the eight-member phase stays held until all members are approved and green.


Generated with xum • Model: unavailable • Thinking: unavailable • Cost: $unavailable

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 1c9725b711

ℹ️ 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".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: 1c9725b711

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Signed-off-by: Thomas Kosiewski <tk@coder.com>

---

_Generated with `xum` • Model: `unavailable` • Thinking: `unavailable` • Cost: `$unavailable`_

<!-- mux-attribution: model=unavailable thinking=unavailable costs=unavailable -->

Change-Id: I8e8213dd9ce3c49524397757d99ebad2af2d6164
@ThomasK33
ThomasK33 force-pushed the codex/effect-history-row-scanner branch from 1c9725b to e9a86bd Compare September 11, 2026 19:25
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

Please review updated head e9a86bd825f356c6c59d07cadcaa386a0781ec92 against its stack base. This layer’s own source delta is unchanged; it is rebased onto the merged CI-gate prerequisite #4223 and the reviewed ancestor fixes. Please review against its stack base.

Final integrated validation passes on #4191 052fc084517c1a6fd8cfbecdf08c05b635358a32 (4026 tests / 36442 assertions) and #4209 02651d365f63c9dc04d95744207f42f8065d6f35 (4095 tests / 36847 assertions), across 54 affected suites each. Full source/test TypeScript and make static-check pass on both exact commits.

All eight members remain held until current-head review approval and required CI are complete.


Generated with xum • Model: unavailable • Thinking: unavailable • Cost: $unavailable

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: e9a86bd825

ℹ️ 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".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: e9a86bd825

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

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.

1 participant