Skip to content

core, backends: expose bounded overview metadata and paged document discovery #3643

Closed

Description

@schlessera

Part of #3640.

Context

A project inventory needs enough metadata to choose what to read next. (listDocuments, packages/core/src/lib/ops/read.ts:175-194) currently emits path/title/type/relevance/status/tags; summary, update date, deadline and source size are absent. The CLI's existing (listCommand, packages/core/src/cli/commands/list.ts:33-73) returns richer SearchResult rows, so the gap is not identical on every surface. (brainListTool, packages/ui-backend-pi/src/brain-tools.ts:225-256) has its own wrapper. The current list API has a result limit but no continuation cursor or path-prefix scope.

Pi search also drops existing core metadata in its model-visible formatting (brainSearchTool, packages/ui-backend-pi/src/brain-tools.ts:94-155). This forces extra reads for dates/status even when indexed facts already exist. Read the parent and docs/integration-contract/cli.md, docs/integration-contract/mcp.md and docs/content-index-queries.md before choosing the additive projection.

Scope

  • Offer an additive bounded overview projection with summary, frontmatter update date, status, deadline and a clearly defined source-size fact/estimate, consistently available through CLI, MCP and Pi. Preserve each legacy default response.
  • Add a contained path-prefix filter and paged continuation for discovery, so callers can enumerate the intended document set without a raw filesystem glob or silently stopping at a limit.
  • Preserve useful existing metadata in Pi search's model-visible results under an explicit output budget.
  • Reuse concrete shared operations/query results under Epic: the brain CLI and MCP server call one operations layer and one index reader #1341; do not put SQL back into CLI commands or create a second provider-resolution path.

Out of scope

Inventing project activity from directory placement, rewriting summaries/frontmatter, changing ranking or taxonomy, multi-query search and opening every file body to construct an expensive overview. Metadata helps select evidence; it does not establish current repository activity.

Acceptance criteria

  • The additive projection, field provenance/nullable cases and units are documented. A frontmatter date is distinguished from filesystem mtime and actual development activity; an indexed-body estimate is never labeled as exact full-file UTF-8 size.
  • Identical fixtures expose equivalent requested facts on all three surfaces; Pi search retains core-provided dates/status/summaries when requested. Legacy defaults/shapes and warnings remain compatible.
  • A stable, documented ordering and scoped cursor let a fixture larger than the current limit be fully enumerated without duplicates/omissions while the index is unchanged. Changed/invalid/stale cursor behavior is explicit.
  • Prefix matching respects path segments and containment/provider masks; a neighbouring prefix or unrelated file does not leak into the requested inventory.
  • Whole rows, metadata, cursor and warnings fit a hard aggregate output bound, with honest continuation/omission information. Large summaries do not yield clipped invalid JSON or empty pages that cannot advance.
  • Missing/stale index, unreadable or changed source-size metadata and concurrent indexing retain truthful warning/provenance behavior.
  • A project-overview fixture demonstrates which reads can be avoided while preserving evidence quality. A mutation that removes required metadata or breaks paging makes the appropriate contract/runtime test fail before restoration.

Verification

Use Odysseus fixtures with the pinned 2026-07-12 date. Cover multi-page and long-field cases, unchanged legacy CLI/MCP envelopes, real MCP calls and Pi tool execution. Run focused tests with bun run test, typecheck/lint and preflight. Re-run retrieval goldens only if retrieval behavior changes; such a change needs a reviewed explanation.

Contract impact

Additive opt-in CLI/MCP/backend discovery surface and possibly supported query fields. Carry contract, update owning contract components/schema snapshots/API reports in the same CONTRACT: commit and add a minor 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

  1. added
    type: feat
    area: core
    area: mcp
    area: backends
    contract
    on Nov 6, 2026
  2. added
    priority: p2
    agent-ready
    on Nov 8, 2026
  3. self-assigned this
    on Nov 8, 2026
  4. schlessera commented on Nov 8, 2026

    @schlessera
    OwnerAuthor

    Claimed as part of the #3640 epic run (claim token c3640-ec699b9a-3643).

    • Branch: feat/3643-overview-discovery, PR targeting the epic integration branch epic/3640-bounded-retrieval; the epic lands on main as one batch.
    • Readiness check (2026-11-08, origin/main 1619741): every code citation in this body still points at its named anchor.
    • Collision check over the cited files: no path collisions with open PRs; only shared test-category closure overlaps.
  5. schlessera commented on Nov 8, 2026

    @schlessera
    OwnerAuthor

    Delivered to the epic branch (2026-11-08): #3684 merged into epic/3640-bounded-retrieval as 2b101ab. Its ready-candidate proof passed on head ebdb875. This issue stays open until the epic lands on main.

    What shipped:

    • brain list --path-prefix/--overview/--cursor, plus the matching brain_list inputs on MCP and Pi (path_prefix, overview, cursor) and the pageIndexDocuments query. All run one shared core operation (packages/core/src/lib/document-page.ts).
    • Any of the three inputs opts into one bounded page: { documents, next_cursor, total, truncated?, warnings }.
      • Rows are ordered by updated, newest first, then by path.
      • Each page is at most 30,000 UTF-8 bytes of compact JSON, whole rows only.
      • An oversized row is shortened in place and named in clipped.
    • overview adds summary, updated, deadline, indexed_at and indexed_body_bytes.
      • updated is the frontmatter date, not the file mtime or project activity.
      • indexed_body_bytes is an estimate of the indexed body, never the whole file's size.
    • path_prefix matches whole path segments.
    • Cursors:
      • a malformed cursor, or one from another listing's filters or prefix, is refused;
      • a cursor carried across an index change continues, with a stale-cursor warning.
    • Pi brain_search takes overview to keep status, dates and summaries under its output budget.
    • Calls without the new inputs return the legacy output byte for byte.

    Mutation receipts are in #3684. Follow-up: an exact full-file size would need the indexer to store a stat for markdown files. It is not filed, because the documented estimate meets the criteria.

  6. added this to the 0.45.0 milestone on Nov 8, 2026
  7. removed their assignment
    on Nov 8, 2026
  8. added a commit that references this issue on Nov 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readyarea: backendsarea: corearea: mcpcontractpriority: p2type: feat

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions