Repository navigation
Description
Part of #3640.
Blocked by #3683
Context
Delegated research may require evidence from a defined document set while excluding work handled elsewhere. (assembleContext, packages/core/src/lib/context-assembler.ts:239-371) loads canonical documents, retrieved sections and related neighbours, but callers cannot constrain all these paths explicitly. Turning off canonical inclusion does not prevent the same path from returning as a search hit or neighbour.
Core passes identity/current-focus flags through (contextBriefing, packages/core/src/lib/ops/read.ts:115-130). Pi intentionally disables their automatic injection (async context, packages/ui-backend-pi/src/brain-access.ts:224-243) and exposes fewer parameters (brainContextTool, packages/ui-backend-pi/src/brain-tools.ts:158-174). Preserve that existing distinction for unscoped calls; do not describe both defaults as the same.
Scope
- Add explicit bounded include/exclude path scope to context assembly and its CLI/MCP/Pi front doors, with clear exact-path/prefix semantics and precedence. An explicit exclusion wins throughout assembly, including automatic canonical content and graph-related enrichment.
- Allow callers to gather a budgeted briefing from a known set of paths, with query-driven selection where requested, without silently expanding into unrelated content.
- Return/document enough coverage information to distinguish a scoped briefing from a complete inventory and show what was omitted for budget or availability.
Out of scope
Changing the meaning of unscoped calls, inventing summaries, new query languages/extension seams, provider-history rewriting and broadening access through a caller's include list. Ranked retrieval remains different from exhaustive enumeration, which the discovery child owns.
Acceptance criteria
- Additive schemas specify bounded inputs, scope combination and canonical/related behavior consistently across the CLI, MCP and Pi. Existing unscoped behavior and budget/monotonicity guarantees remain covered.
- A fixture excludes
context/current-focus.mdandprojects/_index.mdwhile making both canonical/relevant/linked candidates. Neither file is opened or its content returned through the context operation, including fallback, section expansion and neighbour enrichment. - A known include set constrains candidate selection and expansion as documented; exclusions override includes, aliases cannot bypass containment or scope, and unrelated documents never fill spare budget.
- Every returned excerpt retains its actual source path and selection provenance. Budget exhaustion, unavailable content and omitted requested paths are explicit; completeness is never inferred from a successful briefing.
- Scope applies before excluded source hydration and consistently to all retrieval lanes. Existing policy/provider masks still dominate caller scope.
- Keyless real CLI/MCP and Pi tests verify the behavior. Mutations that ignore the scope in the canonical path, search expansion or neighbour path each trigger the intended assertion, then pass after restoration.
- A scoped project-evidence task is evaluated against targeted individual reads without losing required evidence or claiming the briefing enumerates every project.
Verification
Use pinned-date Odysseus fixtures, sentinel file-open instrumentation and the existing context-assembler.test.ts, MCP/CLI contract, Pi context and provider-history suites. Exercise the actual runtime as well as pure selection tests. Run focused bun run test, typecheck/lint and preflight; keep external model evaluation outside offline tests.
Contract impact
Additive optional CLI/MCP/Pi inputs and any new coverage envelope need the owning contract updates, schema snapshots/API reports, CONTRACT: prefix and minor changeset. Do not change an existing string result into a required object or alter old defaults under an additive label. 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.
Updated 2026-11-08: Everything else in this issue landed on main in #3721 (merge 26b45cb, from sub-PR #3675). One acceptance criterion remains: "A scoped project-evidence task is evaluated against targeted individual reads without losing required evidence." The evaluation ran, but the scoped briefing kept only a snippet of one raft status fact, because section expansion cannot widen a chunk that merged two short sections. Coverage reports that excerpt as a snippet. #3683 is the fix. Once #3683 lands, rerun the project-evidence evaluation from #3675 and close this issue on a full result. Alternatively, a maintainer may accept the honest-coverage result as meeting the criterion.
Activity
schlessera commentedon Nov 8, 2026
Claimed as part of the #3640 epic run (claim token
c3640-ec699b9a-3644).feat/3644-context-path-scope, 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.CONTRACT: feat(core, backends): honor explicit path scope throughout …
schlessera commentedon Nov 8, 2026
Delivered to the epic branch (2026-11-08): #3675 merged into
epic/3640-bounded-retrievalas 561091e. Its ready-candidate proof run passed on head 65284ac. This issue stays open until the epic lands onmain.What shipped:
brain context --include/--exclude(repeatable), MCPbrain_contextinclude/exclude, and the same Pi parameters, all served by one shared assembler. Each list takes up to 64 entries of 1–512 characters./. There are no globs. An exclusion always wins over an inclusion, matches any casing and follows the real path, so a symlink cannot get round it.budget,unavailable,not_rankedorexcluded. It always saysexhaustive: false. The coverage note is bounded to 20 partial excerpts and 20 omissions.Decisions taken within scope:
not_rankedrather than loaded anyway.Evaluation limit: on the scoped project-evidence task, nothing was lost silently, but one raft status fact was cut. Existing section expansion cannot widen a chunk that merged two short sections, so the briefing kept only a snippet, and coverage marks that excerpt as one. That is filed as #3683.
Mutation receipts are in #3675: the canonical, search and neighbour lanes each ignoring scope, and the real-path check removed. Each fails its named test before restoration.
Merge epic/3640-bounded-retrieval into feat/3643-overview-discovery
Merge pull request #3721 from schlessera/epic/3640-bounded-retrieval