Repository navigation
Description
Context
Found by #3644. When the indexer merges two short sections into one chunk, context assembly's section expansion in (sourcePart, packages/core/src/lib/context-assembler.ts:677-709; hitSection, same file:722-745) keeps only a one-line snippet of that chunk, even when budget remains. In the #3644 project-evidence evaluation, a scoped briefing over two project status.md files missed the raft status fact "Get permission and the tools, then cut and join the timber"; coverage correctly reported the excerpt as a snippet.
Scope
Let section expansion widen a merged chunk to its full span when the budget allows, preserving budget, monotonicity and provenance guarantees.
Out of scope
Chunking changes in the indexer, ranking changes.
Acceptance criteria
- On the core, backends: honor explicit path scope throughout context assembly #3644 fixture (
makeScopeBrain), the scoped briefing includes the full raft merged-chunk span, including "Get permission and the tools, then cut and join the timber", when the budget allows; the assertion atpackages/core/tests/context-scope.test.ts:345is inverted accordingly. - A uniquely matched folded section still expands to that section only (existing test at
packages/core/tests/context-assembler.test.ts:865-879unchanged); the unknown/ambiguous case (:883-899) now expands to the whole span when it fits and keeps the snippet when it does not. - Budget and monotonicity tests still pass; a tight budget still degrades to the snippet with coverage saying so.
- Retrieval goldens are rerun, and any diff is explained in the PR.
Verification
packages/core/tests/context-assembler.test.ts and the context-scope tests; bun run test, bun run check:pr --base origin/main.
Contract impact
None expected (briefing content within existing budget semantics).
Refs #3644
Current-source distinction and remaining evidence
The inspected main already expands a folded chunk into one matching section when its match line uniquely identifies that section. It deliberately retains the snippet when the folded chunk's match line is unknown or ambiguous. The existing tests encode both behaviors: a short section folded into a long one (packages/core/tests/context-assembler.test.ts:865-879) and when the match cannot be placed in a folded chunk (packages/core/tests/context-assembler.test.ts:883-899). Therefore a blanket claim that merged short sections cannot expand is not established by the current source. The #3644 scoped implementation and its exact coverage fixture have now landed through #3721. The bounded reproduction below resolves the earlier fixture gap.
Reproduction complete (2026-11-08): the exact Odysseus fixture is makeScopeBrain (packages/core/tests/helpers/context-scope-fixture.ts:45), over the committed corpus status files. bun run test packages/core/tests/context-scope.test.ts -t 'scoped project-evidence' passes both evaluation cases (19 assertions) at the inspected SHA on Bun 1.4.4. Its assertion at packages/core/tests/context-scope.test.ts:345 explicitly confirms the missing raft fact rather than asserting complete coverage.
A separate bounded call of the same real initializer/indexer/assembler used query project status next action, maxTokens 2000, now 2026-07-12, include projects/active/raft/status.md and projects/active/sail-repairs/status.md, exclude context/current-focus.md and projects/_index.md. Actual: the output is 212 estimated tokens with an 800-token per-hit cap; raft is form: snippet, sail repairs is section, no omitted paths, budgetExhausted: false. The full raft fact Get permission and the tools, then cut and join the timber is absent (the snippet ends cut and join the...), although the targeted source read contains it.
The raft's best chunk is index 0, heading Next action, with a folded ## Latest session (2026-06-30) and the full next-action sentence. The real chunkMatchLine (packages/core/src/lib/search-engine.ts:1034) returns null. sourcePart therefore reaches its deliberate folded/unknown-match null fallback, before a source section can be selected. This is not a uniquely matched section rejected for lack of budget. No product code was changed or paid provider called.
needs: decision question (resolved below): retain expansion into one uniquely matched source section and diagnose a failure of that existing behavior, or explicitly broaden expansion to every component section/full merged-chunk span when budget allows? The latter changes the existing matching-section and ambiguous-fallback semantics and needs a scoped product/contract decision; it must not pull unrelated component sections across caller scope or budget. Recommendation: preserve the existing unambiguous-section rule unless the maintainer explicitly wants this observed unknown-match folded chunk to widen. The precise scoped case is now established; it demonstrates the deliberate fallback rather than a failure of uniquely matched expansion. The maintainer must record the chosen behavior and update acceptance/contract assessment before clearing this decision need. The missing fact is now observed on main; no implementation or approval of whole-span expansion follows from it.
If the report is an existing-rule defect, provide the matching failing-first section-selection test. If a wider expansion is selected, specify ordering, provenance/coverage, ambiguous-match and truncation behavior, preserving excluded-file no-open, monotonicity and whole-block cuts. #3644 supplies the discovery context, not a blanket dependency on finishing its entire implementation. This context-evidence scope fits #3640.
Triage 2026-11-08 at main 1619741f291f525d17cde4970a5ada40644117c1: Found existing folded-section success and deliberate ambiguity-fallback logic; recorded exact missing fixture/evidence and the narrower-versus-whole-span decision. Priority p2 reflects wanted unscheduled work; assignments and milestones are preserved.
Triage 2026-11-08 at main 8752570331ffebdbb9233196412781f6cd71f3d9: Resolved the exact-fixture prerequisite with the shipped evaluation and a bounded real-assembler observation. Removed needs: repro; retained the genuine expansion/compatibility ruling and p2. No broader expansion is approved.
Maintainer decision — 2026-11-08
widen when the match is unknown or ambiguous.
- Unique match: when the match line identifies exactly one section of a folded chunk, behaviour is unchanged and that section expands.
- Unknown or ambiguous match (
chunkMatchLinereturns null, or the line spans several component sections): if the remaining per-hit and total budget fits the whole merged chunk span, emit that span, meaning all of its component sections in source order as one excerpt. If it does not fit, keep today's snippet, with coverage saying so. - Every component section comes from the hit's own file, by construction. Caller scope is respected, excluded files are never opened, monotonicity and whole-block cuts hold, and no section from another chunk is pulled in.
- Coverage reports the widened excerpt with its line range using the existing coverage forms. If an implementation finds that a new form value is required, that is an additive
CONTRACT:change and must be called out in the PR. - Retrieval goldens are rerun and every diff is explained.
2026-11-08: folded the ruling into the acceptance criteria; removed needs: decision, added agent-ready.
Activity
schlessera commentedon Nov 8, 2026
Raised to
priority: p2. It blocks #3644, which is p2, and a blocker takes at least the priority of the issue it blocks.schlessera commentedon Nov 8, 2026
Decision (maintainer, 2026-11-08): widen when the match is unknown or ambiguous.
chunkMatchLinereturns null, or the line spans several component sections): if the remaining per-hit and total budget fits the whole merged chunk span, emit that span, meaning all of its component sections in source order as one excerpt. If it does not fit, keep today's snippet, with coverage saying so.CONTRACT:change and must be called out in the PR.schlessera commentedon Nov 9, 2026
2026-11-09: detached from epic #3640 by maintainer decision (ruling). This issue is now standalone. Its scope, labels and readiness are unchanged.