141. Deterministic filtered entity-context-snapshot staging
Date: 2026-09-07
Status
Accepted
ADR 0151 partially supersedes the human threshold inherited from ADR 0133 for Fullsend-controlled model-bound snapshot records in the target contract: admission uses the selected harness's effective human_min_role above an immutable triage floor. Snapshot v1 retains its historical threshold; deterministic assembly, current-revision checks, and filtering remain required.
Context
Issue #6407 identifies that agents and harness scripts repeatedly fetch the issue or change proposal they are handling, including comments, reviews, checks, and logs. Those tool calls spend tokens, make runs depend on runtime network access, and give each consumer a different view when the entity changes during a run.
Forge content is also untrusted input. Fetching it directly from inside the sandbox bypasses the deterministic point where Fullsend can bound, normalize, redact, and label content before it reaches an agent. This decision generalizes the preferred prefetch model from ADR 0017 to every issue and change-proposal run.
This ADR's entity-context-snapshot is the staged data snapshot. It is distinct from the dispatch-layer routing category called entity context in ADR 0076. The qualified name is intentional: it identifies the data structure without redefining ADR 0076's established routing term.
ADR 0133 defines the security boundary for actor-attributed source data: authorization is evaluated for the actor of each current source revision, authorization permits data to be considered but does not make its text safe, and every admitted record must pass the common filtering, delimitation, and fail-closed rules. This ADR applies that boundary to the deterministic snapshot path rather than defining a second trust model.
Decision
Before the harness pre-script, fullsend run uses forge.Client to assemble one immutable snapshot of the handled entity. The runner applies a mandatory, deterministic content pipeline to each complete selected source: Unicode safety normalization, secret and sensitive-data redaction, injection scanning, then size limits. A detector failure or timeout aborts snapshot assembly. It fails closed when required data cannot be fetched or safely represented. Filtered content is the only copy exposed to scripts and the agent; the manifest records every truncation, replacement, finding, and fetch error without retaining rejected content.
Record admission follows ADR 0133 and the role thresholds selected by the agent's harness under ADR 0054 and ADR 0098. Fullsend verifies the source record's current-revision actor and current authorization independently of the event sender, poller, retrieval credential, or discovery provenance. Unauthorized, unattributed, or unverifiable comments and reviews are omitted and represented by bounded manifest gaps; they are not exposed as raw or filtered text. For a bot actor, Fullsend uses the provider-backed exact actor.bot_role recognition defined by ADR 0107; the human repository-role threshold does not apply. A bot with no recognized role, or with an unavailable or unverifiable lookup, remains omitted. Future ADRs may broaden admission to additional provider-backed bot identities, but this ADR does not invent a second bot-role mechanism. Successful authorization is therefore an admission prerequisite, not a claim that the record is trustworthy or can change platform authority.
The handled entity's body is actor-attributed content and follows the same current-revision attribution and authorization rule. If its author is missing, unverifiable, unauthorized, or fails filtering, Fullsend records an entity-scope gap and aborts snapshot assembly; "required entity body" means required only after successful admission and filtering.
The snapshot is written outside the repository clone. Host-side pre- and post-scripts receive FULLSEND_CONTEXT_DIR pointing to an access-restricted temporary directory outside the retained run-output tree; inside the sandbox the same variable points to the runner-owned reserved sibling path /sandbox/entity-context-snapshot. Fullsend must reject any checkout or host_files destination that would overlap that path, and must abort if the reserved path already exists with unexpected contents. Fullsend uploads that directory after sandbox creation and before repository/runtime execution. Consumers therefore use the same variable and relative paths on both sides of the sandbox boundary, and the context cannot be staged or committed accidentally with repository files.
The exact tree, schemas, canonical serialization, stable record-key derivation, filter statuses, and compatibility rules are the versioned entity-context-snapshot v1 specification. Content records and mutable observation state are separate: resolving or reordering a thread changes its state/index files, never an unchanged comment or review body. No runner-clock timestamp enters the staged tree. Given the same complete normalized acquisition inputs defined by the v1 specification— including forge responses, authorization-provider results, effective admission policy, collection profile, size bounds, filter version, and active credential-redaction registry—implementations produce the same paths and bytes; breaking that guarantee requires a new major specification.
The snapshot contains forge state that cannot be reconstructed from the target Git checkout. It does not copy diffs, commit history, changed-file manifests, or repository revision metadata. Fullsend provisions sufficient Git objects and refs separately; controllers derive and filter diffs or commit projections for agents and sub-agents that need them. Git object IDs appear in the entity-context-snapshot to relate reviews, threads, comments, and agent runs to repository state, and as the collected target revision in check metadata.
Each comment and review is a self-contained attributed record whose filename sorts chronologically. The initial body uses the same record format and sorts first. Order files define whole-conversation and review-focused projections and refer to the same records rather than copying content. New replies append without rewriting unchanged record files. Review-thread relationships, commit references, and immutable Fullsend agent-run receipts preserve enough provenance to relate a finding, the reviewed revision, a subsequent fix, and a re-review.
The pre-script may inspect the host snapshot and skip the run. At assembly time, Fullsend retains the exact index.json bytes, or a digest of those bytes, in host-private run state outside FULLSEND_CONTEXT_DIR. After the pre-script, Fullsend compares the on-disk root index with that retained value and aborts on any difference; it does not accept a rewritten index or re-parse it as the root of trust. Only after that comparison does it verify child digests and the exact manifest path set against the assembly-time index. Fullsend removes extra paths or aborts assembly before upload. The sandbox copy is agent-immutable: it is exposed through a read-only bind mount, or, where that is unavailable, a root-owned tree with mode 0555 directories and 0444 files while the agent runs unprivileged with CAP_FOWNER and equivalent write-overriding capabilities removed. If neither mechanism can be enforced, Fullsend aborts before launching the agent.
When a runtime injects staged context into a model request, it emits each ordered record as a distinct content block, followed by relationship and mutable-state blocks and then run-specific instructions. It must not collapse the records into one changing prompt block when cache reuse is intended. Provider prompt caching remains an optimization, not a conformance guarantee; agents that read records through tools still pay the corresponding tool-result tokens. Deterministic order projections remain navigation aids for selective reads. Runtime forge reads for entity-context-snapshot source kinds are denied by default. An explicitly configured host-side extension may fetch a kind outside the snapshot only when it applies the same versioned pipeline and fail-closed rules and exposes no raw payload to the sandbox; it records the omission and extension result outside the immutable v1 snapshot. A present extension configuration that cannot be parsed denies every runtime entity-context-snapshot fetch. Extension output uses the snapshot's filter_version, filter statuses including rejected, and the same detector-failure abort rules. V1 extension output outside the manifest is host-only and never sandbox-visible. Making an extension result sandbox-visible requires a versioned schema that lists its path in the manifest and subjects it to the same filtering, digest, permissions, exact-path, and cleanup rules.
The host snapshot uses a mode-0700 directory and mode-0600 files. Those host permissions do not make a sandbox copy read-only. Fullsend removes the sandbox copy after its last sandbox consumer and the host copy after the post-script, on success, failure, skip, or handled cancellation; startup also scavenges orphaned context directories after abnormal termination. Context is excluded from retained run artifacts by construction. Diagnostics may retain only bounded counts, digests, and filtering findings, never bodies or logs.
Consequences
- Agents start with one filtered, versioned view and avoid duplicate forge reads, but token and provider-cache savings are conditional on selective projections and segmented runtime injection rather than automatic consequences of staging files.
- Fullsend must provision the Git objects and refs required by each run, let controllers derive and filter repository projections on demand, and add segmented context input, cache-boundary support, and efficiency telemetry before claiming an improvement.
- Shipped and custom review, fix, and code agents must migrate from mutable sticky summaries and single-body hand-offs to discovered entity-context-snapshot projections, publish immutable per-run result receipts while retaining human-facing summaries, and anchor decisions to record keys and revisions.
- Forge adapters must expose review/reply relationships, locations, reviewed-revision references, checks, and immutable agent-result references through
forge.Client; unavailable or unrecoverable forge history is an explicit manifest gap, not a silent omission. - Snapshot assembly adds bounded startup latency and storage and can become stale, so collection profiles avoid indiscriminate log/history fetching and deterministic post-processing still validates relevant revisions before any forge mutation.
- The actor-attributed data boundary, including fresh authorization, common filtering, redaction, delimitation, and fail-closed behavior, is inherited from ADR 0133; future snapshot or retrieval paths must preserve that boundary rather than treating this file layout as a security mechanism by itself.
