Repository navigation
Description
Part of #3640.
Blocked by #3641
Context
Agents that already know several document paths or section requests currently issue one brain_read per item. A bounded aggregate operation can reduce per-call overhead and give the caller one total output budget. Implement only after the evaluation child supplies a positive contract decision and qualification gates; do not interpret a closed but negative/inconclusive spike as a go-ahead.
Current shared reading is (readDocument, packages/core/src/lib/ops/read.ts:139-147); the core wrappers are (registerReadTools, packages/core/src/mcp-server.ts:212-414) and Pi uses (brainReadTool, packages/ui-backend-pi/src/brain-tools.ts:178-221). (brainReadBaseResult, packages/ui-sdk/src/server/brain-read-base.ts:58-100) is an existing example of honest paging, but is a separate hosted-write base contract. Read the parent constraints and docs/integration-contract/mcp.md.
Scope
- Implement the approved bounded read-many operation once in core with a CLI
--jsonfront door, MCPbrain_read_manyand Pi adapter, unless the spike's explicit decision chooses another additive naming shape. - Accept a bounded list of document/section requests, label each result with its path and selection, and enforce per-item plus complete serialized-response caps. Report full/outline/partial/error outcomes and continuation or unreturned requests without silently losing items.
- Apply each member's existing containment/provider restrictions and cancellation, with bounded I/O/work and deterministic ordering. An unavailable member must not discard successful reads.
- Integrate static tool rosters, read allowlists, voice/restricted postures and lock classification in both backends. Keep journal observation conservative unless the actual execution path proves the required capability; an annotation alone proves nothing.
Out of scope
Implicit recursive/glob ingestion, automatic traversal of related files, write batching, a generic batch executor, provider migration and treating a retrieval response/page hash as a hosted write-base authorization. Existing single-file calls and their output/defaults remain unchanged.
Acceptance criteria
- CLI, MCP and Pi expose the approved schema and equivalent selection/error/budget semantics, using a shared operation rather than independent implementations.
- Each requested item is accounted for and traceable. Missing/refused items, duplicates, invalid sections, insufficient aggregate budget and cancellation have deterministic documented behavior.
- Hard bounds hold for file count, raw-read/work limits, selected content and serialized model-visible output, including metadata, warnings, escaping, large frontmatter/headings and non-ASCII text. Continuation makes progress and detects relevant source changes as specified.
- Traversal, escaping symlinks, masked content and out-of-scope files remain refused per member. Mixed success/failure batches preserve the same authority as individual reads.
- All legacy read and hosted
brain_read_basecontracts remain intact, including opt-in outline thresholds, exact section bytes and whole-document base receipts. - Real keyless MCP and Pi runtime proof exercises multi-item results, policy gating, concurrent callers and cancellation. Mutating a cap or containment check makes a named test fail on the expected assertion before restoration.
- Evaluation compares the delivered operation with existing parallel reads under the spike's gates, reporting quality and request/token/latency evidence without assuming a speedup proportional to tool count.
Verification
Use Odysseus fixtures and the pinned date. Extend the real MCP contract/schema snapshots, CLI contract and Pi read/runtime tests as applicable. Run focused bun run test commands, the provider-history guard for both backends, typecheck/lint and bun run check:pr --base origin/main; preserve failing-first/restored receipts. Keep provider-cost experiments outside tests.
Contract impact
Additive CLI JSON/MCP/backend surface: update the relevant integration-contract components, schema snapshots and API reports in the same CONTRACT: commit, with contract and a changeset for a minor release. A legacy default-cap change is excluded by #383. Release scheduling follows the positive decision and is not assigned here.
Remaining contract decision
The maintainer must accept the positive contract and qualification gates from #3641 before implementation: distinct-tool/overload shape, units, numeric caps, partial/continuation and error semantics. Fold that selected result into this body. A closed negative or inconclusive spike does not satisfy this prerequisite. Recommendation: keep the additive distinct-tool candidate only if #3641 supports it; this is not approval. Keep needs: decision and blocked until the actual output is verified.
Triage 2026-11-08 at main 1619741f291f525d17cde4970a5ada40644117c1: Verified still-open #3641 and current read adapters. Priority p2 reflects wanted unscheduled work; readiness waits on the contract ruling.
Activity
docs: qualify a bounded multi-read against parallel brain_read (#3641) (
schlessera commentedon Nov 8, 2026
Claimed as part of the #3640 epic run (claim token
c3640-ec699b9a-3642).feat/3642-bounded-read-many, with a PR targeting the epic integration branchepic/3640-bounded-retrieval.docs/decisions/bounded-multi-read.md, 8843b7b). This work starts from that tip. core, backends: qualify bounded multi-read contracts against parallel retrieval #3641 stays open until the epic reachesmain, soblockedand theBlocked byline remain until then.test: list brain_read_many among the installed and experiment core to…
CONTRACT: feat(core, backends): add bounded multi-document and sectio…
schlessera commentedon Nov 8, 2026
Delivered to the epic branch (2026-11-08): #3702 merged into
epic/3640-bounded-retrievalas c40d04d. Its ready-candidate proof passed on head 26b15eb. This issue stays open until the epic lands onmain.What shipped:
brain_read_manyon MCP and Pi, plusbrain read-many --json. All three are thin adapters over one core operation (readMany,packages/core/src/lib/ops/read-many.ts), built to the core, backends: qualify bounded multi-read contracts against parallel retrieval #3641 contract.max_total_chars24,000 (2,000–40,000) andmax_item_chars8,000 (min 512), both counted asJSON.stringify(result).length;full,outline,partial,duplicateorerror;sha256, and a continuation with a stale hash reportssource_changed;voice-permission.md), the no-lock reads and the index barrier.HOST_READS. It is not in schedules (ui-server: scheduled jobs cannot use brain_read_many #3712), server instructions or skills, per the rollout gate that requires a recorded real-model trial first.brain_read,readDocumentand the hostedbrain_read_baseare unchanged.Evaluation: the #3641 harness was rerun against the real tool and passes 26/26. No speedup is claimed:
Provider tokens, cost and model usability are not measured. Choices made where the decision record left details open are listed in its "Delivered in #3642" section. The 14 mutation receipts are in #3702.
Merge pull request #3721 from schlessera/epic/3640-bounded-retrieval