From 68c41aed31f85f33940cf8eaed244a0f87342259 Mon Sep 17 00:00:00 2001 From: Barak Korren Date: Mon, 7 Sep 2026 16:05:18 +0300 Subject: [PATCH 01/33] docs(#6407): adopt deterministic entity context staging Record a runner-owned, filtered entity snapshot that is available before the pre-script and exposed through predictable paths outside the repository clone. Signed-off-by: Barak Korren Assisted-by: Codex (gpt-5.6-sol) --- ...edential-isolation-for-sandboxed-agents.md | 3 + ...inistic-filtered-entity-context-staging.md | 100 ++++++++++++++++++ docs/architecture.md | 5 + docs/problems/security-threat-model.md | 2 + 4 files changed, 110 insertions(+) create mode 100644 docs/ADRs/0107-deterministic-filtered-entity-context-staging.md diff --git a/docs/ADRs/0017-credential-isolation-for-sandboxed-agents.md b/docs/ADRs/0017-credential-isolation-for-sandboxed-agents.md index 60aed52173..a3b6b34a0a 100644 --- a/docs/ADRs/0017-credential-isolation-for-sandboxed-agents.md +++ b/docs/ADRs/0017-credential-isolation-for-sandboxed-agents.md @@ -18,6 +18,9 @@ Date: 2026-04-01 Accepted (credential delivery tiers extended by [ADR 0025](0025-provider-credential-delivery-for-sandboxed-agents.md)) +The default prefetch model is standardized for handled entity content by +[ADR 0107](0107-deterministic-filtered-entity-context-staging.md). + ## Context When sandboxed agents need to perform operations requiring credentials (e.g. reading or writing GitHub issues), the credential must be kept away from the agent process. A compromised agent with access to a credential can exfiltrate it — once the credential leaves the sandbox, the attacker can use it without any sandbox constraints. diff --git a/docs/ADRs/0107-deterministic-filtered-entity-context-staging.md b/docs/ADRs/0107-deterministic-filtered-entity-context-staging.md new file mode 100644 index 0000000000..3fe3b49ae5 --- /dev/null +++ b/docs/ADRs/0107-deterministic-filtered-entity-context-staging.md @@ -0,0 +1,100 @@ +--- +title: "107. Deterministic filtered entity-context staging" +status: Accepted +relates_to: + - agent-architecture + - security-threat-model +topics: + - entity-context + - security + - harness + - token-cost +--- + +# 107. Deterministic filtered entity-context staging + +Date: 2026-09-07 + +## Status + +Accepted + +## Context + +[Issue #6407](https://github.com/fullsend-ai/fullsend/issues/6407) identifies +that agents and harness scripts repeatedly fetch the issue or change proposal +they are handling, including comments, reviews, diffs, 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](0017-credential-isolation-for-sandboxed-agents.md) to every issue and +change-proposal run. + +## 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: size limits, Unicode safety normalization, +secret and sensitive-data redaction, and injection scanning. 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. + +The snapshot is written outside the repository clone. Host-side pre- and +post-scripts receive `FULLSEND_CONTEXT_DIR` pointing to +`/context`; inside the sandbox the same variable points to +`/sandbox/workspace/context`. 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 v1 directory is optimized for selective agent reads: + +```text +context/ +├── index.json +├── summary.md +├── entity.json +├── body.md +├── comments/ +│ ├── 0001-.md +│ └── 0002-.md +├── reviews/ +│ └── 0001-.md +├── changes/ +│ ├── diff.patch +│ └── commits.json +└── checks/ + └── / + ├── metadata.json + └── log.txt +``` + +`index.json` is the authoritative, versioned manifest. It identifies the forge, +repository, entity kind and ID, snapshot time/revision, schema version, and an +ordered entry for every staged file with source ID and URL, author, timestamps, +media type, byte count, SHA-256 digest, and filtering/truncation status. +`summary.md` is a generated navigation aid containing bounded metadata and +links, not a second copy of bodies. Collections and files that do not apply are +omitted. Entries use canonical ordering and zero-padded ordinals plus +forge-stable IDs, so identical forge responses produce byte-identical trees. + +The pre-script may inspect the host snapshot and skip the run. It cannot mutate +the agent's view: Fullsend verifies the manifest digests before upload and +restores or rejects changed files. The sandbox copy is read-only to the agent. +Agent prompts should point to `summary.md` and instruct the agent to open only +the files needed for its task; runtime forge reads remain an explicit fallback +for data outside the entity snapshot, not the default way to obtain it. + +## Consequences + +- Agents start with a consistent, filtered view of entity content and need fewer forge tool calls and prompt tokens. +- Pre-scripts, agents, validation, and post-scripts share one versioned relative-path contract without putting generated input in Git. +- Snapshot assembly adds startup latency and storage, bounded by per-entry and total-size limits. +- A snapshot can become stale during a run, so outputs that mutate forge state must still validate relevant revisions in deterministic post-processing. +- Forge adapters must expose the snapshot inputs through `forge.Client`; platform-specific gaps are explicit manifest errors rather than silent omissions. diff --git a/docs/architecture.md b/docs/architecture.md index 38731196ab..7276bb5944 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -181,6 +181,11 @@ repo baseline and overrides) (contract: [`docs/normative/prescript-output/v1`](normative/prescript-output/v1/README.md)), replacing the inline workflow pre-checks and their scaffold script copies ([ADR 0072](ADRs/0072-pre-script-output-protocol.md)). +- Deterministic entity context: before the pre-script, the runner fetches one + bounded entity snapshot through `forge.Client`, filters untrusted content, + and stages a versioned per-record file tree outside the repository. Scripts + and the sandbox use `FULLSEND_CONTEXT_DIR` with the same relative paths + ([ADR 0107](ADRs/0107-deterministic-filtered-entity-context-staging.md)). - CEL-guarded overlays: an `overlays:` list of CEL-guarded config overlays generalizes the `forge:` block, letting harness authors condition scripts, skills, env vars, and other fields on any event diff --git a/docs/problems/security-threat-model.md b/docs/problems/security-threat-model.md index 0cd38da66f..ca3520cbc5 100644 --- a/docs/problems/security-threat-model.md +++ b/docs/problems/security-threat-model.md @@ -58,6 +58,8 @@ The attack surface is the same as for visible prompt injection — PR descriptio - **Edge and proxy guardrails** — Some organizations filter or moderate **outbound** model traffic (prompts or completions) or tool invocations at a **gateway** in front of providers and MCP servers — for example policy-as-code, rate limits, or vendor moderation hooks. That can add defense in depth and consistent telemetry, but it does not remove the need for **in-agent** separation of trusted instructions from untrusted forge content; see [landscape.md](../landscape.md#agent-gateway). A compromised gateway policy is a concentrated risk, so gateway configuration should be governed like other agent infrastructure. - **Input sanitization** — strip or flag non-rendering Unicode characters before content reaches agents. Specific character classes to target: Tag characters (U+E0000–U+E007F), zero-width characters (U+200B, U+200C, U+200D, U+FEFF), bidirectional overrides (U+202A–U+202E, U+2066–U+2069), and variation selectors. This is more tractable than general prompt injection detection because the characters themselves are the signal — their mere presence in a PR description or code comment is suspicious, regardless of what they encode. However, some of these characters have legitimate uses in internationalized text, so stripping must be context-aware or at minimum flag rather than silently remove. + Deterministic filtering and finding disclosure for fetched entity content is + decided in [ADR 0107](../ADRs/0107-deterministic-filtered-entity-context-staging.md). - **Separation of data and instructions** — agent prompts should clearly delineate between "system instructions" and "untrusted input being analyzed" - **Multi-agent verification** — a reviewing agent's decision is checked by a separate security agent that specifically looks for injection patterns - **Principle of least privilege** — agents should have the minimum permissions needed. A reviewing agent doesn't need merge authority. From 4238860065e0d9d2fa17136abc2acacebfba01c5 Mon Sep 17 00:00:00 2001 From: Barak Korren Date: Tue, 8 Sep 2026 14:18:55 +0300 Subject: [PATCH 02/33] docs(#6407): specify stable entity context snapshots Separate immutable record content from mutable thread state, move the byte-level contract into a normative v1 specification, and define cleanup outside retained run artifacts. Signed-off-by: Barak Korren Assisted-by: Codex (gpt-5.6-sol) --- ...inistic-filtered-entity-context-staging.md | 51 +++---- docs/normative/entity-context/v1/README.md | 130 ++++++++++++++++++ .../entity-context/v1/check.schema.json | 18 +++ .../entity-context/v1/commits.schema.json | 25 ++++ .../entity-context/v1/entity.schema.json | 27 ++++ .../entity-context/v1/index.schema.json | 110 +++++++++++++++ .../v1/thread-state.schema.json | 29 ++++ 7 files changed, 358 insertions(+), 32 deletions(-) create mode 100644 docs/normative/entity-context/v1/README.md create mode 100644 docs/normative/entity-context/v1/check.schema.json create mode 100644 docs/normative/entity-context/v1/commits.schema.json create mode 100644 docs/normative/entity-context/v1/entity.schema.json create mode 100644 docs/normative/entity-context/v1/index.schema.json create mode 100644 docs/normative/entity-context/v1/thread-state.schema.json diff --git a/docs/ADRs/0107-deterministic-filtered-entity-context-staging.md b/docs/ADRs/0107-deterministic-filtered-entity-context-staging.md index 3fe3b49ae5..c332a57c7d 100644 --- a/docs/ADRs/0107-deterministic-filtered-entity-context-staging.md +++ b/docs/ADRs/0107-deterministic-filtered-entity-context-staging.md @@ -47,42 +47,21 @@ content. The snapshot is written outside the repository clone. Host-side pre- and post-scripts receive `FULLSEND_CONTEXT_DIR` pointing to -`/context`; inside the sandbox the same variable points to +an access-restricted temporary directory outside the retained run-output +tree; inside the sandbox the same variable points to `/sandbox/workspace/context`. 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 v1 directory is optimized for selective agent reads: - -```text -context/ -├── index.json -├── summary.md -├── entity.json -├── body.md -├── comments/ -│ ├── 0001-.md -│ └── 0002-.md -├── reviews/ -│ └── 0001-.md -├── changes/ -│ ├── diff.patch -│ └── commits.json -└── checks/ - └── / - ├── metadata.json - └── log.txt -``` - -`index.json` is the authoritative, versioned manifest. It identifies the forge, -repository, entity kind and ID, snapshot time/revision, schema version, and an -ordered entry for every staged file with source ID and URL, author, timestamps, -media type, byte count, SHA-256 digest, and filtering/truncation status. -`summary.md` is a generated navigation aid containing bounded metadata and -links, not a second copy of bodies. Collections and files that do not apply are -omitted. Entries use canonical ordering and zero-padded ordinals plus -forge-stable IDs, so identical forge responses produce byte-identical trees. +The exact tree, schemas, canonical serialization, stable record-key derivation, +filter statuses, and compatibility rules are the versioned +[entity-context v1 specification](../normative/entity-context/v1/README.md). +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 forge state and filter version, implementations produce the same paths +and bytes; breaking that guarantee requires a new major specification. The pre-script may inspect the host snapshot and skip the run. It cannot mutate the agent's view: Fullsend verifies the manifest digests before upload and @@ -91,10 +70,18 @@ Agent prompts should point to `summary.md` and instruct the agent to open only the files needed for its task; runtime forge reads remain an explicit fallback for data outside the entity snapshot, not the default way to obtain it. +The host snapshot uses a mode-`0700` directory and mode-`0600` files. 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, diffs, or +logs. + ## Consequences - Agents start with a consistent, filtered view of entity content and need fewer forge tool calls and prompt tokens. - Pre-scripts, agents, validation, and post-scripts share one versioned relative-path contract without putting generated input in Git. -- Snapshot assembly adds startup latency and storage, bounded by per-entry and total-size limits. +- Snapshot assembly adds startup latency and ephemeral storage, bounded by per-entry and total-size limits. - A snapshot can become stale during a run, so outputs that mutate forge state must still validate relevant revisions in deterministic post-processing. - Forge adapters must expose the snapshot inputs through `forge.Client`; platform-specific gaps are explicit manifest errors rather than silent omissions. diff --git a/docs/normative/entity-context/v1/README.md b/docs/normative/entity-context/v1/README.md new file mode 100644 index 0000000000..a81fb7089d --- /dev/null +++ b/docs/normative/entity-context/v1/README.md @@ -0,0 +1,130 @@ +# Entity context v1 + +This specification defines the deterministic, filtered entity snapshot adopted +by [ADR 0107](../../../ADRs/0107-deterministic-filtered-entity-context-staging.md). +It is the contract between forge adapters, `fullsend run`, harness scripts, and +agent runtimes. + +## Tree + +Entries that do not apply to an entity are omitted. JSON documents use their +linked schemas. + +```text +context/ +├── index.json +├── summary.md +├── entity/ +│ ├── metadata.json +│ └── body.md +├── comments/.md +├── reviews/.md +├── changes/ +│ ├── diff.patch +│ └── commits.json +├── checks// +│ ├── metadata.json +│ └── log.txt +└── state/ + └── threads.json +``` + +`index.json` conforms to +[`index.schema.json`](index.schema.json) and enumerates every other staged file. +`entity/metadata.json`, `changes/commits.json`, check metadata, and +`state/threads.json` conform respectively to +[`entity.schema.json`](entity.schema.json), +[`commits.schema.json`](commits.schema.json), +[`check.schema.json`](check.schema.json), and +[`thread-state.schema.json`](thread-state.schema.json). `summary.md` is a +bounded navigation view generated only from the manifest and state documents; +it must not duplicate record bodies or logs. + +## Stable records and mutable state + +A record key is the lowercase hexadecimal SHA-256 of these UTF-8 strings joined +by a single NUL byte, with no trailing NUL: + +```text +forge identifier, canonical repository identifier, record kind, forge record ID +``` + +The forge record ID is the platform's immutable opaque ID, not a mutable URL, +ordinal, database row position, or display number. Record kinds are `comment`, +`review`, and `check`. This derivation makes paths safe and stable without +requiring consumers to parse forge-specific IDs. + +Comment and review Markdown files contain only the filtered body. Their +manifest records map forge IDs and metadata to body paths, while manifest file +entries carry byte counts, digests, media types, and filter results. Bodies do not +contain author, timestamps, ordering, thread membership, resolution, outdated, +or minimized state. Those properties belong in `index.json` or +`state/threads.json`. Consequently, resolving a thread or inserting an earlier +record can change the index, state, and generated summary but must not rename or +rewrite an unchanged content file. An edited body changes only that record's +body bytes, digest, filtering result, and source-provided update metadata. + +Check status is observation state in `checks//metadata.json`; its +log file contains only filtered log bytes. A growing or replaced forge log is +changed content and may change `log.txt`. A new check attempt has a new forge +record ID and therefore a new record key. + +## Canonical bytes + +JSON is UTF-8 serialized with the JSON Canonicalization Scheme (RFC 8785), with +no byte-order mark or trailing newline. Arrays use the order defined below; +objects use RFC 8785 member ordering. + +Text bodies, patches, and logs are UTF-8 after the v1 filter pipeline, use LF +line endings, have no byte-order mark, and end in exactly one LF. The pipeline +applies size bounds, Unicode safety normalization, secret/sensitive-data +redaction, and injection scanning in that order. `filter.status` is: + +All attacker-controlled strings in JSON metadata pass through the same pipeline +before canonical serialization. + +- `unchanged`: emitted bytes equal normalized source bytes; +- `modified`: one or more replacements or redactions were applied; +- `truncated`: a size bound removed source bytes, whether or not other filters also changed them; +- `rejected`: no content file is emitted because the source could not be represented safely. + +Every emitted file has a manifest `sha256` over its emitted bytes. A rejected +source has a record but no content path or file entry. +Findings contain codes and counts, not rejected source text. Filters and bounds +are identified by `filter_version`; changing emitted bytes for the same input +requires a new filter version. Removing or reinterpreting a status requires v2. + +## Ordering and determinism + +Manifest record arrays and thread arrays are sorted by source `created_at`, then +by the forge record ID's UTF-8 byte order. Thread `comment_ids` preserve forge +thread order. Commit arrays preserve forge history order. Other arrays state +their ordering in their owning schema before being added to v1. + +`generated_at` or another runner-clock value is forbidden anywhere under the +context root. Acquisition timing belongs in run telemetry outside the staged +tree. Source-provided timestamps, entity update time, PR head SHA, and check +attempt IDs are permitted because they describe forge state. With identical +forge responses, size bounds, and `filter_version`, the complete tree has +identical paths and bytes. + +## Lifecycle and access + +The host tree is created outside both the repository and retained run-output +tree with directory mode `0700` and file mode `0600`. The sandbox copy is +read-only. Fullsend removes the sandbox copy after the runtime's last use and +the host copy after the post-script on every controlled exit, including skip, +failure, and cancellation. Fullsend also scavenges abandoned context trees on +startup after an unclean termination. + +Artifact collectors must exclude entity-context trees. Retained diagnostics +may contain bounded record counts, content digests, filter codes/counts, and +cleanup errors, but never entity bodies, comment/review bodies, diffs, or logs. + +## Compatibility + +Consumers must reject an unsupported `schema_version` or `filter_version`; they +must ignore unknown object properties within v1. Adding an optional record kind +or property is compatible. Changing existing path derivation, canonical bytes, +required fields, field meaning, or ordering requires +`docs/normative/entity-context/v2/` and a superseding ADR. diff --git a/docs/normative/entity-context/v1/check.schema.json b/docs/normative/entity-context/v1/check.schema.json new file mode 100644 index 0000000000..b78d9ca25f --- /dev/null +++ b/docs/normative/entity-context/v1/check.schema.json @@ -0,0 +1,18 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://fullsend.sh/schemas/entity-context/v1/check.schema.json", + "title": "Fullsend entity-context check metadata v1", + "type": "object", + "required": ["id", "name", "status", "attempt"], + "properties": { + "id": { "type": "string", "minLength": 1 }, + "name": { "type": "string" }, + "status": { "type": "string", "minLength": 1 }, + "conclusion": { "type": ["string", "null"] }, + "attempt": { "type": "integer", "minimum": 1 }, + "source_url": { "type": "string", "format": "uri" }, + "started_at": { "type": "string", "format": "date-time" }, + "completed_at": { "type": ["string", "null"], "format": "date-time" } + }, + "additionalProperties": false +} diff --git a/docs/normative/entity-context/v1/commits.schema.json b/docs/normative/entity-context/v1/commits.schema.json new file mode 100644 index 0000000000..da081a9af3 --- /dev/null +++ b/docs/normative/entity-context/v1/commits.schema.json @@ -0,0 +1,25 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://fullsend.sh/schemas/entity-context/v1/commits.schema.json", + "title": "Fullsend entity-context commits v1", + "type": "object", + "required": ["commits"], + "properties": { + "commits": { + "type": "array", + "items": { + "type": "object", + "required": ["id", "sha", "subject", "committed_at"], + "properties": { + "id": { "type": "string", "minLength": 1 }, + "sha": { "type": "string", "pattern": "^[0-9a-fA-F]+$" }, + "subject": { "type": "string" }, + "author": { "type": "string" }, + "committed_at": { "type": "string", "format": "date-time" } + }, + "additionalProperties": false + } + } + }, + "additionalProperties": false +} diff --git a/docs/normative/entity-context/v1/entity.schema.json b/docs/normative/entity-context/v1/entity.schema.json new file mode 100644 index 0000000000..4bf2c4f7b4 --- /dev/null +++ b/docs/normative/entity-context/v1/entity.schema.json @@ -0,0 +1,27 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://fullsend.sh/schemas/entity-context/v1/entity.schema.json", + "title": "Fullsend entity metadata v1", + "type": "object", + "required": ["kind", "id", "number", "title", "state", "source_url", "created_at", "updated_at", "labels"], + "properties": { + "kind": { "enum": ["issue", "change_proposal"] }, + "id": { "type": "string", "minLength": 1 }, + "number": { "type": ["integer", "string"] }, + "title": { "type": "string" }, + "state": { "type": "string", "minLength": 1 }, + "source_url": { "type": "string", "format": "uri" }, + "author": { "type": "string" }, + "created_at": { "type": "string", "format": "date-time" }, + "updated_at": { "type": "string", "format": "date-time" }, + "labels": { + "type": "array", + "items": { "type": "string" }, + "uniqueItems": true + }, + "head_sha": { "type": "string", "pattern": "^[0-9a-fA-F]+$" }, + "head_ref": { "type": "string" }, + "base_ref": { "type": "string" } + }, + "additionalProperties": false +} diff --git a/docs/normative/entity-context/v1/index.schema.json b/docs/normative/entity-context/v1/index.schema.json new file mode 100644 index 0000000000..45a61a1f4b --- /dev/null +++ b/docs/normative/entity-context/v1/index.schema.json @@ -0,0 +1,110 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://fullsend.sh/schemas/entity-context/v1/index.schema.json", + "title": "Fullsend entity-context index v1", + "type": "object", + "required": ["schema_version", "filter_version", "source", "entity", "files", "records"], + "properties": { + "schema_version": { "const": 1 }, + "filter_version": { "type": "string", "minLength": 1 }, + "source": { + "type": "object", + "required": ["forge", "repository"], + "properties": { + "forge": { "type": "string", "minLength": 1 }, + "repository": { "type": "string", "minLength": 1 } + }, + "additionalProperties": false + }, + "entity": { + "type": "object", + "required": ["kind", "id"], + "properties": { + "kind": { "enum": ["issue", "change_proposal"] }, + "id": { "type": "string", "minLength": 1 }, + "updated_at": { "type": "string", "format": "date-time" }, + "head_sha": { "type": "string", "pattern": "^[0-9a-fA-F]+$" } + }, + "additionalProperties": false + }, + "files": { + "type": "array", + "items": { "$ref": "#/$defs/file" } + }, + "records": { + "type": "array", + "items": { "$ref": "#/$defs/record" } + } + }, + "additionalProperties": false, + "$defs": { + "filter": { + "type": "object", + "required": ["status", "findings"], + "properties": { + "status": { "enum": ["unchanged", "modified", "truncated", "rejected"] }, + "findings": { + "type": "array", + "items": { + "type": "object", + "required": ["code", "count"], + "properties": { + "code": { "type": "string", "minLength": 1 }, + "count": { "type": "integer", "minimum": 1 } + }, + "additionalProperties": false + } + } + }, + "additionalProperties": false + }, + "file": { + "type": "object", + "required": ["path", "role", "media_type", "bytes", "sha256"], + "properties": { + "path": { + "type": "string", + "pattern": "^(summary[.]md|entity/(metadata[.]json|body[.]md)|comments/[0-9a-f]{64}[.]md|reviews/[0-9a-f]{64}[.]md|changes/(diff[.]patch|commits[.]json)|checks/[0-9a-f]{64}/(metadata[.]json|log[.]txt)|state/threads[.]json)$" + }, + "role": { + "enum": ["summary", "entity_metadata", "entity_body", "comment_body", "review_body", "diff", "commits", "check_metadata", "check_log", "thread_state"] + }, + "media_type": { "type": "string", "minLength": 1 }, + "bytes": { "type": "integer", "minimum": 0 }, + "sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" }, + "filter": { "$ref": "#/$defs/filter" } + }, + "additionalProperties": false + }, + "record": { + "type": "object", + "required": ["kind", "id", "record_key", "created_at", "filter"], + "properties": { + "kind": { "enum": ["comment", "review", "check"] }, + "id": { "type": "string", "minLength": 1 }, + "record_key": { "type": "string", "pattern": "^[0-9a-f]{64}$" }, + "content_path": { "type": "string", "pattern": "^(comments|reviews)/[0-9a-f]{64}[.]md$" }, + "metadata_path": { "type": "string", "pattern": "^checks/[0-9a-f]{64}/metadata[.]json$" }, + "log_path": { "type": "string", "pattern": "^checks/[0-9a-f]{64}/log[.]txt$" }, + "source_url": { "type": "string", "format": "uri" }, + "author": { "type": "string" }, + "created_at": { "type": "string", "format": "date-time" }, + "updated_at": { "type": "string", "format": "date-time" }, + "filter": { "$ref": "#/$defs/filter" } + }, + "allOf": [ + { + "if": { "properties": { "filter": { "properties": { "status": { "const": "rejected" } } } } }, + "then": { "not": { "anyOf": [{ "required": ["content_path"] }, { "required": ["metadata_path"] }, { "required": ["log_path"] }] } }, + "else": { + "oneOf": [ + { "required": ["content_path"] }, + { "required": ["metadata_path"] } + ] + } + } + ], + "additionalProperties": false + } + } +} diff --git a/docs/normative/entity-context/v1/thread-state.schema.json b/docs/normative/entity-context/v1/thread-state.schema.json new file mode 100644 index 0000000000..bd4723c192 --- /dev/null +++ b/docs/normative/entity-context/v1/thread-state.schema.json @@ -0,0 +1,29 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://fullsend.sh/schemas/entity-context/v1/thread-state.schema.json", + "title": "Fullsend entity-context thread state v1", + "type": "object", + "required": ["threads"], + "properties": { + "threads": { + "type": "array", + "items": { + "type": "object", + "required": ["id", "comment_ids", "resolved", "outdated"], + "properties": { + "id": { "type": "string", "minLength": 1 }, + "comment_ids": { + "type": "array", + "items": { "type": "string", "minLength": 1 }, + "uniqueItems": true + }, + "resolved": { "type": "boolean" }, + "outdated": { "type": "boolean" }, + "minimized": { "type": "boolean" } + }, + "additionalProperties": false + } + } + }, + "additionalProperties": false +} From 2b2f6155a08cd82d33cc29805906d2942be61bf8 Mon Sep 17 00:00:00 2001 From: Barak Korren Date: Tue, 8 Sep 2026 14:26:14 +0300 Subject: [PATCH 03/33] docs(#6407): make conversation context cache-stable Include immutable attribution in each conversation record and define canonical whole-conversation and per-thread views whose normal reply path preserves the existing byte prefix. Signed-off-by: Barak Korren Assisted-by: Codex (gpt-5.6-sol) --- ...inistic-filtered-entity-context-staging.md | 13 +++- docs/normative/entity-context/v1/README.md | 73 ++++++++++++++----- .../entity-context/v1/entity.schema.json | 5 +- .../entity-context/v1/index.schema.json | 9 ++- .../v1/thread-state.schema.json | 4 +- 5 files changed, 77 insertions(+), 27 deletions(-) diff --git a/docs/ADRs/0107-deterministic-filtered-entity-context-staging.md b/docs/ADRs/0107-deterministic-filtered-entity-context-staging.md index c332a57c7d..1a5b31659f 100644 --- a/docs/ADRs/0107-deterministic-filtered-entity-context-staging.md +++ b/docs/ADRs/0107-deterministic-filtered-entity-context-staging.md @@ -63,12 +63,19 @@ or review body. No runner-clock timestamp enters the staged tree. Given the same forge state and filter version, implementations produce the same paths and bytes; breaking that guarantee requires a new major specification. +Each comment and review is a self-contained attributed record. Fullsend also +renders the initial body and records into canonical whole-conversation and +per-thread Markdown views. New replies append without rewriting an unchanged +prefix, so runtimes can place conversation bytes before mutable state in the +agent context and preserve provider prompt-cache eligibility. + The pre-script may inspect the host snapshot and skip the run. It cannot mutate the agent's view: Fullsend verifies the manifest digests before upload and restores or rejects changed files. The sandbox copy is read-only to the agent. -Agent prompts should point to `summary.md` and instruct the agent to open only -the files needed for its task; runtime forge reads remain an explicit fallback -for data outside the entity snapshot, not the default way to obtain it. +Agent prompts should lead with the canonical conversation view and place +mutable state after that stable prefix; `summary.md` remains the navigation aid +for selective reads. Runtime forge reads are an explicit fallback for data +outside the snapshot, not the default way to obtain it. The host snapshot uses a mode-`0700` directory and mode-`0600` files. Fullsend removes the sandbox copy after its last sandbox consumer and the host copy after diff --git a/docs/normative/entity-context/v1/README.md b/docs/normative/entity-context/v1/README.md index a81fb7089d..29a8d918b2 100644 --- a/docs/normative/entity-context/v1/README.md +++ b/docs/normative/entity-context/v1/README.md @@ -14,11 +14,13 @@ linked schemas. context/ ├── index.json ├── summary.md +├── conversation.md ├── entity/ │ ├── metadata.json │ └── body.md ├── comments/.md ├── reviews/.md +├── threads/.md ├── changes/ │ ├── diff.patch │ └── commits.json @@ -38,7 +40,8 @@ context/ [`check.schema.json`](check.schema.json), and [`thread-state.schema.json`](thread-state.schema.json). `summary.md` is a bounded navigation view generated only from the manifest and state documents; -it must not duplicate record bodies or logs. +it must not duplicate record bodies or logs. `conversation.md` and the files +under `threads/` are canonical concatenation views defined below. ## Stable records and mutable state @@ -51,18 +54,53 @@ forge identifier, canonical repository identifier, record kind, forge record ID The forge record ID is the platform's immutable opaque ID, not a mutable URL, ordinal, database row position, or display number. Record kinds are `comment`, -`review`, and `check`. This derivation makes paths safe and stable without -requiring consumers to parse forge-specific IDs. - -Comment and review Markdown files contain only the filtered body. Their -manifest records map forge IDs and metadata to body paths, while manifest file -entries carry byte counts, digests, media types, and filter results. Bodies do not -contain author, timestamps, ordering, thread membership, resolution, outdated, -or minimized state. Those properties belong in `index.json` or -`state/threads.json`. Consequently, resolving a thread or inserting an earlier -record can change the index, state, and generated summary but must not rename or -rewrite an unchanged content file. An edited body changes only that record's -body bytes, digest, filtering result, and source-provided update metadata. +`review`, `check`, and `thread`. This derivation makes paths safe and stable +without requiring consumers to parse forge-specific IDs. + +Comment and review Markdown files are self-contained records with this exact +UTF-8 layout; header values are canonical JSON strings (or `null`) on one line: + +```text +Fullsend-Record: "comment" +Source-ID: "opaque-forge-id" +Source-URL: "https://forge.example/..." +Author-ID: "opaque-actor-id" +Author: "forge-login" +Created-At: "2026-09-08T10:15:30Z" + +Filtered Markdown body. +``` + +`Fullsend-Record` is `"comment"` or `"review"`. The header order and blank +line are fixed. `Author-ID` and `Author` may be `null` when the forge withholds +or has deleted the actor. All header strings are filtered before JSON-string +serialization. The file contains no update time, ordering, thread membership, +resolution, outdated, or minimized state; those properties belong in +`index.json` or `state/threads.json`. Consequently, resolving a thread or +inserting an earlier record must not rename or rewrite an unchanged record. +Changing its body or attribution fields changes that record's bytes and digest. + +`entity/body.md` uses the same layout with `Fullsend-Record: "entity"`, the +entity's stable ID and URL, and its author attribution and creation time. This +makes the initial issue or change-proposal body the first self-contained turn. + +## Concatenation views and prompt caching + +`conversation.md` is the byte-for-byte concatenation of `entity/body.md`, then +all comment and review record files in manifest order. `threads/.md` +is the same concatenation of the records named by that thread's `comment_ids`. +Before every item after the first, the renderer writes LF, `---`, and LF; each +source file already ends in exactly one LF. No summary, resolution flag, or +other mutable state is embedded in either view. + +When a later record sorts after the existing records, rendering appends bytes +and leaves the entire previous view as an identical prefix. This is the normal +reply path and permits the runtime to send the conversation first, then append +state or task instructions, preserving prompt-cache reuse. A backfilled earlier +record, edit, deletion, or attribution change necessarily invalidates the view +from the first affected record onward. Per-record files still isolate that +change. Consumers that need current resolution state read `state/threads.json` +or place it after the conversation prefix; they never infer state from a body. Check status is observation state in `checks//metadata.json`; its log file contains only filtered log bytes. A growing or replaced forge log is @@ -96,10 +134,11 @@ requires a new filter version. Removing or reinterpreting a status requires v2. ## Ordering and determinism -Manifest record arrays and thread arrays are sorted by source `created_at`, then -by the forge record ID's UTF-8 byte order. Thread `comment_ids` preserve forge -thread order. Commit arrays preserve forge history order. Other arrays state -their ordering in their owning schema before being added to v1. +Manifest record arrays are sorted by source `created_at`, then by the forge +record ID's UTF-8 byte order. Thread arrays use thread creation time and then +thread ID; `comment_ids` preserve forge thread order. Commit arrays preserve +forge history order. Other arrays state their ordering in their owning schema +before being added to v1. `generated_at` or another runner-clock value is forbidden anywhere under the context root. Acquisition timing belongs in run telemetry outside the staged diff --git a/docs/normative/entity-context/v1/entity.schema.json b/docs/normative/entity-context/v1/entity.schema.json index 4bf2c4f7b4..cc349eaa94 100644 --- a/docs/normative/entity-context/v1/entity.schema.json +++ b/docs/normative/entity-context/v1/entity.schema.json @@ -3,7 +3,7 @@ "$id": "https://fullsend.sh/schemas/entity-context/v1/entity.schema.json", "title": "Fullsend entity metadata v1", "type": "object", - "required": ["kind", "id", "number", "title", "state", "source_url", "created_at", "updated_at", "labels"], + "required": ["kind", "id", "number", "title", "state", "source_url", "author_id", "author", "created_at", "updated_at", "labels"], "properties": { "kind": { "enum": ["issue", "change_proposal"] }, "id": { "type": "string", "minLength": 1 }, @@ -11,7 +11,8 @@ "title": { "type": "string" }, "state": { "type": "string", "minLength": 1 }, "source_url": { "type": "string", "format": "uri" }, - "author": { "type": "string" }, + "author_id": { "type": ["string", "null"] }, + "author": { "type": ["string", "null"] }, "created_at": { "type": "string", "format": "date-time" }, "updated_at": { "type": "string", "format": "date-time" }, "labels": { diff --git a/docs/normative/entity-context/v1/index.schema.json b/docs/normative/entity-context/v1/index.schema.json index 45a61a1f4b..f58f011e4b 100644 --- a/docs/normative/entity-context/v1/index.schema.json +++ b/docs/normative/entity-context/v1/index.schema.json @@ -64,10 +64,10 @@ "properties": { "path": { "type": "string", - "pattern": "^(summary[.]md|entity/(metadata[.]json|body[.]md)|comments/[0-9a-f]{64}[.]md|reviews/[0-9a-f]{64}[.]md|changes/(diff[.]patch|commits[.]json)|checks/[0-9a-f]{64}/(metadata[.]json|log[.]txt)|state/threads[.]json)$" + "pattern": "^(summary[.]md|conversation[.]md|entity/(metadata[.]json|body[.]md)|comments/[0-9a-f]{64}[.]md|reviews/[0-9a-f]{64}[.]md|threads/[0-9a-f]{64}[.]md|changes/(diff[.]patch|commits[.]json)|checks/[0-9a-f]{64}/(metadata[.]json|log[.]txt)|state/threads[.]json)$" }, "role": { - "enum": ["summary", "entity_metadata", "entity_body", "comment_body", "review_body", "diff", "commits", "check_metadata", "check_log", "thread_state"] + "enum": ["summary", "conversation", "thread_conversation", "entity_metadata", "entity_body", "comment_body", "review_body", "diff", "commits", "check_metadata", "check_log", "thread_state"] }, "media_type": { "type": "string", "minLength": 1 }, "bytes": { "type": "integer", "minimum": 0 }, @@ -78,7 +78,7 @@ }, "record": { "type": "object", - "required": ["kind", "id", "record_key", "created_at", "filter"], + "required": ["kind", "id", "record_key", "author_id", "author", "created_at", "filter"], "properties": { "kind": { "enum": ["comment", "review", "check"] }, "id": { "type": "string", "minLength": 1 }, @@ -87,7 +87,8 @@ "metadata_path": { "type": "string", "pattern": "^checks/[0-9a-f]{64}/metadata[.]json$" }, "log_path": { "type": "string", "pattern": "^checks/[0-9a-f]{64}/log[.]txt$" }, "source_url": { "type": "string", "format": "uri" }, - "author": { "type": "string" }, + "author_id": { "type": ["string", "null"] }, + "author": { "type": ["string", "null"] }, "created_at": { "type": "string", "format": "date-time" }, "updated_at": { "type": "string", "format": "date-time" }, "filter": { "$ref": "#/$defs/filter" } diff --git a/docs/normative/entity-context/v1/thread-state.schema.json b/docs/normative/entity-context/v1/thread-state.schema.json index bd4723c192..b7a6dd6f05 100644 --- a/docs/normative/entity-context/v1/thread-state.schema.json +++ b/docs/normative/entity-context/v1/thread-state.schema.json @@ -9,9 +9,11 @@ "type": "array", "items": { "type": "object", - "required": ["id", "comment_ids", "resolved", "outdated"], + "required": ["id", "thread_key", "created_at", "comment_ids", "resolved", "outdated"], "properties": { "id": { "type": "string", "minLength": 1 }, + "thread_key": { "type": "string", "pattern": "^[0-9a-f]{64}$" }, + "created_at": { "type": "string", "format": "date-time" }, "comment_ids": { "type": "array", "items": { "type": "string", "minLength": 1 }, From c84c43bf30be9d5664ce5288ab48531a4126391e Mon Sep 17 00:00:00 2001 From: Barak Korren Date: Tue, 8 Sep 2026 14:31:22 +0300 Subject: [PATCH 04/33] docs(#6407): avoid duplicate conversation views Store each attributed conversation record once, name records for chronological glob concatenation, and use lightweight thread order files for thread-specific assembly. Signed-off-by: Barak Korren Assisted-by: Codex (gpt-5.6-sol) --- ...inistic-filtered-entity-context-staging.md | 19 ++--- docs/normative/entity-context/v1/README.md | 76 ++++++++++--------- .../entity-context/v1/index.schema.json | 8 +- .../v1/thread-state.schema.json | 3 +- 4 files changed, 55 insertions(+), 51 deletions(-) diff --git a/docs/ADRs/0107-deterministic-filtered-entity-context-staging.md b/docs/ADRs/0107-deterministic-filtered-entity-context-staging.md index 1a5b31659f..661bad9704 100644 --- a/docs/ADRs/0107-deterministic-filtered-entity-context-staging.md +++ b/docs/ADRs/0107-deterministic-filtered-entity-context-staging.md @@ -63,19 +63,20 @@ or review body. No runner-clock timestamp enters the staged tree. Given the same forge state and filter version, implementations produce the same paths and bytes; breaking that guarantee requires a new major specification. -Each comment and review is a self-contained attributed record. Fullsend also -renders the initial body and records into canonical whole-conversation and -per-thread Markdown views. New replies append without rewriting an unchanged -prefix, so runtimes can place conversation bytes before mutable state in the -agent context and preserve provider prompt-cache eligibility. +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. Whole-conversation assembly is a glob concatenation; per-thread order +files contain paths to the same records rather than copied content. New replies +append without rewriting an unchanged prefix, preserving prompt-cache +eligibility when runtimes concatenate records before mutable state. The pre-script may inspect the host snapshot and skip the run. It cannot mutate the agent's view: Fullsend verifies the manifest digests before upload and restores or rejects changed files. The sandbox copy is read-only to the agent. -Agent prompts should lead with the canonical conversation view and place -mutable state after that stable prefix; `summary.md` remains the navigation aid -for selective reads. Runtime forge reads are an explicit fallback for data -outside the snapshot, not the default way to obtain it. +Agent prompts should concatenate conversation records first and place mutable +state after that stable prefix; `summary.md` remains the navigation aid for +selective reads. Runtime forge reads are an explicit fallback for data outside +the snapshot, not the default way to obtain it. The host snapshot uses a mode-`0700` directory and mode-`0600` files. Fullsend removes the sandbox copy after its last sandbox consumer and the host copy after diff --git a/docs/normative/entity-context/v1/README.md b/docs/normative/entity-context/v1/README.md index 29a8d918b2..80280d61e3 100644 --- a/docs/normative/entity-context/v1/README.md +++ b/docs/normative/entity-context/v1/README.md @@ -14,13 +14,9 @@ linked schemas. context/ ├── index.json ├── summary.md -├── conversation.md -├── entity/ -│ ├── metadata.json -│ └── body.md -├── comments/.md -├── reviews/.md -├── threads/.md +├── entity/metadata.json +├── records/-.md +├── threads/.order ├── changes/ │ ├── diff.patch │ └── commits.json @@ -40,8 +36,8 @@ context/ [`check.schema.json`](check.schema.json), and [`thread-state.schema.json`](thread-state.schema.json). `summary.md` is a bounded navigation view generated only from the manifest and state documents; -it must not duplicate record bodies or logs. `conversation.md` and the files -under `threads/` are canonical concatenation views defined below. +it must not duplicate record bodies or logs. Files under `threads/` contain +only ordered relative paths to records. ## Stable records and mutable state @@ -54,8 +50,8 @@ forge identifier, canonical repository identifier, record kind, forge record ID The forge record ID is the platform's immutable opaque ID, not a mutable URL, ordinal, database row position, or display number. Record kinds are `comment`, -`review`, `check`, and `thread`. This derivation makes paths safe and stable -without requiring consumers to parse forge-specific IDs. +`review`, `check`, `thread`, and `entity`. This derivation makes paths safe and +stable without requiring consumers to parse forge-specific IDs. Comment and review Markdown files are self-contained records with this exact UTF-8 layout; header values are canonical JSON strings (or `null`) on one line: @@ -80,27 +76,32 @@ resolution, outdated, or minimized state; those properties belong in inserting an earlier record must not rename or rewrite an unchanged record. Changing its body or attribution fields changes that record's bytes and digest. -`entity/body.md` uses the same layout with `Fullsend-Record: "entity"`, the -entity's stable ID and URL, and its author attribution and creation time. This -makes the initial issue or change-proposal body the first self-contained turn. - -## Concatenation views and prompt caching - -`conversation.md` is the byte-for-byte concatenation of `entity/body.md`, then -all comment and review record files in manifest order. `threads/.md` -is the same concatenation of the records named by that thread's `comment_ids`. -Before every item after the first, the renderer writes LF, `---`, and LF; each -source file already ends in exactly one LF. No summary, resolution flag, or -other mutable state is embedded in either view. - -When a later record sorts after the existing records, rendering appends bytes -and leaves the entire previous view as an identical prefix. This is the normal -reply path and permits the runtime to send the conversation first, then append -state or task instructions, preserving prompt-cache reuse. A backfilled earlier -record, edit, deletion, or attribution change necessarily invalidates the view -from the first affected record onward. Per-record files still isolate that -change. Consumers that need current resolution state read `state/threads.json` -or place it after the conversation prefix; they never infer state from a body. +The initial issue or change-proposal body uses the same layout with +`Fullsend-Record: "entity"`, the entity's stable ID and URL, and its author +attribution and creation time. This makes it the first self-contained turn. + +## Filename order and prompt caching + +An ordinary record filename is +`records/-.md`. `` is its source `created_at` +normalized to UTC as `YYYYMMDDTHHMMSSnnnnnnnnnZ`, with exactly nine fractional +second digits and no punctuation other than `T` and `Z`. The entity-body record +uses the reserved key `00000000T000000000000000Z`, so it always sorts first. +Creation time is immutable forge data; edits do not rename a record. + +Because all path components are restricted to these ASCII forms, +`LC_ALL=C cat records/*.md` concatenates the entire conversation in canonical +order without an intermediate file. Each `threads/.order` contains +the relative record path for each thread member followed by LF, in forge thread +order. From the context root, `xargs cat < threads/.order` +concatenates one thread; paths contain no whitespace or shell metacharacters. + +A normal later reply adds one lexically later file and appends one path to its +thread order file, leaving all earlier record bytes and the whole-conversation +prefix unchanged for prompt-cache reuse. A backfilled earlier record, edit, +deletion, or attribution change necessarily invalidates the assembled context +from the first affected record onward. Consumers place mutable state after the +record concatenation and never infer resolution from record content. Check status is observation state in `checks//metadata.json`; its log file contains only filtered log bytes. A growing or replaced forge log is @@ -134,11 +135,12 @@ requires a new filter version. Removing or reinterpreting a status requires v2. ## Ordering and determinism -Manifest record arrays are sorted by source `created_at`, then by the forge -record ID's UTF-8 byte order. Thread arrays use thread creation time and then -thread ID; `comment_ids` preserve forge thread order. Commit arrays preserve -forge history order. Other arrays state their ordering in their owning schema -before being added to v1. +Manifest record arrays and record filenames are sorted by source `created_at`, +then by the record key's ASCII byte order. The reserved entity-body order key +sorts before them. Thread arrays use thread creation time and then thread ID; +`comment_ids` and `.order` lines preserve forge thread order. Commit arrays +preserve forge history order. Other arrays state their ordering in their owning +schema before being added to v1. `generated_at` or another runner-clock value is forbidden anywhere under the context root. Acquisition timing belongs in run telemetry outside the staged diff --git a/docs/normative/entity-context/v1/index.schema.json b/docs/normative/entity-context/v1/index.schema.json index f58f011e4b..fe05929e15 100644 --- a/docs/normative/entity-context/v1/index.schema.json +++ b/docs/normative/entity-context/v1/index.schema.json @@ -64,10 +64,10 @@ "properties": { "path": { "type": "string", - "pattern": "^(summary[.]md|conversation[.]md|entity/(metadata[.]json|body[.]md)|comments/[0-9a-f]{64}[.]md|reviews/[0-9a-f]{64}[.]md|threads/[0-9a-f]{64}[.]md|changes/(diff[.]patch|commits[.]json)|checks/[0-9a-f]{64}/(metadata[.]json|log[.]txt)|state/threads[.]json)$" + "pattern": "^(summary[.]md|entity/metadata[.]json|records/([0-9]{8}T[0-9]{15}Z)-[0-9a-f]{64}[.]md|threads/[0-9a-f]{64}[.]order|changes/(diff[.]patch|commits[.]json)|checks/[0-9a-f]{64}/(metadata[.]json|log[.]txt)|state/threads[.]json)$" }, "role": { - "enum": ["summary", "conversation", "thread_conversation", "entity_metadata", "entity_body", "comment_body", "review_body", "diff", "commits", "check_metadata", "check_log", "thread_state"] + "enum": ["summary", "entity_metadata", "entity_record", "comment_record", "review_record", "thread_order", "diff", "commits", "check_metadata", "check_log", "thread_state"] }, "media_type": { "type": "string", "minLength": 1 }, "bytes": { "type": "integer", "minimum": 0 }, @@ -80,10 +80,10 @@ "type": "object", "required": ["kind", "id", "record_key", "author_id", "author", "created_at", "filter"], "properties": { - "kind": { "enum": ["comment", "review", "check"] }, + "kind": { "enum": ["entity", "comment", "review", "check"] }, "id": { "type": "string", "minLength": 1 }, "record_key": { "type": "string", "pattern": "^[0-9a-f]{64}$" }, - "content_path": { "type": "string", "pattern": "^(comments|reviews)/[0-9a-f]{64}[.]md$" }, + "content_path": { "type": "string", "pattern": "^records/[0-9]{8}T[0-9]{15}Z-[0-9a-f]{64}[.]md$" }, "metadata_path": { "type": "string", "pattern": "^checks/[0-9a-f]{64}/metadata[.]json$" }, "log_path": { "type": "string", "pattern": "^checks/[0-9a-f]{64}/log[.]txt$" }, "source_url": { "type": "string", "format": "uri" }, diff --git a/docs/normative/entity-context/v1/thread-state.schema.json b/docs/normative/entity-context/v1/thread-state.schema.json index b7a6dd6f05..9baa9ce1c1 100644 --- a/docs/normative/entity-context/v1/thread-state.schema.json +++ b/docs/normative/entity-context/v1/thread-state.schema.json @@ -9,11 +9,12 @@ "type": "array", "items": { "type": "object", - "required": ["id", "thread_key", "created_at", "comment_ids", "resolved", "outdated"], + "required": ["id", "thread_key", "created_at", "order_path", "comment_ids", "resolved", "outdated"], "properties": { "id": { "type": "string", "minLength": 1 }, "thread_key": { "type": "string", "pattern": "^[0-9a-f]{64}$" }, "created_at": { "type": "string", "format": "date-time" }, + "order_path": { "type": "string", "pattern": "^threads/[0-9a-f]{64}[.]order$" }, "comment_ids": { "type": "array", "items": { "type": "string", "minLength": 1 }, From a62360964963401297ef235289d567908ddee3a3 Mon Sep 17 00:00:00 2001 From: Barak Korren Date: Wed, 9 Sep 2026 10:21:04 +0300 Subject: [PATCH 05/33] docs(adr): clarify entity context history and caching Define segmented projections and runtime cache boundaries so repeated agents can reuse stable prompt prefixes without overstating token savings. Record review relationships, immutable agent-run lineage, richer commit history, collection profiles, and explicit source gaps. Document the required follow-up work for runtimes, forge adapters, and shipped agents. Signed-off-by: Barak Korren Assisted-by: Codex (gpt-5.6-sol) --- ...inistic-filtered-entity-context-staging.md | 28 +++--- docs/architecture.md | 6 +- docs/normative/entity-context/v1/README.md | 92 ++++++++++++++----- .../entity-context/v1/agent-runs.schema.json | 34 +++++++ .../entity-context/v1/commits.schema.json | 9 +- .../entity-context/v1/index.schema.json | 21 ++++- .../entity-context/v1/reviews.schema.json | 68 ++++++++++++++ .../v1/thread-state.schema.json | 9 +- 8 files changed, 218 insertions(+), 49 deletions(-) create mode 100644 docs/normative/entity-context/v1/agent-runs.schema.json create mode 100644 docs/normative/entity-context/v1/reviews.schema.json diff --git a/docs/ADRs/0107-deterministic-filtered-entity-context-staging.md b/docs/ADRs/0107-deterministic-filtered-entity-context-staging.md index 661bad9704..ceaca90d32 100644 --- a/docs/ADRs/0107-deterministic-filtered-entity-context-staging.md +++ b/docs/ADRs/0107-deterministic-filtered-entity-context-staging.md @@ -65,16 +65,22 @@ and bytes; breaking that guarantee requires a new major specification. 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. Whole-conversation assembly is a glob concatenation; per-thread order -files contain paths to the same records rather than copied content. New replies -append without rewriting an unchanged prefix, preserving prompt-cache -eligibility when runtimes concatenate records before mutable state. +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 +history, 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. It cannot mutate the agent's view: Fullsend verifies the manifest digests before upload and restores or rejects changed files. The sandbox copy is read-only to the agent. -Agent prompts should concatenate conversation records first and place mutable -state after that stable prefix; `summary.md` remains the navigation aid for +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. `summary.md` and deterministic projections remain navigation aids for selective reads. Runtime forge reads are an explicit fallback for data outside the snapshot, not the default way to obtain it. @@ -88,8 +94,8 @@ logs. ## Consequences -- Agents start with a consistent, filtered view of entity content and need fewer forge tool calls and prompt tokens. -- Pre-scripts, agents, validation, and post-scripts share one versioned relative-path contract without putting generated input in Git. -- Snapshot assembly adds startup latency and ephemeral storage, bounded by per-entry and total-size limits. -- A snapshot can become stale during a run, so outputs that mutate forge state must still validate relevant revisions in deterministic post-processing. -- Forge adapters must expose the snapshot inputs through `forge.Client`; platform-specific gaps are explicit manifest errors rather than silent omissions. +- 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 add collection profiles, segmented context input and cache-boundary support to runtime backends, and telemetry for forge calls, staged/read bytes, input/cache tokens, latency, cost, and history-recall quality before claiming an efficiency improvement. +- Shipped and custom review, fix, and code agents must migrate from mutable sticky summaries and single-body hand-offs to discovered entity-context 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 revisions, commits, comparisons, checks, and immutable agent-result references through `forge.Client`; unavailable or unrecoverable edit and force-push 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. diff --git a/docs/architecture.md b/docs/architecture.md index 7276bb5944..73a390dff9 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -183,8 +183,10 @@ repo baseline and overrides) ([ADR 0072](ADRs/0072-pre-script-output-protocol.md)). - Deterministic entity context: before the pre-script, the runner fetches one bounded entity snapshot through `forge.Client`, filters untrusted content, - and stages a versioned per-record file tree outside the repository. Scripts - and the sandbox use `FULLSEND_CONTEXT_DIR` with the same relative paths + and stages a versioned per-record file tree with relationship, projection, + and immutable agent-run lineage metadata outside the repository. Scripts and + the sandbox use `FULLSEND_CONTEXT_DIR` with the same relative paths; runtimes + may inject ordered records as separate cacheable input blocks ([ADR 0107](ADRs/0107-deterministic-filtered-entity-context-staging.md)). - CEL-guarded overlays: an `overlays:` list of CEL-guarded config overlays generalizes the `forge:` block, letting harness authors diff --git a/docs/normative/entity-context/v1/README.md b/docs/normative/entity-context/v1/README.md index 80280d61e3..50786121e7 100644 --- a/docs/normative/entity-context/v1/README.md +++ b/docs/normative/entity-context/v1/README.md @@ -17,6 +17,12 @@ context/ ├── entity/metadata.json ├── records/-.md ├── threads/.order +├── views/ +│ ├── conversation.order +│ ├── unresolved-review.order +│ └── reviews/.order +├── relations/reviews.json +├── history/agent-runs.json ├── changes/ │ ├── diff.patch │ └── commits.json @@ -29,15 +35,19 @@ context/ `index.json` conforms to [`index.schema.json`](index.schema.json) and enumerates every other staged file. -`entity/metadata.json`, `changes/commits.json`, check metadata, and +`entity/metadata.json`, `relations/reviews.json`, +`history/agent-runs.json`, `changes/commits.json`, check metadata, and `state/threads.json` conform respectively to [`entity.schema.json`](entity.schema.json), +[`reviews.schema.json`](reviews.schema.json), +[`agent-runs.schema.json`](agent-runs.schema.json), [`commits.schema.json`](commits.schema.json), [`check.schema.json`](check.schema.json), and [`thread-state.schema.json`](thread-state.schema.json). `summary.md` is a bounded navigation view generated only from the manifest and state documents; it must not duplicate record bodies or logs. Files under `threads/` contain -only ordered relative paths to records. +only ordered relative paths to records. Files under `views/` are deterministic +projections containing those same paths, one per LF-terminated line. ## Stable records and mutable state @@ -71,8 +81,8 @@ Filtered Markdown body. line are fixed. `Author-ID` and `Author` may be `null` when the forge withholds or has deleted the actor. All header strings are filtered before JSON-string serialization. The file contains no update time, ordering, thread membership, -resolution, outdated, or minimized state; those properties belong in -`index.json` or `state/threads.json`. Consequently, resolving a thread or +review location, resolution, outdated, or minimized state; those properties +belong in `index.json`, `relations/`, or `state/`. Consequently, resolving a thread or inserting an earlier record must not rename or rewrite an unchanged record. Changing its body or attribution fields changes that record's bytes and digest. @@ -80,7 +90,7 @@ The initial issue or change-proposal body uses the same layout with `Fullsend-Record: "entity"`, the entity's stable ID and URL, and its author attribution and creation time. This makes it the first self-contained turn. -## Filename order and prompt caching +## Ordering files and prompt assembly An ordinary record filename is `records/-.md`. `` is its source `created_at` @@ -89,25 +99,59 @@ second digits and no punctuation other than `T` and `Z`. The entity-body record uses the reserved key `00000000T000000000000000Z`, so it always sorts first. Creation time is immutable forge data; edits do not rename a record. -Because all path components are restricted to these ASCII forms, -`LC_ALL=C cat records/*.md` concatenates the entire conversation in canonical -order without an intermediate file. Each `threads/.order` contains -the relative record path for each thread member followed by LF, in forge thread -order. From the context root, `xargs cat < threads/.order` -concatenates one thread; paths contain no whitespace or shell metacharacters. - -A normal later reply adds one lexically later file and appends one path to its -thread order file, leaving all earlier record bytes and the whole-conversation -prefix unchanged for prompt-cache reuse. A backfilled earlier record, edit, -deletion, or attribution change necessarily invalidates the assembled context -from the first affected record onward. Consumers place mutable state after the -record concatenation and never infer resolution from record content. +`views/conversation.order` lists the entity record and all comment and review +records in canonical chronology. Each `threads/.order` lists that +thread's records in forge order. `views/unresolved-review.order` lists records +in unresolved, non-outdated review threads, ordered by thread creation time and +key and then forge thread order. Each `views/reviews/.order` lists +one formal review followed by records in threads associated with it. A record +path appears at most once in any one order file. Paths contain no whitespace or +shell metacharacters, so a host consumer may materialize a projection with +`xargs cat`, but runtimes use the segmented contract below. + +A runtime that injects a projection into a model request emits each referenced +record as a distinct, ordered content block. Relationship, history, mutable +state, and run-specific instruction blocks follow the stable record blocks. +The runtime must not concatenate all records into one content block when +prompt-cache reuse is intended: appending to that block would change its digest +and lose the otherwise reusable record prefix. A runtime may mark boundaries +using provider-specific cache controls, but provider cache behavior is not a +v1 conformance guarantee. Reading the same files through agent tools avoids +forge calls but still incurs tool-result tokens. + +A normal later reply adds one lexically later file and extends applicable order +files, leaving earlier record blocks byte-identical. A backfilled earlier +record, edit, deletion, or attribution change invalidates reuse from the first +affected block onward. Consumers never infer resolution from record content. Check status is observation state in `checks//metadata.json`; its log file contains only filtered log bytes. A growing or replaced forge log is changed content and may change `log.txt`. A new check attempt has a new forge record ID and therefore a new record key. +## Relationships, history, and collection profiles + +`relations/reviews.json` preserves formal review outcomes and the association +between reviews, replies, reviewed revisions, and diff locations separately +from mutable resolution state. Location fields are optional because forges +expose different subsets. `history/agent-runs.json` contains only immutable, +forge-observable Fullsend run receipts and relates an agent result to its input +revision, result records, and resulting commit. A mutable sticky comment may be +a human-facing summary, but it is not canonical run history and its overwritten +versions cannot be reconstructed from a forge that does not expose edit +history. + +The required `collection_profile` in `index.json` is the lowercase SHA-256 of +the canonically serialized collection configuration: included source kinds, +selection rules, and bounds. For example, a profile may include failed-check +logs without fetching all successful logs. Given the same forge responses, +profile, bounds, and filter version, the tree is identical. Profiles must not +vary collection based on runner time or an agent's intermediate choices. +Missing data within the selected profile is represented as a bounded manifest +gap with a stable code; history unavailable from the forge, including +overwritten edits or unreachable force-pushed commits, is not silently treated +as an empty history. + ## Canonical bytes JSON is UTF-8 serialized with the JSON Canonicalization Scheme (RFC 8785), with @@ -138,16 +182,18 @@ requires a new filter version. Removing or reinterpreting a status requires v2. Manifest record arrays and record filenames are sorted by source `created_at`, then by the record key's ASCII byte order. The reserved entity-body order key sorts before them. Thread arrays use thread creation time and then thread ID; -`comment_ids` and `.order` lines preserve forge thread order. Commit arrays -preserve forge history order. Other arrays state their ordering in their owning -schema before being added to v1. +`record_keys` and thread `.order` lines preserve forge thread order. Commit +arrays preserve forge history order. Agent receipts sort by completion time and +ID; manifest files sort by path, gaps by scope and code, and filter findings by +code. Other arrays state their ordering in their owning schema before being +added to v1. `generated_at` or another runner-clock value is forbidden anywhere under the context root. Acquisition timing belongs in run telemetry outside the staged tree. Source-provided timestamps, entity update time, PR head SHA, and check attempt IDs are permitted because they describe forge state. With identical -forge responses, size bounds, and `filter_version`, the complete tree has -identical paths and bytes. +forge responses, `collection_profile`, size bounds, and `filter_version`, the +complete tree has identical paths and bytes. ## Lifecycle and access diff --git a/docs/normative/entity-context/v1/agent-runs.schema.json b/docs/normative/entity-context/v1/agent-runs.schema.json new file mode 100644 index 0000000000..3d7b7a37bd --- /dev/null +++ b/docs/normative/entity-context/v1/agent-runs.schema.json @@ -0,0 +1,34 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://fullsend.sh/schemas/entity-context/v1/agent-runs.schema.json", + "title": "Fullsend entity-context immutable agent-run receipts v1", + "type": "object", + "required": ["runs"], + "properties": { + "runs": { + "type": "array", + "items": { + "type": "object", + "required": ["id", "agent", "status", "input_revision", "result_record_keys", "source_url", "completed_at"], + "properties": { + "id": { "type": "string", "minLength": 1 }, + "agent": { "type": "string", "minLength": 1 }, + "status": { "type": "string", "minLength": 1 }, + "input_revision": { "type": "string", "minLength": 1 }, + "input_head_sha": { "type": "string", "pattern": "^[0-9a-fA-F]+$" }, + "result_record_keys": { + "type": "array", + "items": { "type": "string", "pattern": "^[0-9a-f]{64}$" }, + "uniqueItems": true + }, + "resulting_commit_sha": { "type": "string", "pattern": "^[0-9a-fA-F]+$" }, + "source_url": { "type": "string", "format": "uri" }, + "started_at": { "type": "string", "format": "date-time" }, + "completed_at": { "type": "string", "format": "date-time" } + }, + "additionalProperties": false + } + } + }, + "additionalProperties": false +} diff --git a/docs/normative/entity-context/v1/commits.schema.json b/docs/normative/entity-context/v1/commits.schema.json index da081a9af3..7c105547dd 100644 --- a/docs/normative/entity-context/v1/commits.schema.json +++ b/docs/normative/entity-context/v1/commits.schema.json @@ -9,11 +9,16 @@ "type": "array", "items": { "type": "object", - "required": ["id", "sha", "subject", "committed_at"], + "required": ["id", "sha", "message", "parent_shas", "committed_at"], "properties": { "id": { "type": "string", "minLength": 1 }, "sha": { "type": "string", "pattern": "^[0-9a-fA-F]+$" }, - "subject": { "type": "string" }, + "message": { "type": "string" }, + "parent_shas": { + "type": "array", + "items": { "type": "string", "pattern": "^[0-9a-fA-F]+$" }, + "uniqueItems": true + }, "author": { "type": "string" }, "committed_at": { "type": "string", "format": "date-time" } }, diff --git a/docs/normative/entity-context/v1/index.schema.json b/docs/normative/entity-context/v1/index.schema.json index fe05929e15..9105d8bf3c 100644 --- a/docs/normative/entity-context/v1/index.schema.json +++ b/docs/normative/entity-context/v1/index.schema.json @@ -3,10 +3,11 @@ "$id": "https://fullsend.sh/schemas/entity-context/v1/index.schema.json", "title": "Fullsend entity-context index v1", "type": "object", - "required": ["schema_version", "filter_version", "source", "entity", "files", "records"], + "required": ["schema_version", "filter_version", "collection_profile", "source", "entity", "files", "records", "gaps"], "properties": { "schema_version": { "const": 1 }, "filter_version": { "type": "string", "minLength": 1 }, + "collection_profile": { "type": "string", "pattern": "^[0-9a-f]{64}$" }, "source": { "type": "object", "required": ["forge", "repository"], @@ -34,6 +35,10 @@ "records": { "type": "array", "items": { "$ref": "#/$defs/record" } + }, + "gaps": { + "type": "array", + "items": { "$ref": "#/$defs/gap" } } }, "additionalProperties": false, @@ -64,10 +69,10 @@ "properties": { "path": { "type": "string", - "pattern": "^(summary[.]md|entity/metadata[.]json|records/([0-9]{8}T[0-9]{15}Z)-[0-9a-f]{64}[.]md|threads/[0-9a-f]{64}[.]order|changes/(diff[.]patch|commits[.]json)|checks/[0-9a-f]{64}/(metadata[.]json|log[.]txt)|state/threads[.]json)$" + "pattern": "^(summary[.]md|entity/metadata[.]json|records/([0-9]{8}T[0-9]{15}Z)-[0-9a-f]{64}[.]md|threads/[0-9a-f]{64}[.]order|views/(conversation|unresolved-review)[.]order|views/reviews/[0-9a-f]{64}[.]order|relations/reviews[.]json|history/agent-runs[.]json|changes/(diff[.]patch|commits[.]json)|checks/[0-9a-f]{64}/(metadata[.]json|log[.]txt)|state/threads[.]json)$" }, "role": { - "enum": ["summary", "entity_metadata", "entity_record", "comment_record", "review_record", "thread_order", "diff", "commits", "check_metadata", "check_log", "thread_state"] + "enum": ["summary", "entity_metadata", "entity_record", "comment_record", "review_record", "thread_order", "conversation_view", "unresolved_review_view", "review_view", "reviews", "agent_runs", "diff", "commits", "check_metadata", "check_log", "thread_state"] }, "media_type": { "type": "string", "minLength": 1 }, "bytes": { "type": "integer", "minimum": 0 }, @@ -76,6 +81,16 @@ }, "additionalProperties": false }, + "gap": { + "type": "object", + "required": ["scope", "code", "count"], + "properties": { + "scope": { "type": "string", "minLength": 1 }, + "code": { "type": "string", "minLength": 1 }, + "count": { "type": "integer", "minimum": 1 } + }, + "additionalProperties": false + }, "record": { "type": "object", "required": ["kind", "id", "record_key", "author_id", "author", "created_at", "filter"], diff --git a/docs/normative/entity-context/v1/reviews.schema.json b/docs/normative/entity-context/v1/reviews.schema.json new file mode 100644 index 0000000000..29b1f3fd68 --- /dev/null +++ b/docs/normative/entity-context/v1/reviews.schema.json @@ -0,0 +1,68 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://fullsend.sh/schemas/entity-context/v1/reviews.schema.json", + "title": "Fullsend entity-context review relationships v1", + "type": "object", + "required": ["reviews", "threads"], + "properties": { + "reviews": { + "type": "array", + "items": { + "type": "object", + "required": ["id", "record_key", "state", "reviewed_sha", "submitted_at"], + "properties": { + "id": { "type": "string", "minLength": 1 }, + "record_key": { "type": "string", "pattern": "^[0-9a-f]{64}$" }, + "state": { "type": "string", "minLength": 1 }, + "reviewed_sha": { "type": "string", "pattern": "^[0-9a-fA-F]+$" }, + "submitted_at": { "type": "string", "format": "date-time" }, + "dismissed_at": { "type": ["string", "null"], "format": "date-time" } + }, + "additionalProperties": false + } + }, + "threads": { + "type": "array", + "items": { + "type": "object", + "required": ["id", "thread_key", "created_at", "order_path", "record_keys", "replies"], + "properties": { + "id": { "type": "string", "minLength": 1 }, + "thread_key": { "type": "string", "pattern": "^[0-9a-f]{64}$" }, + "created_at": { "type": "string", "format": "date-time" }, + "order_path": { "type": "string", "pattern": "^threads/[0-9a-f]{64}[.]order$" }, + "record_keys": { + "type": "array", + "items": { "type": "string", "pattern": "^[0-9a-f]{64}$" }, + "uniqueItems": true + }, + "replies": { + "type": "array", + "items": { + "type": "object", + "required": ["record_key", "parent_record_key"], + "properties": { + "record_key": { "type": "string", "pattern": "^[0-9a-f]{64}$" }, + "parent_record_key": { "type": "string", "pattern": "^[0-9a-f]{64}$" } + }, + "additionalProperties": false + } + }, + "review_id": { "type": "string", "minLength": 1 }, + "review_record_key": { "type": "string", "pattern": "^[0-9a-f]{64}$" }, + "reviewed_sha": { "type": "string", "pattern": "^[0-9a-fA-F]+$" }, + "path": { "type": "string" }, + "diff_hunk": { "type": "string" }, + "line": { "type": ["integer", "null"], "minimum": 1 }, + "side": { "enum": ["left", "right", null] }, + "start_line": { "type": ["integer", "null"], "minimum": 1 }, + "original_line": { "type": ["integer", "null"], "minimum": 1 }, + "original_start_line": { "type": ["integer", "null"], "minimum": 1 }, + "original_side": { "enum": ["left", "right", null] } + }, + "additionalProperties": false + } + } + }, + "additionalProperties": false +} diff --git a/docs/normative/entity-context/v1/thread-state.schema.json b/docs/normative/entity-context/v1/thread-state.schema.json index 9baa9ce1c1..eddee4e29a 100644 --- a/docs/normative/entity-context/v1/thread-state.schema.json +++ b/docs/normative/entity-context/v1/thread-state.schema.json @@ -9,17 +9,10 @@ "type": "array", "items": { "type": "object", - "required": ["id", "thread_key", "created_at", "order_path", "comment_ids", "resolved", "outdated"], + "required": ["id", "thread_key", "resolved", "outdated"], "properties": { "id": { "type": "string", "minLength": 1 }, "thread_key": { "type": "string", "pattern": "^[0-9a-f]{64}$" }, - "created_at": { "type": "string", "format": "date-time" }, - "order_path": { "type": "string", "pattern": "^threads/[0-9a-f]{64}[.]order$" }, - "comment_ids": { - "type": "array", - "items": { "type": "string", "minLength": 1 }, - "uniqueItems": true - }, "resolved": { "type": "boolean" }, "outdated": { "type": "boolean" }, "minimized": { "type": "boolean" } From f8443018970e9ee32405515f61461ef4fa405487 Mon Sep 17 00:00:00 2001 From: Barak Korren Date: Wed, 9 Sep 2026 10:38:26 +0300 Subject: [PATCH 06/33] docs(adr): separate entity and repository context Limit staged entity context to forge state that cannot be reconstructed from Git. Remove diff, commit, and repository-topology materialization while retaining Git object IDs as review, thread, and agent-run relationship anchors. Assign repository history provisioning and derived, filtered diff generation to Fullsend controllers. Signed-off-by: Barak Korren Assisted-by: Codex (gpt-5.6-sol) --- ...inistic-filtered-entity-context-staging.md | 18 +++++++---- docs/architecture.md | 8 +++-- docs/normative/entity-context/v1/README.md | 32 ++++++++++--------- .../entity-context/v1/commits.schema.json | 30 ----------------- .../entity-context/v1/entity.schema.json | 5 +-- .../entity-context/v1/index.schema.json | 7 ++-- .../entity-context/v1/reviews.schema.json | 1 - 7 files changed, 38 insertions(+), 63 deletions(-) delete mode 100644 docs/normative/entity-context/v1/commits.schema.json diff --git a/docs/ADRs/0107-deterministic-filtered-entity-context-staging.md b/docs/ADRs/0107-deterministic-filtered-entity-context-staging.md index ceaca90d32..8e9a92f678 100644 --- a/docs/ADRs/0107-deterministic-filtered-entity-context-staging.md +++ b/docs/ADRs/0107-deterministic-filtered-entity-context-staging.md @@ -23,7 +23,7 @@ Accepted [Issue #6407](https://github.com/fullsend-ai/fullsend/issues/6407) identifies that agents and harness scripts repeatedly fetch the issue or change proposal -they are handling, including comments, reviews, diffs, checks, and logs. Those +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. @@ -63,12 +63,19 @@ or review body. No runner-clock timestamp enters the staged tree. Given the same forge state and filter version, 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 entity context +only to relate reviews, threads, comments, and agent runs to repository state. + 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 -history, and immutable Fullsend agent-run receipts preserve enough provenance +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. It cannot mutate @@ -89,13 +96,12 @@ 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, diffs, or -logs. +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 add collection profiles, segmented context input and cache-boundary support to runtime backends, and telemetry for forge calls, staged/read bytes, input/cache tokens, latency, cost, and history-recall quality before claiming an efficiency improvement. +- 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 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 revisions, commits, comparisons, checks, and immutable agent-result references through `forge.Client`; unavailable or unrecoverable edit and force-push history is an explicit manifest gap, not a silent omission. +- 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. diff --git a/docs/architecture.md b/docs/architecture.md index 73a390dff9..5ca83515ce 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -184,9 +184,11 @@ repo baseline and overrides) - Deterministic entity context: before the pre-script, the runner fetches one bounded entity snapshot through `forge.Client`, filters untrusted content, and stages a versioned per-record file tree with relationship, projection, - and immutable agent-run lineage metadata outside the repository. Scripts and - the sandbox use `FULLSEND_CONTEXT_DIR` with the same relative paths; runtimes - may inject ordered records as separate cacheable input blocks + and immutable agent-run lineage metadata outside the repository. Repository + diffs and commit history remain derived from the separately provisioned Git + checkout; entity context carries Git object IDs only as relationship anchors. + Scripts and the sandbox use `FULLSEND_CONTEXT_DIR` with the same relative + paths; runtimes may inject ordered records as separate cacheable input blocks ([ADR 0107](ADRs/0107-deterministic-filtered-entity-context-staging.md)). - CEL-guarded overlays: an `overlays:` list of CEL-guarded config overlays generalizes the `forge:` block, letting harness authors diff --git a/docs/normative/entity-context/v1/README.md b/docs/normative/entity-context/v1/README.md index 50786121e7..5ed32542f4 100644 --- a/docs/normative/entity-context/v1/README.md +++ b/docs/normative/entity-context/v1/README.md @@ -23,9 +23,6 @@ context/ │ └── reviews/.order ├── relations/reviews.json ├── history/agent-runs.json -├── changes/ -│ ├── diff.patch -│ └── commits.json ├── checks// │ ├── metadata.json │ └── log.txt @@ -36,12 +33,11 @@ context/ `index.json` conforms to [`index.schema.json`](index.schema.json) and enumerates every other staged file. `entity/metadata.json`, `relations/reviews.json`, -`history/agent-runs.json`, `changes/commits.json`, check metadata, and +`history/agent-runs.json`, check metadata, and `state/threads.json` conform respectively to [`entity.schema.json`](entity.schema.json), [`reviews.schema.json`](reviews.schema.json), [`agent-runs.schema.json`](agent-runs.schema.json), -[`commits.schema.json`](commits.schema.json), [`check.schema.json`](check.schema.json), and [`thread-state.schema.json`](thread-state.schema.json). `summary.md` is a bounded navigation view generated only from the manifest and state documents; @@ -63,6 +59,13 @@ ordinal, database row position, or display number. Record kinds are `comment`, `review`, `check`, `thread`, and `entity`. This derivation makes paths safe and stable without requiring consumers to parse forge-specific IDs. +The tree contains forge entity state that is not reconstructible from the +target Git checkout. Diffs, commits, changed-file lists, branches, and revision +topology are repository context and are not staged here. Fullsend provides the +required Git objects and refs separately, and controllers may derive filtered +diff or history projections outside this tree. Git object IDs occur here only +as relationship values in review, thread, and agent-run documents. + Comment and review Markdown files are self-contained records with this exact UTF-8 layout; header values are canonical JSON strings (or `null`) on one line: @@ -132,7 +135,7 @@ record ID and therefore a new record key. ## Relationships, history, and collection profiles `relations/reviews.json` preserves formal review outcomes and the association -between reviews, replies, reviewed revisions, and diff locations separately +between reviews, replies, reviewed revisions, and code locations separately from mutable resolution state. Location fields are optional because forges expose different subsets. `history/agent-runs.json` contains only immutable, forge-observable Fullsend run receipts and relates an agent result to its input @@ -158,7 +161,7 @@ JSON is UTF-8 serialized with the JSON Canonicalization Scheme (RFC 8785), with no byte-order mark or trailing newline. Arrays use the order defined below; objects use RFC 8785 member ordering. -Text bodies, patches, and logs are UTF-8 after the v1 filter pipeline, use LF +Text bodies and logs are UTF-8 after the v1 filter pipeline, use LF line endings, have no byte-order mark, and end in exactly one LF. The pipeline applies size bounds, Unicode safety normalization, secret/sensitive-data redaction, and injection scanning in that order. `filter.status` is: @@ -182,16 +185,15 @@ requires a new filter version. Removing or reinterpreting a status requires v2. Manifest record arrays and record filenames are sorted by source `created_at`, then by the record key's ASCII byte order. The reserved entity-body order key sorts before them. Thread arrays use thread creation time and then thread ID; -`record_keys` and thread `.order` lines preserve forge thread order. Commit -arrays preserve forge history order. Agent receipts sort by completion time and -ID; manifest files sort by path, gaps by scope and code, and filter findings by -code. Other arrays state their ordering in their owning schema before being -added to v1. +`record_keys` and thread `.order` lines preserve forge thread order. Agent +receipts sort by completion time and ID; manifest files sort by path, gaps by +scope and code, and filter findings by code. Other arrays state their ordering +in their owning schema before being added to v1. `generated_at` or another runner-clock value is forbidden anywhere under the context root. Acquisition timing belongs in run telemetry outside the staged -tree. Source-provided timestamps, entity update time, PR head SHA, and check -attempt IDs are permitted because they describe forge state. With identical +tree. Source-provided timestamps, entity update time, Git object IDs used as +relationship values, and check attempt IDs are permitted. With identical forge responses, `collection_profile`, size bounds, and `filter_version`, the complete tree has identical paths and bytes. @@ -206,7 +208,7 @@ startup after an unclean termination. Artifact collectors must exclude entity-context trees. Retained diagnostics may contain bounded record counts, content digests, filter codes/counts, and -cleanup errors, but never entity bodies, comment/review bodies, diffs, or logs. +cleanup errors, but never entity bodies, comment/review bodies, or logs. ## Compatibility diff --git a/docs/normative/entity-context/v1/commits.schema.json b/docs/normative/entity-context/v1/commits.schema.json deleted file mode 100644 index 7c105547dd..0000000000 --- a/docs/normative/entity-context/v1/commits.schema.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://fullsend.sh/schemas/entity-context/v1/commits.schema.json", - "title": "Fullsend entity-context commits v1", - "type": "object", - "required": ["commits"], - "properties": { - "commits": { - "type": "array", - "items": { - "type": "object", - "required": ["id", "sha", "message", "parent_shas", "committed_at"], - "properties": { - "id": { "type": "string", "minLength": 1 }, - "sha": { "type": "string", "pattern": "^[0-9a-fA-F]+$" }, - "message": { "type": "string" }, - "parent_shas": { - "type": "array", - "items": { "type": "string", "pattern": "^[0-9a-fA-F]+$" }, - "uniqueItems": true - }, - "author": { "type": "string" }, - "committed_at": { "type": "string", "format": "date-time" } - }, - "additionalProperties": false - } - } - }, - "additionalProperties": false -} diff --git a/docs/normative/entity-context/v1/entity.schema.json b/docs/normative/entity-context/v1/entity.schema.json index cc349eaa94..b65aa2194d 100644 --- a/docs/normative/entity-context/v1/entity.schema.json +++ b/docs/normative/entity-context/v1/entity.schema.json @@ -19,10 +19,7 @@ "type": "array", "items": { "type": "string" }, "uniqueItems": true - }, - "head_sha": { "type": "string", "pattern": "^[0-9a-fA-F]+$" }, - "head_ref": { "type": "string" }, - "base_ref": { "type": "string" } + } }, "additionalProperties": false } diff --git a/docs/normative/entity-context/v1/index.schema.json b/docs/normative/entity-context/v1/index.schema.json index 9105d8bf3c..803e974553 100644 --- a/docs/normative/entity-context/v1/index.schema.json +++ b/docs/normative/entity-context/v1/index.schema.json @@ -23,8 +23,7 @@ "properties": { "kind": { "enum": ["issue", "change_proposal"] }, "id": { "type": "string", "minLength": 1 }, - "updated_at": { "type": "string", "format": "date-time" }, - "head_sha": { "type": "string", "pattern": "^[0-9a-fA-F]+$" } + "updated_at": { "type": "string", "format": "date-time" } }, "additionalProperties": false }, @@ -69,10 +68,10 @@ "properties": { "path": { "type": "string", - "pattern": "^(summary[.]md|entity/metadata[.]json|records/([0-9]{8}T[0-9]{15}Z)-[0-9a-f]{64}[.]md|threads/[0-9a-f]{64}[.]order|views/(conversation|unresolved-review)[.]order|views/reviews/[0-9a-f]{64}[.]order|relations/reviews[.]json|history/agent-runs[.]json|changes/(diff[.]patch|commits[.]json)|checks/[0-9a-f]{64}/(metadata[.]json|log[.]txt)|state/threads[.]json)$" + "pattern": "^(summary[.]md|entity/metadata[.]json|records/([0-9]{8}T[0-9]{15}Z)-[0-9a-f]{64}[.]md|threads/[0-9a-f]{64}[.]order|views/(conversation|unresolved-review)[.]order|views/reviews/[0-9a-f]{64}[.]order|relations/reviews[.]json|history/agent-runs[.]json|checks/[0-9a-f]{64}/(metadata[.]json|log[.]txt)|state/threads[.]json)$" }, "role": { - "enum": ["summary", "entity_metadata", "entity_record", "comment_record", "review_record", "thread_order", "conversation_view", "unresolved_review_view", "review_view", "reviews", "agent_runs", "diff", "commits", "check_metadata", "check_log", "thread_state"] + "enum": ["summary", "entity_metadata", "entity_record", "comment_record", "review_record", "thread_order", "conversation_view", "unresolved_review_view", "review_view", "reviews", "agent_runs", "check_metadata", "check_log", "thread_state"] }, "media_type": { "type": "string", "minLength": 1 }, "bytes": { "type": "integer", "minimum": 0 }, diff --git a/docs/normative/entity-context/v1/reviews.schema.json b/docs/normative/entity-context/v1/reviews.schema.json index 29b1f3fd68..913b350721 100644 --- a/docs/normative/entity-context/v1/reviews.schema.json +++ b/docs/normative/entity-context/v1/reviews.schema.json @@ -52,7 +52,6 @@ "review_record_key": { "type": "string", "pattern": "^[0-9a-f]{64}$" }, "reviewed_sha": { "type": "string", "pattern": "^[0-9a-fA-F]+$" }, "path": { "type": "string" }, - "diff_hunk": { "type": "string" }, "line": { "type": ["integer", "null"], "minimum": 1 }, "side": { "enum": ["left", "right", null] }, "start_line": { "type": ["integer", "null"], "minimum": 1 }, From 5e0485538e95cb45643ed1a4495c1882aa968b83 Mon Sep 17 00:00:00 2001 From: Barak Korren Date: Wed, 9 Sep 2026 11:35:40 +0300 Subject: [PATCH 07/33] docs(#6407): align entity context contract Make v1 schema compatibility explicitly closed, align schema identifiers with the normative convention, and restore the filter-status definition flow. Signed-off-by: Barak Korren Assisted-by: Codex (gpt-5.6-sol) --- docs/normative/entity-context/v1/README.md | 13 +++++++------ .../entity-context/v1/agent-runs.schema.json | 4 ++-- docs/normative/entity-context/v1/check.schema.json | 4 ++-- docs/normative/entity-context/v1/entity.schema.json | 4 ++-- docs/normative/entity-context/v1/index.schema.json | 4 ++-- .../normative/entity-context/v1/reviews.schema.json | 4 ++-- .../entity-context/v1/thread-state.schema.json | 4 ++-- 7 files changed, 19 insertions(+), 18 deletions(-) diff --git a/docs/normative/entity-context/v1/README.md b/docs/normative/entity-context/v1/README.md index 5ed32542f4..64e7b2244a 100644 --- a/docs/normative/entity-context/v1/README.md +++ b/docs/normative/entity-context/v1/README.md @@ -166,14 +166,14 @@ line endings, have no byte-order mark, and end in exactly one LF. The pipeline applies size bounds, Unicode safety normalization, secret/sensitive-data redaction, and injection scanning in that order. `filter.status` is: -All attacker-controlled strings in JSON metadata pass through the same pipeline -before canonical serialization. - - `unchanged`: emitted bytes equal normalized source bytes; - `modified`: one or more replacements or redactions were applied; - `truncated`: a size bound removed source bytes, whether or not other filters also changed them; - `rejected`: no content file is emitted because the source could not be represented safely. +All attacker-controlled strings in JSON metadata pass through the same pipeline +before canonical serialization. + Every emitted file has a manifest `sha256` over its emitted bytes. A rejected source has a record but no content path or file entry. Findings contain codes and counts, not rejected source text. Filters and bounds @@ -213,7 +213,8 @@ cleanup errors, but never entity bodies, comment/review bodies, or logs. ## Compatibility Consumers must reject an unsupported `schema_version` or `filter_version`; they -must ignore unknown object properties within v1. Adding an optional record kind -or property is compatible. Changing existing path derivation, canonical bytes, -required fields, field meaning, or ordering requires +must validate every document against the v1 schemas. The schemas are closed: +adding a property, record kind, enum value, or status is a breaking change. +Changing path derivation, canonical bytes, required fields, field meaning, or +ordering likewise requires `docs/normative/entity-context/v2/` and a superseding ADR. diff --git a/docs/normative/entity-context/v1/agent-runs.schema.json b/docs/normative/entity-context/v1/agent-runs.schema.json index 3d7b7a37bd..a4445730e4 100644 --- a/docs/normative/entity-context/v1/agent-runs.schema.json +++ b/docs/normative/entity-context/v1/agent-runs.schema.json @@ -1,7 +1,7 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://fullsend.sh/schemas/entity-context/v1/agent-runs.schema.json", - "title": "Fullsend entity-context immutable agent-run receipts v1", + "$id": "https://fullsend.ai/normative/entity-context/v1/agent-runs.schema.json", + "title": "AgentRuns", "type": "object", "required": ["runs"], "properties": { diff --git a/docs/normative/entity-context/v1/check.schema.json b/docs/normative/entity-context/v1/check.schema.json index b78d9ca25f..bbe7fc3b34 100644 --- a/docs/normative/entity-context/v1/check.schema.json +++ b/docs/normative/entity-context/v1/check.schema.json @@ -1,7 +1,7 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://fullsend.sh/schemas/entity-context/v1/check.schema.json", - "title": "Fullsend entity-context check metadata v1", + "$id": "https://fullsend.ai/normative/entity-context/v1/check.schema.json", + "title": "CheckMetadata", "type": "object", "required": ["id", "name", "status", "attempt"], "properties": { diff --git a/docs/normative/entity-context/v1/entity.schema.json b/docs/normative/entity-context/v1/entity.schema.json index b65aa2194d..5b2d110741 100644 --- a/docs/normative/entity-context/v1/entity.schema.json +++ b/docs/normative/entity-context/v1/entity.schema.json @@ -1,7 +1,7 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://fullsend.sh/schemas/entity-context/v1/entity.schema.json", - "title": "Fullsend entity metadata v1", + "$id": "https://fullsend.ai/normative/entity-context/v1/entity.schema.json", + "title": "EntityMetadata", "type": "object", "required": ["kind", "id", "number", "title", "state", "source_url", "author_id", "author", "created_at", "updated_at", "labels"], "properties": { diff --git a/docs/normative/entity-context/v1/index.schema.json b/docs/normative/entity-context/v1/index.schema.json index 803e974553..e1daca60fe 100644 --- a/docs/normative/entity-context/v1/index.schema.json +++ b/docs/normative/entity-context/v1/index.schema.json @@ -1,7 +1,7 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://fullsend.sh/schemas/entity-context/v1/index.schema.json", - "title": "Fullsend entity-context index v1", + "$id": "https://fullsend.ai/normative/entity-context/v1/index.schema.json", + "title": "EntityContextIndex", "type": "object", "required": ["schema_version", "filter_version", "collection_profile", "source", "entity", "files", "records", "gaps"], "properties": { diff --git a/docs/normative/entity-context/v1/reviews.schema.json b/docs/normative/entity-context/v1/reviews.schema.json index 913b350721..6745f822e5 100644 --- a/docs/normative/entity-context/v1/reviews.schema.json +++ b/docs/normative/entity-context/v1/reviews.schema.json @@ -1,7 +1,7 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://fullsend.sh/schemas/entity-context/v1/reviews.schema.json", - "title": "Fullsend entity-context review relationships v1", + "$id": "https://fullsend.ai/normative/entity-context/v1/reviews.schema.json", + "title": "ReviewRelationships", "type": "object", "required": ["reviews", "threads"], "properties": { diff --git a/docs/normative/entity-context/v1/thread-state.schema.json b/docs/normative/entity-context/v1/thread-state.schema.json index eddee4e29a..01c78ef20d 100644 --- a/docs/normative/entity-context/v1/thread-state.schema.json +++ b/docs/normative/entity-context/v1/thread-state.schema.json @@ -1,7 +1,7 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://fullsend.sh/schemas/entity-context/v1/thread-state.schema.json", - "title": "Fullsend entity-context thread state v1", + "$id": "https://fullsend.ai/normative/entity-context/v1/thread-state.schema.json", + "title": "ThreadState", "type": "object", "required": ["threads"], "properties": { From 9274bb0f62e639569915ed770e8e24ed782838c5 Mon Sep 17 00:00:00 2001 From: Barak Korren Date: Wed, 9 Sep 2026 12:00:51 +0300 Subject: [PATCH 08/33] docs(#6407): distinguish thread source keys Clarify that thread participates in stable key derivation without creating manifest record entries. Signed-off-by: Barak Korren Assisted-by: Codex (gpt-5.6-sol) --- docs/normative/entity-context/v1/README.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/normative/entity-context/v1/README.md b/docs/normative/entity-context/v1/README.md index 64e7b2244a..d9ffbd3b20 100644 --- a/docs/normative/entity-context/v1/README.md +++ b/docs/normative/entity-context/v1/README.md @@ -55,9 +55,12 @@ forge identifier, canonical repository identifier, record kind, forge record ID ``` The forge record ID is the platform's immutable opaque ID, not a mutable URL, -ordinal, database row position, or display number. Record kinds are `comment`, -`review`, `check`, `thread`, and `entity`. This derivation makes paths safe and -stable without requiring consumers to parse forge-specific IDs. +ordinal, database row position, or display number. Source kinds used in this +derivation are `comment`, `review`, `check`, `thread`, and `entity`. Manifest +record entries use only `entity`, `comment`, `review`, and `check`; `thread` +keys identify relationship and ordering data under `relations/` and `threads/`, +not files under `records/`. This derivation makes paths safe and stable without +requiring consumers to parse forge-specific IDs. The tree contains forge entity state that is not reconstructible from the target Git checkout. Diffs, commits, changed-file lists, branches, and revision From 819d0ecf4832da5b3d3f24af9f95243a6b025148 Mon Sep 17 00:00:00 2001 From: Barak Korren Date: Wed, 9 Sep 2026 12:28:03 +0300 Subject: [PATCH 09/33] docs(#6407): tighten entity context canonical bytes Define omission semantics for optional JSON properties and constrain Git object IDs to supported digest widths. Signed-off-by: Barak Korren Assisted-by: Codex (gpt-5.6-sol) --- docs/normative/entity-context/v1/README.md | 6 ++++++ .../entity-context/v1/agent-runs.schema.json | 4 ++-- .../entity-context/v1/check.schema.json | 4 ++-- .../entity-context/v1/reviews.schema.json | 18 +++++++++--------- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/docs/normative/entity-context/v1/README.md b/docs/normative/entity-context/v1/README.md index d9ffbd3b20..da55c9d098 100644 --- a/docs/normative/entity-context/v1/README.md +++ b/docs/normative/entity-context/v1/README.md @@ -164,6 +164,12 @@ JSON is UTF-8 serialized with the JSON Canonicalization Scheme (RFC 8785), with no byte-order mark or trailing newline. Arrays use the order defined below; objects use RFC 8785 member ordering. +Properties marked required by a schema are always emitted. If a required +property is nullable and its normalized source value is unavailable, it is +emitted as JSON `null`. A non-required property is emitted only when its +normalized source value is available; otherwise it is omitted and is never +synthesized as `null` or with a default value. + Text bodies and logs are UTF-8 after the v1 filter pipeline, use LF line endings, have no byte-order mark, and end in exactly one LF. The pipeline applies size bounds, Unicode safety normalization, secret/sensitive-data diff --git a/docs/normative/entity-context/v1/agent-runs.schema.json b/docs/normative/entity-context/v1/agent-runs.schema.json index a4445730e4..4319f94c9a 100644 --- a/docs/normative/entity-context/v1/agent-runs.schema.json +++ b/docs/normative/entity-context/v1/agent-runs.schema.json @@ -15,13 +15,13 @@ "agent": { "type": "string", "minLength": 1 }, "status": { "type": "string", "minLength": 1 }, "input_revision": { "type": "string", "minLength": 1 }, - "input_head_sha": { "type": "string", "pattern": "^[0-9a-fA-F]+$" }, + "input_head_sha": { "type": "string", "pattern": "^[0-9a-fA-F]{40}([0-9a-fA-F]{24})?$" }, "result_record_keys": { "type": "array", "items": { "type": "string", "pattern": "^[0-9a-f]{64}$" }, "uniqueItems": true }, - "resulting_commit_sha": { "type": "string", "pattern": "^[0-9a-fA-F]+$" }, + "resulting_commit_sha": { "type": "string", "pattern": "^[0-9a-fA-F]{40}([0-9a-fA-F]{24})?$" }, "source_url": { "type": "string", "format": "uri" }, "started_at": { "type": "string", "format": "date-time" }, "completed_at": { "type": "string", "format": "date-time" } diff --git a/docs/normative/entity-context/v1/check.schema.json b/docs/normative/entity-context/v1/check.schema.json index bbe7fc3b34..56bec29af7 100644 --- a/docs/normative/entity-context/v1/check.schema.json +++ b/docs/normative/entity-context/v1/check.schema.json @@ -8,11 +8,11 @@ "id": { "type": "string", "minLength": 1 }, "name": { "type": "string" }, "status": { "type": "string", "minLength": 1 }, - "conclusion": { "type": ["string", "null"] }, + "conclusion": { "type": "string" }, "attempt": { "type": "integer", "minimum": 1 }, "source_url": { "type": "string", "format": "uri" }, "started_at": { "type": "string", "format": "date-time" }, - "completed_at": { "type": ["string", "null"], "format": "date-time" } + "completed_at": { "type": "string", "format": "date-time" } }, "additionalProperties": false } diff --git a/docs/normative/entity-context/v1/reviews.schema.json b/docs/normative/entity-context/v1/reviews.schema.json index 6745f822e5..8879749f27 100644 --- a/docs/normative/entity-context/v1/reviews.schema.json +++ b/docs/normative/entity-context/v1/reviews.schema.json @@ -14,9 +14,9 @@ "id": { "type": "string", "minLength": 1 }, "record_key": { "type": "string", "pattern": "^[0-9a-f]{64}$" }, "state": { "type": "string", "minLength": 1 }, - "reviewed_sha": { "type": "string", "pattern": "^[0-9a-fA-F]+$" }, + "reviewed_sha": { "type": "string", "pattern": "^[0-9a-fA-F]{40}([0-9a-fA-F]{24})?$" }, "submitted_at": { "type": "string", "format": "date-time" }, - "dismissed_at": { "type": ["string", "null"], "format": "date-time" } + "dismissed_at": { "type": "string", "format": "date-time" } }, "additionalProperties": false } @@ -50,14 +50,14 @@ }, "review_id": { "type": "string", "minLength": 1 }, "review_record_key": { "type": "string", "pattern": "^[0-9a-f]{64}$" }, - "reviewed_sha": { "type": "string", "pattern": "^[0-9a-fA-F]+$" }, + "reviewed_sha": { "type": "string", "pattern": "^[0-9a-fA-F]{40}([0-9a-fA-F]{24})?$" }, "path": { "type": "string" }, - "line": { "type": ["integer", "null"], "minimum": 1 }, - "side": { "enum": ["left", "right", null] }, - "start_line": { "type": ["integer", "null"], "minimum": 1 }, - "original_line": { "type": ["integer", "null"], "minimum": 1 }, - "original_start_line": { "type": ["integer", "null"], "minimum": 1 }, - "original_side": { "enum": ["left", "right", null] } + "line": { "type": "integer", "minimum": 1 }, + "side": { "enum": ["left", "right"] }, + "start_line": { "type": "integer", "minimum": 1 }, + "original_line": { "type": "integer", "minimum": 1 }, + "original_start_line": { "type": "integer", "minimum": 1 }, + "original_side": { "enum": ["left", "right"] } }, "additionalProperties": false } From f82d5a0b3e492e1c9127cdd0fd018080b3fae6d5 Mon Sep 17 00:00:00 2001 From: Barak Korren Date: Mon, 14 Sep 2026 13:10:47 +0300 Subject: [PATCH 10/33] docs(#6407): address entity context review feedback Separate immutable records from mutable actor authorization state, align the entity context vocabulary with normalized events, and tighten deterministic serialization and schema constraints. Signed-off-by: Barak Korren Assisted-by: Codex (gpt-5.6-sol) --- ...slash-command-entity-context-separation.md | 5 + ...inistic-filtered-entity-context-staging.md | 37 +- docs/normative/entity-context/v1/README.md | 487 +++++++++++++++--- .../entity-context/v1/actor-state.schema.json | 38 ++ .../entity-context/v1/agent-runs.schema.json | 22 +- .../entity-context/v1/check.schema.json | 37 +- .../entity-context/v1/collection.schema.json | 50 ++ .../entity-context/v1/common.schema.json | 33 ++ .../entity-context/v1/entity.schema.json | 37 +- .../entity-context/v1/index.schema.json | 117 ++++- .../entity-context/v1/reviews.schema.json | 41 +- .../v1/thread-state.schema.json | 10 +- docs/normative/normalized-event/v1/README.md | 5 + 13 files changed, 763 insertions(+), 156 deletions(-) create mode 100644 docs/normative/entity-context/v1/actor-state.schema.json create mode 100644 docs/normative/entity-context/v1/collection.schema.json create mode 100644 docs/normative/entity-context/v1/common.schema.json diff --git a/docs/ADRs/0076-slash-command-entity-context-separation.md b/docs/ADRs/0076-slash-command-entity-context-separation.md index b4cdcab800..213243976d 100644 --- a/docs/ADRs/0076-slash-command-entity-context-separation.md +++ b/docs/ADRs/0076-slash-command-entity-context-separation.md @@ -20,6 +20,11 @@ Accepted Extends entity-context rules for conversation surfaces in [ADR 0086](0086-conversation-surface-for-agent-participation.md). +Terminology note: this ADR uses *entity context* for a dispatch-layer routing +category. [ADR 0107](0107-deterministic-filtered-entity-context-staging.md) +later uses the same phrase for the distinct filtered data snapshot staged for +a handled Git-forge entity. + Refines [ADR 0002](0002-initial-fullsend-design.md) (initial design) and reinforces [ADR 0020](0020-composable-single-responsibility-agents-with-individual-sandboxes.md) (single-responsibility agents). diff --git a/docs/ADRs/0107-deterministic-filtered-entity-context-staging.md b/docs/ADRs/0107-deterministic-filtered-entity-context-staging.md index 8e9a92f678..1631174206 100644 --- a/docs/ADRs/0107-deterministic-filtered-entity-context-staging.md +++ b/docs/ADRs/0107-deterministic-filtered-entity-context-staging.md @@ -34,16 +34,21 @@ the preferred prefetch model from [ADR 0017](0017-credential-isolation-for-sandboxed-agents.md) to every issue and change-proposal run. +This ADR's *entity context* is the staged data snapshot. It is distinct from +the dispatch-layer routing category called entity context in +[ADR 0076](0076-slash-command-entity-context-separation.md). + ## 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: size limits, Unicode safety normalization, -secret and sensitive-data redaction, and injection scanning. 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. +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. The snapshot is written outside the repository clone. Host-side pre- and post-scripts receive `FULLSEND_CONTEXT_DIR` pointing to @@ -80,16 +85,28 @@ 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. It cannot mutate the agent's view: Fullsend verifies the manifest digests before upload and -restores or rejects changed files. The sandbox copy is read-only to the agent. +restores or rejects changed files. The uploaded tree must contain exactly the +paths listed by the manifest; Fullsend removes extra paths or aborts assembly +before upload. The sandbox copy is read-only to 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. `summary.md` and deterministic projections remain navigation aids for -selective reads. Runtime forge reads are an explicit fallback for data outside -the snapshot, not the default way to obtain it. +tokens. Deterministic order projections remain navigation aids for selective +reads. Runtime forge reads for entity-context 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 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. Fullsend removes the sandbox copy after its last sandbox consumer and the host copy after diff --git a/docs/normative/entity-context/v1/README.md b/docs/normative/entity-context/v1/README.md index da55c9d098..76b7b96306 100644 --- a/docs/normative/entity-context/v1/README.md +++ b/docs/normative/entity-context/v1/README.md @@ -5,20 +5,32 @@ by [ADR 0107](../../../ADRs/0107-deterministic-filtered-entity-context-staging.m It is the contract between forge adapters, `fullsend run`, harness scripts, and agent runtimes. +Here, *entity context* means the staged data snapshot for a handled Git-forge +entity. [ADR 0076](../../../ADRs/0076-slash-command-entity-context-separation.md) +uses the same phrase for the distinct routing category that determines which +agent or slash command may handle an issue, change proposal, or conversation. +Entity-context v1 applies only to GitHub, GitLab, and Forgejo work items and +change proposals. A non-forge `work_item`, such as Jira, does not start v1 +snapshot assembly; the runner records an `unsupported_entity` diagnostic +outside the tree and continues under that integration's existing input +contract. Runtime entity-context forge reads remain denied. + ## Tree -Entries that do not apply to an entity are omitted. JSON documents use their -linked schemas. +The singleton JSON documents and the two top-level order views shown below are +always emitted. Array-valued sections are empty when there is nothing to +report. Record, thread, review-view, check, and log entries are emitted only +when selected by `collection.json`. JSON documents use their linked schemas. ```text context/ ├── index.json -├── summary.md +├── collection.json ├── entity/metadata.json ├── records/-.md ├── threads/.order ├── views/ -│ ├── conversation.order +│ ├── timeline.order │ ├── unresolved-review.order │ └── reviews/.order ├── relations/reviews.json @@ -27,40 +39,72 @@ context/ │ ├── metadata.json │ └── log.txt └── state/ + ├── actors.json └── threads.json ``` -`index.json` conforms to -[`index.schema.json`](index.schema.json) and enumerates every other staged file. -`entity/metadata.json`, `relations/reviews.json`, -`history/agent-runs.json`, check metadata, and -`state/threads.json` conform respectively to +`index.json` conforms to [`index.schema.json`](index.schema.json) and enumerates +every other staged file. `collection.json`, `entity/metadata.json`, +`relations/reviews.json`, `history/agent-runs.json`, check metadata, +`state/actors.json`, and `state/threads.json` conform respectively to +[`collection.schema.json`](collection.schema.json), [`entity.schema.json`](entity.schema.json), [`reviews.schema.json`](reviews.schema.json), [`agent-runs.schema.json`](agent-runs.schema.json), -[`check.schema.json`](check.schema.json), and -[`thread-state.schema.json`](thread-state.schema.json). `summary.md` is a -bounded navigation view generated only from the manifest and state documents; -it must not duplicate record bodies or logs. Files under `threads/` contain -only ordered relative paths to records. Files under `views/` are deterministic -projections containing those same paths, one per LF-terminated line. +[`check.schema.json`](check.schema.json), +[`actor-state.schema.json`](actor-state.schema.json), and +[`thread-state.schema.json`](thread-state.schema.json). Files under `threads/` +contain only ordered relative paths to records. Files under `views/` are +deterministic projections containing those same paths, one per LF-terminated +line. `views/timeline.order` and `views/unresolved-review.order` exist even when +empty. + +The canonical empty singleton documents are `{"reviews":[],"threads":[]}` for +`relations/reviews.json`, `{"runs":[]}` for `history/agent-runs.json`, +`{"actors":[]}` for `state/actors.json`, and `{"threads":[]}` for +`state/threads.json`, serialized under RFC 8785. An empty order view is a +zero-byte file. ## Stable records and mutable state -A record key is the lowercase hexadecimal SHA-256 of these UTF-8 strings joined -by a single NUL byte, with no trailing NUL: +A record key is the lowercase hexadecimal SHA-256 of these four UTF-8 strings +joined by a single NUL byte, with no trailing NUL: ```text -forge identifier, canonical repository identifier, record kind, forge record ID +://, source.repository_id, record kind, forge record ID ``` -The forge record ID is the platform's immutable opaque ID, not a mutable URL, -ordinal, database row position, or display number. Source kinds used in this -derivation are `comment`, `review`, `check`, `thread`, and `entity`. Manifest -record entries use only `entity`, `comment`, `review`, and `check`; `thread` -keys identify relationship and ordering data under `relations/` and `threads/`, -not files under `records/`. This derivation makes paths safe and stable without -requiring consumers to parse forge-specific IDs. +`source.forge` is `github`, `gitlab`, or `forgejo`. `source.host` is the +lowercase DNS name, with a port from 1 through 65535 appended as decimal +`:` if and only if the HTTPS port is not 443, and no scheme or path. +The default port is always omitted. `source.repository_id` and each forge +record ID use these positive mappings: + +- GitHub uses the GraphQL node ID exposed as `node_id` for the repository and + each entity, comment, review, check run, or review thread. +- GitLab uses the global project or record `id`, serialized in base-10 without + leading zeroes; a discussion thread uses its opaque API `id`. Project-scoped + issue or merge-request `iid` values are display numbers and are not IDs here. +- Forgejo uses the numeric repository or record `id`, serialized in base-10 + without leading zeroes. Issue and change-proposal `number` values are display + numbers and are not IDs here. + +Actor IDs follow the same rule: GitHub `node_id`, or the GitLab/Forgejo numeric +user `id` in base-10 without leading zeroes. References to a deleted actor +retain the immutable ID when the forge exposes it and otherwise use `null`. + +`source.repository` is a navigation value, not a hash input: GitHub uses +lowercase `owner/repository`; GitLab uses the API's canonical +`path_with_namespace`; Forgejo uses lowercase API `full_name`. All forms use +literal `/` separators with no leading/trailing slash or percent encoding. +Repository transfers and renames therefore do not rewrite record keys. + +Source kinds used in key derivation are `comment`, `review`, `check`, `thread`, +and `entity`. Manifest record entries use only `entity`, `comment`, `review`, +and `check`; `thread` keys identify relationship and ordering data under +`relations/` and `threads/`, not files under `records/`. A selected object that +lacks its required canonical ID produces an `invalid_metadata` gap and is not +assigned an adapter-specific substitute. The tree contains forge entity state that is not reconstructible from the target Git checkout. Diffs, commits, changed-file lists, branches, and revision @@ -75,26 +119,29 @@ UTF-8 layout; header values are canonical JSON strings (or `null`) on one line: ```text Fullsend-Record: "comment" Source-ID: "opaque-forge-id" -Source-URL: "https://forge.example/..." Author-ID: "opaque-actor-id" -Author: "forge-login" -Created-At: "2026-09-08T10:15:30Z" +Created-At: "2026-09-08T10:15:30.000000000Z" Filtered Markdown body. ``` `Fullsend-Record` is `"comment"` or `"review"`. The header order and blank -line are fixed. `Author-ID` and `Author` may be `null` when the forge withholds -or has deleted the actor. All header strings are filtered before JSON-string -serialization. The file contains no update time, ordering, thread membership, -review location, resolution, outdated, or minimized state; those properties -belong in `index.json`, `relations/`, or `state/`. Consequently, resolving a thread or -inserting an earlier record must not rename or rewrite an unchanged record. -Changing its body or attribution fields changes that record's bytes and digest. +line are fixed. `Author-ID` may be `null` when the forge withholds or has +deleted the actor. The immutable actor ID is included because attribution is +part of the source record. The current login and navigation URL stay in +`index.json` and `state/actors.json`: either may change after an account or +repository rename without the record changing. Effective repository role is +also excluded because permissions can change without the comment changing. +The file contains no update time, ordering, thread membership, review location, +resolution, outdated, or minimized state; those properties belong in +`index.json`, `relations/`, or `state/`. Consequently, resolving a thread, +renaming an actor or repository, changing an actor's permission, or inserting +an earlier record must not rename or rewrite an unchanged record. Changing its +body or immutable attribution ID changes that record's bytes and digest. The initial issue or change-proposal body uses the same layout with -`Fullsend-Record: "entity"`, the entity's stable ID and URL, and its author -attribution and creation time. This makes it the first self-contained turn. +`Fullsend-Record: "entity"`, the entity's stable ID, immutable author ID, and +creation time. This makes it the first self-contained turn. ## Ordering files and prompt assembly @@ -105,7 +152,7 @@ second digits and no punctuation other than `T` and `Z`. The entity-body record uses the reserved key `00000000T000000000000000Z`, so it always sorts first. Creation time is immutable forge data; edits do not rename a record. -`views/conversation.order` lists the entity record and all comment and review +`views/timeline.order` lists the entity record and all comment and review records in canonical chronology. Each `threads/.order` lists that thread's records in forge order. `views/unresolved-review.order` lists records in unresolved, non-outdated review threads, ordered by thread creation time and @@ -133,30 +180,168 @@ affected block onward. Consumers never infer resolution from record content. Check status is observation state in `checks//metadata.json`; its log file contains only filtered log bytes. A growing or replaced forge log is changed content and may change `log.txt`. A new check attempt has a new forge -record ID and therefore a new record key. +record ID and therefore a new record key; v1 has no separate synthesized +attempt number. Its `created_at` is the forge's +immutable check-run creation time and is also the check manifest record's +`created_at`; a runner first-observed time is forbidden. Check status is +normalized to `queued`, `in_progress`, or `completed`; conclusions are +`success`, `failure`, `neutral`, `cancelled`, `skipped`, `timed_out`, +`action_required`, or `stale`. +Queued checks have no start, completion, or conclusion fields. In-progress +checks require `started_at` and have no completion or conclusion. Completed +checks require `completed_at` and `conclusion`; they also require +`started_at` except when a `skipped` or `cancelled` check is explicitly known +to have never run. +Check manifest records carry `created_at` but no `author_id` or `author`. + +Adapters use these exhaustive v1 native-status mappings: + +- GitHub `queued`, `waiting`, `requested`, and `pending` map to `queued`; + `in_progress` maps to `in_progress`; `completed` maps to `completed` and its + native conclusion maps identically to the v1 conclusion vocabulary, except + `startup_failure`, which maps to `failure`. +- GitLab `created`, `waiting_for_resource`, `waiting_for_callback`, `preparing`, `pending`, `scheduled`, + and `manual` map to `queued`; `running` and `canceling` map to `in_progress`; + `success`, `failed`, `canceled`, and `skipped` map to `completed` with + conclusions `success`, `failure`, `cancelled`, and `skipped`, respectively. +- Forgejo `pending`, `waiting`, and `blocked` map to `queued`; `running` maps to + `in_progress`; `success`, `failure`, `error`, `warning`, `cancelled`, + `canceled`, and `skipped` map to `completed` with conclusions `success`, + `failure`, `failure`, `neutral`, `cancelled`, `cancelled`, and `skipped`, + respectively. + +Any native status or conclusion not listed above is `invalid_metadata`; an +adapter must not invent another mapping. Any mapped check whose forge data +cannot satisfy `check.schema.json`'s status-specific timestamp requirements is +also `invalid_metadata`. Completed `skipped` and `cancelled` checks require +`completed_at` and may omit `started_at` when the forge says the job never ran; +all other completed checks require both timestamps. Native timestamp fields +forbidden for the mapped status are omitted rather than copied. ## Relationships, history, and collection profiles -`relations/reviews.json` preserves formal review outcomes and the association -between reviews, replies, reviewed revisions, and code locations separately -from mutable resolution state. Location fields are optional because forges -expose different subsets. `history/agent-runs.json` contains only immutable, -forge-observable Fullsend run receipts and relates an agent result to its input -revision, result records, and resulting commit. A mutable sticky comment may be -a human-facing summary, but it is not canonical run history and its overwritten -versions cannot be reconstructed from a forge that does not expose edit -history. - -The required `collection_profile` in `index.json` is the lowercase SHA-256 of -the canonically serialized collection configuration: included source kinds, -selection rules, and bounds. For example, a profile may include failed-check -logs without fetching all successful logs. Given the same forge responses, -profile, bounds, and filter version, the tree is identical. Profiles must not -vary collection based on runner time or an agent's intermediate choices. -Missing data within the selected profile is represented as a bounded manifest -gap with a stable code; history unavailable from the forge, including -overwritten edits or unreachable force-pushed commits, is not silently treated -as an empty history. +`relations/reviews.json` preserves normalized formal review outcomes and the +association between reviews, replies, reviewed revisions, and code locations +separately from mutable resolution state. Review states use `approved`, +`changes_requested`, `commented`, and `dismissed`, matching normalized-event +v1. Forge sides such as GitHub `LEFT` and `RIGHT` are lowercased to `left` and +`right`. Reviewed revisions and location fields are optional because forges +expose different subsets. `state/threads.json` references the actor that +resolved each resolved thread, and `relations/reviews.json` references the +actor that dismissed each dismissed review. A nullable reference explicitly +records that the forge did not expose the actor; a nullable dismissal timestamp +does the same when the forge exposes the disposition but not its time. Actor +references resolve through `state/actors.json`. + +Review adapters use these exhaustive v1 mappings: + +- GitHub `APPROVED`, `CHANGES_REQUESTED`, `COMMENTED`, and `DISMISSED` map to + their lowercase v1 equivalents. `PENDING` reviews are unsubmitted and are + omitted. +- GitLab approval summaries and current-approver lists do not have immutable + review record IDs and are not formal v1 review records. GitLab discussion + notes are staged as comments and threads. When immutable approval history is + unavailable, the `reviews` scope records a partial `history_unavailable` gap. +- Forgejo `APPROVED`, `REQUEST_CHANGES`, `COMMENT`, and `DISMISSED` map to + `approved`, `changes_requested`, `commented`, and `dismissed`, respectively. + `PENDING` and `REQUEST_REVIEW` rows are unsubmitted reviewer requests and are + omitted. + +Any other native formal-review state is `invalid_metadata`. GitHub uses its +native outdated observation. For GitLab and Forgejo thread APIs that expose no +outdated equivalent, producers emit `outdated: false`; they never infer it from +the current diff. + +The `threads` arrays in `relations/reviews.json` and `state/threads.json` have +exactly the same unique `thread_key` set. Every relationship thread therefore +has an explicit state row, including unresolved threads with `resolved: false` +and an explicit `outdated` boolean. Missing, duplicate, or extra thread-state +rows make the `reviews` scope unusable and add an `invalid_metadata` gap. + +`state/actors.json` contains the current, forge-verified effective repository +permission for each referenced author, resolver, and dismisser. Roles use the +[ADR 0054](../../../ADRs/0054-require-authorization-on-all-agent-dispatch-paths.md) +and normalized-event v1 vocabulary: `admin`, `maintain`, `write`, +`triage`, `read`, `none`, and `external`. `role_verified: false` is paired with +`role: null` and means consumers must fail closed rather than infer authority +from forge association labels such as GitHub `authorAssociation`. Each row +states whether the actor is a `human` or `bot`. A bot's role is that bot +identity's own effective permission on the target repository, never Fullsend's +installation permission. A permission lookup failure, including a collaborator +API 404, emits `role_verified: false` and `role: null`. + +Entity-context and normalized-event v1 carry independently versioned copies of +the actor-role vocabulary. They match when this version is accepted, but a +non-breaking role addition to normalized-event v1 does not extend this closed +schema; a value must validate against the schema of every document that uses +it. + +Every non-null `author_id`, `resolved_by_actor_id`, and +`dismissed_by_actor_id` referenced anywhere in the snapshot appears exactly +once in the actor array. JSON Schema cannot express uniqueness by one object +property, so producers enforce this cross-document invariant. Consumers treat +a duplicate or missing actor row exactly like `role_verified: false`. The actor +array sorts by actor ID. Because permissions and dispositions are mutable +observation state, changing them changes state or relationship documents but +not record files. Role values are observed during snapshot assembly, not +copied from a historical comment event. + +`history/agent-runs.json` +contains only immutable, forge-observable Fullsend run receipts and relates an +agent result to its input revision, result records, and resulting commit. A +receipt's `input_revision` is the lowercase SHA-256 of the RFC 8785 +`index.json` bytes consumed by that run; `input_head_sha`, when present, is the +separate Git revision checked out for the run. Receipt status is `success`, +`failure`, `cancelled`, `skipped`, or `timed_out`. A mutable sticky comment may +be a human-facing summary, but it is not canonical +run history and its overwritten versions cannot be reconstructed from a forge +that does not expose edit history. + +`collection.json` is the exact collection configuration and conforms to +`collection.schema.json`. Its source-kind array sorts by ASCII byte order. +Non-entity records first enter the corresponding canonical order from +[Ordering and determinism](#ordering-and-determinism); `record_selection` +retains either the oldest or newest `max_records_per_source` entries for each +included source, then output ordering follows the same chronology rules. +After comment and review record selection, thread `record_keys`, reply edges, +thread order files, and review views contain only retained records that have an +emitted `content_path`. A reply edge is emitted only when both endpoints remain +and have content paths. A thread with no such records is omitted from both +relationship and state arrays and has no order or view file; dangling record +keys and order lines are forbidden. +`check_log_selection` is `none`, `failed`, or `all`. `failed` means the parent +check conclusion is `failure`, `timed_out`, `action_required`, or `stale`; +`cancelled`, `skipped`, and `neutral` checks are not failed. `check_logs` can be +included only with `checks`. Check record selection and +`max_records_per_source` are applied first. Logs are then selected only from +the retained parent checks and use the parent's `created_at` and `record_key` +for deterministic order; logs are not a second independently counted record +source. Bounds apply after the +full-source security pipeline described below: `max_record_bytes` bounds each +record body, `max_log_bytes` bounds each log, and +`max_metadata_string_bytes` bounds each source-derived display string. Labels +first sort canonically and then retain the first `max_labels` entries. +Structural strings cannot be truncated. +Exceeding `max_metadata_string_bytes` makes a structural value invalid. +`max_source_bytes` is the pre-decode acquisition cap described below. +`collection_profile` equals the lowercase SHA-256 of the exact RFC 8785 +`collection.json` bytes and therefore also equals that file's manifest digest. +Profiles must not vary based on runner time or an agent's intermediate choices. +For a retained check, the index record has `log_path` if and only if +`check_log_selection` selected its log and filtering produced the file without +an unusable `invalid_metadata` or `unsafe_content` gap. + +Missing selected data is represented in `index.json.gaps`; it is never silently +treated as an empty history. Scopes are `entity`, `comments`, `reviews`, +`checks`, `check_logs`, `agent_runs`, and `actors`. `profile_bound` and +`history_unavailable` gaps have `usability: partial`; consumers may use present +records but must not claim the scope is complete. `unsupported`, +`authorization_failed`, `fetch_failed`, `source_too_large`, +`invalid_metadata`, and `unsafe_content` have `usability: unusable`; consumers +must not make an authority or completeness decision from that scope. Any +`actors` gap makes authorization unusable and therefore fails closed. Runtimes +and host scripts +must inspect relevant gaps before consuming records or state. ## Canonical bytes @@ -164,27 +349,133 @@ JSON is UTF-8 serialized with the JSON Canonicalization Scheme (RFC 8785), with no byte-order mark or trailing newline. Arrays use the order defined below; objects use RFC 8785 member ordering. +Every JSON timestamp is normalized to UTC and serialized with exactly nine +fractional-second digits as `YYYY-MM-DDTHH:MM:SS.nnnnnnnnnZ`. Offset forms, +omitted fractions, and other equivalent RFC 3339 spellings are not canonical. +Git object IDs are serialized as lowercase hexadecimal strings. + Properties marked required by a schema are always emitted. If a required property is nullable and its normalized source value is unavailable, it is emitted as JSON `null`. A non-required property is emitted only when its normalized source value is available; otherwise it is omitted and is never synthesized as `null` or with a default value. -Text bodies and logs are UTF-8 after the v1 filter pipeline, use LF -line endings, have no byte-order mark, and end in exactly one LF. The pipeline -applies size bounds, Unicode safety normalization, secret/sensitive-data -redaction, and injection scanning in that order. `filter.status` is: +Text bodies and logs are UTF-8 after the v1 filter pipeline, use LF line +endings, and have no byte-order mark. Line-ending normalization canonicalizes a +non-empty body or log to exactly one trailing LF before `filter.status` is +computed. The byte bound includes that LF. To bound non-empty text, remove all +trailing LFs, retain the longest prefix ending at a UTF-8 code-point boundary +whose bytes plus one LF fit the bound, then append one LF. An empty body +contributes zero bytes after the record header's required blank line; an empty +log is a zero-byte file. + +The pipeline operates on the complete selected source in this order: + +1. decode and normalize line endings, then apply Unicode safety normalization; +2. redact secrets and sensitive data from the complete normalized source; +3. scan the complete redacted source for prompt injection and reject it when + policy says it cannot be represented safely; +4. for record bodies and logs, apply the configured byte bound at a UTF-8 + code-point boundary and enforce the single trailing LF rule; and +5. if step 4 removed bytes, scan the exact emitted bytes again for prompt + injection and reject them if unsafe in isolation. + +Secret and sensitive-data detectors must never run only on a truncated prefix. +Because redaction precedes the bound, a secret match cannot straddle an +uninspected truncation boundary. Injection detection covers both the complete +redacted source and the exact truncated bytes the consumer would receive. +An input exceeding the profile's `max_source_bytes` is not decoded and adds an +unusable `source_too_large` gap; no prefix is emitted. A pipeline component +error, timeout, or unavailable detector aborts snapshot assembly; it never +passes through original bytes. + +Every `filter_version` strips and records findings for, at minimum, Unicode tag +characters U+E0000--U+E007F; zero-width U+200B--U+200D and U+FEFF; +bidirectional controls U+202A--U+202E and U+2066--U+2069; variation selectors +U+FE00--U+FE0F and U+E0100--U+E01EF; and interlinear annotations +U+FFF9--U+FFFB. A filter version may cover more classes, but it cannot weaken +these invariants. + +Fullsend's shipped filter version must not be weaker than its Unicode safety +scanner at the commit that accepts this specification. That scanner also +removes nulls, terminal escapes, LRM/RLM, word joiners, other format (`Cf`) +characters, and applies reported NFKC normalization. Those additional +transformations are bound to the shipped `filter_version`; they are not +silently added to the portable character-class floor above, and changing their +output requires a new filter version. + +The v1 redaction floor detects exact run credentials registered by Fullsend; +OpenAI, Anthropic, GitHub, GitLab, Slack, Google, AWS, Stripe, SendGrid, +Hugging Face, npm, PyPI, Vault, and age secret prefixes; private-key blocks; +authorization headers; secret-named environment and JSON values; database URL +passwords; and structured SSN, payment-card, and IBAN values. Exact pattern and +validation semantics are part of `filter_version`. A later filter version may +add detectors but must not remove or narrow this floor. + +The deterministic injection floor rejects matches for instruction override, +system-prompt replacement, unrestricted-role requests, concealment from the +user, credential-file or environment exfiltration, hidden HTML instructions, +and translate-then-execute requests. Exact patterns and thresholds are part of +`filter_version`; ML detectors may supplement them only when their model, +threshold, and deterministic execution contract are also versioned. No +detector reliably blocks every visible prompt injection. Runtimes therefore +mark staged records as untrusted data in distinct content blocks, prohibit +following instructions from those blocks, and retain least-privilege tool and +credential boundaries as the primary defense. + +`filter.status` is: - `unchanged`: emitted bytes equal normalized source bytes; - `modified`: one or more replacements or redactions were applied; -- `truncated`: a size bound removed source bytes, whether or not other filters also changed them; -- `rejected`: no content file is emitted because the source could not be represented safely. +- `truncated`: a size bound removed source bytes, whether or not earlier filters + also changed them; findings still report every replacement and redaction; +- `rejected`: no content file is emitted because the source could not be + represented safely. + +Source-derived display strings in JSON metadata pass through Unicode safety, +redaction, and complete-source injection scanning, then are bounded at a UTF-8 +code-point boundary with no trailing LF added. Bound display strings first; drop +empty optional values, re-unique labels, then sort labels and apply +`max_labels`. A required singleton title that becomes empty or unsafe aborts +assembly like a rejected entity body. Required nullable entity.author, +record.author, and actor.login values become JSON `null` when unsafe or empty. +An unsafe or empty check name or agent name rejects only its affected optional +record with an `unsafe_content`/`invalid_metadata` gap; it never aborts an +otherwise valid entity snapshot. Unsafe labels are dropped and findings are +retained. A truncated display string is scanned again exactly as emitted +before canonical serialization. This includes entity titles and labels; entity +and manifest-record author logins; actor logins; check names; and agent names. +Redaction reduces exposure but does not promise anonymization; +provider retention and prompt caching of remaining content are governed by the +configured provider trust boundary, not by this cleanup guarantee. + +Structural strings are not rewritten because doing so could change identity or +target a different resource. Canonical IDs use the mappings above. Repository +paths, review file paths, and source URLs first undergo the Unicode-safety scan +and then strict structural validation. Repository file paths are relative, +slash-separated, contain no `.` or `..` segment, percent-encoded dot, slash, or +backslash, control character, or non-rendering class named above. Source URLs +use HTTPS, contain no userinfo or credentials, and have a lowercase authority +exactly equal to `source.host`; schemes such as `javascript`, `data`, and +`file` are invalid. The shared `source_url` schema definition enforces the +closed URI shape, while producers and consumers enforce the cross-document +host equality. An unsafe structural value, whether its property is required or +optional, causes the selected source and its files to be omitted and produces +an unusable `invalid_metadata` or `unsafe_content` gap. Structural values are +never emitted after filtering or truncation. + +`index.json.filter` records filtering of source-derived values in the index. +Manifest file entries require `filter` for entity, review, agent-run, check, and +actor JSON documents; each value summarizes that document's filtered metadata. +Generated collection, state-without-display-text, and order documents do not +invent filter findings. + +Every emitted file other than the root `index.json` has a manifest `sha256` +over its emitted bytes. A rejected non-entity source has a record but no content +path or file entry and adds an `unsafe_content` gap for its scope. A rejected or +missing entity-body record aborts snapshot assembly, and Fullsend must not +launch scripts or an agent with that snapshot. -All attacker-controlled strings in JSON metadata pass through the same pipeline -before canonical serialization. - -Every emitted file has a manifest `sha256` over its emitted bytes. A rejected -source has a record but no content path or file entry. Findings contain codes and counts, not rejected source text. Filters and bounds are identified by `filter_version`; changing emitted bytes for the same input requires a new filter version. Removing or reinterpreting a status requires v2. @@ -193,16 +484,20 @@ requires a new filter version. Removing or reinterpreting a status requires v2. Manifest record arrays and record filenames are sorted by source `created_at`, then by the record key's ASCII byte order. The reserved entity-body order key -sorts before them. Thread arrays use thread creation time and then thread ID; -`record_keys` and thread `.order` lines preserve forge thread order. Agent -receipts sort by completion time and ID; manifest files sort by path, gaps by -scope and code, and filter findings by code. Other arrays state their ordering -in their owning schema before being added to v1. +sorts before them. Formal review arrays sort by `submitted_at` and then review +ID. Relationship thread arrays sort by `created_at` and then thread ID; each +thread's `record_keys`, `replies`, and `.order` lines preserve forge thread +order. Mutable thread-state arrays sort by the thread key's ASCII byte order. +Actor-state arrays sort by actor ID's UTF-8 byte order. Agent receipts sort by +completion time and ID; each receipt's `result_record_keys` sort by ASCII byte +order. Entity labels sort by their filtered UTF-8 byte order. Manifest files +sort by path, gaps by scope and code, and filter findings by code. Other arrays +state their ordering in their owning schema before being added to v1. `generated_at` or another runner-clock value is forbidden anywhere under the context root. Acquisition timing belongs in run telemetry outside the staged tree. Source-provided timestamps, entity update time, Git object IDs used as -relationship values, and check attempt IDs are permitted. With identical +relationship values, and forge check record IDs are permitted. With identical forge responses, `collection_profile`, size bounds, and `filter_version`, the complete tree has identical paths and bytes. @@ -222,8 +517,46 @@ cleanup errors, but never entity bodies, comment/review bodies, or logs. ## Compatibility Consumers must reject an unsupported `schema_version` or `filter_version`; they -must validate every document against the v1 schemas. The schemas are closed: +must validate `index.json`, `collection.json`, `entity/metadata.json`, +`relations/reviews.json`, `history/agent-runs.json`, check metadata documents, +`state/actors.json`, and `state/threads.json` against their v1 schemas. Other +emitted files follow the byte contracts above. The schemas are closed: adding a property, record kind, enum value, or status is a breaking change. Changing path derivation, canonical bytes, required fields, field meaning, or ordering likewise requires `docs/normative/entity-context/v2/` and a superseding ADR. + +The schema committed with the accepting ADR defines v1. Subsequent additions, +even an optional property, require v2: older closed-schema consumers would +reject them, and `schema_version` has no minor-version representation. + +## Relationship to normalized-event v1 + +Entity context stages only work items (issues) and change proposals (PRs or +MRs); normalized-event's `conversation` entity kind from ADR 0086 is outside +this version's scope. Entity-context `kind` uses normalized-event's `work_item` +and `change_proposal` values. Entity-context `id` is the forge's immutable +opaque object ID because it participates in stable path derivation, while +`number` is the positive display number projected into normalized-event +`entity.id` for routing. Adapters must preserve that explicit mapping rather +than treating the two `id` fields as interchangeable. + +Entity state is normalized to `open` or `closed` for work items and to `open`, +`closed`, or `merged` for change proposals. Adapters use these exhaustive v1 +mappings: + +- GitHub issue `OPEN` and `CLOSED` map to `open` and `closed`. A pull request + with `merged: true` maps to `merged`; otherwise `OPEN` and `CLOSED` map to + `open` and `closed`. +- GitLab issue and merge-request `opened` and `closed` map to `open` and + `closed`; merge-request `merged` maps to `merged`. Merge-request `locked` + is GitLab's merge-in-progress lock and maps to `open`; the separate + `discussion_locked` field is omitted from entity metadata v1. +- Forgejo issue and pull-request `open` and `closed` map to `open` and `closed`; + a pull request with `merged: true` maps to `merged` regardless of its native + closed state. + +Any other native state on an optional record is `invalid_metadata`; adapters +must not invent another mapping. Because entity metadata and body are required +singletons, an unrepresentable entity state aborts snapshot assembly instead +of emitting an entity gap. diff --git a/docs/normative/entity-context/v1/actor-state.schema.json b/docs/normative/entity-context/v1/actor-state.schema.json new file mode 100644 index 0000000000..2c268797ae --- /dev/null +++ b/docs/normative/entity-context/v1/actor-state.schema.json @@ -0,0 +1,38 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://fullsend.ai/normative/entity-context/v1/actor-state.schema.json", + "title": "ActorState", + "type": "object", + "required": ["actors"], + "properties": { + "actors": { + "type": "array", + "uniqueItems": true, + "items": { + "type": "object", + "required": ["id", "kind", "login", "role", "role_verified"], + "properties": { + "id": { "type": "string", "minLength": 1 }, + "kind": { "enum": ["human", "bot"] }, + "login": { "type": ["string", "null"], "minLength": 1 }, + "role": { + "oneOf": [ + { "$ref": "common.schema.json#/$defs/actor_role" }, + { "type": "null" } + ] + }, + "role_verified": { "type": "boolean" } + }, + "allOf": [ + { + "if": { "properties": { "role_verified": { "const": true } }, "required": ["role_verified"] }, + "then": { "properties": { "role": { "$ref": "common.schema.json#/$defs/actor_role" } } }, + "else": { "properties": { "role": { "type": "null" } } } + } + ], + "additionalProperties": false + } + } + }, + "additionalProperties": false +} diff --git a/docs/normative/entity-context/v1/agent-runs.schema.json b/docs/normative/entity-context/v1/agent-runs.schema.json index 4319f94c9a..907abf0df6 100644 --- a/docs/normative/entity-context/v1/agent-runs.schema.json +++ b/docs/normative/entity-context/v1/agent-runs.schema.json @@ -13,18 +13,22 @@ "properties": { "id": { "type": "string", "minLength": 1 }, "agent": { "type": "string", "minLength": 1 }, - "status": { "type": "string", "minLength": 1 }, - "input_revision": { "type": "string", "minLength": 1 }, - "input_head_sha": { "type": "string", "pattern": "^[0-9a-fA-F]{40}([0-9a-fA-F]{24})?$" }, + "status": { "enum": ["success", "failure", "cancelled", "skipped", "timed_out"] }, + "input_revision": { + "$ref": "common.schema.json#/$defs/record_key", + "description": "SHA-256 of the canonical index.json consumed by this run." + }, + "input_head_sha": { "$ref": "common.schema.json#/$defs/git_oid" }, "result_record_keys": { "type": "array", - "items": { "type": "string", "pattern": "^[0-9a-f]{64}$" }, - "uniqueItems": true + "items": { "$ref": "common.schema.json#/$defs/record_key" }, + "uniqueItems": true, + "description": "Result record keys sorted by ASCII byte order." }, - "resulting_commit_sha": { "type": "string", "pattern": "^[0-9a-fA-F]{40}([0-9a-fA-F]{24})?$" }, - "source_url": { "type": "string", "format": "uri" }, - "started_at": { "type": "string", "format": "date-time" }, - "completed_at": { "type": "string", "format": "date-time" } + "resulting_commit_sha": { "$ref": "common.schema.json#/$defs/git_oid" }, + "source_url": { "$ref": "common.schema.json#/$defs/source_url" }, + "started_at": { "$ref": "common.schema.json#/$defs/timestamp" }, + "completed_at": { "$ref": "common.schema.json#/$defs/timestamp" } }, "additionalProperties": false } diff --git a/docs/normative/entity-context/v1/check.schema.json b/docs/normative/entity-context/v1/check.schema.json index 56bec29af7..e65eb96920 100644 --- a/docs/normative/entity-context/v1/check.schema.json +++ b/docs/normative/entity-context/v1/check.schema.json @@ -3,16 +3,37 @@ "$id": "https://fullsend.ai/normative/entity-context/v1/check.schema.json", "title": "CheckMetadata", "type": "object", - "required": ["id", "name", "status", "attempt"], + "required": ["id", "name", "status", "created_at"], "properties": { "id": { "type": "string", "minLength": 1 }, - "name": { "type": "string" }, - "status": { "type": "string", "minLength": 1 }, - "conclusion": { "type": "string" }, - "attempt": { "type": "integer", "minimum": 1 }, - "source_url": { "type": "string", "format": "uri" }, - "started_at": { "type": "string", "format": "date-time" }, - "completed_at": { "type": "string", "format": "date-time" } + "name": { "type": "string", "minLength": 1 }, + "status": { "enum": ["queued", "in_progress", "completed"] }, + "conclusion": { "enum": ["success", "failure", "neutral", "cancelled", "skipped", "timed_out", "action_required", "stale"] }, + "source_url": { "$ref": "common.schema.json#/$defs/source_url" }, + "created_at": { "$ref": "common.schema.json#/$defs/timestamp" }, + "started_at": { "$ref": "common.schema.json#/$defs/timestamp" }, + "completed_at": { "$ref": "common.schema.json#/$defs/timestamp" } }, + "allOf": [ + { + "if": { "properties": { "status": { "const": "queued" } }, "required": ["status"] }, + "then": { "not": { "anyOf": [{ "required": ["started_at"] }, { "required": ["completed_at"] }, { "required": ["conclusion"] }] } } + }, + { + "if": { "properties": { "status": { "const": "in_progress" } }, "required": ["status"] }, + "then": { + "required": ["started_at"], + "not": { "anyOf": [{ "required": ["completed_at"] }, { "required": ["conclusion"] }] } + } + }, + { + "if": { "properties": { "status": { "const": "completed" } }, "required": ["status"] }, + "then": { + "required": ["completed_at", "conclusion"], + "if": { "properties": { "conclusion": { "enum": ["cancelled", "skipped"] } }, "required": ["conclusion"] }, + "else": { "required": ["started_at"] } + } + } + ], "additionalProperties": false } diff --git a/docs/normative/entity-context/v1/collection.schema.json b/docs/normative/entity-context/v1/collection.schema.json new file mode 100644 index 0000000000..4895b8929a --- /dev/null +++ b/docs/normative/entity-context/v1/collection.schema.json @@ -0,0 +1,50 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://fullsend.ai/normative/entity-context/v1/collection.schema.json", + "title": "EntityContextCollection", + "type": "object", + "required": ["included_sources", "record_selection", "check_log_selection", "bounds"], + "properties": { + "included_sources": { + "type": "array", + "items": { "enum": ["entity", "comments", "reviews", "checks", "check_logs", "agent_runs"] }, + "contains": { "const": "entity" }, + "uniqueItems": true, + "description": "Source kinds sorted by ASCII byte order; entity is always present." + }, + "record_selection": { + "enum": ["oldest", "newest"], + "description": "Which end of canonical source order is retained when a record-count bound applies." + }, + "check_log_selection": { + "enum": ["none", "failed", "all"], + "description": "Which selected checks have logs collected." + }, + "bounds": { + "type": "object", + "required": ["max_records_per_source", "max_source_bytes", "max_record_bytes", "max_log_bytes", "max_metadata_string_bytes", "max_labels"], + "properties": { + "max_records_per_source": { "type": "integer", "minimum": 1 }, + "max_source_bytes": { "type": "integer", "minimum": 1 }, + "max_record_bytes": { "type": "integer", "minimum": 1 }, + "max_log_bytes": { "type": "integer", "minimum": 1 }, + "max_metadata_string_bytes": { "type": "integer", "minimum": 1 }, + "max_labels": { "type": "integer", "minimum": 0 } + }, + "additionalProperties": false + } + }, + "allOf": [ + { + "if": { "properties": { "included_sources": { "contains": { "const": "check_logs" } } }, "required": ["included_sources"] }, + "then": { + "properties": { + "included_sources": { "contains": { "const": "checks" } }, + "check_log_selection": { "enum": ["failed", "all"] } + } + }, + "else": { "properties": { "check_log_selection": { "const": "none" } } } + } + ], + "additionalProperties": false +} diff --git a/docs/normative/entity-context/v1/common.schema.json b/docs/normative/entity-context/v1/common.schema.json new file mode 100644 index 0000000000..01aa5b380b --- /dev/null +++ b/docs/normative/entity-context/v1/common.schema.json @@ -0,0 +1,33 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://fullsend.ai/normative/entity-context/v1/common.schema.json", + "title": "EntityContextCommonDefinitions", + "$defs": { + "timestamp": { + "type": "string", + "format": "date-time", + "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}[.][0-9]{9}Z$" + }, + "git_oid": { + "type": "string", + "pattern": "^[0-9a-f]{40}([0-9a-f]{24})?$" + }, + "record_key": { + "type": "string", + "pattern": "^[0-9a-f]{64}$" + }, + "repository_path": { + "type": "string", + "minLength": 1, + "pattern": "^(?!/)(?!.*//)(?!.*[/]$)(?!.*(^|/)[.]{1,2}(/|$))(?!.*%(?:2[EeFf]|5[Cc]))(?!.*[\u200b-\u200d\u202a-\u202e\u2066-\u2069\ufeff\ufe00-\ufe0f\ufff9-\ufffb])[A-Za-z0-9._/~!$&()+,;=:@%#\\[\\]{} -]+$" + }, + "source_url": { + "type": "string", + "format": "uri", + "pattern": "^https://[a-z0-9.-]+(?::(?!443(?:/|$))(?:[1-9]|[1-9][0-9]{1,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5]))?(?:/[A-Za-z0-9._~!$&()*+,;=:@%/?#-]*)?$" + }, + "actor_role": { + "enum": ["admin", "maintain", "write", "triage", "read", "none", "external"] + } + } +} diff --git a/docs/normative/entity-context/v1/entity.schema.json b/docs/normative/entity-context/v1/entity.schema.json index 5b2d110741..93bfe0f350 100644 --- a/docs/normative/entity-context/v1/entity.schema.json +++ b/docs/normative/entity-context/v1/entity.schema.json @@ -5,21 +5,36 @@ "type": "object", "required": ["kind", "id", "number", "title", "state", "source_url", "author_id", "author", "created_at", "updated_at", "labels"], "properties": { - "kind": { "enum": ["issue", "change_proposal"] }, - "id": { "type": "string", "minLength": 1 }, - "number": { "type": ["integer", "string"] }, - "title": { "type": "string" }, - "state": { "type": "string", "minLength": 1 }, - "source_url": { "type": "string", "format": "uri" }, - "author_id": { "type": ["string", "null"] }, - "author": { "type": ["string", "null"] }, - "created_at": { "type": "string", "format": "date-time" }, - "updated_at": { "type": "string", "format": "date-time" }, + "kind": { "enum": ["work_item", "change_proposal"] }, + "id": { + "type": "string", + "minLength": 1, + "description": "Immutable opaque forge object ID used for record keys; distinct from normalized-event v1 entity.id." + }, + "number": { + "type": "integer", + "minimum": 1, + "description": "Positive forge display number projected into normalized-event v1 entity.id." + }, + "title": { "type": "string", "minLength": 1 }, + "state": { "enum": ["open", "closed", "merged"] }, + "source_url": { "$ref": "common.schema.json#/$defs/source_url" }, + "author_id": { "type": ["string", "null"], "minLength": 1 }, + "author": { "type": ["string", "null"], "minLength": 1 }, + "created_at": { "$ref": "common.schema.json#/$defs/timestamp" }, + "updated_at": { "$ref": "common.schema.json#/$defs/timestamp" }, "labels": { "type": "array", "items": { "type": "string" }, - "uniqueItems": true + "uniqueItems": true, + "description": "Filtered label strings sorted by UTF-8 byte order." } }, + "allOf": [ + { + "if": { "properties": { "kind": { "const": "work_item" } }, "required": ["kind"] }, + "then": { "properties": { "state": { "enum": ["open", "closed"] } } } + } + ], "additionalProperties": false } diff --git a/docs/normative/entity-context/v1/index.schema.json b/docs/normative/entity-context/v1/index.schema.json index e1daca60fe..9e5a7a492f 100644 --- a/docs/normative/entity-context/v1/index.schema.json +++ b/docs/normative/entity-context/v1/index.schema.json @@ -3,27 +3,63 @@ "$id": "https://fullsend.ai/normative/entity-context/v1/index.schema.json", "title": "EntityContextIndex", "type": "object", - "required": ["schema_version", "filter_version", "collection_profile", "source", "entity", "files", "records", "gaps"], + "required": ["schema_version", "filter_version", "collection_profile", "filter", "source", "entity", "files", "records", "gaps"], "properties": { "schema_version": { "const": 1 }, "filter_version": { "type": "string", "minLength": 1 }, - "collection_profile": { "type": "string", "pattern": "^[0-9a-f]{64}$" }, + "collection_profile": { "$ref": "common.schema.json#/$defs/record_key" }, + "filter": { + "allOf": [ + { "$ref": "#/$defs/filter" }, + { "properties": { "status": { "enum": ["unchanged", "modified", "truncated"] } } } + ] + }, "source": { "type": "object", - "required": ["forge", "repository"], + "required": ["forge", "host", "repository_id", "repository"], "properties": { - "forge": { "type": "string", "minLength": 1 }, - "repository": { "type": "string", "minLength": 1 } + "forge": { "enum": ["github", "gitlab", "forgejo"] }, + "host": { "type": "string", "pattern": "^[a-z0-9.-]+(?::(?!443$)(?:[1-9]|[1-9][0-9]{1,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5]))?$" }, + "repository_id": { "type": "string", "minLength": 1 }, + "repository": { + "allOf": [ + { "$ref": "common.schema.json#/$defs/repository_path" }, + { "pattern": "^[^/]+(/[^/]+)+$" } + ] + } }, + "allOf": [ + { + "if": { "properties": { "forge": { "const": "github" } }, "required": ["forge"] }, + "then": { + "properties": { + "repository_id": { "pattern": "^[A-Za-z0-9_=/+-]+$" }, + "repository": { "pattern": "^[a-z0-9_.-]+/[a-z0-9_.-]+$" } + } + } + }, + { + "if": { "properties": { "forge": { "enum": ["gitlab", "forgejo"] } }, "required": ["forge"] }, + "then": { "properties": { "repository_id": { "pattern": "^[1-9][0-9]*$" } } } + }, + { + "if": { "properties": { "forge": { "const": "forgejo" } }, "required": ["forge"] }, + "then": { "properties": { "repository": { "pattern": "^[a-z0-9_.-]+/[a-z0-9_.-]+$" } } } + } + ], "additionalProperties": false }, "entity": { "type": "object", "required": ["kind", "id"], "properties": { - "kind": { "enum": ["issue", "change_proposal"] }, - "id": { "type": "string", "minLength": 1 }, - "updated_at": { "type": "string", "format": "date-time" } + "kind": { "enum": ["work_item", "change_proposal"] }, + "id": { + "type": "string", + "minLength": 1, + "description": "Immutable opaque forge object ID; distinct from the positive display number in normalized-event v1 entity.id." + }, + "updated_at": { "$ref": "common.schema.json#/$defs/timestamp" } }, "additionalProperties": false }, @@ -68,54 +104,83 @@ "properties": { "path": { "type": "string", - "pattern": "^(summary[.]md|entity/metadata[.]json|records/([0-9]{8}T[0-9]{15}Z)-[0-9a-f]{64}[.]md|threads/[0-9a-f]{64}[.]order|views/(conversation|unresolved-review)[.]order|views/reviews/[0-9a-f]{64}[.]order|relations/reviews[.]json|history/agent-runs[.]json|checks/[0-9a-f]{64}/(metadata[.]json|log[.]txt)|state/threads[.]json)$" + "pattern": "^(collection[.]json|entity/metadata[.]json|records/([0-9]{8}T[0-9]{15}Z)-[0-9a-f]{64}[.]md|threads/[0-9a-f]{64}[.]order|views/(timeline|unresolved-review)[.]order|views/reviews/[0-9a-f]{64}[.]order|relations/reviews[.]json|history/agent-runs[.]json|checks/[0-9a-f]{64}/(metadata[.]json|log[.]txt)|state/(actors|threads)[.]json)$" }, "role": { - "enum": ["summary", "entity_metadata", "entity_record", "comment_record", "review_record", "thread_order", "conversation_view", "unresolved_review_view", "review_view", "reviews", "agent_runs", "check_metadata", "check_log", "thread_state"] + "enum": ["collection", "entity_metadata", "entity_record", "comment_record", "review_record", "thread_order", "timeline_view", "unresolved_review_view", "review_view", "reviews", "agent_runs", "check_metadata", "check_log", "actor_state", "thread_state"] }, "media_type": { "type": "string", "minLength": 1 }, "bytes": { "type": "integer", "minimum": 0 }, - "sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" }, - "filter": { "$ref": "#/$defs/filter" } + "sha256": { "$ref": "common.schema.json#/$defs/record_key" }, + "filter": { + "allOf": [ + { "$ref": "#/$defs/filter" }, + { "properties": { "status": { "enum": ["unchanged", "modified", "truncated"] } } } + ] + } }, + "allOf": [ + { + "if": { "properties": { "role": { "enum": ["entity_metadata", "reviews", "agent_runs", "check_metadata", "actor_state"] } }, "required": ["role"] }, + "then": { "required": ["filter"] } + } + ], "additionalProperties": false }, "gap": { "type": "object", - "required": ["scope", "code", "count"], + "required": ["scope", "code", "usability", "count"], "properties": { - "scope": { "type": "string", "minLength": 1 }, - "code": { "type": "string", "minLength": 1 }, + "scope": { "enum": ["entity", "comments", "reviews", "checks", "check_logs", "agent_runs", "actors"] }, + "code": { "enum": ["profile_bound", "history_unavailable", "unsupported", "authorization_failed", "fetch_failed", "source_too_large", "invalid_metadata", "unsafe_content"] }, + "usability": { "enum": ["partial", "unusable"] }, "count": { "type": "integer", "minimum": 1 } }, + "allOf": [ + { + "if": { "properties": { "code": { "enum": ["profile_bound", "history_unavailable"] } }, "required": ["code"] }, + "then": { "properties": { "usability": { "const": "partial" } } }, + "else": { "properties": { "usability": { "const": "unusable" } } } + } + ], "additionalProperties": false }, "record": { "type": "object", - "required": ["kind", "id", "record_key", "author_id", "author", "created_at", "filter"], + "required": ["kind", "id", "record_key", "created_at", "filter"], "properties": { "kind": { "enum": ["entity", "comment", "review", "check"] }, "id": { "type": "string", "minLength": 1 }, - "record_key": { "type": "string", "pattern": "^[0-9a-f]{64}$" }, + "record_key": { "$ref": "common.schema.json#/$defs/record_key" }, "content_path": { "type": "string", "pattern": "^records/[0-9]{8}T[0-9]{15}Z-[0-9a-f]{64}[.]md$" }, "metadata_path": { "type": "string", "pattern": "^checks/[0-9a-f]{64}/metadata[.]json$" }, "log_path": { "type": "string", "pattern": "^checks/[0-9a-f]{64}/log[.]txt$" }, - "source_url": { "type": "string", "format": "uri" }, - "author_id": { "type": ["string", "null"] }, - "author": { "type": ["string", "null"] }, - "created_at": { "type": "string", "format": "date-time" }, - "updated_at": { "type": "string", "format": "date-time" }, + "source_url": { "$ref": "common.schema.json#/$defs/source_url" }, + "author_id": { "type": ["string", "null"], "minLength": 1 }, + "author": { "type": ["string", "null"], "minLength": 1 }, + "created_at": { "$ref": "common.schema.json#/$defs/timestamp" }, + "updated_at": { "$ref": "common.schema.json#/$defs/timestamp" }, "filter": { "$ref": "#/$defs/filter" } }, "allOf": [ + { + "if": { "properties": { "kind": { "const": "check" } }, "required": ["kind"] }, + "then": { "not": { "anyOf": [{ "required": ["author_id"] }, { "required": ["author"] }] } }, + "else": { "required": ["author_id", "author"] } + }, { "if": { "properties": { "filter": { "properties": { "status": { "const": "rejected" } } } } }, "then": { "not": { "anyOf": [{ "required": ["content_path"] }, { "required": ["metadata_path"] }, { "required": ["log_path"] }] } }, "else": { - "oneOf": [ - { "required": ["content_path"] }, - { "required": ["metadata_path"] } - ] + "if": { "properties": { "kind": { "const": "check" } } }, + "then": { + "required": ["metadata_path"], + "not": { "required": ["content_path"] } + }, + "else": { + "required": ["content_path"], + "not": { "anyOf": [{ "required": ["metadata_path"] }, { "required": ["log_path"] }] } + } } } ], diff --git a/docs/normative/entity-context/v1/reviews.schema.json b/docs/normative/entity-context/v1/reviews.schema.json index 8879749f27..7f6809575b 100644 --- a/docs/normative/entity-context/v1/reviews.schema.json +++ b/docs/normative/entity-context/v1/reviews.schema.json @@ -9,15 +9,28 @@ "type": "array", "items": { "type": "object", - "required": ["id", "record_key", "state", "reviewed_sha", "submitted_at"], + "required": ["id", "record_key", "state", "submitted_at"], "properties": { "id": { "type": "string", "minLength": 1 }, - "record_key": { "type": "string", "pattern": "^[0-9a-f]{64}$" }, - "state": { "type": "string", "minLength": 1 }, - "reviewed_sha": { "type": "string", "pattern": "^[0-9a-fA-F]{40}([0-9a-fA-F]{24})?$" }, - "submitted_at": { "type": "string", "format": "date-time" }, - "dismissed_at": { "type": "string", "format": "date-time" } + "record_key": { "$ref": "common.schema.json#/$defs/record_key" }, + "state": { "enum": ["approved", "changes_requested", "commented", "dismissed"] }, + "reviewed_sha": { "$ref": "common.schema.json#/$defs/git_oid" }, + "submitted_at": { "$ref": "common.schema.json#/$defs/timestamp" }, + "dismissed_at": { + "oneOf": [ + { "$ref": "common.schema.json#/$defs/timestamp" }, + { "type": "null" } + ] + }, + "dismissed_by_actor_id": { "type": ["string", "null"], "minLength": 1 } }, + "allOf": [ + { + "if": { "properties": { "state": { "const": "dismissed" } }, "required": ["state"] }, + "then": { "required": ["dismissed_at", "dismissed_by_actor_id"] }, + "else": { "not": { "anyOf": [{ "required": ["dismissed_at"] }, { "required": ["dismissed_by_actor_id"] }] } } + } + ], "additionalProperties": false } }, @@ -28,12 +41,12 @@ "required": ["id", "thread_key", "created_at", "order_path", "record_keys", "replies"], "properties": { "id": { "type": "string", "minLength": 1 }, - "thread_key": { "type": "string", "pattern": "^[0-9a-f]{64}$" }, - "created_at": { "type": "string", "format": "date-time" }, + "thread_key": { "$ref": "common.schema.json#/$defs/record_key" }, + "created_at": { "$ref": "common.schema.json#/$defs/timestamp" }, "order_path": { "type": "string", "pattern": "^threads/[0-9a-f]{64}[.]order$" }, "record_keys": { "type": "array", - "items": { "type": "string", "pattern": "^[0-9a-f]{64}$" }, + "items": { "$ref": "common.schema.json#/$defs/record_key" }, "uniqueItems": true }, "replies": { @@ -42,16 +55,16 @@ "type": "object", "required": ["record_key", "parent_record_key"], "properties": { - "record_key": { "type": "string", "pattern": "^[0-9a-f]{64}$" }, - "parent_record_key": { "type": "string", "pattern": "^[0-9a-f]{64}$" } + "record_key": { "$ref": "common.schema.json#/$defs/record_key" }, + "parent_record_key": { "$ref": "common.schema.json#/$defs/record_key" } }, "additionalProperties": false } }, "review_id": { "type": "string", "minLength": 1 }, - "review_record_key": { "type": "string", "pattern": "^[0-9a-f]{64}$" }, - "reviewed_sha": { "type": "string", "pattern": "^[0-9a-fA-F]{40}([0-9a-fA-F]{24})?$" }, - "path": { "type": "string" }, + "review_record_key": { "$ref": "common.schema.json#/$defs/record_key" }, + "reviewed_sha": { "$ref": "common.schema.json#/$defs/git_oid" }, + "path": { "$ref": "common.schema.json#/$defs/repository_path" }, "line": { "type": "integer", "minimum": 1 }, "side": { "enum": ["left", "right"] }, "start_line": { "type": "integer", "minimum": 1 }, diff --git a/docs/normative/entity-context/v1/thread-state.schema.json b/docs/normative/entity-context/v1/thread-state.schema.json index 01c78ef20d..4362655ec3 100644 --- a/docs/normative/entity-context/v1/thread-state.schema.json +++ b/docs/normative/entity-context/v1/thread-state.schema.json @@ -12,11 +12,19 @@ "required": ["id", "thread_key", "resolved", "outdated"], "properties": { "id": { "type": "string", "minLength": 1 }, - "thread_key": { "type": "string", "pattern": "^[0-9a-f]{64}$" }, + "thread_key": { "$ref": "common.schema.json#/$defs/record_key" }, "resolved": { "type": "boolean" }, + "resolved_by_actor_id": { "type": ["string", "null"], "minLength": 1 }, "outdated": { "type": "boolean" }, "minimized": { "type": "boolean" } }, + "allOf": [ + { + "if": { "properties": { "resolved": { "const": true } }, "required": ["resolved"] }, + "then": { "required": ["resolved_by_actor_id"] }, + "else": { "not": { "required": ["resolved_by_actor_id"] } } + } + ], "additionalProperties": false } } diff --git a/docs/normative/normalized-event/v1/README.md b/docs/normative/normalized-event/v1/README.md index 4c20e6071f..76e6b9385a 100644 --- a/docs/normative/normalized-event/v1/README.md +++ b/docs/normative/normalized-event/v1/README.md @@ -85,6 +85,11 @@ remains the normative stricter check. Adding a new `transition.kind` is **non-breaking** — CEL triggers use boolean expressions, not exhaustive enum matching. +Normalized-event and entity-context v1 carry independently versioned copies of +the actor-role vocabulary. They match when entity-context v1 is accepted, but +a role added non-breakingly here does not extend entity-context's closed v1 +schema; adapters validate each document against its own schema. + ## Adapters Input drivers map native forge events into this struct: From 78e782a93bef1f74eff8166a7759e24b9f693128 Mon Sep 17 00:00:00 2001 From: Barak Korren Date: Wed, 16 Sep 2026 13:39:56 +0300 Subject: [PATCH 11/33] docs(#6407): remove staged source URLs Keep forge and record identifiers for provenance while omitting navigation URLs from the agent-visible entity-context contract. Align order/view filtering and required singleton structural failure semantics with the schemas. Signed-off-by: Barak Korren Assisted-by: Codex (gpt-5.6-sol) --- docs/normative/entity-context/v1/README.md | 52 +++++++++++-------- .../entity-context/v1/agent-runs.schema.json | 3 +- .../entity-context/v1/check.schema.json | 1 - .../entity-context/v1/common.schema.json | 5 -- .../entity-context/v1/entity.schema.json | 3 +- .../entity-context/v1/index.schema.json | 1 - 6 files changed, 33 insertions(+), 32 deletions(-) diff --git a/docs/normative/entity-context/v1/README.md b/docs/normative/entity-context/v1/README.md index 76b7b96306..8bd3b1a8fc 100644 --- a/docs/normative/entity-context/v1/README.md +++ b/docs/normative/entity-context/v1/README.md @@ -128,10 +128,13 @@ Filtered Markdown body. `Fullsend-Record` is `"comment"` or `"review"`. The header order and blank line are fixed. `Author-ID` may be `null` when the forge withholds or has deleted the actor. The immutable actor ID is included because attribution is -part of the source record. The current login and navigation URL stay in -`index.json` and `state/actors.json`: either may change after an account or -repository rename without the record changing. Effective repository role is -also excluded because permissions can change without the comment changing. +part of the source record. The current login stays in `index.json` and +`state/actors.json`: it may change after an account rename without the record +changing. Navigation URLs are intentionally omitted from the staged tree; +forge, host, repository, and immutable record IDs provide provenance, while a +host-side adapter can construct a link when a human needs one. Effective +repository role is also excluded because permissions can change without the +comment changing. The file contains no update time, ordering, thread membership, review location, resolution, outdated, or minimized state; those properties belong in `index.json`, `relations/`, or `state/`. Consequently, resolving a thread, @@ -152,15 +155,19 @@ second digits and no punctuation other than `T` and `Z`. The entity-body record uses the reserved key `00000000T000000000000000Z`, so it always sorts first. Creation time is immutable forge data; edits do not rename a record. -`views/timeline.order` lists the entity record and all comment and review +Every order/view file lists only records that have an emitted `content_path`; +rejected comments and reviews never create dangling order lines. The entity +record is always present because an entity-body rejection aborts assembly. +`views/timeline.order` lists that entity record and retained comment/review records in canonical chronology. Each `threads/.order` lists that -thread's records in forge order. `views/unresolved-review.order` lists records -in unresolved, non-outdated review threads, ordered by thread creation time and -key and then forge thread order. Each `views/reviews/.order` lists -one formal review followed by records in threads associated with it. A record -path appears at most once in any one order file. Paths contain no whitespace or -shell metacharacters, so a host consumer may materialize a projection with -`xargs cat`, but runtimes use the segmented contract below. +thread's retained records in forge order. `views/unresolved-review.order` +lists retained records in unresolved, non-outdated review threads, ordered by +thread creation time and key and then forge thread order. A +`views/reviews/.order` file is emitted only for a retained formal +review; it lists that review followed by retained records in threads associated +with it. A record path appears at most once in any one order file. Paths contain +no whitespace or shell metacharacters, so a host consumer may materialize a +projection with `xargs cat`, but runtimes use the segmented contract below. A runtime that injects a projection into a model request emits each referenced record as a distinct, ordered content block. Relationship, history, mutable @@ -451,17 +458,20 @@ configured provider trust boundary, not by this cleanup guarantee. Structural strings are not rewritten because doing so could change identity or target a different resource. Canonical IDs use the mappings above. Repository -paths, review file paths, and source URLs first undergo the Unicode-safety scan -and then strict structural validation. Repository file paths are relative, +paths and review file paths first undergo the Unicode-safety scan and then strict +structural validation. Repository file paths are relative, slash-separated, contain no `.` or `..` segment, percent-encoded dot, slash, or backslash, control character, or non-rendering class named above. Source URLs -use HTTPS, contain no userinfo or credentials, and have a lowercase authority -exactly equal to `source.host`; schemes such as `javascript`, `data`, and -`file` are invalid. The shared `source_url` schema definition enforces the -closed URI shape, while producers and consumers enforce the cross-document -host equality. An unsafe structural value, whether its property is required or -optional, causes the selected source and its files to be omitted and produces -an unusable `invalid_metadata` or `unsafe_content` gap. Structural values are +are intentionally not part of the agent-visible v1 tree; forge, host, +repository, and immutable record IDs provide provenance without copying +navigation URLs into staged metadata. An unsafe structural value, whether its +property is required or optional, produces an unusable `invalid_metadata` or +`unsafe_content` gap. For optional records and their related files, that gap +omits the selected source as described above. Required singleton structural +values cannot be omitted: an unsafe, missing, or schema-invalid entity `id`, or +index `source` field +(`host`, `repository_id`, or `repository`), aborts snapshot assembly rather +than emitting an invalid singleton or dangling manifest. Structural values are never emitted after filtering or truncation. `index.json.filter` records filtering of source-derived values in the index. diff --git a/docs/normative/entity-context/v1/agent-runs.schema.json b/docs/normative/entity-context/v1/agent-runs.schema.json index 907abf0df6..19447bfeac 100644 --- a/docs/normative/entity-context/v1/agent-runs.schema.json +++ b/docs/normative/entity-context/v1/agent-runs.schema.json @@ -9,7 +9,7 @@ "type": "array", "items": { "type": "object", - "required": ["id", "agent", "status", "input_revision", "result_record_keys", "source_url", "completed_at"], + "required": ["id", "agent", "status", "input_revision", "result_record_keys", "completed_at"], "properties": { "id": { "type": "string", "minLength": 1 }, "agent": { "type": "string", "minLength": 1 }, @@ -26,7 +26,6 @@ "description": "Result record keys sorted by ASCII byte order." }, "resulting_commit_sha": { "$ref": "common.schema.json#/$defs/git_oid" }, - "source_url": { "$ref": "common.schema.json#/$defs/source_url" }, "started_at": { "$ref": "common.schema.json#/$defs/timestamp" }, "completed_at": { "$ref": "common.schema.json#/$defs/timestamp" } }, diff --git a/docs/normative/entity-context/v1/check.schema.json b/docs/normative/entity-context/v1/check.schema.json index e65eb96920..91ecb05a53 100644 --- a/docs/normative/entity-context/v1/check.schema.json +++ b/docs/normative/entity-context/v1/check.schema.json @@ -9,7 +9,6 @@ "name": { "type": "string", "minLength": 1 }, "status": { "enum": ["queued", "in_progress", "completed"] }, "conclusion": { "enum": ["success", "failure", "neutral", "cancelled", "skipped", "timed_out", "action_required", "stale"] }, - "source_url": { "$ref": "common.schema.json#/$defs/source_url" }, "created_at": { "$ref": "common.schema.json#/$defs/timestamp" }, "started_at": { "$ref": "common.schema.json#/$defs/timestamp" }, "completed_at": { "$ref": "common.schema.json#/$defs/timestamp" } diff --git a/docs/normative/entity-context/v1/common.schema.json b/docs/normative/entity-context/v1/common.schema.json index 01aa5b380b..4f5ed72658 100644 --- a/docs/normative/entity-context/v1/common.schema.json +++ b/docs/normative/entity-context/v1/common.schema.json @@ -21,11 +21,6 @@ "minLength": 1, "pattern": "^(?!/)(?!.*//)(?!.*[/]$)(?!.*(^|/)[.]{1,2}(/|$))(?!.*%(?:2[EeFf]|5[Cc]))(?!.*[\u200b-\u200d\u202a-\u202e\u2066-\u2069\ufeff\ufe00-\ufe0f\ufff9-\ufffb])[A-Za-z0-9._/~!$&()+,;=:@%#\\[\\]{} -]+$" }, - "source_url": { - "type": "string", - "format": "uri", - "pattern": "^https://[a-z0-9.-]+(?::(?!443(?:/|$))(?:[1-9]|[1-9][0-9]{1,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5]))?(?:/[A-Za-z0-9._~!$&()*+,;=:@%/?#-]*)?$" - }, "actor_role": { "enum": ["admin", "maintain", "write", "triage", "read", "none", "external"] } diff --git a/docs/normative/entity-context/v1/entity.schema.json b/docs/normative/entity-context/v1/entity.schema.json index 93bfe0f350..7e0d6aab57 100644 --- a/docs/normative/entity-context/v1/entity.schema.json +++ b/docs/normative/entity-context/v1/entity.schema.json @@ -3,7 +3,7 @@ "$id": "https://fullsend.ai/normative/entity-context/v1/entity.schema.json", "title": "EntityMetadata", "type": "object", - "required": ["kind", "id", "number", "title", "state", "source_url", "author_id", "author", "created_at", "updated_at", "labels"], + "required": ["kind", "id", "number", "title", "state", "author_id", "author", "created_at", "updated_at", "labels"], "properties": { "kind": { "enum": ["work_item", "change_proposal"] }, "id": { @@ -18,7 +18,6 @@ }, "title": { "type": "string", "minLength": 1 }, "state": { "enum": ["open", "closed", "merged"] }, - "source_url": { "$ref": "common.schema.json#/$defs/source_url" }, "author_id": { "type": ["string", "null"], "minLength": 1 }, "author": { "type": ["string", "null"], "minLength": 1 }, "created_at": { "$ref": "common.schema.json#/$defs/timestamp" }, diff --git a/docs/normative/entity-context/v1/index.schema.json b/docs/normative/entity-context/v1/index.schema.json index 9e5a7a492f..29351ba6c2 100644 --- a/docs/normative/entity-context/v1/index.schema.json +++ b/docs/normative/entity-context/v1/index.schema.json @@ -155,7 +155,6 @@ "content_path": { "type": "string", "pattern": "^records/[0-9]{8}T[0-9]{15}Z-[0-9a-f]{64}[.]md$" }, "metadata_path": { "type": "string", "pattern": "^checks/[0-9a-f]{64}/metadata[.]json$" }, "log_path": { "type": "string", "pattern": "^checks/[0-9a-f]{64}/log[.]txt$" }, - "source_url": { "$ref": "common.schema.json#/$defs/source_url" }, "author_id": { "type": ["string", "null"], "minLength": 1 }, "author": { "type": ["string", "null"], "minLength": 1 }, "created_at": { "$ref": "common.schema.json#/$defs/timestamp" }, From bf0405c09e7ac903c7b58b74941f07f00b00292e Mon Sep 17 00:00:00 2001 From: Barak Korren Date: Wed, 16 Sep 2026 13:44:26 +0300 Subject: [PATCH 12/33] docs(#6407): harden staged context trust boundaries Anchor pre-script verification to the assembly-time root manifest and require an agent-immutable sandbox copy. Abort when either integrity or immutability mechanism cannot be enforced. Signed-off-by: Barak Korren Assisted-by: Codex (gpt-5.6-sol) --- ...inistic-filtered-entity-context-staging.md | 24 ++++++++++++----- docs/normative/entity-context/v1/README.md | 27 +++++++++++++------ 2 files changed, 36 insertions(+), 15 deletions(-) diff --git a/docs/ADRs/0107-deterministic-filtered-entity-context-staging.md b/docs/ADRs/0107-deterministic-filtered-entity-context-staging.md index 1631174206..3e37ca575d 100644 --- a/docs/ADRs/0107-deterministic-filtered-entity-context-staging.md +++ b/docs/ADRs/0107-deterministic-filtered-entity-context-staging.md @@ -83,11 +83,20 @@ 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. It cannot mutate -the agent's view: Fullsend verifies the manifest digests before upload and -restores or rejects changed files. The uploaded tree must contain exactly the -paths listed by the manifest; Fullsend removes extra paths or aborts assembly -before upload. The sandbox copy is read-only to the agent. +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 @@ -108,8 +117,9 @@ 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. Fullsend -removes the sandbox copy after its last sandbox consumer and the host copy after +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 diff --git a/docs/normative/entity-context/v1/README.md b/docs/normative/entity-context/v1/README.md index 8bd3b1a8fc..5c643ee9b2 100644 --- a/docs/normative/entity-context/v1/README.md +++ b/docs/normative/entity-context/v1/README.md @@ -481,10 +481,16 @@ Generated collection, state-without-display-text, and order documents do not invent filter findings. Every emitted file other than the root `index.json` has a manifest `sha256` -over its emitted bytes. A rejected non-entity source has a record but no content -path or file entry and adds an `unsafe_content` gap for its scope. A rejected or -missing entity-body record aborts snapshot assembly, and Fullsend must not -launch scripts or an agent with that snapshot. +over its emitted bytes. The assembler retains the exact root `index.json` bytes, +or a digest of them, in host-private run state outside the context tree. After +the host pre-script, Fullsend compares the on-disk root index with that retained +assembly value and aborts on any difference; it never treats a rewritten +on-disk index as the root of trust. Only the retained assembly index is used to +verify child digests and the exact manifest path set. A rejected non-entity +source has a record but no content path or file entry and adds an +`unsafe_content` gap for its scope. A rejected or missing entity-body record +aborts snapshot assembly, and Fullsend must not launch scripts or an agent with +that snapshot. Findings contain codes and counts, not rejected source text. Filters and bounds are identified by `filter_version`; changing emitted bytes for the same input @@ -515,10 +521,15 @@ complete tree has identical paths and bytes. The host tree is created outside both the repository and retained run-output tree with directory mode `0700` and file mode `0600`. The sandbox copy is -read-only. Fullsend removes the sandbox copy after the runtime's last use and -the host copy after the post-script on every controlled exit, including skip, -failure, and cancellation. Fullsend also scavenges abandoned context trees on -startup after an unclean termination. +agent-immutable: Fullsend exposes it through a read-only bind mount, or, when +that is unavailable, uses 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. A plain mode-`0600` copy owned by the +agent does not satisfy this contract; if neither mechanism can be enforced, +Fullsend aborts before launching the agent. Fullsend removes the sandbox copy +after the runtime's last use and the host copy after the post-script on every +controlled exit, including skip, failure, and cancellation. Fullsend also +scavenges abandoned context trees on startup after an unclean termination. Artifact collectors must exclude entity-context trees. Retained diagnostics may contain bounded record counts, content digests, filter codes/counts, and From f3b18a4a85188ed7596462ce0ad46b26f829bcea Mon Sep 17 00:00:00 2001 From: Barak Korren Date: Wed, 16 Sep 2026 14:39:21 +0300 Subject: [PATCH 13/33] docs(#6407): address entity context review comments Require filtering metadata for emitted check logs, represent never-started GitHub startup failures without invented timestamps, and document the v1 ASCII structural path boundary. Signed-off-by: Barak Korren Assisted-by: Codex (gpt-5.6-sol) --- docs/normative/entity-context/v1/README.md | 30 ++++++++++++++----- .../entity-context/v1/check.schema.json | 7 +++-- .../entity-context/v1/index.schema.json | 2 +- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/docs/normative/entity-context/v1/README.md b/docs/normative/entity-context/v1/README.md index 5c643ee9b2..5bc9bc5023 100644 --- a/docs/normative/entity-context/v1/README.md +++ b/docs/normative/entity-context/v1/README.md @@ -197,8 +197,13 @@ normalized to `queued`, `in_progress`, or `completed`; conclusions are Queued checks have no start, completion, or conclusion fields. In-progress checks require `started_at` and have no completion or conclusion. Completed checks require `completed_at` and `conclusion`; they also require -`started_at` except when a `skipped` or `cancelled` check is explicitly known -to have never run. +`started_at` except when the forge explicitly reports that the job never +started. This includes `skipped` and `cancelled` checks known never to have +run, and GitHub `startup_failure` (which maps to the v1 `failure` conclusion). +Because the normalized schema cannot retain the native cause of a `failure`, it +permits a completed failure without `started_at`; adapters must use that form +only for a forge-reported never-started outcome and must not omit +`started_at` from an ordinary failure. Check manifest records carry `created_at` but no `author_id` or `author`. Adapters use these exhaustive v1 native-status mappings: @@ -220,9 +225,10 @@ Adapters use these exhaustive v1 native-status mappings: Any native status or conclusion not listed above is `invalid_metadata`; an adapter must not invent another mapping. Any mapped check whose forge data cannot satisfy `check.schema.json`'s status-specific timestamp requirements is -also `invalid_metadata`. Completed `skipped` and `cancelled` checks require -`completed_at` and may omit `started_at` when the forge says the job never ran; -all other completed checks require both timestamps. Native timestamp fields +also `invalid_metadata`. Completed `skipped` and `cancelled` checks, and +GitHub `startup_failure` mapped to `failure`, require `completed_at` and may +omit `started_at` when the forge says the job never ran; all other completed +checks require both timestamps. Native timestamp fields forbidden for the mapped status are omitted rather than copied. ## Relationships, history, and collection profiles @@ -459,7 +465,12 @@ configured provider trust boundary, not by this cleanup guarantee. Structural strings are not rewritten because doing so could change identity or target a different resource. Canonical IDs use the mappings above. Repository paths and review file paths first undergo the Unicode-safety scan and then strict -structural validation. Repository file paths are relative, +structural validation. v1 deliberately restricts `repository_path` to the +printable-ASCII allow-list encoded by `common.schema.json` (including its +explicit punctuation set and excluding non-ASCII letters and apostrophes); this +is an explicit compatibility and security boundary, not an implicit Unicode +normalization. Non-ASCII or other out-of-alphabet values are structurally +invalid. Repository file paths are relative, slash-separated, contain no `.` or `..` segment, percent-encoded dot, slash, or backslash, control character, or non-rendering class named above. Source URLs are intentionally not part of the agent-visible v1 tree; forge, host, @@ -475,8 +486,11 @@ than emitting an invalid singleton or dangling manifest. Structural values are never emitted after filtering or truncation. `index.json.filter` records filtering of source-derived values in the index. -Manifest file entries require `filter` for entity, review, agent-run, check, and -actor JSON documents; each value summarizes that document's filtered metadata. +Manifest file entries require `filter` for entity, review, agent-run, check +metadata, check logs, and actor JSON documents. A `check_log` entry's filter +describes the emitted log bytes only; the parent check record's filter remains +the separate summary of filtered check metadata. Each manifest value summarizes +the filtered bytes for its own document or file. Generated collection, state-without-display-text, and order documents do not invent filter findings. diff --git a/docs/normative/entity-context/v1/check.schema.json b/docs/normative/entity-context/v1/check.schema.json index 91ecb05a53..19b3cc1206 100644 --- a/docs/normative/entity-context/v1/check.schema.json +++ b/docs/normative/entity-context/v1/check.schema.json @@ -10,7 +10,10 @@ "status": { "enum": ["queued", "in_progress", "completed"] }, "conclusion": { "enum": ["success", "failure", "neutral", "cancelled", "skipped", "timed_out", "action_required", "stale"] }, "created_at": { "$ref": "common.schema.json#/$defs/timestamp" }, - "started_at": { "$ref": "common.schema.json#/$defs/timestamp" }, + "started_at": { + "$ref": "common.schema.json#/$defs/timestamp", + "description": "Required for in-progress checks and completed checks that the forge reports as having started. A completed failure may omit it only when the native forge outcome explicitly says the job never started, such as GitHub startup_failure." + }, "completed_at": { "$ref": "common.schema.json#/$defs/timestamp" } }, "allOf": [ @@ -29,7 +32,7 @@ "if": { "properties": { "status": { "const": "completed" } }, "required": ["status"] }, "then": { "required": ["completed_at", "conclusion"], - "if": { "properties": { "conclusion": { "enum": ["cancelled", "skipped"] } }, "required": ["conclusion"] }, + "if": { "properties": { "conclusion": { "enum": ["cancelled", "skipped", "failure"] } }, "required": ["conclusion"] }, "else": { "required": ["started_at"] } } } diff --git a/docs/normative/entity-context/v1/index.schema.json b/docs/normative/entity-context/v1/index.schema.json index 29351ba6c2..c2f06c7092 100644 --- a/docs/normative/entity-context/v1/index.schema.json +++ b/docs/normative/entity-context/v1/index.schema.json @@ -121,7 +121,7 @@ }, "allOf": [ { - "if": { "properties": { "role": { "enum": ["entity_metadata", "reviews", "agent_runs", "check_metadata", "actor_state"] } }, "required": ["role"] }, + "if": { "properties": { "role": { "enum": ["entity_metadata", "reviews", "agent_runs", "check_metadata", "check_log", "actor_state"] } }, "required": ["role"] }, "then": { "required": ["filter"] } } ], From b155f892c99fadbcff254f5bfcef082407617600 Mon Sep 17 00:00:00 2001 From: Barak Korren Date: Thu, 17 Sep 2026 02:45:36 +0300 Subject: [PATCH 14/33] docs(#6407): close entity context review gaps Make never-started checks schema-visible, fail closed for unusable entity gaps, reject percent-encoded structural paths, and disclose the accepted ADR 0076 annotation. Signed-off-by: Barak Korren Assisted-by: Codex (gpt-5.6-sol) --- docs/normative/entity-context/v1/README.md | 38 +++++++++++-------- .../entity-context/v1/check.schema.json | 19 ++++++---- .../entity-context/v1/common.schema.json | 2 +- 3 files changed, 35 insertions(+), 24 deletions(-) diff --git a/docs/normative/entity-context/v1/README.md b/docs/normative/entity-context/v1/README.md index 5bc9bc5023..1597222e79 100644 --- a/docs/normative/entity-context/v1/README.md +++ b/docs/normative/entity-context/v1/README.md @@ -196,14 +196,13 @@ normalized to `queued`, `in_progress`, or `completed`; conclusions are `action_required`, or `stale`. Queued checks have no start, completion, or conclusion fields. In-progress checks require `started_at` and have no completion or conclusion. Completed -checks require `completed_at` and `conclusion`; they also require -`started_at` except when the forge explicitly reports that the job never -started. This includes `skipped` and `cancelled` checks known never to have -run, and GitHub `startup_failure` (which maps to the v1 `failure` conclusion). -Because the normalized schema cannot retain the native cause of a `failure`, it -permits a completed failure without `started_at`; adapters must use that form -only for a forge-reported never-started outcome and must not omit -`started_at` from an ordinary failure. +checks require `completed_at`, `conclusion`, and `never_started`. +`never_started: true` is emitted only when the forge explicitly reports that +the job never started; it forbids `started_at` and is limited to `failure`, +`skipped`, or `cancelled`. This includes GitHub `startup_failure`, which maps +to the v1 `failure` conclusion. `never_started: false` requires `started_at`. +Consumers must use the explicit flag and must not infer never-started state from +an omitted timestamp. Check manifest records carry `created_at` but no `author_id` or `author`. Adapters use these exhaustive v1 native-status mappings: @@ -211,7 +210,7 @@ Adapters use these exhaustive v1 native-status mappings: - GitHub `queued`, `waiting`, `requested`, and `pending` map to `queued`; `in_progress` maps to `in_progress`; `completed` maps to `completed` and its native conclusion maps identically to the v1 conclusion vocabulary, except - `startup_failure`, which maps to `failure`. + `startup_failure`, which maps to `failure` with `never_started: true`. - GitLab `created`, `waiting_for_resource`, `waiting_for_callback`, `preparing`, `pending`, `scheduled`, and `manual` map to `queued`; `running` and `canceling` map to `in_progress`; `success`, `failed`, `canceled`, and `skipped` map to `completed` with @@ -225,10 +224,9 @@ Adapters use these exhaustive v1 native-status mappings: Any native status or conclusion not listed above is `invalid_metadata`; an adapter must not invent another mapping. Any mapped check whose forge data cannot satisfy `check.schema.json`'s status-specific timestamp requirements is -also `invalid_metadata`. Completed `skipped` and `cancelled` checks, and -GitHub `startup_failure` mapped to `failure`, require `completed_at` and may -omit `started_at` when the forge says the job never ran; all other completed -checks require both timestamps. Native timestamp fields +also `invalid_metadata`. Completed checks with `never_started: true` require +`completed_at` and omit `started_at`; all other completed checks require both +timestamps. Native timestamp fields forbidden for the mapped status are omitted rather than copied. ## Relationships, history, and collection profiles @@ -352,7 +350,12 @@ records but must not claim the scope is complete. `unsupported`, `authorization_failed`, `fetch_failed`, `source_too_large`, `invalid_metadata`, and `unsafe_content` have `usability: unusable`; consumers must not make an authority or completeness decision from that scope. Any -`actors` gap makes authorization unusable and therefore fails closed. Runtimes +unusable `entity`-scope gap for the required entity body or metadata aborts +snapshot assembly, including `authorization_failed`, `fetch_failed`, +`source_too_large`, `invalid_metadata`, and `unsafe_content`; Fullsend must not +launch scripts or an agent with that snapshot. The same gap codes remain +non-aborting unusable gaps for optional scopes. Any `actors` gap makes +authorization unusable and therefore fails closed. Runtimes and host scripts must inspect relevant gaps before consuming records or state. @@ -471,8 +474,11 @@ explicit punctuation set and excluding non-ASCII letters and apostrophes); this is an explicit compatibility and security boundary, not an implicit Unicode normalization. Non-ASCII or other out-of-alphabet values are structurally invalid. Repository file paths are relative, -slash-separated, contain no `.` or `..` segment, percent-encoded dot, slash, or -backslash, control character, or non-rendering class named above. Source URLs +slash-separated, contain no `.` or `..` segment, percent sign or percent-encoded +dot, slash, or backslash, control character, or non-rendering class named above. +These values are untrusted forge data and must never be interpolated into shell +commands; generated order-file paths have a separate shell-safe contract. +Source URLs are intentionally not part of the agent-visible v1 tree; forge, host, repository, and immutable record IDs provide provenance without copying navigation URLs into staged metadata. An unsafe structural value, whether its diff --git a/docs/normative/entity-context/v1/check.schema.json b/docs/normative/entity-context/v1/check.schema.json index 19b3cc1206..675f42549a 100644 --- a/docs/normative/entity-context/v1/check.schema.json +++ b/docs/normative/entity-context/v1/check.schema.json @@ -10,29 +10,34 @@ "status": { "enum": ["queued", "in_progress", "completed"] }, "conclusion": { "enum": ["success", "failure", "neutral", "cancelled", "skipped", "timed_out", "action_required", "stale"] }, "created_at": { "$ref": "common.schema.json#/$defs/timestamp" }, - "started_at": { - "$ref": "common.schema.json#/$defs/timestamp", - "description": "Required for in-progress checks and completed checks that the forge reports as having started. A completed failure may omit it only when the native forge outcome explicitly says the job never started, such as GitHub startup_failure." + "started_at": { "$ref": "common.schema.json#/$defs/timestamp" }, + "never_started": { + "type": "boolean", + "description": "Required for completed checks. True only when the forge explicitly reports that the job never started; false requires started_at." }, "completed_at": { "$ref": "common.schema.json#/$defs/timestamp" } }, "allOf": [ { "if": { "properties": { "status": { "const": "queued" } }, "required": ["status"] }, - "then": { "not": { "anyOf": [{ "required": ["started_at"] }, { "required": ["completed_at"] }, { "required": ["conclusion"] }] } } + "then": { "not": { "anyOf": [{ "required": ["started_at"] }, { "required": ["completed_at"] }, { "required": ["conclusion"] }, { "required": ["never_started"] }] } } }, { "if": { "properties": { "status": { "const": "in_progress" } }, "required": ["status"] }, "then": { "required": ["started_at"], - "not": { "anyOf": [{ "required": ["completed_at"] }, { "required": ["conclusion"] }] } + "not": { "anyOf": [{ "required": ["completed_at"] }, { "required": ["conclusion"] }, { "required": ["never_started"] }] } } }, { "if": { "properties": { "status": { "const": "completed" } }, "required": ["status"] }, "then": { - "required": ["completed_at", "conclusion"], - "if": { "properties": { "conclusion": { "enum": ["cancelled", "skipped", "failure"] } }, "required": ["conclusion"] }, + "required": ["completed_at", "conclusion", "never_started"], + "if": { "properties": { "never_started": { "const": true } }, "required": ["never_started"] }, + "then": { + "properties": { "conclusion": { "enum": ["cancelled", "skipped", "failure"] } }, + "not": { "required": ["started_at"] } + }, "else": { "required": ["started_at"] } } } diff --git a/docs/normative/entity-context/v1/common.schema.json b/docs/normative/entity-context/v1/common.schema.json index 4f5ed72658..a9d0de3275 100644 --- a/docs/normative/entity-context/v1/common.schema.json +++ b/docs/normative/entity-context/v1/common.schema.json @@ -19,7 +19,7 @@ "repository_path": { "type": "string", "minLength": 1, - "pattern": "^(?!/)(?!.*//)(?!.*[/]$)(?!.*(^|/)[.]{1,2}(/|$))(?!.*%(?:2[EeFf]|5[Cc]))(?!.*[\u200b-\u200d\u202a-\u202e\u2066-\u2069\ufeff\ufe00-\ufe0f\ufff9-\ufffb])[A-Za-z0-9._/~!$&()+,;=:@%#\\[\\]{} -]+$" + "pattern": "^(?!/)(?!.*//)(?!.*[/]$)(?!.*(^|/)[.]{1,2}(/|$))(?!.*%)(?!.*[\u200b-\u200d\u202a-\u202e\u2066-\u2069\ufeff\ufe00-\ufe0f\ufff9-\ufffb])[A-Za-z0-9._/~!$&()+,;=:@#\\[\\]{} -]+$" }, "actor_role": { "enum": ["admin", "maintain", "write", "triage", "read", "none", "external"] From 6762d747cf6383872c6a2c5127b7decba19b8955 Mon Sep 17 00:00:00 2001 From: Barak Korren Date: Thu, 17 Sep 2026 12:38:29 +0300 Subject: [PATCH 15/33] fix(#6407): normalize pre-start check outcomes Represent completed skipped and cancelled checks without native start times as explicit never-started records, and define a source-derived completion fallback when terminal timestamps are absent. Signed-off-by: Barak Korren Assisted-by: Codex (gpt-5.6-sol) --- docs/normative/entity-context/v1/README.md | 27 +++++++++++++++---- .../entity-context/v1/check.schema.json | 7 +++-- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/docs/normative/entity-context/v1/README.md b/docs/normative/entity-context/v1/README.md index 1597222e79..f939c2a324 100644 --- a/docs/normative/entity-context/v1/README.md +++ b/docs/normative/entity-context/v1/README.md @@ -198,9 +198,12 @@ Queued checks have no start, completion, or conclusion fields. In-progress checks require `started_at` and have no completion or conclusion. Completed checks require `completed_at`, `conclusion`, and `never_started`. `never_started: true` is emitted only when the forge explicitly reports that -the job never started; it forbids `started_at` and is limited to `failure`, -`skipped`, or `cancelled`. This includes GitHub `startup_failure`, which maps -to the v1 `failure` conclusion. `never_started: false` requires `started_at`. +the job never started; for a completed `skipped` or `cancelled` outcome, the +adapter treats a missing native `started_at` as that explicit never-started +report. It forbids `started_at` and is limited to `failure`, `skipped`, or +`cancelled`. This includes GitHub `startup_failure`, which maps to the v1 +`failure` conclusion. `never_started: false` requires `started_at`; adapters +must not set it on an ordinary `failure` merely because `started_at` is absent. Consumers must use the explicit flag and must not infer never-started state from an omitted timestamp. Check manifest records carry `created_at` but no `author_id` or `author`. @@ -211,22 +214,36 @@ Adapters use these exhaustive v1 native-status mappings: `in_progress` maps to `in_progress`; `completed` maps to `completed` and its native conclusion maps identically to the v1 conclusion vocabulary, except `startup_failure`, which maps to `failure` with `never_started: true`. + Completed `skipped` and `cancelled` runs with no native `started_at` also + emit `never_started: true`; all other completed conclusions require + `never_started: false` and a native `started_at`. - GitLab `created`, `waiting_for_resource`, `waiting_for_callback`, `preparing`, `pending`, `scheduled`, and `manual` map to `queued`; `running` and `canceling` map to `in_progress`; `success`, `failed`, `canceled`, and `skipped` map to `completed` with conclusions `success`, `failure`, `cancelled`, and `skipped`, respectively. + For completed `canceled` and `skipped` jobs, a null native `started_at` is + the explicit never-started report and emits `never_started: true`; otherwise + they emit `never_started: false`. A `failed` job with no native `started_at` + remains ordinary failure and is `invalid_metadata`. - Forgejo `pending`, `waiting`, and `blocked` map to `queued`; `running` maps to `in_progress`; `success`, `failure`, `error`, `warning`, `cancelled`, `canceled`, and `skipped` map to `completed` with conclusions `success`, `failure`, `failure`, `neutral`, `cancelled`, `cancelled`, and `skipped`, - respectively. + respectively. For completed `cancelled`, `canceled`, and `skipped` jobs, a + null native `started_at` is the explicit never-started report and emits + `never_started: true`; otherwise they emit `never_started: false`. Any native status or conclusion not listed above is `invalid_metadata`; an adapter must not invent another mapping. Any mapped check whose forge data cannot satisfy `check.schema.json`'s status-specific timestamp requirements is also `invalid_metadata`. Completed checks with `never_started: true` require `completed_at` and omit `started_at`; all other completed checks require both -timestamps. Native timestamp fields +timestamps. `completed_at` is the native terminal timestamp when present. If a +never-started completed check has no native terminal timestamp, the adapter +uses its immutable source `created_at` as the canonical fallback; this records +the only source-derived time available and is not a runner-observed completion +time. If either required source timestamp is absent or invalid, the check is +`invalid_metadata`. Native timestamp fields forbidden for the mapped status are omitted rather than copied. ## Relationships, history, and collection profiles diff --git a/docs/normative/entity-context/v1/check.schema.json b/docs/normative/entity-context/v1/check.schema.json index 675f42549a..734702708b 100644 --- a/docs/normative/entity-context/v1/check.schema.json +++ b/docs/normative/entity-context/v1/check.schema.json @@ -13,9 +13,12 @@ "started_at": { "$ref": "common.schema.json#/$defs/timestamp" }, "never_started": { "type": "boolean", - "description": "Required for completed checks. True only when the forge explicitly reports that the job never started; false requires started_at." + "description": "Required for completed checks. True only when the forge explicitly reports a never-started terminal, including a completed skipped or cancelled outcome with no native started_at under the adapter mapping; false requires started_at." }, - "completed_at": { "$ref": "common.schema.json#/$defs/timestamp" } + "completed_at": { + "$ref": "common.schema.json#/$defs/timestamp", + "description": "Native terminal timestamp when available. For never_started true, an absent native terminal timestamp is canonically represented by the source created_at value; this is not a runner-observed completion time." + } }, "allOf": [ { From 2d829b731a149c362a6160915434262d443e3464 Mon Sep 17 00:00:00 2001 From: Barak Korren Date: Tue, 22 Sep 2026 09:44:35 +0300 Subject: [PATCH 16/33] docs(#6407): define entity schema bundle resolution Document the local v1 schema bundle, sibling reference resolution, and the no-network meaning of schema identifiers for consumers. Signed-off-by: Barak Korren Assisted-by: Codex (gpt-5.6-sol) --- docs/normative/entity-context/v1/README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/normative/entity-context/v1/README.md b/docs/normative/entity-context/v1/README.md index f939c2a324..360304d27c 100644 --- a/docs/normative/entity-context/v1/README.md +++ b/docs/normative/entity-context/v1/README.md @@ -578,7 +578,15 @@ Consumers must reject an unsupported `schema_version` or `filter_version`; they must validate `index.json`, `collection.json`, `entity/metadata.json`, `relations/reviews.json`, `history/agent-runs.json`, check metadata documents, `state/actors.json`, and `state/threads.json` against their v1 schemas. Other -emitted files follow the byte contracts above. The schemas are closed: +emitted files follow the byte contracts above. The files under +`docs/normative/entity-context/v1/` form one local schema bundle: consumers +must load every sibling `*.schema.json` file into the same resolver registry, +keyed by its `$id` and filename, before validating any document. Relative +references such as `common.schema.json#/$defs/timestamp` resolve to sibling +files within that directory. `$id` values are stable schema identifiers, not +documented HTTP endpoints; consumers must not fetch them over the network, and +an unavailable sibling or unresolved reference is a validation error. The +schemas are closed: adding a property, record kind, enum value, or status is a breaking change. Changing path derivation, canonical bytes, required fields, field meaning, or ordering likewise requires From 02c561fa9a682294591b2292350f1141d1c31e16 Mon Sep 17 00:00:00 2001 From: Barak Korren Date: Wed, 23 Sep 2026 10:59:41 +0300 Subject: [PATCH 17/33] docs(#6407): clarify entity-context v1 contract Signed-off-by: Barak Korren Assisted-by: Codex (gpt-5.6-sol) --- ...inistic-filtered-entity-context-staging.md | 9 +++-- docs/architecture.md | 3 +- docs/normative/entity-context/v1/README.md | 33 +++++++++++++------ .../entity-context/v1/index.schema.json | 16 ++++++++- 4 files changed, 46 insertions(+), 15 deletions(-) diff --git a/docs/ADRs/0107-deterministic-filtered-entity-context-staging.md b/docs/ADRs/0107-deterministic-filtered-entity-context-staging.md index 3e37ca575d..a3029f8e8c 100644 --- a/docs/ADRs/0107-deterministic-filtered-entity-context-staging.md +++ b/docs/ADRs/0107-deterministic-filtered-entity-context-staging.md @@ -34,9 +34,12 @@ the preferred prefetch model from [ADR 0017](0017-credential-isolation-for-sandboxed-agents.md) to every issue and change-proposal run. -This ADR's *entity context* is the staged data snapshot. It is distinct from -the dispatch-layer routing category called entity context in -[ADR 0076](0076-slash-command-entity-context-separation.md). +This ADR's *forge entity snapshot* is the staged data snapshot. It is distinct +from the dispatch-layer routing category called entity context in +[ADR 0076](0076-slash-command-entity-context-separation.md). The v1 +compatibility path and schema identifiers retain the `entity-context` name; +this is known naming debt, and implementation work should evaluate renaming +those identifiers before they become public compatibility commitments. ## Decision diff --git a/docs/architecture.md b/docs/architecture.md index 5ca83515ce..75823299cc 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -181,7 +181,8 @@ repo baseline and overrides) (contract: [`docs/normative/prescript-output/v1`](normative/prescript-output/v1/README.md)), replacing the inline workflow pre-checks and their scaffold script copies ([ADR 0072](ADRs/0072-pre-script-output-protocol.md)). -- Deterministic entity context: before the pre-script, the runner fetches one +- Deterministic forge entity snapshot (the `entity-context` v1 compatibility + name): before the pre-script, the runner fetches one bounded entity snapshot through `forge.Client`, filters untrusted content, and stages a versioned per-record file tree with relationship, projection, and immutable agent-run lineage metadata outside the repository. Repository diff --git a/docs/normative/entity-context/v1/README.md b/docs/normative/entity-context/v1/README.md index 360304d27c..2b37470f75 100644 --- a/docs/normative/entity-context/v1/README.md +++ b/docs/normative/entity-context/v1/README.md @@ -5,10 +5,13 @@ by [ADR 0107](../../../ADRs/0107-deterministic-filtered-entity-context-staging.m It is the contract between forge adapters, `fullsend run`, harness scripts, and agent runtimes. -Here, *entity context* means the staged data snapshot for a handled Git-forge -entity. [ADR 0076](../../../ADRs/0076-slash-command-entity-context-separation.md) -uses the same phrase for the distinct routing category that determines which -agent or slash command may handle an issue, change proposal, or conversation. +Here, *forge entity snapshot* means the staged data snapshot for a handled +Git-forge entity. The compatibility path and schema identifiers retain the +`entity-context` name for v1; implementation work should evaluate renaming +those identifiers before they become a public compatibility commitment. +[ADR 0076](../../../ADRs/0076-slash-command-entity-context-separation.md) uses +*entity context* for the distinct routing category that determines which agent +or slash command may handle an issue, change proposal, or conversation. Entity-context v1 applies only to GitHub, GitLab, and Forgejo work items and change proposals. A non-forge `work_item`, such as Jira, does not start v1 snapshot assembly; the runner records an `unsupported_entity` diagnostic @@ -59,6 +62,12 @@ deterministic projections containing those same paths, one per LF-terminated line. `views/timeline.order` and `views/unresolved-review.order` exist even when empty. +Manifest `media_type` values are closed by file role: JSON documents use +`application/json`, comment/review/entity records use `text/markdown`, and +order views plus check logs use `text/plain`. Producers must emit the value +specified for the role; media-type parameters and alternate spellings are not +valid v1 values. + The canonical empty singleton documents are `{"reviews":[],"threads":[]}` for `relations/reviews.json`, `{"runs":[]}` for `history/agent-runs.json`, `{"actors":[]}` for `state/actors.json`, and `{"threads":[]}` for @@ -67,12 +76,16 @@ zero-byte file. ## Stable records and mutable state -A record key is the lowercase hexadecimal SHA-256 of these four UTF-8 strings -joined by a single NUL byte, with no trailing NUL: - -```text -://, source.repository_id, record kind, forge record ID -``` +A record key is the lowercase hexadecimal SHA-256 of four UTF-8 strings. In +order, the strings are `://`, +``, the record kind, and the forge record ID. Encode each +string as UTF-8 and concatenate them with exactly one U+0000 byte between +adjacent fields and no trailing U+0000. Commas and spaces shown in prose are +not part of the input. For example, the four fields +`github://github.com`, `R_kgDOExample`, `comment`, and `IC_kwDOExample` produce +the byte sequence `github://github.com\0R_kgDOExample\0comment\0IC_kwDOExample` +and the key +`c73645a72a9c5de28d71e3e1efe235b9a5d02ee6dfe7dc0ef06cf3d0e5ee3421`. `source.forge` is `github`, `gitlab`, or `forgejo`. `source.host` is the lowercase DNS name, with a port from 1 through 65535 appended as decimal diff --git a/docs/normative/entity-context/v1/index.schema.json b/docs/normative/entity-context/v1/index.schema.json index c2f06c7092..a7b4c96953 100644 --- a/docs/normative/entity-context/v1/index.schema.json +++ b/docs/normative/entity-context/v1/index.schema.json @@ -109,7 +109,9 @@ "role": { "enum": ["collection", "entity_metadata", "entity_record", "comment_record", "review_record", "thread_order", "timeline_view", "unresolved_review_view", "review_view", "reviews", "agent_runs", "check_metadata", "check_log", "actor_state", "thread_state"] }, - "media_type": { "type": "string", "minLength": 1 }, + "media_type": { + "enum": ["application/json", "text/markdown", "text/plain"] + }, "bytes": { "type": "integer", "minimum": 0 }, "sha256": { "$ref": "common.schema.json#/$defs/record_key" }, "filter": { @@ -120,6 +122,18 @@ } }, "allOf": [ + { + "if": { "properties": { "role": { "enum": ["collection", "entity_metadata", "reviews", "agent_runs", "check_metadata", "actor_state", "thread_state"] } }, "required": ["role"] }, + "then": { "properties": { "media_type": { "const": "application/json" } } } + }, + { + "if": { "properties": { "role": { "enum": ["entity_record", "comment_record", "review_record"] } }, "required": ["role"] }, + "then": { "properties": { "media_type": { "const": "text/markdown" } } } + }, + { + "if": { "properties": { "role": { "enum": ["thread_order", "timeline_view", "unresolved_review_view", "review_view", "check_log"] } }, "required": ["role"] }, + "then": { "properties": { "media_type": { "const": "text/plain" } } } + }, { "if": { "properties": { "role": { "enum": ["entity_metadata", "reviews", "agent_runs", "check_metadata", "check_log", "actor_state"] } }, "required": ["role"] }, "then": { "required": ["filter"] } From be3215d3652d28179464b25efe330d11521ecf8d Mon Sep 17 00:00:00 2001 From: Barak Korren Date: Wed, 23 Sep 2026 11:44:15 +0300 Subject: [PATCH 18/33] docs(#6407): include entity record header kind Signed-off-by: Barak Korren Assisted-by: Codex (gpt-5.6-sol) --- docs/normative/entity-context/v1/README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/normative/entity-context/v1/README.md b/docs/normative/entity-context/v1/README.md index 2b37470f75..be0bcda4ec 100644 --- a/docs/normative/entity-context/v1/README.md +++ b/docs/normative/entity-context/v1/README.md @@ -138,8 +138,10 @@ Created-At: "2026-09-08T10:15:30.000000000Z" Filtered Markdown body. ``` -`Fullsend-Record` is `"comment"` or `"review"`. The header order and blank -line are fixed. `Author-ID` may be `null` when the forge withholds or has +`Fullsend-Record` is `"entity"`, `"comment"`, or `"review"`. The header order +and blank line are fixed. `"entity"` is required for the reserved entity-body +record; `"comment"` and `"review"` identify ordinary conversation records. +`Author-ID` may be `null` when the forge withholds or has deleted the actor. The immutable actor ID is included because attribution is part of the source record. The current login stays in `index.json` and `state/actors.json`: it may change after an account rename without the record From 3dbeedf97bfcf624b1a06cba7719efde874a7cd3 Mon Sep 17 00:00:00 2001 From: Barak Korren Date: Wed, 23 Sep 2026 12:09:40 +0300 Subject: [PATCH 19/33] docs(#6407): harden entity-context contract Signed-off-by: Barak Korren Assisted-by: Codex (gpt-5.6-sol) --- ...inistic-filtered-entity-context-staging.md | 17 ++++--- docs/normative/entity-context/v1/README.md | 48 +++++++++++++++++-- .../entity-context/v1/actor-state.schema.json | 2 +- .../entity-context/v1/agent-runs.schema.json | 2 +- .../entity-context/v1/check.schema.json | 2 +- .../entity-context/v1/common.schema.json | 19 +++++++- .../entity-context/v1/entity.schema.json | 10 ++-- .../entity-context/v1/index.schema.json | 25 ++++++---- .../entity-context/v1/reviews.schema.json | 13 +++-- .../v1/thread-state.schema.json | 9 +++- 10 files changed, 115 insertions(+), 32 deletions(-) diff --git a/docs/ADRs/0107-deterministic-filtered-entity-context-staging.md b/docs/ADRs/0107-deterministic-filtered-entity-context-staging.md index a3029f8e8c..a2432f3dea 100644 --- a/docs/ADRs/0107-deterministic-filtered-entity-context-staging.md +++ b/docs/ADRs/0107-deterministic-filtered-entity-context-staging.md @@ -54,13 +54,16 @@ every truncation, replacement, finding, and fetch error without retaining rejected content. 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 -`/sandbox/workspace/context`. 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. +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`. 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 diff --git a/docs/normative/entity-context/v1/README.md b/docs/normative/entity-context/v1/README.md index be0bcda4ec..e8d76b5456 100644 --- a/docs/normative/entity-context/v1/README.md +++ b/docs/normative/entity-context/v1/README.md @@ -16,7 +16,10 @@ Entity-context v1 applies only to GitHub, GitLab, and Forgejo work items and change proposals. A non-forge `work_item`, such as Jira, does not start v1 snapshot assembly; the runner records an `unsupported_entity` diagnostic outside the tree and continues under that integration's existing input -contract. Runtime entity-context forge reads remain denied. +contract. This host-only `unsupported_entity` diagnostic is unrelated to the +`gaps[].code` value `unsupported` for an omitted or partial in-tree scope and +never appears in a schema document. Runtime entity-context forge reads remain +denied. ## Tree @@ -290,6 +293,18 @@ Review adapters use these exhaustive v1 mappings: `PENDING` and `REQUEST_REVIEW` rows are unsubmitted reviewer requests and are omitted. +Formal review timestamp mapping is also exhaustive. The record's +`created_at`, its filename order key, and the relationship `submitted_at` all +use the canonical submission time. For GitHub this is native `submittedAt`; +native `createdAt` is the start of a pending review and is not used for a +submitted record. A submitted GitHub review without `submittedAt` is +`invalid_metadata`. Forgejo uses native `submitted_at` when present and uses +native `created_at` only when the completed review exposes no separate +submission field; if neither is present it is `invalid_metadata`. GitLab has +no formal v1 review records, so discussion notes use their native note +`created_at` as comment time and have no `submitted_at`. Adapters must not use +runner-observed time as a fallback. + Any other native formal-review state is `invalid_metadata`. GitHub uses its native outdated observation. For GitLab and Forgejo thread APIs that expose no outdated equivalent, producers emit `outdated: false`; they never infer it from @@ -346,6 +361,13 @@ Non-entity records first enter the corresponding canonical order from [Ordering and determinism](#ordering-and-determinism); `record_selection` retains either the oldest or newest `max_records_per_source` entries for each included source, then output ordering follows the same chronology rules. +When a bound drops records, the producer emits exactly one `profile_bound` gap +for each affected scope, with `count` equal to the number dropped. Counts from +multiple bounds for the same scope and code are aggregated, and the gaps array +contains at most one row for each `(scope, code)` pair, sorted by scope and +code. Dropping labels because of `max_labels` emits an `entity`-scope +`profile_bound` gap whose count is the number of dropped labels and sets the +entity-metadata filter status to `truncated`; it is never silent. After comment and review record selection, thread `record_keys`, reply edges, thread order files, and review views contain only retained records that have an emitted `content_path`. A reply edge is emitted only when both endpoints remain @@ -500,7 +522,13 @@ configured provider trust boundary, not by this cleanup guarantee. Structural strings are not rewritten because doing so could change identity or target a different resource. Canonical IDs use the mappings above. Repository paths and review file paths first undergo the Unicode-safety scan and then strict -structural validation. v1 deliberately restricts `repository_path` to the +structural validation. The `repository_path` and `source.host` schema patterns +use only RE2-compatible syntax and enforce their printable alphabet; producers +additionally enforce the documented segment, leading-slash, trailing-slash, +port-range, and default-port rules. A validator that cannot compile or +evaluate any security pattern must report a validation error and abort required +snapshot assembly; it must never ignore the pattern or fall back to a weaker +constraint. v1 deliberately restricts `repository_path` to the printable-ASCII allow-list encoded by `common.schema.json` (including its explicit punctuation set and excluding non-ASCII letters and apostrophes); this is an explicit compatibility and security boundary, not an implicit Unicode @@ -508,8 +536,10 @@ normalization. Non-ASCII or other out-of-alphabet values are structurally invalid. Repository file paths are relative, slash-separated, contain no `.` or `..` segment, percent sign or percent-encoded dot, slash, or backslash, control character, or non-rendering class named above. -These values are untrusted forge data and must never be interpolated into shell -commands; generated order-file paths have a separate shell-safe contract. +The host port is 1 through 65535, and `:443` is rejected because the default +port is omitted. These values are untrusted forge data and must never be +interpolated into shell commands; generated order-file paths have a separate +shell-safe contract. Source URLs are intentionally not part of the agent-visible v1 tree; forge, host, repository, and immutable record IDs provide provenance without copying @@ -523,6 +553,16 @@ index `source` field than emitting an invalid singleton or dangling manifest. Structural values are never emitted after filtering or truncation. +All structural IDs use the schema's `common.schema.json` `structural_id` +definition, which excludes whitespace, control characters, slashes, and shell +separators. Adapters apply the narrower forge mapping before schema validation: +GitHub node IDs use `[A-Za-z0-9_=-]+`; GitLab and Forgejo numeric IDs use +`[1-9][0-9]*`; GitLab discussion IDs use +`[A-Za-z0-9][A-Za-z0-9._:-]*`; and filter finding codes use +`[a-z][a-z0-9._-]*`. A value outside its forge mapping is `invalid_metadata`; +it is rejected or the affected optional record is omitted rather than +rewritten. Unsafe required IDs abort assembly. + `index.json.filter` records filtering of source-derived values in the index. Manifest file entries require `filter` for entity, review, agent-run, check metadata, check logs, and actor JSON documents. A `check_log` entry's filter diff --git a/docs/normative/entity-context/v1/actor-state.schema.json b/docs/normative/entity-context/v1/actor-state.schema.json index 2c268797ae..7a40642a5a 100644 --- a/docs/normative/entity-context/v1/actor-state.schema.json +++ b/docs/normative/entity-context/v1/actor-state.schema.json @@ -12,7 +12,7 @@ "type": "object", "required": ["id", "kind", "login", "role", "role_verified"], "properties": { - "id": { "type": "string", "minLength": 1 }, + "id": { "$ref": "common.schema.json#/$defs/structural_id" }, "kind": { "enum": ["human", "bot"] }, "login": { "type": ["string", "null"], "minLength": 1 }, "role": { diff --git a/docs/normative/entity-context/v1/agent-runs.schema.json b/docs/normative/entity-context/v1/agent-runs.schema.json index 19447bfeac..8a64136087 100644 --- a/docs/normative/entity-context/v1/agent-runs.schema.json +++ b/docs/normative/entity-context/v1/agent-runs.schema.json @@ -11,7 +11,7 @@ "type": "object", "required": ["id", "agent", "status", "input_revision", "result_record_keys", "completed_at"], "properties": { - "id": { "type": "string", "minLength": 1 }, + "id": { "$ref": "common.schema.json#/$defs/structural_id" }, "agent": { "type": "string", "minLength": 1 }, "status": { "enum": ["success", "failure", "cancelled", "skipped", "timed_out"] }, "input_revision": { diff --git a/docs/normative/entity-context/v1/check.schema.json b/docs/normative/entity-context/v1/check.schema.json index 734702708b..2f36ac0b6a 100644 --- a/docs/normative/entity-context/v1/check.schema.json +++ b/docs/normative/entity-context/v1/check.schema.json @@ -5,7 +5,7 @@ "type": "object", "required": ["id", "name", "status", "created_at"], "properties": { - "id": { "type": "string", "minLength": 1 }, + "id": { "$ref": "common.schema.json#/$defs/structural_id" }, "name": { "type": "string", "minLength": 1 }, "status": { "enum": ["queued", "in_progress", "completed"] }, "conclusion": { "enum": ["success", "failure", "neutral", "cancelled", "skipped", "timed_out", "action_required", "stale"] }, diff --git a/docs/normative/entity-context/v1/common.schema.json b/docs/normative/entity-context/v1/common.schema.json index a9d0de3275..4907631858 100644 --- a/docs/normative/entity-context/v1/common.schema.json +++ b/docs/normative/entity-context/v1/common.schema.json @@ -16,10 +16,27 @@ "type": "string", "pattern": "^[0-9a-f]{64}$" }, + "structural_id": { + "type": "string", + "pattern": "^[A-Za-z0-9][A-Za-z0-9._~:+,=@-]*$", + "description": "Forge or receipt identifier. Structural IDs use a printable, separator-safe ASCII alphabet and are never rewritten. Forge-specific mappings further restrict this alphabet." + }, + "finding_code": { + "type": "string", + "pattern": "^[a-z][a-z0-9._-]*$" + }, "repository_path": { "type": "string", "minLength": 1, - "pattern": "^(?!/)(?!.*//)(?!.*[/]$)(?!.*(^|/)[.]{1,2}(/|$))(?!.*%)(?!.*[\u200b-\u200d\u202a-\u202e\u2066-\u2069\ufeff\ufe00-\ufe0f\ufff9-\ufffb])[A-Za-z0-9._/~!$&()+,;=:@#\\[\\]{} -]+$" + "pattern": "^[A-Za-z0-9._/~!$&()+,;=:@#\\[\\]{} -]+$", + "allOf": [ + { "not": { "pattern": "^/" } }, + { "not": { "pattern": "/$" } }, + { "not": { "pattern": "//" } }, + { "not": { "pattern": "(^|/)\\.{1,2}(/|$)" } }, + { "not": { "pattern": "%" } }, + { "not": { "pattern": "[\u200b-\u200d\u202a-\u202e\u2066-\u2069\ufeff\ufe00-\ufe0f\ufff9-\ufffb]" } } + ] }, "actor_role": { "enum": ["admin", "maintain", "write", "triage", "read", "none", "external"] diff --git a/docs/normative/entity-context/v1/entity.schema.json b/docs/normative/entity-context/v1/entity.schema.json index 7e0d6aab57..3c0ff00089 100644 --- a/docs/normative/entity-context/v1/entity.schema.json +++ b/docs/normative/entity-context/v1/entity.schema.json @@ -7,8 +7,7 @@ "properties": { "kind": { "enum": ["work_item", "change_proposal"] }, "id": { - "type": "string", - "minLength": 1, + "$ref": "common.schema.json#/$defs/structural_id", "description": "Immutable opaque forge object ID used for record keys; distinct from normalized-event v1 entity.id." }, "number": { @@ -18,7 +17,12 @@ }, "title": { "type": "string", "minLength": 1 }, "state": { "enum": ["open", "closed", "merged"] }, - "author_id": { "type": ["string", "null"], "minLength": 1 }, + "author_id": { + "oneOf": [ + { "$ref": "common.schema.json#/$defs/structural_id" }, + { "type": "null" } + ] + }, "author": { "type": ["string", "null"], "minLength": 1 }, "created_at": { "$ref": "common.schema.json#/$defs/timestamp" }, "updated_at": { "$ref": "common.schema.json#/$defs/timestamp" }, diff --git a/docs/normative/entity-context/v1/index.schema.json b/docs/normative/entity-context/v1/index.schema.json index a7b4c96953..5bbb46efeb 100644 --- a/docs/normative/entity-context/v1/index.schema.json +++ b/docs/normative/entity-context/v1/index.schema.json @@ -19,8 +19,12 @@ "required": ["forge", "host", "repository_id", "repository"], "properties": { "forge": { "enum": ["github", "gitlab", "forgejo"] }, - "host": { "type": "string", "pattern": "^[a-z0-9.-]+(?::(?!443$)(?:[1-9]|[1-9][0-9]{1,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5]))?$" }, - "repository_id": { "type": "string", "minLength": 1 }, + "host": { + "type": "string", + "pattern": "^[a-z0-9.-]+(:([1-9]|[1-9][0-9]{1,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5]))?$", + "allOf": [{ "not": { "pattern": ":443$" } }] + }, + "repository_id": { "$ref": "common.schema.json#/$defs/structural_id" }, "repository": { "allOf": [ { "$ref": "common.schema.json#/$defs/repository_path" }, @@ -55,8 +59,7 @@ "properties": { "kind": { "enum": ["work_item", "change_proposal"] }, "id": { - "type": "string", - "minLength": 1, + "$ref": "common.schema.json#/$defs/structural_id", "description": "Immutable opaque forge object ID; distinct from the positive display number in normalized-event v1 entity.id." }, "updated_at": { "$ref": "common.schema.json#/$defs/timestamp" } @@ -73,7 +76,8 @@ }, "gaps": { "type": "array", - "items": { "$ref": "#/$defs/gap" } + "items": { "$ref": "#/$defs/gap" }, + "description": "At most one row per (scope, code) pair; producers aggregate counts before canonical serialization and sort by scope then code." } }, "additionalProperties": false, @@ -89,7 +93,7 @@ "type": "object", "required": ["code", "count"], "properties": { - "code": { "type": "string", "minLength": 1 }, + "code": { "$ref": "common.schema.json#/$defs/finding_code" }, "count": { "type": "integer", "minimum": 1 } }, "additionalProperties": false @@ -164,12 +168,17 @@ "required": ["kind", "id", "record_key", "created_at", "filter"], "properties": { "kind": { "enum": ["entity", "comment", "review", "check"] }, - "id": { "type": "string", "minLength": 1 }, + "id": { "$ref": "common.schema.json#/$defs/structural_id" }, "record_key": { "$ref": "common.schema.json#/$defs/record_key" }, "content_path": { "type": "string", "pattern": "^records/[0-9]{8}T[0-9]{15}Z-[0-9a-f]{64}[.]md$" }, "metadata_path": { "type": "string", "pattern": "^checks/[0-9a-f]{64}/metadata[.]json$" }, "log_path": { "type": "string", "pattern": "^checks/[0-9a-f]{64}/log[.]txt$" }, - "author_id": { "type": ["string", "null"], "minLength": 1 }, + "author_id": { + "oneOf": [ + { "$ref": "common.schema.json#/$defs/structural_id" }, + { "type": "null" } + ] + }, "author": { "type": ["string", "null"], "minLength": 1 }, "created_at": { "$ref": "common.schema.json#/$defs/timestamp" }, "updated_at": { "$ref": "common.schema.json#/$defs/timestamp" }, diff --git a/docs/normative/entity-context/v1/reviews.schema.json b/docs/normative/entity-context/v1/reviews.schema.json index 7f6809575b..59432cee89 100644 --- a/docs/normative/entity-context/v1/reviews.schema.json +++ b/docs/normative/entity-context/v1/reviews.schema.json @@ -11,7 +11,7 @@ "type": "object", "required": ["id", "record_key", "state", "submitted_at"], "properties": { - "id": { "type": "string", "minLength": 1 }, + "id": { "$ref": "common.schema.json#/$defs/structural_id" }, "record_key": { "$ref": "common.schema.json#/$defs/record_key" }, "state": { "enum": ["approved", "changes_requested", "commented", "dismissed"] }, "reviewed_sha": { "$ref": "common.schema.json#/$defs/git_oid" }, @@ -22,7 +22,12 @@ { "type": "null" } ] }, - "dismissed_by_actor_id": { "type": ["string", "null"], "minLength": 1 } + "dismissed_by_actor_id": { + "oneOf": [ + { "$ref": "common.schema.json#/$defs/structural_id" }, + { "type": "null" } + ] + } }, "allOf": [ { @@ -40,7 +45,7 @@ "type": "object", "required": ["id", "thread_key", "created_at", "order_path", "record_keys", "replies"], "properties": { - "id": { "type": "string", "minLength": 1 }, + "id": { "$ref": "common.schema.json#/$defs/structural_id" }, "thread_key": { "$ref": "common.schema.json#/$defs/record_key" }, "created_at": { "$ref": "common.schema.json#/$defs/timestamp" }, "order_path": { "type": "string", "pattern": "^threads/[0-9a-f]{64}[.]order$" }, @@ -61,7 +66,7 @@ "additionalProperties": false } }, - "review_id": { "type": "string", "minLength": 1 }, + "review_id": { "$ref": "common.schema.json#/$defs/structural_id" }, "review_record_key": { "$ref": "common.schema.json#/$defs/record_key" }, "reviewed_sha": { "$ref": "common.schema.json#/$defs/git_oid" }, "path": { "$ref": "common.schema.json#/$defs/repository_path" }, diff --git a/docs/normative/entity-context/v1/thread-state.schema.json b/docs/normative/entity-context/v1/thread-state.schema.json index 4362655ec3..c58e3098c8 100644 --- a/docs/normative/entity-context/v1/thread-state.schema.json +++ b/docs/normative/entity-context/v1/thread-state.schema.json @@ -11,10 +11,15 @@ "type": "object", "required": ["id", "thread_key", "resolved", "outdated"], "properties": { - "id": { "type": "string", "minLength": 1 }, + "id": { "$ref": "common.schema.json#/$defs/structural_id" }, "thread_key": { "$ref": "common.schema.json#/$defs/record_key" }, "resolved": { "type": "boolean" }, - "resolved_by_actor_id": { "type": ["string", "null"], "minLength": 1 }, + "resolved_by_actor_id": { + "oneOf": [ + { "$ref": "common.schema.json#/$defs/structural_id" }, + { "type": "null" } + ] + }, "outdated": { "type": "boolean" }, "minimized": { "type": "boolean" } }, From 86fb1de0dba54309a47b3672e0a128d6500a8a15 Mon Sep 17 00:00:00 2001 From: Barak Korren Date: Wed, 23 Sep 2026 14:55:49 +0300 Subject: [PATCH 20/33] docs(#6407): qualify entity context snapshot name Use entity-context-snapshot for the normative v1 bundle and reserved sandbox mount while retaining FULLSEND_CONTEXT_DIR for consumer stability. Signed-off-by: Barak Korren Assisted-by: Codex (gpt-5.6-sol) --- ...slash-command-entity-context-separation.md | 4 +-- ...inistic-filtered-entity-context-staging.md | 30 ++++++++--------- docs/architecture.md | 7 ++-- .../v1/README.md | 33 +++++++++---------- .../v1/actor-state.schema.json | 2 +- .../v1/agent-runs.schema.json | 2 +- .../v1/check.schema.json | 2 +- .../v1/collection.schema.json | 2 +- .../v1/common.schema.json | 2 +- .../v1/entity.schema.json | 2 +- .../v1/index.schema.json | 2 +- .../v1/reviews.schema.json | 2 +- .../v1/thread-state.schema.json | 2 +- docs/normative/normalized-event/v1/README.md | 9 ++--- 14 files changed, 51 insertions(+), 50 deletions(-) rename docs/normative/{entity-context => entity-context-snapshot}/v1/README.md (97%) rename docs/normative/{entity-context => entity-context-snapshot}/v1/actor-state.schema.json (92%) rename docs/normative/{entity-context => entity-context-snapshot}/v1/agent-runs.schema.json (93%) rename docs/normative/{entity-context => entity-context-snapshot}/v1/check.schema.json (96%) rename docs/normative/{entity-context => entity-context-snapshot}/v1/collection.schema.json (95%) rename docs/normative/{entity-context => entity-context-snapshot}/v1/common.schema.json (94%) rename docs/normative/{entity-context => entity-context-snapshot}/v1/entity.schema.json (94%) rename docs/normative/{entity-context => entity-context-snapshot}/v1/index.schema.json (99%) rename docs/normative/{entity-context => entity-context-snapshot}/v1/reviews.schema.json (97%) rename docs/normative/{entity-context => entity-context-snapshot}/v1/thread-state.schema.json (92%) diff --git a/docs/ADRs/0076-slash-command-entity-context-separation.md b/docs/ADRs/0076-slash-command-entity-context-separation.md index 213243976d..1d2f4ee460 100644 --- a/docs/ADRs/0076-slash-command-entity-context-separation.md +++ b/docs/ADRs/0076-slash-command-entity-context-separation.md @@ -22,8 +22,8 @@ Extends entity-context rules for conversation surfaces in Terminology note: this ADR uses *entity context* for a dispatch-layer routing category. [ADR 0107](0107-deterministic-filtered-entity-context-staging.md) -later uses the same phrase for the distinct filtered data snapshot staged for -a handled Git-forge entity. +later names the distinct filtered data snapshot staged for a handled Git-forge +entity *entity-context-snapshot*. Refines [ADR 0002](0002-initial-fullsend-design.md) (initial design) and reinforces [ADR 0020](0020-composable-single-responsibility-agents-with-individual-sandboxes.md) diff --git a/docs/ADRs/0107-deterministic-filtered-entity-context-staging.md b/docs/ADRs/0107-deterministic-filtered-entity-context-staging.md index a2432f3dea..ebc2481ba8 100644 --- a/docs/ADRs/0107-deterministic-filtered-entity-context-staging.md +++ b/docs/ADRs/0107-deterministic-filtered-entity-context-staging.md @@ -1,17 +1,17 @@ --- -title: "107. Deterministic filtered entity-context staging" +title: "107. Deterministic filtered entity-context-snapshot staging" status: Accepted relates_to: - agent-architecture - security-threat-model topics: - - entity-context + - entity-context-snapshot - security - harness - token-cost --- -# 107. Deterministic filtered entity-context staging +# 107. Deterministic filtered entity-context-snapshot staging Date: 2026-09-07 @@ -34,12 +34,11 @@ the preferred prefetch model from [ADR 0017](0017-credential-isolation-for-sandboxed-agents.md) to every issue and change-proposal run. -This ADR's *forge entity snapshot* is the staged data snapshot. It is distinct +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](0076-slash-command-entity-context-separation.md). The v1 -compatibility path and schema identifiers retain the `entity-context` name; -this is known naming debt, and implementation work should evaluate renaming -those identifiers before they become public compatibility commitments. +[ADR 0076](0076-slash-command-entity-context-separation.md). The qualified +name is intentional: it identifies the data structure without redefining ADR +0076's established routing term. ## Decision @@ -57,7 +56,7 @@ 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`. Fullsend must reject any checkout or `host_files` +`/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 @@ -67,7 +66,7 @@ files. The exact tree, schemas, canonical serialization, stable record-key derivation, filter statuses, and compatibility rules are the versioned -[entity-context v1 specification](../normative/entity-context/v1/README.md). +[entity-context-snapshot v1 specification](../normative/entity-context-snapshot/v1/README.md). 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 @@ -78,8 +77,9 @@ 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 entity context -only to relate reviews, threads, comments, and agent runs to repository state. +agents and sub-agents that need them. Git object IDs appear in the +entity-context-snapshot only to relate reviews, threads, comments, and agent runs +to repository state. Each comment and review is a self-contained attributed record whose filename sorts chronologically. The initial body uses the same record format and sorts @@ -110,12 +110,12 @@ 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 source kinds are denied by +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 fetch. +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 @@ -135,6 +135,6 @@ only bounded counts, digests, and filtering findings, never bodies or logs. - 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 projections, publish immutable per-run result receipts while retaining human-facing summaries, and anchor decisions to record keys and revisions. +- 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. diff --git a/docs/architecture.md b/docs/architecture.md index 75823299cc..dcfba16ad7 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -181,13 +181,14 @@ repo baseline and overrides) (contract: [`docs/normative/prescript-output/v1`](normative/prescript-output/v1/README.md)), replacing the inline workflow pre-checks and their scaffold script copies ([ADR 0072](ADRs/0072-pre-script-output-protocol.md)). -- Deterministic forge entity snapshot (the `entity-context` v1 compatibility - name): before the pre-script, the runner fetches one +- Deterministic forge entity-context-snapshot (v1): before the pre-script, the + runner fetches one bounded entity snapshot through `forge.Client`, filters untrusted content, and stages a versioned per-record file tree with relationship, projection, and immutable agent-run lineage metadata outside the repository. Repository diffs and commit history remain derived from the separately provisioned Git - checkout; entity context carries Git object IDs only as relationship anchors. + checkout; the entity-context-snapshot carries Git object IDs only as + relationship anchors. Scripts and the sandbox use `FULLSEND_CONTEXT_DIR` with the same relative paths; runtimes may inject ordered records as separate cacheable input blocks ([ADR 0107](ADRs/0107-deterministic-filtered-entity-context-staging.md)). diff --git a/docs/normative/entity-context/v1/README.md b/docs/normative/entity-context-snapshot/v1/README.md similarity index 97% rename from docs/normative/entity-context/v1/README.md rename to docs/normative/entity-context-snapshot/v1/README.md index e8d76b5456..9b4a8fffe4 100644 --- a/docs/normative/entity-context/v1/README.md +++ b/docs/normative/entity-context-snapshot/v1/README.md @@ -1,25 +1,24 @@ -# Entity context v1 +# Entity-context-snapshot v1 -This specification defines the deterministic, filtered entity snapshot adopted -by [ADR 0107](../../../ADRs/0107-deterministic-filtered-entity-context-staging.md). +This specification defines the deterministic, filtered entity-context-snapshot +adopted by [ADR 0107](../../../ADRs/0107-deterministic-filtered-entity-context-staging.md). It is the contract between forge adapters, `fullsend run`, harness scripts, and agent runtimes. -Here, *forge entity snapshot* means the staged data snapshot for a handled -Git-forge entity. The compatibility path and schema identifiers retain the -`entity-context` name for v1; implementation work should evaluate renaming -those identifiers before they become a public compatibility commitment. -[ADR 0076](../../../ADRs/0076-slash-command-entity-context-separation.md) uses -*entity context* for the distinct routing category that determines which agent -or slash command may handle an issue, change proposal, or conversation. -Entity-context v1 applies only to GitHub, GitLab, and Forgejo work items and -change proposals. A non-forge `work_item`, such as Jira, does not start v1 +Here, *entity-context-snapshot* means the staged data snapshot for a handled +Git-forge entity. The qualified name distinguishes this data structure from +the dispatch-layer routing category called *entity context* in +[ADR 0076](../../../ADRs/0076-slash-command-entity-context-separation.md), +which determines the agent or slash command that may handle an issue, change +proposal, or conversation. Entity-context-snapshot v1 applies only to GitHub, +GitLab, and Forgejo work items and change proposals. A non-forge `work_item`, +such as Jira, does not start v1 snapshot assembly; the runner records an `unsupported_entity` diagnostic outside the tree and continues under that integration's existing input contract. This host-only `unsupported_entity` diagnostic is unrelated to the `gaps[].code` value `unsupported` for an omitted or partial in-tree scope and -never appears in a schema document. Runtime entity-context forge reads remain -denied. +never appears in a schema document. Runtime entity-context-snapshot forge reads +remain denied. ## Tree @@ -623,7 +622,7 @@ after the runtime's last use and the host copy after the post-script on every controlled exit, including skip, failure, and cancellation. Fullsend also scavenges abandoned context trees on startup after an unclean termination. -Artifact collectors must exclude entity-context trees. Retained diagnostics +Artifact collectors must exclude entity-context-snapshot trees. Retained diagnostics may contain bounded record counts, content digests, filter codes/counts, and cleanup errors, but never entity bodies, comment/review bodies, or logs. @@ -634,7 +633,7 @@ must validate `index.json`, `collection.json`, `entity/metadata.json`, `relations/reviews.json`, `history/agent-runs.json`, check metadata documents, `state/actors.json`, and `state/threads.json` against their v1 schemas. Other emitted files follow the byte contracts above. The files under -`docs/normative/entity-context/v1/` form one local schema bundle: consumers +`docs/normative/entity-context-snapshot/v1/` form one local schema bundle: consumers must load every sibling `*.schema.json` file into the same resolver registry, keyed by its `$id` and filename, before validating any document. Relative references such as `common.schema.json#/$defs/timestamp` resolve to sibling @@ -645,7 +644,7 @@ schemas are closed: adding a property, record kind, enum value, or status is a breaking change. Changing path derivation, canonical bytes, required fields, field meaning, or ordering likewise requires -`docs/normative/entity-context/v2/` and a superseding ADR. +`docs/normative/entity-context-snapshot/v2/` and a superseding ADR. The schema committed with the accepting ADR defines v1. Subsequent additions, even an optional property, require v2: older closed-schema consumers would diff --git a/docs/normative/entity-context/v1/actor-state.schema.json b/docs/normative/entity-context-snapshot/v1/actor-state.schema.json similarity index 92% rename from docs/normative/entity-context/v1/actor-state.schema.json rename to docs/normative/entity-context-snapshot/v1/actor-state.schema.json index 7a40642a5a..a981b5c883 100644 --- a/docs/normative/entity-context/v1/actor-state.schema.json +++ b/docs/normative/entity-context-snapshot/v1/actor-state.schema.json @@ -1,6 +1,6 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://fullsend.ai/normative/entity-context/v1/actor-state.schema.json", + "$id": "https://fullsend.ai/normative/entity-context-snapshot/v1/actor-state.schema.json", "title": "ActorState", "type": "object", "required": ["actors"], diff --git a/docs/normative/entity-context/v1/agent-runs.schema.json b/docs/normative/entity-context-snapshot/v1/agent-runs.schema.json similarity index 93% rename from docs/normative/entity-context/v1/agent-runs.schema.json rename to docs/normative/entity-context-snapshot/v1/agent-runs.schema.json index 8a64136087..f01384380e 100644 --- a/docs/normative/entity-context/v1/agent-runs.schema.json +++ b/docs/normative/entity-context-snapshot/v1/agent-runs.schema.json @@ -1,6 +1,6 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://fullsend.ai/normative/entity-context/v1/agent-runs.schema.json", + "$id": "https://fullsend.ai/normative/entity-context-snapshot/v1/agent-runs.schema.json", "title": "AgentRuns", "type": "object", "required": ["runs"], diff --git a/docs/normative/entity-context/v1/check.schema.json b/docs/normative/entity-context-snapshot/v1/check.schema.json similarity index 96% rename from docs/normative/entity-context/v1/check.schema.json rename to docs/normative/entity-context-snapshot/v1/check.schema.json index 2f36ac0b6a..1688f4b74a 100644 --- a/docs/normative/entity-context/v1/check.schema.json +++ b/docs/normative/entity-context-snapshot/v1/check.schema.json @@ -1,6 +1,6 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://fullsend.ai/normative/entity-context/v1/check.schema.json", + "$id": "https://fullsend.ai/normative/entity-context-snapshot/v1/check.schema.json", "title": "CheckMetadata", "type": "object", "required": ["id", "name", "status", "created_at"], diff --git a/docs/normative/entity-context/v1/collection.schema.json b/docs/normative/entity-context-snapshot/v1/collection.schema.json similarity index 95% rename from docs/normative/entity-context/v1/collection.schema.json rename to docs/normative/entity-context-snapshot/v1/collection.schema.json index 4895b8929a..05e92639ab 100644 --- a/docs/normative/entity-context/v1/collection.schema.json +++ b/docs/normative/entity-context-snapshot/v1/collection.schema.json @@ -1,6 +1,6 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://fullsend.ai/normative/entity-context/v1/collection.schema.json", + "$id": "https://fullsend.ai/normative/entity-context-snapshot/v1/collection.schema.json", "title": "EntityContextCollection", "type": "object", "required": ["included_sources", "record_selection", "check_log_selection", "bounds"], diff --git a/docs/normative/entity-context/v1/common.schema.json b/docs/normative/entity-context-snapshot/v1/common.schema.json similarity index 94% rename from docs/normative/entity-context/v1/common.schema.json rename to docs/normative/entity-context-snapshot/v1/common.schema.json index 4907631858..f395c13042 100644 --- a/docs/normative/entity-context/v1/common.schema.json +++ b/docs/normative/entity-context-snapshot/v1/common.schema.json @@ -1,6 +1,6 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://fullsend.ai/normative/entity-context/v1/common.schema.json", + "$id": "https://fullsend.ai/normative/entity-context-snapshot/v1/common.schema.json", "title": "EntityContextCommonDefinitions", "$defs": { "timestamp": { diff --git a/docs/normative/entity-context/v1/entity.schema.json b/docs/normative/entity-context-snapshot/v1/entity.schema.json similarity index 94% rename from docs/normative/entity-context/v1/entity.schema.json rename to docs/normative/entity-context-snapshot/v1/entity.schema.json index 3c0ff00089..50860ca85d 100644 --- a/docs/normative/entity-context/v1/entity.schema.json +++ b/docs/normative/entity-context-snapshot/v1/entity.schema.json @@ -1,6 +1,6 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://fullsend.ai/normative/entity-context/v1/entity.schema.json", + "$id": "https://fullsend.ai/normative/entity-context-snapshot/v1/entity.schema.json", "title": "EntityMetadata", "type": "object", "required": ["kind", "id", "number", "title", "state", "author_id", "author", "created_at", "updated_at", "labels"], diff --git a/docs/normative/entity-context/v1/index.schema.json b/docs/normative/entity-context-snapshot/v1/index.schema.json similarity index 99% rename from docs/normative/entity-context/v1/index.schema.json rename to docs/normative/entity-context-snapshot/v1/index.schema.json index 5bbb46efeb..7254d36705 100644 --- a/docs/normative/entity-context/v1/index.schema.json +++ b/docs/normative/entity-context-snapshot/v1/index.schema.json @@ -1,6 +1,6 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://fullsend.ai/normative/entity-context/v1/index.schema.json", + "$id": "https://fullsend.ai/normative/entity-context-snapshot/v1/index.schema.json", "title": "EntityContextIndex", "type": "object", "required": ["schema_version", "filter_version", "collection_profile", "filter", "source", "entity", "files", "records", "gaps"], diff --git a/docs/normative/entity-context/v1/reviews.schema.json b/docs/normative/entity-context-snapshot/v1/reviews.schema.json similarity index 97% rename from docs/normative/entity-context/v1/reviews.schema.json rename to docs/normative/entity-context-snapshot/v1/reviews.schema.json index 59432cee89..b1ec013f60 100644 --- a/docs/normative/entity-context/v1/reviews.schema.json +++ b/docs/normative/entity-context-snapshot/v1/reviews.schema.json @@ -1,6 +1,6 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://fullsend.ai/normative/entity-context/v1/reviews.schema.json", + "$id": "https://fullsend.ai/normative/entity-context-snapshot/v1/reviews.schema.json", "title": "ReviewRelationships", "type": "object", "required": ["reviews", "threads"], diff --git a/docs/normative/entity-context/v1/thread-state.schema.json b/docs/normative/entity-context-snapshot/v1/thread-state.schema.json similarity index 92% rename from docs/normative/entity-context/v1/thread-state.schema.json rename to docs/normative/entity-context-snapshot/v1/thread-state.schema.json index c58e3098c8..8ce7e6e794 100644 --- a/docs/normative/entity-context/v1/thread-state.schema.json +++ b/docs/normative/entity-context-snapshot/v1/thread-state.schema.json @@ -1,6 +1,6 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://fullsend.ai/normative/entity-context/v1/thread-state.schema.json", + "$id": "https://fullsend.ai/normative/entity-context-snapshot/v1/thread-state.schema.json", "title": "ThreadState", "type": "object", "required": ["threads"], diff --git a/docs/normative/normalized-event/v1/README.md b/docs/normative/normalized-event/v1/README.md index 76e6b9385a..9eed4a5f0a 100644 --- a/docs/normative/normalized-event/v1/README.md +++ b/docs/normative/normalized-event/v1/README.md @@ -85,10 +85,11 @@ remains the normative stricter check. Adding a new `transition.kind` is **non-breaking** — CEL triggers use boolean expressions, not exhaustive enum matching. -Normalized-event and entity-context v1 carry independently versioned copies of -the actor-role vocabulary. They match when entity-context v1 is accepted, but -a role added non-breakingly here does not extend entity-context's closed v1 -schema; adapters validate each document against its own schema. +Normalized-event and entity-context-snapshot v1 carry independently versioned +copies of the actor-role vocabulary. They match when entity-context-snapshot v1 +is accepted, but a role added non-breakingly here does not extend +entity-context-snapshot's closed v1 schema; adapters validate each document +against its own schema. ## Adapters From 7561cc6177033985e47b6ee43ecbaa19336d9d11 Mon Sep 17 00:00:00 2001 From: Barak Korren Date: Wed, 23 Sep 2026 14:59:16 +0300 Subject: [PATCH 21/33] docs(#6407): align GitHub structural ID rules Define one GitHub node-ID alphabet across the entity-context-snapshot contract and enforce it for indexed GitHub IDs while documenting adapter validation for child documents. Signed-off-by: Barak Korren Assisted-by: Codex (gpt-5.6-sol) --- .../entity-context-snapshot/v1/README.md | 8 +++- .../v1/common.schema.json | 7 +++- .../v1/index.schema.json | 42 ++++++++++++++++++- 3 files changed, 53 insertions(+), 4 deletions(-) diff --git a/docs/normative/entity-context-snapshot/v1/README.md b/docs/normative/entity-context-snapshot/v1/README.md index 9b4a8fffe4..d9c2542794 100644 --- a/docs/normative/entity-context-snapshot/v1/README.md +++ b/docs/normative/entity-context-snapshot/v1/README.md @@ -555,10 +555,14 @@ never emitted after filtering or truncation. All structural IDs use the schema's `common.schema.json` `structural_id` definition, which excludes whitespace, control characters, slashes, and shell separators. Adapters apply the narrower forge mapping before schema validation: -GitHub node IDs use `[A-Za-z0-9_=-]+`; GitLab and Forgejo numeric IDs use +GitHub node IDs use `[A-Za-z0-9][A-Za-z0-9_=-]*` (the schema's +`github_node_id` definition); GitLab and Forgejo numeric IDs use `[1-9][0-9]*`; GitLab discussion IDs use `[A-Za-z0-9][A-Za-z0-9._:-]*`; and filter finding codes use -`[a-z][a-z0-9._-]*`. A value outside its forge mapping is `invalid_metadata`; +`[a-z][a-z0-9._-]*`. Every GitHub-sourced structural ID uses the same +`github_node_id` mapping, including entity, record, actor, review, thread, +check, and agent-run IDs; the standalone child schemas rely on the adapter +check because they do not carry `source.forge`. A value outside its forge mapping is `invalid_metadata`; it is rejected or the affected optional record is omitted rather than rewritten. Unsafe required IDs abort assembly. diff --git a/docs/normative/entity-context-snapshot/v1/common.schema.json b/docs/normative/entity-context-snapshot/v1/common.schema.json index f395c13042..76432fb0e5 100644 --- a/docs/normative/entity-context-snapshot/v1/common.schema.json +++ b/docs/normative/entity-context-snapshot/v1/common.schema.json @@ -18,9 +18,14 @@ }, "structural_id": { "type": "string", - "pattern": "^[A-Za-z0-9][A-Za-z0-9._~:+,=@-]*$", + "pattern": "^[A-Za-z0-9][A-Za-z0-9._:=-]*$", "description": "Forge or receipt identifier. Structural IDs use a printable, separator-safe ASCII alphabet and are never rewritten. Forge-specific mappings further restrict this alphabet." }, + "github_node_id": { + "type": "string", + "pattern": "^[A-Za-z0-9][A-Za-z0-9_=-]*$", + "description": "GitHub GraphQL node_id. Every GitHub-sourced structural ID uses this adapter mapping before schema validation." + }, "finding_code": { "type": "string", "pattern": "^[a-z][a-z0-9._-]*$" diff --git a/docs/normative/entity-context-snapshot/v1/index.schema.json b/docs/normative/entity-context-snapshot/v1/index.schema.json index 7254d36705..d89801d3a1 100644 --- a/docs/normative/entity-context-snapshot/v1/index.schema.json +++ b/docs/normative/entity-context-snapshot/v1/index.schema.json @@ -37,7 +37,7 @@ "if": { "properties": { "forge": { "const": "github" } }, "required": ["forge"] }, "then": { "properties": { - "repository_id": { "pattern": "^[A-Za-z0-9_=/+-]+$" }, + "repository_id": { "$ref": "common.schema.json#/$defs/github_node_id" }, "repository": { "pattern": "^[a-z0-9_.-]+/[a-z0-9_.-]+$" } } } @@ -80,6 +80,46 @@ "description": "At most one row per (scope, code) pair; producers aggregate counts before canonical serialization and sort by scope then code." } }, + "allOf": [ + { + "if": { + "properties": { + "source": { + "properties": { "forge": { "const": "github" } }, + "required": ["forge"] + } + }, + "required": ["source"] + }, + "then": { + "properties": { + "source": { + "properties": { + "repository_id": { "$ref": "common.schema.json#/$defs/github_node_id" } + } + }, + "entity": { + "properties": { + "id": { "$ref": "common.schema.json#/$defs/github_node_id" } + } + }, + "records": { + "items": { + "properties": { + "id": { "$ref": "common.schema.json#/$defs/github_node_id" }, + "author_id": { + "oneOf": [ + { "$ref": "common.schema.json#/$defs/github_node_id" }, + { "type": "null" } + ] + } + } + } + } + } + } + } + ], "additionalProperties": false, "$defs": { "filter": { From 8e6d1af91cb299b1de68f188165a041598215f05 Mon Sep 17 00:00:00 2001 From: Barak Korren Date: Wed, 23 Sep 2026 21:30:44 +0300 Subject: [PATCH 22/33] docs(#6407): clarify snapshot ordering names Make manifest and filename ordering rules explicit and finish the entity-context-snapshot terminology migration. Signed-off-by: Barak Korren Assisted-by: Codex (gpt-5.6-sol) --- .../entity-context-snapshot/v1/README.md | 25 +++++++++++-------- .../v1/collection.schema.json | 2 +- .../v1/common.schema.json | 2 +- .../v1/index.schema.json | 2 +- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/docs/normative/entity-context-snapshot/v1/README.md b/docs/normative/entity-context-snapshot/v1/README.md index d9c2542794..8127e58edc 100644 --- a/docs/normative/entity-context-snapshot/v1/README.md +++ b/docs/normative/entity-context-snapshot/v1/README.md @@ -327,8 +327,8 @@ identity's own effective permission on the target repository, never Fullsend's installation permission. A permission lookup failure, including a collaborator API 404, emits `role_verified: false` and `role: null`. -Entity-context and normalized-event v1 carry independently versioned copies of -the actor-role vocabulary. They match when this version is accepted, but a +Entity-context-snapshot and normalized-event v1 carry independently versioned +copies of the actor-role vocabulary. They match when this version is accepted, but a non-breaking role addition to normalized-event v1 does not extend this closed schema; a value must validate against the schema of every document that uses it. @@ -593,10 +593,14 @@ requires a new filter version. Removing or reinterpreting a status requires v2. ## Ordering and determinism -Manifest record arrays and record filenames are sorted by source `created_at`, -then by the record key's ASCII byte order. The reserved entity-body order key -sorts before them. Formal review arrays sort by `submitted_at` and then review -ID. Relationship thread arrays sort by `created_at` and then thread ID; each +Manifest `records[]` entries are sorted by each record's real source +`created_at`, then by the record key's ASCII byte order; the reserved +entity-body order key does not change this array order. Record filenames are +sorted by their filename order key, which reserves +`00000000T000000000000000Z` for the entity body so it sorts first. `files[]` +remains path-sorted, and check paths do not embed an order key. Formal review +arrays sort by `submitted_at` and then review ID. Relationship thread arrays +sort by `created_at` and then thread ID; each thread's `record_keys`, `replies`, and `.order` lines preserve forge thread order. Mutable thread-state arrays sort by the thread key's ASCII byte order. Actor-state arrays sort by actor ID's UTF-8 byte order. Agent receipts sort by @@ -656,10 +660,11 @@ reject them, and `schema_version` has no minor-version representation. ## Relationship to normalized-event v1 -Entity context stages only work items (issues) and change proposals (PRs or -MRs); normalized-event's `conversation` entity kind from ADR 0086 is outside -this version's scope. Entity-context `kind` uses normalized-event's `work_item` -and `change_proposal` values. Entity-context `id` is the forge's immutable +Entity-context-snapshot stages only work items (issues) and change proposals +(PRs or MRs); normalized-event's `conversation` entity kind from ADR 0086 is +outside this version's scope. Entity-context-snapshot `kind` uses +normalized-event's `work_item` and `change_proposal` values. +Entity-context-snapshot `id` is the forge's immutable opaque object ID because it participates in stable path derivation, while `number` is the positive display number projected into normalized-event `entity.id` for routing. Adapters must preserve that explicit mapping rather diff --git a/docs/normative/entity-context-snapshot/v1/collection.schema.json b/docs/normative/entity-context-snapshot/v1/collection.schema.json index 05e92639ab..d8577ccb99 100644 --- a/docs/normative/entity-context-snapshot/v1/collection.schema.json +++ b/docs/normative/entity-context-snapshot/v1/collection.schema.json @@ -1,7 +1,7 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://fullsend.ai/normative/entity-context-snapshot/v1/collection.schema.json", - "title": "EntityContextCollection", + "title": "EntityContextSnapshotCollection", "type": "object", "required": ["included_sources", "record_selection", "check_log_selection", "bounds"], "properties": { diff --git a/docs/normative/entity-context-snapshot/v1/common.schema.json b/docs/normative/entity-context-snapshot/v1/common.schema.json index 76432fb0e5..571627664d 100644 --- a/docs/normative/entity-context-snapshot/v1/common.schema.json +++ b/docs/normative/entity-context-snapshot/v1/common.schema.json @@ -1,7 +1,7 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://fullsend.ai/normative/entity-context-snapshot/v1/common.schema.json", - "title": "EntityContextCommonDefinitions", + "title": "EntityContextSnapshotCommonDefinitions", "$defs": { "timestamp": { "type": "string", diff --git a/docs/normative/entity-context-snapshot/v1/index.schema.json b/docs/normative/entity-context-snapshot/v1/index.schema.json index d89801d3a1..deae280f90 100644 --- a/docs/normative/entity-context-snapshot/v1/index.schema.json +++ b/docs/normative/entity-context-snapshot/v1/index.schema.json @@ -1,7 +1,7 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://fullsend.ai/normative/entity-context-snapshot/v1/index.schema.json", - "title": "EntityContextIndex", + "title": "EntityContextSnapshotIndex", "type": "object", "required": ["schema_version", "filter_version", "collection_profile", "filter", "source", "entity", "files", "records", "gaps"], "properties": { From 7f73bf3c60b619870179eeb9e4f3a37150898a11 Mon Sep 17 00:00:00 2001 From: Barak Korren Date: Wed, 23 Sep 2026 23:28:10 +0300 Subject: [PATCH 23/33] docs(#6407): tighten snapshot source and trust rules Constrain collection sources by entity kind, bind checks to the collected change-proposal HEAD, and require comment admission through the current authorization contract with baseline content filtering. Keep bot roles as audit data without treating Fullsend installation permissions as comment trust, and mark every snapshot-derived block untrusted for runtime consumption. Signed-off-by: Barak Korren Assisted-by: Codex (gpt-5.6-sol) --- .../entity-context-snapshot/v1/README.md | 59 ++++++++++++++++--- .../v1/check.schema.json | 6 +- .../v1/collection.schema.json | 16 ++++- 3 files changed, 71 insertions(+), 10 deletions(-) diff --git a/docs/normative/entity-context-snapshot/v1/README.md b/docs/normative/entity-context-snapshot/v1/README.md index 8127e58edc..a587c2be24 100644 --- a/docs/normative/entity-context-snapshot/v1/README.md +++ b/docs/normative/entity-context-snapshot/v1/README.md @@ -159,6 +159,19 @@ renaming an actor or repository, changing an actor's permission, or inserting an earlier record must not rename or rewrite an unchanged record. Changing its body or immutable attribution ID changes that record's bytes and digest. +Before a comment is admitted to the snapshot, the producer applies the +current [authorization contract](../../../normative/authorization/v1/README.md), +which implements ADR 0054 and its later, explicitly documented extensions. +Comments that are not authorized for the handled transition are omitted and +count in the `comments` scope's `authorization_failed` gap. The current +GitHub exceptions for label transitions and submitted bot reviews authorize +those specific transitions; they do not make arbitrary bot-authored comments +trusted, and v1 has no general bot allow-list. A future ADR may add an +additional trusted-bot mechanism. Every admitted comment still passes the +complete filter pipeline below, including Unicode safety that removes +invisible text and unnecessary control characters, secret redaction, prompt- +injection scanning, and byte bounds. + The initial issue or change-proposal body uses the same layout with `Fullsend-Record: "entity"`, the entity's stable ID, immutable author ID, and creation time. This makes it the first self-contained turn. @@ -201,7 +214,10 @@ files, leaving earlier record blocks byte-identical. A backfilled earlier record, edit, deletion, or attribution change invalidates reuse from the first affected block onward. Consumers never infer resolution from record content. -Check status is observation state in `checks//metadata.json`; its +Checks are a change-proposal-only source. A collection profile for a +`work_item` cannot select `reviews`, `checks`, or `check_logs`; those sources +are not represented as empty scopes or fetch gaps. Check status is observation +state in `checks//metadata.json`; its log file contains only filtered log bytes. A growing or replaced forge log is changed content and may change `log.txt`. A new check attempt has a new forge record ID and therefore a new record key; v1 has no separate synthesized @@ -223,6 +239,14 @@ report. It forbids `started_at` and is limited to `failure`, `skipped`, or must not set it on an ordinary `failure` merely because `started_at` is absent. Consumers must use the explicit flag and must not infer never-started state from an omitted timestamp. + +At collection start, the producer captures the target change-proposal HEAD +revision and retains only checks whose forge-reported revision equals that +`head_sha`. Every retained check records that exact SHA in its check metadata; +the field is required even when a forge exposes only a generic check-run +endpoint. A missing, malformed, or mismatched check revision is +`invalid_metadata` and the check is not emitted. The producer must not fetch +logs or synthesize a check for any other revision. Check manifest records carry `created_at` but no `author_id` or `author`. Adapters use these exhaustive v1 native-status mappings: @@ -325,7 +349,13 @@ from forge association labels such as GitHub `authorAssociation`. Each row states whether the actor is a `human` or `bot`. A bot's role is that bot identity's own effective permission on the target repository, never Fullsend's installation permission. A permission lookup failure, including a collaborator -API 404, emits `role_verified: false` and `role: null`. +API 404, emits `role_verified: false` and `role: null`. These roles are still +needed for auditability and for ordinary authorization decisions about human +authors, resolvers, and dismissers; they are not a content-trust signal. The +authorization contract documents the narrow transition-specific exceptions +for GitHub label changes and submitted bot reviews, which do not turn an +unverified bot role into Fullsend's installation role or authorize arbitrary +bot comments. Entity-context-snapshot and normalized-event v1 carry independently versioned copies of the actor-role vocabulary. They match when this version is accepted, but a @@ -356,6 +386,12 @@ that does not expose edit history. `collection.json` is the exact collection configuration and conforms to `collection.schema.json`. Its source-kind array sorts by ASCII byte order. +`entity_kind` must match the entity metadata kind. For `work_item`, the only +valid non-entity sources are `comments` and `agent_runs`; reviews, checks, and +check logs are inapplicable and cannot be selected. A profile that violates +these entity-kind rules is invalid before fetching or assembly and aborts +collection; it is never represented as an empty scope or an `unsupported` +gap. `change_proposal` profiles may select the full v1 source set. Non-entity records first enter the corresponding canonical order from [Ordering and determinism](#ordering-and-determinism); `record_selection` retains either the oldest or newest `max_records_per_source` entries for each @@ -395,8 +431,10 @@ For a retained check, the index record has `log_path` if and only if `check_log_selection` selected its log and filtering produced the file without an unusable `invalid_metadata` or `unsafe_content` gap. -Missing selected data is represented in `index.json.gaps`; it is never silently -treated as an empty history. Scopes are `entity`, `comments`, `reviews`, +Missing data from a valid selected source is represented in `index.json.gaps`; +it is never silently treated as an empty history. Inapplicable sources are +rejected by the collection profile before fetching and therefore do not create +an empty scope or a gap. Scopes are `entity`, `comments`, `reviews`, `checks`, `check_logs`, `agent_runs`, and `actors`. `profile_bound` and `history_unavailable` gaps have `usability: partial`; consumers may use present records but must not claim the scope is complete. `unsupported`, @@ -487,10 +525,15 @@ user, credential-file or environment exfiltration, hidden HTML instructions, and translate-then-execute requests. Exact patterns and thresholds are part of `filter_version`; ML detectors may supplement them only when their model, threshold, and deterministic execution contract are also versioned. No -detector reliably blocks every visible prompt injection. Runtimes therefore -mark staged records as untrusted data in distinct content blocks, prohibit -following instructions from those blocks, and retain least-privilege tool and -credential boundaries as the primary defense. +detector reliably blocks every visible prompt injection. The entire +entity-context-snapshot tree is therefore untrusted snapshot-derived data: +this includes `index.json`, entity metadata, relations, history, state, +check metadata and logs, order files, and all record bodies. Runtimes must +keep those blocks distinct from run-specific instructions, prohibit following +instructions from any snapshot-derived block, and retain least-privilege tool +and credential boundaries as the primary defense. Filtering and authorization +are not bot bypasses: a bot identity is subject to the same comment admission +and content filtering rules as a human identity. `filter.status` is: diff --git a/docs/normative/entity-context-snapshot/v1/check.schema.json b/docs/normative/entity-context-snapshot/v1/check.schema.json index 1688f4b74a..9300db01a3 100644 --- a/docs/normative/entity-context-snapshot/v1/check.schema.json +++ b/docs/normative/entity-context-snapshot/v1/check.schema.json @@ -3,13 +3,17 @@ "$id": "https://fullsend.ai/normative/entity-context-snapshot/v1/check.schema.json", "title": "CheckMetadata", "type": "object", - "required": ["id", "name", "status", "created_at"], + "required": ["id", "name", "status", "created_at", "head_sha"], "properties": { "id": { "$ref": "common.schema.json#/$defs/structural_id" }, "name": { "type": "string", "minLength": 1 }, "status": { "enum": ["queued", "in_progress", "completed"] }, "conclusion": { "enum": ["success", "failure", "neutral", "cancelled", "skipped", "timed_out", "action_required", "stale"] }, "created_at": { "$ref": "common.schema.json#/$defs/timestamp" }, + "head_sha": { + "$ref": "common.schema.json#/$defs/git_oid", + "description": "The target change-proposal HEAD SHA observed at collection time; only checks for that exact SHA are retained." + }, "started_at": { "$ref": "common.schema.json#/$defs/timestamp" }, "never_started": { "type": "boolean", diff --git a/docs/normative/entity-context-snapshot/v1/collection.schema.json b/docs/normative/entity-context-snapshot/v1/collection.schema.json index d8577ccb99..8b884ae25c 100644 --- a/docs/normative/entity-context-snapshot/v1/collection.schema.json +++ b/docs/normative/entity-context-snapshot/v1/collection.schema.json @@ -3,8 +3,12 @@ "$id": "https://fullsend.ai/normative/entity-context-snapshot/v1/collection.schema.json", "title": "EntityContextSnapshotCollection", "type": "object", - "required": ["included_sources", "record_selection", "check_log_selection", "bounds"], + "required": ["entity_kind", "included_sources", "record_selection", "check_log_selection", "bounds"], "properties": { + "entity_kind": { + "enum": ["work_item", "change_proposal"], + "description": "The forge entity kind being collected; source selection is constrained by this value." + }, "included_sources": { "type": "array", "items": { "enum": ["entity", "comments", "reviews", "checks", "check_logs", "agent_runs"] }, @@ -35,6 +39,16 @@ } }, "allOf": [ + { + "if": { "properties": { "entity_kind": { "const": "work_item" } }, "required": ["entity_kind"] }, + "then": { + "properties": { + "included_sources": { + "items": { "enum": ["entity", "comments", "agent_runs"] } + } + } + } + }, { "if": { "properties": { "included_sources": { "contains": { "const": "check_logs" } } }, "required": ["included_sources"] }, "then": { From 8f232f226e945611f53149c34e132fa8b0ccd00a Mon Sep 17 00:00:00 2001 From: Barak Korren Date: Thu, 24 Sep 2026 00:16:10 +0300 Subject: [PATCH 24/33] docs(#6407): represent bot actors explicitly Use role: bot for bot actors in the snapshot contract instead of attempting to map them to a human repository permission. Mark the value as a non-authority kind marker and reserve richer bot permission mapping for a future ADR. Signed-off-by: Barak Korren Assisted-by: Codex (gpt-5.6-sol) --- .../entity-context-snapshot/v1/README.md | 33 +++++++++---------- .../v1/actor-state.schema.json | 13 ++++++++ .../v1/common.schema.json | 2 +- 3 files changed, 30 insertions(+), 18 deletions(-) diff --git a/docs/normative/entity-context-snapshot/v1/README.md b/docs/normative/entity-context-snapshot/v1/README.md index a587c2be24..088482969b 100644 --- a/docs/normative/entity-context-snapshot/v1/README.md +++ b/docs/normative/entity-context-snapshot/v1/README.md @@ -343,25 +343,24 @@ rows make the `reviews` scope unusable and add an `invalid_metadata` gap. permission for each referenced author, resolver, and dismisser. Roles use the [ADR 0054](../../../ADRs/0054-require-authorization-on-all-agent-dispatch-paths.md) and normalized-event v1 vocabulary: `admin`, `maintain`, `write`, -`triage`, `read`, `none`, and `external`. `role_verified: false` is paired with -`role: null` and means consumers must fail closed rather than infer authority -from forge association labels such as GitHub `authorAssociation`. Each row -states whether the actor is a `human` or `bot`. A bot's role is that bot -identity's own effective permission on the target repository, never Fullsend's -installation permission. A permission lookup failure, including a collaborator -API 404, emits `role_verified: false` and `role: null`. These roles are still -needed for auditability and for ordinary authorization decisions about human -authors, resolvers, and dismissers; they are not a content-trust signal. The -authorization contract documents the narrow transition-specific exceptions -for GitHub label changes and submitted bot reviews, which do not turn an -unverified bot role into Fullsend's installation role or authorize arbitrary -bot comments. +`triage`, `read`, `none`, and `external`; snapshot actor state additionally +uses `bot` as an explicit non-authority marker. Each row states whether the +actor is a `human` or `bot`. For `kind: bot`, producers set `role: bot` and +`role_verified: true`: this records the known actor kind, not a repository +permission, and consumers must not use it to satisfy a human role gate. For +`kind: human`, `role_verified: false` is paired with `role: null` and means +consumers must fail closed rather than infer authority from forge association +labels such as GitHub `authorAssociation`; a permission lookup failure, +including a collaborator API 404, uses that representation. A future ADR may +define a verifiable bot-permission mapping. Until then, the authorization +contract's narrow transition-specific exceptions for GitHub label changes and +submitted bot reviews remain the only bot authorization paths; they do not +authorize arbitrary bot comments. Entity-context-snapshot and normalized-event v1 carry independently versioned -copies of the actor-role vocabulary. They match when this version is accepted, but a -non-breaking role addition to normalized-event v1 does not extend this closed -schema; a value must validate against the schema of every document that uses -it. +copies of the actor-role vocabulary. The snapshot-only `bot` marker is not a +normalized-event repository permission and must not be projected into one; +each value must validate against the schema of the document that uses it. Every non-null `author_id`, `resolved_by_actor_id`, and `dismissed_by_actor_id` referenced anywhere in the snapshot appears exactly diff --git a/docs/normative/entity-context-snapshot/v1/actor-state.schema.json b/docs/normative/entity-context-snapshot/v1/actor-state.schema.json index a981b5c883..4eefc4c8d7 100644 --- a/docs/normative/entity-context-snapshot/v1/actor-state.schema.json +++ b/docs/normative/entity-context-snapshot/v1/actor-state.schema.json @@ -24,6 +24,19 @@ "role_verified": { "type": "boolean" } }, "allOf": [ + { + "if": { "properties": { "kind": { "const": "bot" } }, "required": ["kind"] }, + "then": { + "properties": { + "role": { "const": "bot" }, + "role_verified": { "const": true } + } + } + }, + { + "if": { "properties": { "kind": { "const": "human" } }, "required": ["kind"] }, + "then": { "properties": { "role": { "not": { "const": "bot" } } } } + }, { "if": { "properties": { "role_verified": { "const": true } }, "required": ["role_verified"] }, "then": { "properties": { "role": { "$ref": "common.schema.json#/$defs/actor_role" } } }, diff --git a/docs/normative/entity-context-snapshot/v1/common.schema.json b/docs/normative/entity-context-snapshot/v1/common.schema.json index 571627664d..b725b48858 100644 --- a/docs/normative/entity-context-snapshot/v1/common.schema.json +++ b/docs/normative/entity-context-snapshot/v1/common.schema.json @@ -44,7 +44,7 @@ ] }, "actor_role": { - "enum": ["admin", "maintain", "write", "triage", "read", "none", "external"] + "enum": ["admin", "maintain", "write", "triage", "read", "none", "external", "bot"] } } } From c7230220f8190c13d63a0ca385bf23bdcdb77b36 Mon Sep 17 00:00:00 2001 From: Barak Korren Date: Thu, 24 Sep 2026 10:42:30 +0300 Subject: [PATCH 25/33] docs(#6407): align revision references across contracts Document check head_sha as a permitted repository revision anchor in the ADR and snapshot tree, and make the normalized-event cross-reference explicit that the snapshot bot marker is not an event permission. Signed-off-by: Barak Korren Assisted-by: Codex (gpt-5.6-sol) --- .../0107-deterministic-filtered-entity-context-staging.md | 4 ++-- docs/normative/entity-context-snapshot/v1/README.md | 5 +++-- docs/normative/normalized-event/v1/README.md | 8 ++++---- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/docs/ADRs/0107-deterministic-filtered-entity-context-staging.md b/docs/ADRs/0107-deterministic-filtered-entity-context-staging.md index ebc2481ba8..f8165ba651 100644 --- a/docs/ADRs/0107-deterministic-filtered-entity-context-staging.md +++ b/docs/ADRs/0107-deterministic-filtered-entity-context-staging.md @@ -78,8 +78,8 @@ 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 only to relate reviews, threads, comments, and agent runs -to repository state. +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 diff --git a/docs/normative/entity-context-snapshot/v1/README.md b/docs/normative/entity-context-snapshot/v1/README.md index 088482969b..ae9fca9d2e 100644 --- a/docs/normative/entity-context-snapshot/v1/README.md +++ b/docs/normative/entity-context-snapshot/v1/README.md @@ -125,8 +125,9 @@ The tree contains forge entity state that is not reconstructible from the target Git checkout. Diffs, commits, changed-file lists, branches, and revision topology are repository context and are not staged here. Fullsend provides the required Git objects and refs separately, and controllers may derive filtered -diff or history projections outside this tree. Git object IDs occur here only -as relationship values in review, thread, and agent-run documents. +diff or history projections outside this tree. Git object IDs occur here as +relationship values in review, thread, and agent-run documents, and as the +collected target revision in check metadata `head_sha`. Comment and review Markdown files are self-contained records with this exact UTF-8 layout; header values are canonical JSON strings (or `null`) on one line: diff --git a/docs/normative/normalized-event/v1/README.md b/docs/normative/normalized-event/v1/README.md index 9eed4a5f0a..d86fb420af 100644 --- a/docs/normative/normalized-event/v1/README.md +++ b/docs/normative/normalized-event/v1/README.md @@ -86,10 +86,10 @@ Adding a new `transition.kind` is **non-breaking** — CEL triggers use boolean expressions, not exhaustive enum matching. Normalized-event and entity-context-snapshot v1 carry independently versioned -copies of the actor-role vocabulary. They match when entity-context-snapshot v1 -is accepted, but a role added non-breakingly here does not extend -entity-context-snapshot's closed v1 schema; adapters validate each document -against its own schema. +copies of the actor-role vocabulary. The entity-context-snapshot `bot` marker +is a non-authority kind marker, not a normalized-event repository permission, +and must not be projected into `event.actor.role`; adapters validate each +document against its own schema. ## Adapters From 911f1f01605422398b2e952227f31536fd7391d2 Mon Sep 17 00:00:00 2001 From: Barak Korren Date: Thu, 24 Sep 2026 11:35:40 +0300 Subject: [PATCH 26/33] docs(#6407): keep bot roles unverified Retain role: bot as an explicit actor-kind marker while keeping role_verified false and actor_role limited to repository permissions. This preserves fail-closed consumers until a future ADR defines verifiable bot permission mapping. Signed-off-by: Barak Korren Assisted-by: Codex (gpt-5.6-sol) --- .../entity-context-snapshot/v1/README.md | 25 ++++++++++--------- .../v1/actor-state.schema.json | 9 +++++-- .../v1/common.schema.json | 2 +- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/docs/normative/entity-context-snapshot/v1/README.md b/docs/normative/entity-context-snapshot/v1/README.md index ae9fca9d2e..d756918c6f 100644 --- a/docs/normative/entity-context-snapshot/v1/README.md +++ b/docs/normative/entity-context-snapshot/v1/README.md @@ -345,18 +345,19 @@ permission for each referenced author, resolver, and dismisser. Roles use the [ADR 0054](../../../ADRs/0054-require-authorization-on-all-agent-dispatch-paths.md) and normalized-event v1 vocabulary: `admin`, `maintain`, `write`, `triage`, `read`, `none`, and `external`; snapshot actor state additionally -uses `bot` as an explicit non-authority marker. Each row states whether the -actor is a `human` or `bot`. For `kind: bot`, producers set `role: bot` and -`role_verified: true`: this records the known actor kind, not a repository -permission, and consumers must not use it to satisfy a human role gate. For -`kind: human`, `role_verified: false` is paired with `role: null` and means -consumers must fail closed rather than infer authority from forge association -labels such as GitHub `authorAssociation`; a permission lookup failure, -including a collaborator API 404, uses that representation. A future ADR may -define a verifiable bot-permission mapping. Until then, the authorization -contract's narrow transition-specific exceptions for GitHub label changes and -submitted bot reviews remain the only bot authorization paths; they do not -authorize arbitrary bot comments. +accepts `role: bot` as an explicit non-authority marker outside that +permission-only enum. Each row states whether the actor is a `human` or +`bot`. For `kind: bot`, producers set `role: bot` and `role_verified: false`: +the marker records the known actor kind, while the false verification bit +records that no repository permission was resolved. For `kind: human`, +`role_verified: false` is paired with `role: null` and means consumers must +fail closed rather than infer authority from forge association labels such as +GitHub `authorAssociation`; a permission lookup failure, including a +collaborator API 404, uses that representation. A future ADR may define a +verifiable bot-permission mapping. Until then, the authorization contract's +narrow transition-specific exceptions for GitHub label changes and submitted +bot reviews remain the only bot authorization paths; they do not authorize +arbitrary bot comments. Entity-context-snapshot and normalized-event v1 carry independently versioned copies of the actor-role vocabulary. The snapshot-only `bot` marker is not a diff --git a/docs/normative/entity-context-snapshot/v1/actor-state.schema.json b/docs/normative/entity-context-snapshot/v1/actor-state.schema.json index 4eefc4c8d7..1b0f58b119 100644 --- a/docs/normative/entity-context-snapshot/v1/actor-state.schema.json +++ b/docs/normative/entity-context-snapshot/v1/actor-state.schema.json @@ -18,6 +18,7 @@ "role": { "oneOf": [ { "$ref": "common.schema.json#/$defs/actor_role" }, + { "const": "bot" }, { "type": "null" } ] }, @@ -29,7 +30,7 @@ "then": { "properties": { "role": { "const": "bot" }, - "role_verified": { "const": true } + "role_verified": { "const": false } } } }, @@ -40,7 +41,11 @@ { "if": { "properties": { "role_verified": { "const": true } }, "required": ["role_verified"] }, "then": { "properties": { "role": { "$ref": "common.schema.json#/$defs/actor_role" } } }, - "else": { "properties": { "role": { "type": "null" } } } + "else": { + "properties": { + "role": { "oneOf": [{ "const": "bot" }, { "type": "null" }] } + } + } } ], "additionalProperties": false diff --git a/docs/normative/entity-context-snapshot/v1/common.schema.json b/docs/normative/entity-context-snapshot/v1/common.schema.json index b725b48858..571627664d 100644 --- a/docs/normative/entity-context-snapshot/v1/common.schema.json +++ b/docs/normative/entity-context-snapshot/v1/common.schema.json @@ -44,7 +44,7 @@ ] }, "actor_role": { - "enum": ["admin", "maintain", "write", "triage", "read", "none", "external", "bot"] + "enum": ["admin", "maintain", "write", "triage", "read", "none", "external"] } } } From 5724b82aed3adcf01de5876fc89b813fc4471fbe Mon Sep 17 00:00:00 2001 From: Barak Korren Date: Thu, 24 Sep 2026 11:49:20 +0300 Subject: [PATCH 27/33] docs(#6407): make comment admission policy explicit Record that v1 intentionally applies the run authorization policy to historical comment admission, omitting comments from unauthorized actors while retaining the required entity body. Preserve the narrow trust boundary and leave broader comment or bot trust to future ADRs. Signed-off-by: Barak Korren Assisted-by: Codex (gpt-5.6-sol) --- .../entity-context-snapshot/v1/README.md | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/docs/normative/entity-context-snapshot/v1/README.md b/docs/normative/entity-context-snapshot/v1/README.md index d756918c6f..3b53cbc7c0 100644 --- a/docs/normative/entity-context-snapshot/v1/README.md +++ b/docs/normative/entity-context-snapshot/v1/README.md @@ -163,15 +163,20 @@ body or immutable attribution ID changes that record's bytes and digest. Before a comment is admitted to the snapshot, the producer applies the current [authorization contract](../../../normative/authorization/v1/README.md), which implements ADR 0054 and its later, explicitly documented extensions. -Comments that are not authorized for the handled transition are omitted and -count in the `comments` scope's `authorization_failed` gap. The current +ADR 0054 is fundamentally a dispatch gate; this ADR deliberately reuses its +run-specific handled-transition and target-agent policy as a narrower v1 +historical-comment admission gate. Comments whose authors do not satisfy the +policy are omitted and count in the `comments` scope's `authorization_failed` +gap, rather than exposing the conversation to an agent that could not have +been triggered by that actor. The required entity body is always staged; this +admission rule applies to conversation comments and reviews. The current GitHub exceptions for label transitions and submitted bot reviews authorize those specific transitions; they do not make arbitrary bot-authored comments -trusted, and v1 has no general bot allow-list. A future ADR may add an -additional trusted-bot mechanism. Every admitted comment still passes the -complete filter pipeline below, including Unicode safety that removes -invisible text and unnecessary control characters, secret redaction, prompt- -injection scanning, and byte bounds. +trusted, and v1 has no general bot allow-list. A future ADR may broaden this +trust boundary or add an additional trusted-bot mechanism. Every admitted +comment still passes the complete filter pipeline below, including Unicode +safety that removes invisible text and unnecessary control characters, secret +redaction, prompt-injection scanning, and byte bounds. The initial issue or change-proposal body uses the same layout with `Fullsend-Record: "entity"`, the entity's stable ID, immutable author ID, and From 3bb70432c8f8421474906932a1a86e0e71aaacc9 Mon Sep 17 00:00:00 2001 From: Barak Korren Date: Thu, 24 Sep 2026 12:58:10 +0300 Subject: [PATCH 28/33] docs(#6407): separate role trust from event authorization Use ADR 0054 role ordering and agent thresholds for historical comment admission without importing transition-specific event exceptions. Document that eligible invokers are trusted command sources for v1 while unauthorized comments remain omitted until a future trust-boundary ADR. Signed-off-by: Barak Korren Assisted-by: Codex (gpt-5.6-sol) --- .../entity-context-snapshot/v1/README.md | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/docs/normative/entity-context-snapshot/v1/README.md b/docs/normative/entity-context-snapshot/v1/README.md index 3b53cbc7c0..28a0b5360b 100644 --- a/docs/normative/entity-context-snapshot/v1/README.md +++ b/docs/normative/entity-context-snapshot/v1/README.md @@ -163,20 +163,23 @@ body or immutable attribution ID changes that record's bytes and digest. Before a comment is admitted to the snapshot, the producer applies the current [authorization contract](../../../normative/authorization/v1/README.md), which implements ADR 0054 and its later, explicitly documented extensions. -ADR 0054 is fundamentally a dispatch gate; this ADR deliberately reuses its -run-specific handled-transition and target-agent policy as a narrower v1 -historical-comment admission gate. Comments whose authors do not satisfy the -policy are omitted and count in the `comments` scope's `authorization_failed` -gap, rather than exposing the conversation to an agent that could not have -been triggered by that actor. The required entity body is always staged; this -admission rule applies to conversation comments and reviews. The current -GitHub exceptions for label transitions and submitted bot reviews authorize -those specific transitions; they do not make arbitrary bot-authored comments -trusted, and v1 has no general bot allow-list. A future ADR may broaden this -trust boundary or add an additional trusted-bot mechanism. Every admitted -comment still passes the complete filter pipeline below, including Unicode -safety that removes invisible text and unnecessary control characters, secret -redaction, prompt-injection scanning, and byte bounds. +This ADR deliberately borrows only that contract's forge-neutral role ordering +and minimum-role thresholds for the selected agent category: observation +agents require `triage` or above, while mutation agents require `write` or +above. It does not apply event-specific `transition.kind` rules or exceptions +because comment admission is not event authorization. A comment author whose +verified role meets the selected agent threshold is trusted as an eligible +command source and the comment is admitted; lower or unverified roles are +omitted and count in the `comments` scope's `authorization_failed` gap. This +is the intentional v1 trust boundary: users who may invoke the agent may also +provide its command inputs. The required entity body is always staged; this +admission rule applies to conversation comments and reviews. Bot actors do not +have a verified repository role in v1, so their comments remain outside this +trust boundary until a future ADR defines bot-role resolution or an explicit +allow-list. Every admitted comment still passes the complete filter pipeline +below, including Unicode safety that removes invisible text and unnecessary +control characters, secret redaction, prompt-injection scanning, and byte +bounds. The initial issue or change-proposal body uses the same layout with `Fullsend-Record: "entity"`, the entity's stable ID, immutable author ID, and From 283fbe496f85e9e987e0162586b1b50cf1bcb157 Mon Sep 17 00:00:00 2001 From: Barak Korren Date: Thu, 24 Sep 2026 12:59:28 +0300 Subject: [PATCH 29/33] docs(#6407): account for filtered reviews Count formal reviews omitted by the v1 role-based admission policy in the reviews authorization_failed gap, keeping comment and review scope outcomes consistent. Signed-off-by: Barak Korren Assisted-by: Codex (gpt-5.6-sol) --- docs/normative/entity-context-snapshot/v1/README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/normative/entity-context-snapshot/v1/README.md b/docs/normative/entity-context-snapshot/v1/README.md index 28a0b5360b..2003e21f14 100644 --- a/docs/normative/entity-context-snapshot/v1/README.md +++ b/docs/normative/entity-context-snapshot/v1/README.md @@ -176,10 +176,12 @@ provide its command inputs. The required entity body is always staged; this admission rule applies to conversation comments and reviews. Bot actors do not have a verified repository role in v1, so their comments remain outside this trust boundary until a future ADR defines bot-role resolution or an explicit -allow-list. Every admitted comment still passes the complete filter pipeline -below, including Unicode safety that removes invisible text and unnecessary -control characters, secret redaction, prompt-injection scanning, and byte -bounds. +allow-list. An omitted formal review is counted in the `reviews` scope's +`authorization_failed` gap by the same rule; it is not charged only to +`comments`. Every admitted comment or review still passes the complete filter +pipeline below, including Unicode safety that removes invisible text and +unnecessary control characters, secret redaction, prompt-injection scanning, +and byte bounds. The initial issue or change-proposal body uses the same layout with `Fullsend-Record: "entity"`, the entity's stable ID, immutable author ID, and From c6f7107d6a9127d3ffb9951530cf22294586eadf Mon Sep 17 00:00:00 2001 From: Barak Korren Date: Wed, 14 Oct 2026 08:59:38 +0300 Subject: [PATCH 30/33] docs(#6407): align entity snapshot security boundary Renumber the entity-context-snapshot ADR to 0141 after syncing with upstream main. Reference ADR 0133, ADR 0054, and ADR 0098 for actor attribution, role thresholds, discovery provenance, and filtering instead of duplicating their security contracts. Update the normative specification and living-document links while preserving upstream ADR 0107 bot-identity references. Signed-off-by: Barak Korren Assisted-by: Codex (gpt-5.6-sol) --- ...edential-isolation-for-sandboxed-agents.md | 2 +- ...slash-command-entity-context-separation.md | 2 +- ...nistic-filtered-entity-context-staging.md} | 28 +++++++++++++++++-- docs/architecture.md | 3 +- .../entity-context-snapshot/v1/README.md | 3 +- docs/problems/security-threat-model.md | 3 +- 6 files changed, 34 insertions(+), 7 deletions(-) rename docs/ADRs/{0107-deterministic-filtered-entity-context-staging.md => 0141-deterministic-filtered-entity-context-staging.md} (83%) diff --git a/docs/ADRs/0017-credential-isolation-for-sandboxed-agents.md b/docs/ADRs/0017-credential-isolation-for-sandboxed-agents.md index a3b6b34a0a..fc0ba88326 100644 --- a/docs/ADRs/0017-credential-isolation-for-sandboxed-agents.md +++ b/docs/ADRs/0017-credential-isolation-for-sandboxed-agents.md @@ -19,7 +19,7 @@ Date: 2026-04-01 Accepted (credential delivery tiers extended by [ADR 0025](0025-provider-credential-delivery-for-sandboxed-agents.md)) The default prefetch model is standardized for handled entity content by -[ADR 0107](0107-deterministic-filtered-entity-context-staging.md). +[ADR 0141](0141-deterministic-filtered-entity-context-staging.md). ## Context diff --git a/docs/ADRs/0076-slash-command-entity-context-separation.md b/docs/ADRs/0076-slash-command-entity-context-separation.md index 1d2f4ee460..2a78da1e01 100644 --- a/docs/ADRs/0076-slash-command-entity-context-separation.md +++ b/docs/ADRs/0076-slash-command-entity-context-separation.md @@ -21,7 +21,7 @@ Extends entity-context rules for conversation surfaces in [ADR 0086](0086-conversation-surface-for-agent-participation.md). Terminology note: this ADR uses *entity context* for a dispatch-layer routing -category. [ADR 0107](0107-deterministic-filtered-entity-context-staging.md) +category. [ADR 0141](0141-deterministic-filtered-entity-context-staging.md) later names the distinct filtered data snapshot staged for a handled Git-forge entity *entity-context-snapshot*. diff --git a/docs/ADRs/0107-deterministic-filtered-entity-context-staging.md b/docs/ADRs/0141-deterministic-filtered-entity-context-staging.md similarity index 83% rename from docs/ADRs/0107-deterministic-filtered-entity-context-staging.md rename to docs/ADRs/0141-deterministic-filtered-entity-context-staging.md index f8165ba651..1c8a76be37 100644 --- a/docs/ADRs/0107-deterministic-filtered-entity-context-staging.md +++ b/docs/ADRs/0141-deterministic-filtered-entity-context-staging.md @@ -1,5 +1,5 @@ --- -title: "107. Deterministic filtered entity-context-snapshot staging" +title: "141. Deterministic filtered entity-context-snapshot staging" status: Accepted relates_to: - agent-architecture @@ -11,7 +11,7 @@ topics: - token-cost --- -# 107. Deterministic filtered entity-context-snapshot staging +# 141. Deterministic filtered entity-context-snapshot staging Date: 2026-09-07 @@ -40,6 +40,14 @@ from the dispatch-layer routing category called entity context in name is intentional: it identifies the data structure without redefining ADR 0076's established routing term. +[ADR 0133](0133-actor-attributed-data-security-boundary.md) 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 @@ -52,6 +60,18 @@ 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](0054-require-authorization-on-all-agent-dispatch-paths.md) +and [ADR 0098](0098-entity-first-harness-evaluation.md). 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. The v1 snapshot profile intentionally retains its stricter bot +boundary until a future ADR defines verifiable bot-role admission. Successful +authorization is therefore an admission prerequisite, not a claim that the +record is trustworthy or can change platform authority. + 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 @@ -138,3 +158,7 @@ only bounded counts, digests, and filtering findings, never bodies or logs. - 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. diff --git a/docs/architecture.md b/docs/architecture.md index dcfba16ad7..56d60b32ac 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -191,7 +191,8 @@ repo baseline and overrides) relationship anchors. Scripts and the sandbox use `FULLSEND_CONTEXT_DIR` with the same relative paths; runtimes may inject ordered records as separate cacheable input blocks - ([ADR 0107](ADRs/0107-deterministic-filtered-entity-context-staging.md)). + ([ADR 0141](ADRs/0141-deterministic-filtered-entity-context-staging.md), + constrained by [ADR 0133](ADRs/0133-actor-attributed-data-security-boundary.md)). - CEL-guarded overlays: an `overlays:` list of CEL-guarded config overlays generalizes the `forge:` block, letting harness authors condition scripts, skills, env vars, and other fields on any event diff --git a/docs/normative/entity-context-snapshot/v1/README.md b/docs/normative/entity-context-snapshot/v1/README.md index 2003e21f14..fdb5bbc9e4 100644 --- a/docs/normative/entity-context-snapshot/v1/README.md +++ b/docs/normative/entity-context-snapshot/v1/README.md @@ -1,7 +1,8 @@ # Entity-context-snapshot v1 This specification defines the deterministic, filtered entity-context-snapshot -adopted by [ADR 0107](../../../ADRs/0107-deterministic-filtered-entity-context-staging.md). +adopted by [ADR 0141](../../../ADRs/0141-deterministic-filtered-entity-context-staging.md) +under the actor-attributed data boundary in [ADR 0133](../../../ADRs/0133-actor-attributed-data-security-boundary.md). It is the contract between forge adapters, `fullsend run`, harness scripts, and agent runtimes. diff --git a/docs/problems/security-threat-model.md b/docs/problems/security-threat-model.md index ca3520cbc5..c5513c542d 100644 --- a/docs/problems/security-threat-model.md +++ b/docs/problems/security-threat-model.md @@ -59,7 +59,8 @@ The attack surface is the same as for visible prompt injection — PR descriptio - **Input sanitization** — strip or flag non-rendering Unicode characters before content reaches agents. Specific character classes to target: Tag characters (U+E0000–U+E007F), zero-width characters (U+200B, U+200C, U+200D, U+FEFF), bidirectional overrides (U+202A–U+202E, U+2066–U+2069), and variation selectors. This is more tractable than general prompt injection detection because the characters themselves are the signal — their mere presence in a PR description or code comment is suspicious, regardless of what they encode. However, some of these characters have legitimate uses in internationalized text, so stripping must be context-aware or at minimum flag rather than silently remove. Deterministic filtering and finding disclosure for fetched entity content is - decided in [ADR 0107](../ADRs/0107-deterministic-filtered-entity-context-staging.md). + decided in [ADR 0141](../ADRs/0141-deterministic-filtered-entity-context-staging.md) + under the actor-attributed admission and filtering boundary of [ADR 0133](../ADRs/0133-actor-attributed-data-security-boundary.md). - **Separation of data and instructions** — agent prompts should clearly delineate between "system instructions" and "untrusted input being analyzed" - **Multi-agent verification** — a reviewing agent's decision is checked by a separate security agent that specifically looks for injection patterns - **Principle of least privilege** — agents should have the minimum permissions needed. A reviewing agent doesn't need merge authority. From f251019e4a2bfc0fed7999d10704555ecedc21ba Mon Sep 17 00:00:00 2001 From: Barak Korren Date: Wed, 14 Oct 2026 09:21:33 +0300 Subject: [PATCH 31/33] docs(#6407): admit registered bot comments Align the entity-context-snapshot v1 boundary with ADR 0107 and ADR 0133. Registered bots with an exact provider-backed actor.bot_role may contribute comments and reviews; unknown or unresolved bots remain omitted and fail closed. Signed-off-by: Barak Korren Assisted-by: Codex (gpt-5.6-sol) --- ...inistic-filtered-entity-context-staging.md | 12 +++-- .../entity-context-snapshot/v1/README.md | 47 +++++++++++-------- 2 files changed, 35 insertions(+), 24 deletions(-) diff --git a/docs/ADRs/0141-deterministic-filtered-entity-context-staging.md b/docs/ADRs/0141-deterministic-filtered-entity-context-staging.md index 1c8a76be37..87d1fb0a2f 100644 --- a/docs/ADRs/0141-deterministic-filtered-entity-context-staging.md +++ b/docs/ADRs/0141-deterministic-filtered-entity-context-staging.md @@ -67,10 +67,14 @@ 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. The v1 snapshot profile intentionally retains its stricter bot -boundary until a future ADR defines verifiable bot-role admission. Successful -authorization is therefore an admission prerequisite, not a claim that the -record is trustworthy or can change platform authority. +filtered text. For a bot actor, Fullsend uses the provider-backed exact +`actor.bot_role` recognition defined by [ADR 0107](0107-bot-identity-resolution-for-dispatch-authorization.md); +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 snapshot is written outside the repository clone. Host-side pre- and post-scripts receive `FULLSEND_CONTEXT_DIR` pointing to an access-restricted diff --git a/docs/normative/entity-context-snapshot/v1/README.md b/docs/normative/entity-context-snapshot/v1/README.md index fdb5bbc9e4..90f4a9f6c5 100644 --- a/docs/normative/entity-context-snapshot/v1/README.md +++ b/docs/normative/entity-context-snapshot/v1/README.md @@ -168,21 +168,26 @@ This ADR deliberately borrows only that contract's forge-neutral role ordering and minimum-role thresholds for the selected agent category: observation agents require `triage` or above, while mutation agents require `write` or above. It does not apply event-specific `transition.kind` rules or exceptions -because comment admission is not event authorization. A comment author whose -verified role meets the selected agent threshold is trusted as an eligible -command source and the comment is admitted; lower or unverified roles are -omitted and count in the `comments` scope's `authorization_failed` gap. This -is the intentional v1 trust boundary: users who may invoke the agent may also -provide its command inputs. The required entity body is always staged; this -admission rule applies to conversation comments and reviews. Bot actors do not -have a verified repository role in v1, so their comments remain outside this -trust boundary until a future ADR defines bot-role resolution or an explicit -allow-list. An omitted formal review is counted in the `reviews` scope's -`authorization_failed` gap by the same rule; it is not charged only to -`comments`. Every admitted comment or review still passes the complete filter -pipeline below, including Unicode safety that removes invisible text and -unnecessary control characters, secret redaction, prompt-injection scanning, -and byte bounds. +because comment admission is not event authorization. A human comment author +whose verified role meets the selected agent threshold is trusted as an +eligible command source and the comment is admitted; lower or unverified human +roles are omitted and count in the `comments` scope's `authorization_failed` +gap. For a bot actor, the producer MUST establish provider-positive bot identity +and resolve the exact registered `actor.bot_role` under [ADR 0107](../../../ADRs/0107-bot-identity-resolution-for-dispatch-authorization.md). +The bot's snapshot actor state retains `role: bot`; the human repository-role +threshold does not apply. A bot with no recognized role, or with an unavailable +or unverifiable lookup, is omitted and counted in the same authorization gap. +This is the intentional v1 trust boundary: users who may invoke the agent, and +Fullsend-registered bots admitted by ADR 0107, may provide its command inputs. +The required entity body is always staged; this admission rule applies to +conversation comments and reviews. Label-transition and bot-review event +exceptions authorize an event path only; they do not by themselves authorize +arbitrary bot-authored comment content. An omitted formal review is counted in +the `reviews` scope's `authorization_failed` gap by the same rule; it is not +charged only to `comments`. Every admitted comment or review still passes the +complete filter pipeline below, including Unicode safety that removes invisible +text and unnecessary control characters, secret redaction, prompt-injection +scanning, and byte bounds. The initial issue or change-proposal body uses the same layout with `Fullsend-Record: "entity"`, the entity's stable ID, immutable author ID, and @@ -360,15 +365,17 @@ accepts `role: bot` as an explicit non-authority marker outside that permission-only enum. Each row states whether the actor is a `human` or `bot`. For `kind: bot`, producers set `role: bot` and `role_verified: false`: the marker records the known actor kind, while the false verification bit -records that no repository permission was resolved. For `kind: human`, +records that no human repository permission was resolved; it does not negate a +separate, successful ADR 0107 `actor.bot_role` admission check. For `kind: human`, `role_verified: false` is paired with `role: null` and means consumers must fail closed rather than infer authority from forge association labels such as GitHub `authorAssociation`; a permission lookup failure, including a collaborator API 404, uses that representation. A future ADR may define a -verifiable bot-permission mapping. Until then, the authorization contract's -narrow transition-specific exceptions for GitHub label changes and submitted -bot reviews remain the only bot authorization paths; they do not authorize -arbitrary bot comments. +broader provider-backed bot allow-list or mapping, but registered bot roles +already follow ADR 0107. The authorization contract's narrow +transition-specific exceptions for GitHub label changes and submitted bot +reviews remain event-path exceptions; they do not authorize arbitrary bot +comments without the applicable bot-role admission. Entity-context-snapshot and normalized-event v1 carry independently versioned copies of the actor-role vocabulary. The snapshot-only `bot` marker is not a From bae8744d5f4dda850da5d492bc02f20250b41228 Mon Sep 17 00:00:00 2001 From: Barak Korren Date: Wed, 14 Oct 2026 09:48:28 +0300 Subject: [PATCH 32/33] docs(#6407): close snapshot admission gaps Require entity bodies to pass actor attribution and authorization before staging, include the effective human admission threshold in collection profiles, scan structural paths, and define no-follow verification and complete determinism inputs. Signed-off-by: Barak Korren Assisted-by: Codex (gpt-5.6-sol) --- ...inistic-filtered-entity-context-staging.md | 6 +++ .../entity-context-snapshot/v1/README.md | 52 +++++++++++++------ .../v1/collection.schema.json | 13 ++++- 3 files changed, 55 insertions(+), 16 deletions(-) diff --git a/docs/ADRs/0141-deterministic-filtered-entity-context-staging.md b/docs/ADRs/0141-deterministic-filtered-entity-context-staging.md index 87d1fb0a2f..72221afd37 100644 --- a/docs/ADRs/0141-deterministic-filtered-entity-context-staging.md +++ b/docs/ADRs/0141-deterministic-filtered-entity-context-staging.md @@ -76,6 +76,12 @@ 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 diff --git a/docs/normative/entity-context-snapshot/v1/README.md b/docs/normative/entity-context-snapshot/v1/README.md index 90f4a9f6c5..dc8e9c5509 100644 --- a/docs/normative/entity-context-snapshot/v1/README.md +++ b/docs/normative/entity-context-snapshot/v1/README.md @@ -179,15 +179,19 @@ threshold does not apply. A bot with no recognized role, or with an unavailable or unverifiable lookup, is omitted and counted in the same authorization gap. This is the intentional v1 trust boundary: users who may invoke the agent, and Fullsend-registered bots admitted by ADR 0107, may provide its command inputs. -The required entity body is always staged; this admission rule applies to -conversation comments and reviews. Label-transition and bot-review event -exceptions authorize an event path only; they do not by themselves authorize -arbitrary bot-authored comment content. An omitted formal review is counted in -the `reviews` scope's `authorization_failed` gap by the same rule; it is not -charged only to `comments`. Every admitted comment or review still passes the -complete filter pipeline below, including Unicode safety that removes invisible -text and unnecessary control characters, secret redaction, prompt-injection -scanning, and byte bounds. +The handled entity body is actor-attributed content and MUST pass the same +current-revision attribution and authorization rule before it is staged. A +missing, unverifiable, unauthorized, or unsafe entity body emits an +entity-scope `authorization_failed` or filtering gap and aborts assembly; the +required entity body is required only after successful admission and filtering. +Label-transition and bot-review event exceptions authorize an event path only; +they do not by themselves authorize arbitrary bot-authored comment content. An +omitted formal review is counted in the `reviews` scope's +`authorization_failed` gap by the same rule; it is not charged only to +`comments`. Every admitted entity, comment, or review still passes the complete +filter pipeline below, including Unicode safety that removes invisible text and +unnecessary control characters, secret redaction, prompt-injection scanning, +and byte bounds. The initial issue or change-proposal body uses the same layout with `Fullsend-Record: "entity"`, the entity's stable ID, immutable author ID, and @@ -405,7 +409,11 @@ that does not expose edit history. `collection.json` is the exact collection configuration and conforms to `collection.schema.json`. Its source-kind array sorts by ASCII byte order. -`entity_kind` must match the entity metadata kind. For `work_item`, the only +The required `admission.human_min_role` records the effective per-record human +threshold (`triage` for observation or `write` for mutation); registered bot +roles follow ADR 0107 and do not use that human threshold. The producer derives +this value from the selected harness before serializing and hashing +`collection.json`. `entity_kind` must match the entity metadata kind. For `work_item`, the only valid non-entity sources are `comments` and `agent_runs`; reviews, checks, and check logs are inapplicable and cannot be selected. A profile that violates these entity-kind rules is invalid before fetching or assembly and aborts @@ -582,8 +590,11 @@ configured provider trust boundary, not by this cleanup guarantee. Structural strings are not rewritten because doing so could change identity or target a different resource. Canonical IDs use the mappings above. Repository -paths and review file paths first undergo the Unicode-safety scan and then strict -structural validation. The `repository_path` and `source.host` schema patterns +paths and review file paths MUST undergo the complete source-value filter +pipeline, including Unicode safety, secret redaction, and prompt-injection +scanning, before strict structural validation. An unsafe path is never rewritten: +the producer omits the affected optional record or relationship, and aborts when +a required singleton depends on it. The `repository_path` and `source.host` schema patterns use only RE2-compatible syntax and enforce their printable alphabet; producers additionally enforce the documented segment, leading-slash, trailing-slash, port-range, and default-port rules. A validator that cannot compile or @@ -649,6 +660,14 @@ source has a record but no content path or file entry and adds an aborts snapshot assembly, and Fullsend must not launch scripts or an agent with that snapshot. +Verification, upload, and cleanup MUST reject symlinks and special files at the +context root and every path component, and MUST require regular files beneath +real directories. They use no-follow, containment-preserving directory-handle +operations and upload the bytes from the verified handles (or retain an +equivalent exclusive root handle) so a path cannot be replaced between digest +verification and sandbox upload. If this guarantee cannot be enforced, +assembly aborts before scripts or the agent launch. + Findings contain codes and counts, not rejected source text. Filters and bounds are identified by `filter_version`; changing emitted bytes for the same input requires a new filter version. Removing or reinterpreting a status requires v2. @@ -674,9 +693,12 @@ state their ordering in their owning schema before being added to v1. `generated_at` or another runner-clock value is forbidden anywhere under the context root. Acquisition timing belongs in run telemetry outside the staged tree. Source-provided timestamps, entity update time, Git object IDs used as -relationship values, and forge check record IDs are permitted. With identical -forge responses, `collection_profile`, size bounds, and `filter_version`, the -complete tree has identical paths and bytes. +relationship values, and forge check record IDs are permitted. Determinism is +defined over the complete normalized acquisition inputs: forge responses, +authorization-provider results, effective admission policy, collection +profile, size bounds, filter version, and the active credential-redaction +registry. With those inputs identical, the complete tree has identical paths +and bytes; stale authorization or filtering state MUST NOT be reused. ## Lifecycle and access diff --git a/docs/normative/entity-context-snapshot/v1/collection.schema.json b/docs/normative/entity-context-snapshot/v1/collection.schema.json index 8b884ae25c..fd85499ea2 100644 --- a/docs/normative/entity-context-snapshot/v1/collection.schema.json +++ b/docs/normative/entity-context-snapshot/v1/collection.schema.json @@ -3,12 +3,23 @@ "$id": "https://fullsend.ai/normative/entity-context-snapshot/v1/collection.schema.json", "title": "EntityContextSnapshotCollection", "type": "object", - "required": ["entity_kind", "included_sources", "record_selection", "check_log_selection", "bounds"], + "required": ["entity_kind", "admission", "included_sources", "record_selection", "check_log_selection", "bounds"], "properties": { "entity_kind": { "enum": ["work_item", "change_proposal"], "description": "The forge entity kind being collected; source selection is constrained by this value." }, + "admission": { + "type": "object", + "required": ["human_min_role"], + "properties": { + "human_min_role": { + "enum": ["triage", "write"], + "description": "The effective minimum current forge role for human entity, comment, and review authors: triage for observation runs or write for mutation runs. Registered bot roles follow ADR 0107 and do not use this human threshold." + } + }, + "additionalProperties": false + }, "included_sources": { "type": "array", "items": { "enum": ["entity", "comments", "reviews", "checks", "check_logs", "agent_runs"] }, From 509d40877bac94c5f57cfe5aef5ee6dde88f0b82 Mon Sep 17 00:00:00 2001 From: Barak Korren Date: Wed, 14 Oct 2026 11:02:20 +0300 Subject: [PATCH 33/33] docs(#6407): make snapshot upload immutable Require an immutable digest-verified upload snapshot or equivalent writer exclusion so in-place file changes cannot bypass the retained manifest. Align ADR 0141 determinism with the complete normalized acquisition inputs defined by the v1 specification. Signed-off-by: Barak Korren Assisted-by: Codex (gpt-5.6-sol) --- ...deterministic-filtered-entity-context-staging.md | 7 +++++-- docs/normative/entity-context-snapshot/v1/README.md | 13 ++++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/docs/ADRs/0141-deterministic-filtered-entity-context-staging.md b/docs/ADRs/0141-deterministic-filtered-entity-context-staging.md index 72221afd37..00c86ea48d 100644 --- a/docs/ADRs/0141-deterministic-filtered-entity-context-staging.md +++ b/docs/ADRs/0141-deterministic-filtered-entity-context-staging.md @@ -100,8 +100,11 @@ filter statuses, and compatibility rules are the versioned 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 forge state and filter version, implementations produce the same paths -and bytes; breaking that guarantee requires a new major specification. +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, diff --git a/docs/normative/entity-context-snapshot/v1/README.md b/docs/normative/entity-context-snapshot/v1/README.md index dc8e9c5509..3d94b786cf 100644 --- a/docs/normative/entity-context-snapshot/v1/README.md +++ b/docs/normative/entity-context-snapshot/v1/README.md @@ -662,11 +662,14 @@ that snapshot. Verification, upload, and cleanup MUST reject symlinks and special files at the context root and every path component, and MUST require regular files beneath -real directories. They use no-follow, containment-preserving directory-handle -operations and upload the bytes from the verified handles (or retain an -equivalent exclusive root handle) so a path cannot be replaced between digest -verification and sandbox upload. If this guarantee cannot be enforced, -assembly aborts before scripts or the agent launch. +real directories. After the root-index comparison, Fullsend MUST verify child +bytes into an immutable, digest-verified upload snapshot (for example, a private +copy with concurrent writers excluded and immutable/read-only enforcement), or +hold an equivalent exclusive writer-blocking capability. No-follow handles alone +are insufficient because an already-open regular file can still be truncated or +overwritten in place. The uploaded bytes MUST be the exact bytes verified against +the retained assembly manifest; if immutability or writer exclusion cannot be +enforced, assembly aborts before scripts or the agent launch. Findings contain codes and counts, not rejected source text. Filters and bounds are identified by `filter_version`; changing emitted bytes for the same input