fix(batch): enforce indexed byte and chunk budgets - #980
Open
Tomodad wants to merge 2 commits into
Open
Conversation
Tomodad
marked this pull request as ready for review
July 20, 2026 11:27
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.
Summary
Fixes #961 by bounding
ctx_batch_executeindexed ingestion independently from its Markdown display response.Default policy
Limits are inclusive. Byte budgets count UTF-8 stdout+stderr body bytes after execution capture and before any display-Markdown join or FTS write. Requested increases above any default require
allow_large_ingestion=true.The 8/16 MiB and 4,608-chunk defaults are benchmark-derived, remain configurable, and can be revisited with cross-platform production evidence.
Coordinator review fixes
This revision addresses all three blockers recorded in
stage-1-coordinator-verification.md:getChunksBySource()response inventory hydration withformatBatchSectionInventory(plan.chunks, totalChunks)and caps display at 50 rows with an explicit omitted count.tests/batch-ingestion-handler.test.ts, which invokes the registered real MCPctx_batch_executehandler and checks the bounded response behavior.max_generated_chunksa true generation cap; publicgenerated_chunksnever exceeds the configured maximum.The benchmark now measures the inventory construction included in the production handler path.
Display/index separation and compatibility
contentremains Markdown and remains present.runBatchCommands.outputsremains enabled by default for existing callers.runBatchCommands.commands,structuredContent.indexing, andContentStore.indexPreparedChunks()are additive.includeDisplayOutputs: falseto avoid a second batch-sized display/index join.No silent truncation
Markdown and structured metrics expose:
A partial payload is never labeled complete.
TDD evidence
Corrective RED:
Evidence:
C:\Users\Zhuyixiang\.codex\visualizations\2026\07\16\019f6b86-f029-7950-a7e7-ec7cbe78675f\stage-1-coordinator-red.txtCorrective GREEN, rerun after rebasing onto refreshed
origin/next:Related regression validation:
All Vitest runs in the resumed session used
--maxWorkers=1 --no-file-parallelism. The default all-files parallel suite was deliberately not rerun after two confirmed WindowsWof.syskernel crashes during broad concurrent filesystem enumeration. Directly affected and complete server/store suites passed under serialized execution.Benchmark
Command:
Environment: Node
v24.13.0, Windows x64, three repeats per scenario/mode.Raw result:
C:\Users\Zhuyixiang\.codex\visualizations\2026\07\16\019f6b86-f029-7950-a7e7-ec7cbe78675f\stage-1-benchmark-corrective.jsonSelected default-policy medians:
The coordinator's pre-fix default-policy reproduction returned 4,156 inventory lines and about 144 KiB. The corrected handler returns at most 50 rows and an explicit omitted count.
Orthogonality
PR #898 remains open and unmerged. It changes
ContentStore.#chunkMarkdown()plustests/store-bytecap.test.tsand generated bundles to enforce a per-row Markdown cap.This PR does not modify
#chunkMarkdown()and does not depend on #898. Itssrc/store.tschanges add prepared-chunk ingestion aroundindexPreparedChunks()and iterable vocabulary extraction. File overlap is limited tosrc/store.tsand generated bundles; source hunks are separate. If both land, retain both behaviors and regenerate bundles through the repository build.PR #963 remains open and unmerged. It changes bounded search-result hydration. This PR changes ingestion. Shared
src/store.ts/bundle overlap is semantically orthogonal.Files
src/batch-ingestion.tssrc/server.tssrc/store.tstests/batch-ingestion-budgets.test.tstests/batch-ingestion-handler.test.tstests/batch-ingestion-benchmark.tsserver.bundle.mjscli.bundle.mjsCommits
Base:
origin/next@e1d9448.Checklist
git diff --check