Files
rea/docs/specs/agent-environments/rich-captures/spec.md
T
f93a0335a8 feat(analysis-view): project rich captures from Evidence files and template path pairs (#5293)
Project large local Evidence captures through the authenticated file-source boundary and add guarded opt-in sibling-pair path inference. Preserve request cancellation, resource ownership and file-relative validation diagnostics.

Validated relevant source and compiled CLI/MCP/environment boundaries, static/build/docs/catalog gates, and a real isolated Gitea 28.2.0 capture through CLI, default stdio MCP and HTTP replay. Current-head automated review passed; unrelated long-running platform jobs may still be pending.

Co-authored-by: Edgar Arakelyan <edgar.arakelyan@scale.com>
Co-authored-by: Kaoru0822 <208281322+kaoru0822-kitauji@users.noreply.github.com>
Co-authored-by: gensokyo-dev <gensokyo-dev@users.noreply.github.com>
2026-10-20 10:33:52 +08:00

3.1 KiB

Rich captures for the environment manifest

Issue: https://github.com/morluto/rea/issues/4933

Outcome

A capture large enough to hold a rich application state can be projected into an environment manifest whose tool list stays within what model providers accept. Two changes:

  • inspect_analysis_view accepts a third source, {"kind": "evidence-file", "path": "<absolute path>"}. REA reads one completed Evidence JSON file, authenticates it, and projects it like retained Evidence, so its strings are bounded by the file reader instead of being charged as inline input.
  • The environment-manifest view gains an opt-in template rule, sibling-pair-variance, that templates two adjacent literal segments after a plural literal, such as /repos/{owner}/{repo}/….

Requirements

  • An evidence-file path must be absolute and free of NUL bytes; the CLI resolves a relative path against the working directory before validation, and MCP clients pass an absolute path.
  • The file is read through the shared JSON file reader (regular file, heap and string-length guards) and parsed as complete Evidence. A missing or unreadable file is an EvidenceFileError; JSON that is not complete Evidence is invalid input reported under source.path.
  • Over MCP the read follows the request's cancellation and the server's resource scope, so a failed descriptor close stays owned for retry; a request cancelled before authentication, before projection or during projection returns typed cancellation and records nothing. Before authentication, which copies and hashes the parsed Evidence, REA checks that live heap headroom holds those copies and otherwise returns resource_constraint.
  • A file source projects exactly what the same Evidence projects inline or retained, with the same parent Evidence ID, view parameters and result.
  • The synchronous projection API refuses an unread evidence-file source with a typed capability error; the CLI and MCP adapters read files first.
  • sibling-pair-variance applies only when listed, before sibling-variance, so a single-position merge cannot template one half of a pair first. It compares groups equal in method, origin and segment count except at two adjacent literal positions at index 2 or later that follow a plural literal and precede another literal (a trailing pair, such as /users/alice/followers, names a sub-resource rather than a namespace and name), and merges a bucket only when it holds at least three distinct pairs and both positions vary. Stop words and v1-style versions never qualify, and routes of more than 32 segments are not compared, with a limitation saying so.
  • Its parameters are named from the plural literal, singular plus _namespace and then _name, and labelled sibling-pair-variance.

Non-goals

  • No change to the 96 MiB projection budget or to inline admission.
  • No change to sibling-variance; pairs are a separate rule so every inferred parameter keeps naming the rule that produced it.
  • No inference of semantic names (owner, repo) beyond the plural literal.