Story-1999 functions lane Matter Frame

Matter Frame run-input manifest

Story-1999 records which document versions entered a Vega Matter Frame run, then exposes the Brief provenance count without changing per-fact citations.

The mental model: a frame row says which run produced the Brief. The manifest says which documents were placed on Vega's desk for that run. Citations still say which document proves each claim.

What changed

Manifest table

business.matter_frame_run_inputs stores agent_run_id, document_id, and document_version for each input document.

Immutable storage

The app role can insert and read manifest rows. It cannot update or delete them, matching the audit posture of frame history.

Brief provenance

GET /app/matters/{matter_id}/brief now returns builtFromDocumentCount on the current frame.

Boundaries

  1. The manifest is run-level provenance: it answers what went into the run.
  2. envelope.provenance remains fact-level provenance: it answers what supports a claim.
  3. The Brief joins from matter_frames.agent_run_id to the manifest with one bounded count query.
  4. Firm RLS applies to the manifest table, so another firm cannot count or inspect inputs.

Verification: migration unit tests pin constraints/RLS/grants; integration tests prove real manifest rows, firm isolation, immutability, and the Brief response shape.