Repository navigation
Description
Part of #3640.
Context
Bounded multi-document reads may reduce overhead and improve response budgeting, but current tools can already execute concurrently. Establish the correct baseline and a concrete contract before shipping a new tool. The deliverable is a written decision and reproducible evidence; a no-go or explicitly inconclusive result is valid.
Read (readDocument, packages/core/src/lib/ops/read.ts:139-147), (brainReadTool, packages/ui-backend-pi/src/brain-tools.ts:178-221), (brainReadBaseResult, packages/ui-sdk/src/server/brain-read-base.ts:58-100), and (toolObservation, packages/ui-server/src/brain/tool-observation.ts:37-42). Core MCP registration is (registerReadTools, packages/core/src/mcp-server.ts:212-414). The existing search/context evaluation guide is docs/evaluating-search.md; it measures retrieval quality, not agent tool selection.
Scope
- Specify a candidate
brain_read_manycontract: explicit path/section requests, maximum item count, per-item and aggregate serialized-output budgets, raw-read/work limits, outline/partial/continuation semantics, duplicate handling and item errors. Define byte/character/token units accurately and include metadata/escaping in the aggregate bound. - Compare equivalent sequential individual reads, parallel individual reads and bounded batches, including outline-to-section follow-ups. Separate known-path retrieval from discovery and later dependent reads.
- Measure the actual CLI/MCP and Pi paths and host-inclusive overhead where the native fixture is available. Record cancellation, journal scheduling, load/runtime/package identities and transport boundaries without weakening protections.
- Assess model usability with the same tasks, especially
gpt-6.1-terra, when authorized model access is available. Keep live provider experiments outside offline tests; report unavailable evidence honestly.
Out of scope
Production tool/schema changes, new dependencies/seams, changed ranking, relaxed journal/permission guards and claims that every repeated path is redundant. Do not make an API key or external network a test requirement.
Acceptance criteria
- A source-grounded contract proposal specifies every bound, unit, output discriminator, error and continuation behavior and preserves old single-read semantics. It compares a distinct tool with an overload and explains the choice.
- Reproducible Odysseus scenarios cover small files, large frontmatter, many headings, huge lines, mixed scripts, late-document updates, missing/refused paths, sections and aggregate overflow. Use the pinned
2026-07-12date. - Equivalent comparisons report evidence coverage/attribution, correctness, tool calls, actual provider-request grouping where observable, returned bytes, input/output/cache tokens where reported, latency and cost. Missing dimensions remain unavailable; timing overlap is not silently equated to provider-response identity.
- At least one real keyless MCP/runtime exercise and one Pi exercise establish the mechanics. Scripted provider responses are identified as such and do not count as evidence that Terra chooses or understands the tool.
- Repeated model trials, if run, retain their exact model/route/settings and task/fixture identities; their absence prevents a model-usability claim, not the independent keyless work.
- The issue receives a decision explaining go/no-go, evidence limits, proposed safe defaults and rollout/verification gates. A positive decision supplies the inputs the production-read child needs; closure alone is not approval to ship an unsupported contract.
Verification
Reuse the repository's offline harness and real stdio MCP fixtures; place harness-only tests in experiments/ under docs/process/testing.md. Run the focused harness command through bun run test and record the exact commands and raw/aggregate evidence locations. If fixture prerequisites prevent a dimension, finish independent work and state what remains unqualified. Never reproduce a private corpus in committed evidence.
Contract impact
None for a written spike and private prototype. Any supported production API/CLI or exported contract change belongs to the implementation child and requires its contract update and changeset. No release milestone is assigned.
Triage 2026-11-08 at main 1619741f291f525d17cde4970a5ada40644117c1: Verified the cited shared operations and concrete Pi adapters. The independent brief is complete; p2 reflects wanted unscheduled work. External model evidence is optional and does not block the specified keyless work.
Activity
schlessera commentedon Nov 8, 2026
Claimed as part of the #3640 epic run (claim token
c3640-ec699b9a-3641).spike/3641-bounded-read-contract, PR targeting the epic integration branchepic/3640-bounded-retrieval; the epic lands onmainas one batch.origin/main1619741): every code citation in this body still points at its named anchor.docs: qualify a bounded multi-read against parallel brain_read (#3641) (
schlessera commentedon Nov 8, 2026
Spike decision (2026-11-08): go for a distinct, bounded
brain_read_many, justified by bounding and attribution, not efficiency. Model usability is inconclusive because it was not measured.Delivered in #3674, merged into
epic/3640-bounded-retrievalas 8843b7b. The record isdocs/decisions/bounded-multi-read.md, the harnessexperiments/bounded-read-contract.test.ts, and the reusable helpers sit underexperiments/bounded-read/.Go: a separate tool, not an overload of
brain_read. It gives:full,outline,partial,duplicate,error) with continuation;sha256, so a file that changed between an outline and its follow-up surfaces assource_changed;Today
brain_readover MCP has no cap: a 70,612-char line came back whole, and parallel reads add up without a limit.The overload was rejected because it would:
brain_readcan return one section or stop at a token limit #383 keeps the single read uncapped;brain_read's permission and journal rules without review.No efficiency claim. For the same content the batch is larger:
brain_readcalls already come back in one assistant message and one follow-up request.Safe defaults for #3642:
max_total_chars24,000 (allowed 2,000–40,000), counted asJSON.stringify(result).length, metadata and escaping included;max_item_chars8,000 (minimum 512);Rollout gates:
CONTRACT:commit with the schema snapshot, roster fixtures and a minor changeset.Evidence limits: offline mechanics only, through the real stdio MCP server and Pi's agent loop with a scripted faux provider. Provider tokens, cache, cost, real request grouping and model usability are unavailable. No real-model trial was authorized.
Follow-ups filed: #3680 (host path in the
brain_readerror), #3681 (a same-content rewrite stays stale), #3682 (Pi clip units). #3642 is unblocked by this decision; the dependency is satisfied once this issue closes.CONTRACT: feat(core, backends): add bounded multi-document and sectio…
Merge pull request #3721 from schlessera/epic/3640-bounded-retrieval