Repository navigation
Conversation
Afloat16
marked this pull request as ready for review
November 25, 2026 06:11
There was a problem hiding this comment.
Approve (0 findings)
Scope: base main, merge base 77abdcb3; 1 commit and 3 files reviewed at head 3395075c. I loaded the coderbook (sections 2, 3, 5), ponytail-review (sections 1–3) and karpathy-guidelines (sections 2–3) skills. This review ran in its own session.
Findings
None.
Verified as fine
- The lower bound never rejects a table that fits. For
widthcolumns, a rendered row is at least3*width + 1characters plus its newline:"| ", separators" | "," |". That is more thanwidth, so(rows.length + 1) * width > maxOutputBytes(document-normalizer-core.ts:222) only rejects tables that the old code would also reject atcanonicalizeMarkdown(document-normalizer-core.ts:143-146). - The per-row byte count matches the final canonical size exactly.
escapeMarkdownTableCellturns every\r\n,\rand\nin a cell into a space (document-office-extract.ts:67-68), so the CRLF rewrite incanonicalizeMarkdownhas nothing to change.- Every line starts and ends with
|(a stable starter for NFC), so NFC applied line by line equals NFC applied to the joined text. TextDecoderalready strips a leading BOM (decodeUtf8Text).- The last line ends in
|, so+1per line equals the single\nthatcanonicalizeMarkdownappends after it trims trailing newlines. - So the early exit and the final check agree byte for byte, and the boundary test (
budgetandbudget - 1) covers this.
- Accepted output is unchanged. Cells are still padded to
widthand escaped the same way, the separator row comes right after the header, and the lines are joined with\nas before.canonicalizeMarkdownstill runs last and is still the authoritative size check (document-normalizer-core.ts:130). The escaping/padding test pins the exact old output. - Callers are unaffected.
delimitedToMarkdownis private. Archive entries callnormalizeDocumentContentwithout a budget, so they use the 32 MiB default (document-normalizer.ts:9), exactly as before. The worker and the in-process path (document-normalizer-worker.ts:39,document-normalizer.ts:216) keep their signatures. - Memory is bounded at the production budget. Once the lower bound passes,
rows * widthis at most the budget. The per-line check stops beforelinesgrows past the budget. - Docs and conventions. The README in
src/document-normalizer/now describes the bounded expansion. There are no new dependencies and no env or contract changes. Added lines and the commit message contain no CJK characters. - Test limitation (not a defect). The sparse-table test also returns
DOCUMENT_MARKDOWN_TOO_LARGEon the base commit; the gain is in time and allocation, not in the result. That is reasonable for a perf change where a timing assertion would be flaky.
Process notes
Single commit; no merge commits or fixup commits.
CI
- The checks that ran all passed:
repository-gate,changesandcheck (web). Every other app job was skipped by the path plan. - Per
.github/workflows/ci.yml, the node-services suite does not run in CI, so I ran it locally:vitest run tests/document-normalizer/document-table-budget.test.ts tests/document-normalizer/document-table-literals.test.ts tests/document-normalizer/document-normalizer.test.ts: 3 files, 50 tests passed.tsc --noEmitforapps/node-services: passed.
- I did not re-run the full
pnpm --filter @linger/node-services check. The PR body reports it passing on this head.
Automated review by Claude Code
Automated review of 3395075 by Claude Code.
3 tasks done
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.
What and why
Check a lower bound on the delimited table size before padding sparse rows, then render one row at a time while counting canonical UTF-8 output bytes. This prevents a small sparse CSV or TSV from allocating its complete dense cell matrix before discovering that the Markdown result exceeds the caller's budget.
The exact byte count includes the final newline and NFC normalization. Existing Markdown escaping, padding and accepted output are preserved.
How it was verified
Base: 77abdcb. Node 26.5.0, pnpm 11.7.0.
Same-condition local benchmark: 6,999-byte sparse inputs, 32 KiB output budget; 3 warmups, 7 samples of 3 calls, GC before each sample, median milliseconds per call.
1,000 columns × 1,000 rows: 213.007 ms before, 0.240 ms after.
4,000 columns × 500 rows: 414.846 ms before, 0.253 ms after.
Both versions return
DOCUMENT_MARKDOWN_TOO_LARGE. These measurements exercise a custom output budget and do not measure end-to-end upload latency.50 focused table-budget, literal-table and normalizer tests pass, including exact NFC/multibyte byte limits and the final newline.
Node-services typecheck, changed-file ESLint and diff checks pass. The full owning-app fast gate now passes; see the exact-head validation below.
Command:
pnpm --filter @linger/node-services exec vitest run tests/document-normalizer/document-table-budget.test.ts tests/document-normalizer/document-table-literals.test.ts tests/document-normalizer/document-normalizer.test.ts --maxWorkers=1.Focused tests for the changed behavior
make check BASE=origin/<target-branch>or the fast checks of every touched appNo contract regeneration required
Boundary
The nearest normalizer documentation describes bounded expansion. Input parsing remains bounded by the existing source-size limit; this change specifically bounds generated table construction. No dependency, network request or file walk is added.
Validation follow-up
On
3395075c98f9ddc88d15f152f574b3f6887c4072,pnpm --filter @linger/node-services checkpasses with Node 26.5.0 and pnpm 11.7.0: the feature catalog/typecheck and full ESLint gates pass, followed by 269 test files passed, 8 skipped; 2,715 tests passed, 51 skipped. No additional test exclusions, source changes, or lockfile changes were needed.This establishes the owning app's full fast gate. Unrelated full-repository and optional integration/acceptance suites were not run. The previously recorded performance measurements remain the benchmark evidence; this validation did not rerun those benchmarks.