Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/interplane-mv/patches/8a8e03bd3bdf18fd # interplane-mv INTERPLANE: open interoperability protocol between AI models and agent runtimes. Models express intent. Runtimes retain authority. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers ## GitHub aien-dev/interplane-mv#24 (code only) closed derived `8a8e03bd3bdf18fd` #24 Imported from GitHub aien-dev/interplane-mv#24 (code only) GitHub's metadata for this pull request is unavailable: its state is DERIVED from the commits (merged: the head is reachable from this project's main; open: GitHub kept a merge ref; else closed). Base `59bb72bc7e739ca0b5b547a0d1a3b55915a00e06` · Head `1e50f24404e39c9dcb8d7726558ca0fa2861ad40` greptile-apps[bot] reviewed (COMMENTED) on 2026-10-05 00:15 UTC `aien-dev` has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan . ### Apply it ``` git checkout -b patch-8a8e03bd3bdf18fd 59bb72bc7e739ca0b5b547a0d1a3b55915a00e06 curl -fsSL https://interplane.io/drakestapleton/interplane-mv/patches/8a8e03bd3bdf18fd.patch | git am ``` Raw patch (mbox) · Diff ### Provenance This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record: ``` github-import 1 aien-dev/interplane-mv 24 1e50f24404e39c9dcb8d7726558ca0fa2861ad40 ``` ``` {"kind":"github-import","owner":"aien-dev","repo":"interplane-mv","number":24,"url":"https://github.com/aien-dev/interplane-mv/pull/24","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:40:00Z","metadata":"unavailable","state_derived":true} ``` ### Changes ``` diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a2f9a1c..baa484c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -78,7 +78,7 @@ jobs: import json,sys r=json.load(open('rust-verdicts.json')); p=json.load(open('py-verdicts.json')) bad=[c for c in sorted(set(r)|set(p)) if json.dumps(r.get(c),sort_keys=True)!=json.dumps(p.get(c),sort_keys=True)] - print('cases:',len(r),'mismatches:',bad); sys.exit(1 if bad or len(r)!=32 else 0) + print('cases:',len(r),'mismatches:',bad); sys.exit(1 if bad or len(r)!=35 else 0) PY adapter-aien: runs-on: ubuntu-latest diff --git a/CHANGELOG.md b/CHANGELOG.md index f689021..cbe6c8f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - Security: the Rust lifecycle now accepts an approval continuation only with the `approval_id` the runtime minted for that request, as Python already did; before, any non-empty id was accepted. A non-`authorized` continuation value with the minted id is DENIED in both SDKs. Lifecycle conformance cases `lifecycle/01-05`; 30/30 byte-identical. - Trust vocabulary reconciled (plan cut P1, gaps G1-G3): CROSSVEIL.md default is `tool_result` + `unknown` (the undefined `untrusted_tool_content` and `origin` are gone), VERSIONING.md lists `ContentKind` in place of the undefined `Origin`. Python now reads an unrecognized or non-string `content_kind` as `unknown`, as Rust did; non-string trust is `external_untrusted`. Odysseus `system` result integrity maps to `trusted_runtime` unless Odysseus's own gate marks the result untrusted. Conformance cases 26, 27 (with a harness-only `mock_provenance` seam and JCS round-trip checks); 32/32 byte-identical together with lifecycle/01-05. - InputRecord and Exposure types (plan cut P2): `spec/schemas/input.schema.json`, optional `provenance.exposure` in `intent.schema.json`, Crossveil Trust rules 5 and 6, Rust and Python types in lockstep, one schema-valid example per source class under `conformance/fixtures/input/`, digest fixtures `digest/input-record-01` and `digest/exposure-01` identical in both languages; types only, no pipeline behaviour (cut P3). +- Pipeline input ledger and exposure (plan cut P3): the pipeline records every rendered result as an InputRecord (`parent_id` = its `request_id`), the host registers other inputs with the host-only `register_input`, and every `tool_request` and `CallContext` carries a computed `provenance.exposure` (a forged one is overwritten; an empty ledger, unknown trust or an untraceable `derived_from` gives `external_untrusted`). Conformance cases 28-30 and new optional `expected.inputs` / `expected.exposure`; 35/35 byte-identical in both SDKs, earlier verdicts unchanged. ## Unreleased (0.2, CrossAxis lane) diff --git a/STATUS.md b/STATUS.md index 6ebd91b..8cdc9ba 100644 --- a/STATUS.md +++ b/STATUS.md @@ -18,10 +18,11 @@ byte-identical) · `qualified` (measured against a real model/backend). | CrossAxis expansion v1 (expand + discover, bounded) | conformant | conformant | cases 24, 25 | selections and digests byte-identical across languages; not yet qualified against a live model; never grants authority | | Crossveil pipeline + mock runtime | conformant | conformant | 27 cases | fails closed on adapter faults | | Crossveil trust vocabulary (0.3 cut P1) | conformant | conformant | cases 26, 27 | unrecognized content_kind -> `unknown` in both SDKs (Python used `tool_result` before); absent/null trust -> `unknown`, unrecognized -> `external_untrusted`; `trusted` never true for them, also after a JCS round trip; Odysseus `system` integrity mapped explicitly | -| InputRecord and Exposure types (0.3 cut P2) | conformant | conformant | digest/input-record-01, digest/exposure-01 | schema `input.schema.json`, 9 source-class examples validated in CI; types only: the pipeline records no inputs and computes no exposure until cut P3 | +| InputRecord and Exposure types (0.3 cut P2) | conformant | conformant | digest/input-record-01, digest/exposure-01 | schema `input.schema.json`, 9 source-class examples validated in CI; types; the pipeline now records them (cut P3, next row) | | Crossveil lifecycle: approval continuation | conformant | conformant | lifecycle/01-05 | only the approval_id the runtime minted for that request continues it; forged, empty, missing and other-request ids refused (Rust accepted any non-empty id before 0.3 cut A1); no pipeline continuation call yet (cut A2) | | Reproducibility pins | - | - | - | see docs/RUN-MANIFEST-COMMITS.md (toolchain, pip constraints, action SHAs, AIEN sibling pins) | -| Conformance runner | implemented | implemented | 32/32 both (27 cases + 5 lifecycle, verdicts byte-identical) | `--dump` writes canonical results per case | +| Pipeline input ledger and exposure (0.3 cut P3) | conformant | conformant | cases 28-30 | per-trace ledger of rendered results plus host `register_input`; every `tool_request` and `CallContext` gets a computed `exposure`; forged exposure overwritten; fails closed | +| Conformance runner | implemented | implemented | 35/35 both (30 cases + 5 lifecycle, verdicts byte-identical) | `--dump` writes canonical results per case | | Interplane Probe | qualified | qualified | - | both run live against Qwen3.5-9B/Ollama 0.34.0 with identical verdicts (reports under qualification/reports) | | AIEN adapter | tested (on the real EffectAuthority path, pinned sovereign-core 6554aac; was 10 pipeline tests in 0.1) | - | - | ADR 0003; real aien-mcp SpeculativeLane + aegis gate; aien-cli SafetyEngine not linkable (private); AGPL | | Odysseus adapter | - | tested (55 tests vs odysseus@2992bf6) | - | executes read_file/ls/glob/grep via Odysseus handlers; AGPL | diff --git a/adapters/aien/tests/approval.rs b/adapters/aien/tests/approval.rs index b7fdc1c..d799c90 100644 --- a/adapters/aien/tests/approval.rs +++ b/adapters/aien/tests/approval.rs @@ -23,6 +23,7 @@ fn ctx() -> CallContext { message_id: "m".into(), parent_id: None, model: Party::new("model", "m"), + exposure: None, session: None, } } diff --git a/conformance/fixtures/28-input-ledger-continues.json b/conformance/fixtures/28-input-ledger-continues.json new file mode 100644 index 0000000..54b5eb6 --- /dev/null +++ b/conformance/fixtures/28-input-ledger-continues.json @@ -0,0 +1,230 @@ +{ + "case": "28-input-ledger-continues", + "description": "The pipeline records every rendered result as an InputRecord (parent_id is the request_id) and the next turn's tool_requests see it: the exposure floor falls from user_supplied to workspace_untrusted to external_untrusted as memory and web results enter the ledger. Inputs are never removed.", + "limits": { + "max_argument_bytes": 65536 + }, + "trace_id": "trace-28", + "steps": [ + { + "input": { + "input_id": "in-28-user", + "content_kind": "user_request", + "trust": "user_supplied", + "source": { + "kind": "operator", + "id": "drake" + }, + "origin": "user:prompt", + "content_digest": "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "trace_id": "trace-28", + "parent_id": null, + "derived_from": [] + } + }, + { + "turn": 0, + "dialect": "openai", + "model": "mock-model", + "input": { + "role": "assistant", + "content": null, + "tool_calls": [ + { + "id": "call_28a", + "type": "function", + "function": { + "name": "recall_memory", + "arguments": "{\"query\": \"tests\"}" + } + } + ] + } + }, + { + "turn": 1, + "dialect": "openai", + "model": "mock-model", + "continues": true, + "input": { + "role": "assistant", + "content": null, + "tool_calls": [ + { + "id": "call_28b", + "type": "function", + "function": { + "name": "web_fetch", + "arguments": "{\"url\": \"https://example.com/page\"}" + } + } + ] + } + }, + { + "turn": 2, + "dialect": "openai", + "model": "mock-model", + "continues": true, + "input": { + "role": "assistant", + "content": null, + "tool_calls": [ + { + "id": "call_28c", + "type": "function", + "function": { + "name": "list_dir", + "arguments": "{\"path\": \"/tmp\"}" + } + } + ] + } + } + ], + "expected": { + "observed": [ + { + "request_id": "call_28a", + "stage": "SUCCEEDED", + "decision": "authorized", + "status": "ok", + "error_code": null, + "decide_invoked": true, + "execute_invoked": true, + "result_digest": null + }, + { + "request_id": "call_28b", + "stage": "SUCCEEDED", + "decision": "authorized", + "status": "ok", + "error_code": null, + "decide_invoked": true, + "execute_invoked": true, + "result_digest": null + }, + { + "request_id": "call_28c", + "stage": "SUCCEEDED", + "decision": "authorized", + "status": "ok", + "error_code": null, + "decide_invoked": true, + "execute_invoked": true, + "result_digest": null + } + ], + "turns": [ + { + "turn": 0, + "outcome": "tool_request", + "intents": 1, + "rejected": 0, + "text": "" + }, + { + "turn": 1, + "outcome": "tool_request", + "intents": 1, + "rejected": 0, + "text": "" + }, + { + "turn": 2, + "outcome": "tool_request", + "intents": 1, + "rejected": 0, + "text": "" + } + ], + "runtime": { + "decide_calls": 3, + "execute_calls": 3 + }, + "inputs": [ + { + "input_id": "in-28-user", + "content_kind": "user_request", + "trust": "user_supplied", + "source": { + "kind": "operator", + "id": "drake" + }, + "origin": "user:prompt", + "content_digest": "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "trace_id": "trace-28", + "parent_id": null, + "derived_from": [] + }, + { + "input_id": "in-auto-0", + "content_kind": "memory", + "trust": "workspace_untrusted", + "source": { + "kind": "runtime", + "id": "mock" + }, + "origin": "runtime:mock", + "trace_id": "trace-28", + "parent_id": "call_28a", + "derived_from": [], + "content_digest": "sha256:a095be98e2fcb65b663206008baae917b76dc4d058e970147acc4a83a5d2aedc" + }, + { + "input_id": "in-auto-1", + "content_kind": "web_content", + "trust": "external_untrusted", + "source": { + "kind": "runtime", + "id": "mock" + }, + "origin": "runtime:mock", + "trace_id": "trace-28", + "parent_id": "call_28b", + "derived_from": [], + "content_digest": "sha256:b47a780a310060ded4fe2f28ef1e492c38d6aeda9642a553c7655b38e5185f49" + }, + { + "input_id": "in-auto-2", + "content_kind": "tool_result", + "trust": "unknown", + "source": { + "kind": "runtime", + "id": "mock" + }, + "origin": "runtime:mock", + "trace_id": "trace-28", + "parent_id": "call_28c", + "derived_from": [], + "content_digest": "sha256:f3c9007bb6e656c560f57d1a752ca2fdda1f1829aca02dd2247eea370fa8f540" + } + ], + "exposure": [ + { + "request_id": "call_28a", + "inputs": [ + "in-28-user" + ], + "floor": "user_supplied" + }, + { + "request_id": "call_28b", + "inputs": [ + "in-28-user", + "in-auto-0" + ], + "floor": "workspace_untrusted" + }, + { + "request_id": "call_28c", + "inputs": [ + "in-28-user", + "in-auto-0", + "in-auto-1" + ], + "floor": "external_untrusted" + } + ] + } +} diff --git a/conformance/fixtures/29-input-derived-from.json b/conformance/fixtures/29-input-derived-from.json new file mode 100644 index 0000000..064533d --- /dev/null +++ b/conformance/fixtures/29-input-derived-from.json @@ -0,0 +1,241 @@ +{ + "case": "29-input-derived-from", + "description": "derived_from on nested content is kept as registered. A summary derived from a registered input leaves the floor at user_supplied. An input derived from an id the ledger does not hold cannot be traced, so it counts as external_untrusted whatever trust the host gave it (fail closed).", + "limits": { + "max_argument_bytes": 65536 + }, + "trace_id": "trace-29", + "steps": [ + { + "input": { + "input_id": "in-29-user", + "content_kind": "user_request", + "trust": "user_supplied", + "source": { + "kind": "operator", + "id": "drake" + }, + "origin": "user:prompt", + "content_digest": "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "trace_id": "trace-29", + "parent_id": null, + "derived_from": [] + } + }, + { + "input": { + "input_id": "in-29-summary", + "content_kind": "document", + "trust": "user_supplied", + "source": { + "kind": "operator", + "id": "drake" + }, + "origin": "file:summary.md", + "content_digest": "sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", + "trace_id": "trace-29", + "parent_id": null, + "derived_from": [ + "in-29-user" + ] + } + }, + { + "turn": 0, + "dialect": "openai", + "model": "mock-model", + "input": { + "role": "assistant", + "content": null, + "tool_calls": [ + { + "id": "call_29a", + "type": "function", + "function": { + "name": "append_note", + "arguments": "{\"path\": \"/tmp/notes.md\", \"text\": \"hello\"}" + } + } + ] + } + }, + { + "input": { + "input_id": "in-29-orphan", + "content_kind": "skill", + "trust": "trusted_runtime", + "source": { + "kind": "runtime", + "id": "host" + }, + "origin": "runtime:host", + "content_digest": "sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc", + "trace_id": "trace-29", + "parent_id": null, + "derived_from": [ + "in-29-missing" + ] + } + }, + { + "turn": 1, + "dialect": "openai", + "model": "mock-model", + "continues": true, + "input": { + "role": "assistant", + "content": null, + "tool_calls": [ + { + "id": "call_29b", + "type": "function", + "function": { + "name": "list_dir", + "arguments": "{\"path\": \"/tmp\"}" + } + } + ] + } + } + ], + "expected": { + "observed": [ + { + "request_id": "call_29a", + "stage": "SUCCEEDED", + "decision": "authorized", + "status": "ok", + "error_code": null, + "decide_invoked": true, + "execute_invoked": true, + "result_digest": null + }, + { + "request_id": "call_29b", + "stage": "SUCCEEDED", + "decision": "authorized", + "status": "ok", + "error_code": null, + "decide_invoked": true, + "execute_invoked": true, + "result_digest": null + } + ], + "turns": [ + { + "turn": 0, + "outcome": "tool_request", + "intents": 1, + "rejected": 0, + "text": "" + }, + { + "turn": 1, + "outcome": "tool_request", + "intents": 1, + "rejected": 0, + "text": "" + } + ], + "runtime": { + "decide_calls": 2, + "execute_calls": 2 + }, + "inputs": [ + { + "input_id": "in-29-user", + "content_kind": "user_request", + "trust": "user_supplied", + "source": { + "kind": "operator", + "id": "drake" + }, + "origin": "user:prompt", + "content_digest": "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "trace_id": "trace-29", + "parent_id": null, + "derived_from": [] + }, + { + "input_id": "in-29-summary", + "content_kind": "document", + "trust": "user_supplied", + "source": { + "kind": "operator", + "id": "drake" + }, + "origin": "file:summary.md", + "content_digest": "sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", + "trace_id": "trace-29", + "parent_id": null, + "derived_from": [ + "in-29-user" + ] + }, + { + "input_id": "in-auto-0", + "content_kind": "workspace_content", + "trust": "trusted_runtime", + "source": { + "kind": "runtime", + "id": "mock" + }, + "origin": "runtime:mock", + "trace_id": "trace-29", + "parent_id": "call_29a", + "derived_from": [], + "content_digest": "sha256:57eede4dba9330a0aa51027b0780dd01b7fe516f32f7c98d99171db9e7dacafc" + }, + { + "input_id": "in-29-orphan", + "content_kind": "skill", + "trust": "trusted_runtime", + "source": { + "kind": "runtime", + "id": "host" + }, + "origin": "runtime:host", + "content_digest": "sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc", + "trace_id": "trace-29", + "parent_id": null, + "derived_from": [ + "in-29-missing" + ] + }, + { + "input_id": "in-auto-1", + "content_kind": "tool_result", + "trust": "unknown", + "source": { + "kind": "runtime", + "id": "mock" + }, + "origin": "runtime:mock", + "content_digest": "sha256:583fa4b8bc4fc388ec6c552c756ca0047f6fe190a7cf095880cd7ab26eb18862", + "trace_id": "trace-29", + "parent_id": "call_29b", + "derived_from": [] + } + ], + "exposure": [ + { + "request_id": "call_29a", + "inputs": [ + "in-29-user", + "in-29-summary" + ], + "floor": "user_supplied" + }, + { + "request_id": "call_29b", + "inputs": [ + "in-29-user", + "in-29-summary", + "in-auto-0", + "in-29-orphan" + ], + "floor": "external_untrusted" + } + ] + } +} diff --git a/conformance/fixtures/30-input-forged-exposure.json b/conformance/fixtures/30-input-forged-exposure.json new file mode 100644 index 0000000..f357b22 --- /dev/null +++ b/conformance/fixtures/30-input-forged-exposure.json @@ -0,0 +1,147 @@ +{ + "case": "30-input-forged-exposure", + "description": "An admitted envelope claims provenance.exposure {inputs: [forged-clean], floor: trusted_runtime}. The pipeline never reads it: the request is admitted with the exposure computed from the trace's own ledger, where a web input holds the floor at external_untrusted.", + "limits": { + "max_argument_bytes": 65536 + }, + "trace_id": "trace-30", + "steps": [ + { + "input": { + "input_id": "in-30-user", + "content_kind": "user_request", + "trust": "user_supplied", + "source": { + "kind": "operator", + "id": "drake" + }, + "origin": "user:prompt", + "content_digest": "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "trace_id": "trace-30", + "parent_id": null, + "derived_from": [] + } + }, + { + "input": { + "input_id": "in-30-web", + "content_kind": "web_content", + "trust": "external_untrusted", + "source": { + "kind": "runtime", + "id": "host" + }, + "origin": "https://example.test/page", + "content_digest": "sha256:dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd", + "trace_id": "trace-30", + "parent_id": null, + "derived_from": [] + } + }, + { + "turn": 0, + "envelope": { + "interplane_version": "0.1", + "message_id": "m-30-0-0", + "trace_id": "trace-30", + "parent_id": null, + "timestamp": "2026-01-01T00:00:00Z", + "source": { + "kind": "model", + "id": "mock-model" + }, + "destination": { + "kind": "runtime", + "id": "mock" + }, + "payload": { + "kind": "tool_request", + "request_id": "req-30a", + "tool": { + "namespace": null, + "name": "read_file" + }, + "arguments": { + "path": "/tmp/a.txt" + }, + "provenance": { + "dialect": "openai", + "dialect_version": "1", + "model": "mock-model", + "parser_version": "1.0.0", + "source_turn": 0, + "source_call_id": null, + "source_digest": null, + "raw_name": "read_file", + "coercion": "none", + "exposure": { + "inputs": [ + "forged-clean" + ], + "floor": "trusted_runtime" + } + } + } + } + } + ], + "expected": { + "observed": [ + { + "request_id": "req-30a", + "stage": "SUCCEEDED", + "decision": "authorized", + "status": "ok", + "error_code": null, + "decide_invoked": true, + "execute_invoked": true, + "result_digest": null + } + ], + "turns": [], + "runtime": { + "decide_calls": 1, + "execute_calls": 1 + }, + "inputs": [ + { + "input_id": "in-30-user", + "content_kind": "user_request", + "trust": "user_supplied", + "source": { + "kind": "operator", + "id": "drake" + }, + "origin": "user:prompt", + "content_digest": "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "trace_id": "trace-30", + "parent_id": null, + "derived_from": [] + }, + { + "input_id": "in-30-web", + "content_kind": "web_content", + "trust": "external_untrusted", + "source": { + "kind": "runtime", + "id": "host" + }, + "origin": "https://example.test/page", + "content_digest": "sha256:dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd", + "trace_id": "trace-30", + "parent_id": null, + "derived_from": [] + } + ], + "exposure": [ + { + "request_id": "req-30a", + "inputs": [ + "in-30-user", + "in-30-web" + ], + "floor": "external_untrusted" + } + ] + } +} diff --git a/conformance/runners/validate_fixtures.py b/conformance/runners/validate_fixtures.py index 6aa8d7b..93ea709 100644 --- a/conformance/runners/validate_fixtures.py +++ b/conformance/runners/validate_fixtures.py @@ -4,7 +4,7 @@ Exit status is non-zero on any failure. Checks: * every explicit envelope step validates against envelope.schema.json * every intent in dialects/fixtures validates against intent.schema.json - * fixture shape, 27 required cases, filename == case slug + * fixture shape, 30 required cases, filename == case slug * lifecycle/ fixtures: required set, shape, minting decisions valid against decision.schema.json * expected.runtime counts agree with the observed records * every digest fixture recomputes; InputRecord examples (one per source class) validate @@ -72,7 +72,8 @@ REQUIRED = { "14-unknown-fields","15-oversized-arguments","16-duplicate-request-ids","17-replay","18-model-retry-after-denial", "19-valid-write-request","20-missing-required-argument","21-stale-capability-mapping","22-untrusted-tool-result","23-untrusted-memory-result", "24-expansion-requested-excluded","25-expansion-refused-by-bound", - "26-unrecognized-content-kind","27-absent-null-unrecognized-trust"} + "26-unrecognized-content-kind","27-absent-null-unrecognized-trust", + "28-input-ledger-continues","29-input-derived-from","30-input-forged-exposure"} OBS_KEYS = ["request_id","stage","decision","status","error_code","decide_invoked","execute_invoked","result_digest"] n_env = n_cases = 0 neg_done = False @@ -100,11 +101,17 @@ for p in sorted(glob.glob(os.path.join(FIX, "*.json"))): if V_ENV.is_valid(bad): fail("negative control: envelope without trace_id unexpectedly valid") neg_done = True elif "dialect" in s and "input" in s: pass + elif "input" in s and "dialect" not in s: # host-only input registration (0.3 cut P3) + check(V_INPUT, s["input"], name + " input step") elif "expand" in s: if "selection" not in f: fail("%s: expand step without a selection block" % name) ev = s["expand"].get("evidence", {}) if ev.get("kind") not in ("requested_excluded", "discovery_hit"): fail("%s: bad evidence kind" % name) else: fail("%s: step %s has neither envelope nor dialect+input" % (name, s.get("turn"))) + for rec in exp.get("inputs", []): + check(V_INPUT, rec, name + " expected.inputs") if "content_digest" in rec else None + for e in exp.get("exposure", []): + if set(e) != {"request_id", "inputs", "floor"}: fail("%s: malformed expected.exposure %s" % (name, e)) for c in exp.get("result_checks", []): if set(c) - {"round_trip"} != {"request_id", "path", "equals"} or c.get("round_trip", True) is not True or c["request_id"] not in {o["request_id"] for o in obs}: fail("%s: malformed result_check %s" % (name, c)) diff --git a/python/interplane/conformance.py b/python/interplane/conformance.py index e8233fa..6e26a98 100644 --- a/python/interplane/conformance.py +++ b/python/interplane/conformance.py @@ -66,6 +66,13 @@ def run_case(case: dict) -> dict: ) selections.append(sel.to_dict()) continue + if "input" in step and "dialect" not in step: + # host-only input registration (0.3 cut P3): never reachable from model input + try: + pipe.register_input(step["input"]) + except (ValueError, ProtocolError): + pass + continue if "envelope" in step: result, record = pipe.admit_envelope(step["envelope"], turn=step.get("turn")) results.append(result) @@ -82,6 +89,9 @@ def run_case(case: dict) -> dict: results.extend(out.results) observed.extend(r.to_dict() for r in out.observed) turns.append(out.to_dict()) + # Reported only for cases that assert them, so older verdicts keep their shape. + inputs = pipe.inputs(trace_id) if "inputs" in case["expected"] else [] + exposure = pipe.runtime.seen_exposure if "exposure" in case["expected"] else [] runtime = { "decide_calls": pipe.runtime.decide_calls, "execute_calls": pipe.runtime.execute_calls, @@ -104,6 +114,15 @@ def run_case(case: dict) -> dict: problems.append("selections differ from expected") if "runtime" in expected and runtime != expected["runtime"]: problems.append(f"runtime {runtime!r} != {expected['runtime']!r}") + if "inputs" in expected: + want = expected["inputs"] + ok = len(want) == len(inputs) and all( + all(g.get(k) == v for k, v in w.items()) for w, g in zip(want, inputs) + ) + if not ok: + problems.append(f"inputs {inputs!r} != {want!r}") + if "exposure" in expected and exposure != expected["exposure"]: + problems.append(f"exposure {exposure!r} != {expected['exposure']!r}") for check in expected.get("result_checks", []): match = next((r for r in results if r.request_id == check["request_id"]), None) try: @@ -123,6 +142,8 @@ def run_case(case: dict) -> dict: "turns": turns, "runtime": runtime, "selections": selections, + "inputs": inputs, + "exposure": exposure, "problems": problems, "results": [canonical_result_payload(r) for r in results], } @@ -213,13 +234,12 @@ def main(argv: Optional[list] = None) -> int: failed += err is not None total = len(verdicts) + len(lifecycle) print(f"{total - failed}/{total} passed") - out = { - k: {f: v[f] for f in ("pass", "observed", "turns", "runtime", "selections") if f in v} - for k, v in verdicts.items() - } + fields = ("pass", "observed", "turns", "runtime", "selections", "inputs", "exposure") + out = {k: {f: v[f] for f in fields if f in v} for k, v in verdicts.items()} for v in out.values(): - if not v.get("selections"): - v.pop("selections", None) + for key in ("selections", "inputs", "exposure"): + if not v.get(key): + v.pop(key, None) out.update({k: {"pass": v["pass"], "steps": v["steps"]} for k, v in lifecycle.items()}) Path(args.out).write_text(jcs(out) + "\n", encoding="utf-8") return 1 if failed else 0 diff --git a/python/interplane/crossveil.py b/python/interplane/crossveil.py index 17254f3..165c39f 100644 --- a/python/interplane/crossveil.py +++ b/python/interplane/crossveil.py @@ -23,9 +23,11 @@ from .core import ( ErrorCode, ErrorInfo, Event, + InputRecord, Lifecycle, LifecycleError, Limits, + Party, RequestLedger, State, ToolRef, @@ -225,6 +227,11 @@ def canonical_result_payload(result: ToolResult) -> dict: return payload +_TRUST_RANK = {"trusted_runtime": 3, "user_supplied": 2, "workspace_untrusted": 1} +_RANK_TRUST = {3: "trusted_runtime", 2: "user_supplied", 1: "workspace_untrusted"} +_FAIL_CLOSED_EXPOSURE = {"inputs": [], "floor": "external_untrusted"} + + class Pipeline: """Reference pipeline: Lenshift.parse -> Core.admit -> CrossAxis.map -> decide -> execute.""" @@ -244,6 +251,64 @@ class Pipeline: self.events: list = [] self._seq: dict = {} self._pending: dict = {} # trace_id -> True while results await a model continuation + self._inputs: dict = {} # trace_id -> [InputRecord, ...] in order (0.3 cut P3) + + # -- input ledger and exposure (0.3 cut P3) ----------------------------------- + def register_input(self, record: Any) -> InputRecord: + """Host-only: register an input placed in front of the model on ``record.trace_id``, before + the turn that can see it. Never called from model output or an admitted envelope. Raises + ``ValueError`` on a duplicate ``input_id`` for the trace.""" + rec = record if isinstance(record, InputRecord) else InputRecord.from_dict(record) + ledger = self._inputs.setdefault(rec.trace_id, []) + if any(r.input_id == rec.input_id for r in ledger): + raise ValueError(f"duplicate input_id: {rec.input_id}") + ledger.append(copy.deepcopy(rec)) + return rec + + def inputs(self, trace_id: str) -> list: + """The trace's input ledger as dicts, in registration order.""" + return [r.to_dict() for r in self._inputs.get(trace_id, [])] + + def exposure_for(self, trace_id: str) -> dict: + """Exposure computed from the ledger. Fails closed: an empty ledger, an input of unknown + trust, an input derived from an id the ledger does not hold, or any error all give + ``external_untrusted``.""" + try: + ledger = self._inputs.get(trace_id, []) + ids = {r.input_id for r in ledger} + floor = 3 if ledger else 0 + for r in ledger: + traced = all(d in ids for d in r.derived_from) + floor = min(floor, _TRUST_RANK.get(r.trust, 0) if traced else 0) + return { + "inputs": [r.input_id for r in ledger], + "floor": _RANK_TRUST.get(floor, "external_untrusted"), + } + except Exception: # noqa: BLE001 - fail closed + return copy.deepcopy(_FAIL_CLOSED_EXPOSURE) + + def _record_result(self, trace_id: str, result: ToolResult, rendered: Any) -> None: + """Record a rendered result as an input of the trace (``parent_id`` = its request id).""" + prov = result.provenance or {} + ledger = self._inputs.setdefault(trace_id, []) + n = sum(1 for r in ledger if r.input_id.startswith("in-auto-")) + taken = {r.input_id for r in ledger} + while f"in-auto-{n}" in taken: + n += 1 + rid = self._runtime_id() or "runtime" + ledger.append( + InputRecord( + input_id=f"in-auto-{n}", + content_kind=prov.get("content_kind") or "unknown", + trust=prov.get("trust") or DEFAULT_TRUST, + source=Party(kind="runtime", id=rid), + origin=f"runtime:{rid}", + content_digest=digest(rendered), + trace_id=trace_id, + parent_id=result.request_id, + derived_from=[], + ) + ) # -- events (RelayLine) ------------------------------------------------- @@ -277,6 +342,9 @@ class Pipeline: return result, record def admit_envelope(self, env: Any, *, turn: Optional[int] = None) -> tuple: + return self._admit(env, turn, None) + + def _admit(self, env: Any, turn: Optional[int], turn_exposure: Optional[dict]) -> tuple: """Admit one envelope. Returns ``(ToolResult, ObservedRecord)``. A valid envelope means structurally understandable, never authorized. Order: version, @@ -319,7 +387,11 @@ class Pipeline: if self.limits.arguments_oversized(payload["arguments"]): msg = f"arguments exceed {self.limits.max_argument_bytes} bytes" return self._rejected(rid, ErrorCode.OVERSIZED_ARGUMENTS, trace_id, msg, turn) - return self._process(Envelope.from_dict(env), ToolRequest.from_dict(payload), turn) + intent = ToolRequest.from_dict(payload) + # Exposure is the pipeline's own: whatever the model or envelope claimed is overwritten. + exposure = turn_exposure if turn_exposure is not None else self.exposure_for(trace_id) + intent.provenance["exposure"] = copy.deepcopy(exposure) + return self._process(Envelope.from_dict(env), intent, turn) def _stale(self, cap_req: CapabilityRequest) -> bool: pinned = cap_req.mapping.get("catalog_digest") @@ -365,6 +437,7 @@ class Pipeline: "parent_id": envelope.parent_id, "model": envelope.source, "runtime_session": None, + "exposure": copy.deepcopy(intent.provenance["exposure"]), } runtime_id = self._runtime_id() cap = cap_req.capability @@ -512,6 +585,9 @@ class Pipeline: out.outcome, out.error_code = "rejected", err.code self._emit(trace_id, "tool_error", None, turn, {"error_code": err.code}) return out + exposure = self.exposure_for(trace_id) + for it in parsed.intents: + it.provenance["exposure"] = copy.deepcopy(exposure) out.text = parsed.text out.intents, out.rejected = len(parsed.intents), len(parsed.rejected) if parsed.reasoning_digest: @@ -561,12 +637,13 @@ class Pipeline: "destination": {"kind": "runtime", "id": self._runtime_id() or "runtime"}, "payload": item.to_dict(), } - pairs.append((item, *self.admit_envelope(envelope, turn=turn))) + pairs.append((item, *self._admit(envelope, turn, exposure))) position += 1 for intent, result, record in pairs: out.results.append(result) out.observed.append(record) out.rendered.append(module.render_result(result, intent)) + self._record_result(trace_id, result, out.rendered[-1]) if out.intents: out.outcome = "tool_request" elif out.rejected: @@ -721,6 +798,8 @@ class MockRuntime: def __init__(self) -> None: self.decide_calls = 0 self.execute_calls = 0 + # Harness-only: {request_id, inputs, floor} of ctx["exposure"] seen at each decide. + self.seen_exposure: list = [] # Harness-only: per capability, provenance keys (content_kind, trust, trusted) reported on # an executed result in place of the defaults, as a mislabelling adapter would. Set by the # conformance runner from a fixture's mock_provenance; never read from model content. @@ -763,6 +842,11 @@ class MockRuntime: def decide(self, req: CapabilityRequest, ctx: dict) -> Decision: self.decide_calls += 1 + exp = ctx.get("exposure") + if exp is not None: + self.seen_exposure.append( + {"request_id": req.request_id, "inputs": exp["inputs"], "floor": exp["floor"]} + ) spec = _MOCK_CAPS.get(req.capability) if spec is None: return self._decision(req, "not_found", f"unknown capability: {req.capability}") diff --git a/python/tests/test_conformance.py b/python/tests/test_conformance.py index 9d64f84..a4a9b3b 100644 --- a/python/tests/test_conformance.py +++ b/python/tests/test_conformance.py @@ -28,7 +28,14 @@ def test_runner_writes_sorted_verdicts(tmp_path, capsys): assert len(life) == len(LIFECYCLE) assert all(v["pass"] and set(v) == {"pass", "steps"} for v in life.values()) base = {"pass", "observed", "runtime", "turns"} - assert all(v["pass"] and set(v) - {"selections"} == base for v in data.values()) + optional = {"selections", "inputs", "exposure"} + assert all(v["pass"] and set(v) - optional == base for v in data.values()) + ledger_cases = { + "28-input-ledger-continues", + "29-input-derived-from", + "30-input-forged-exposure", + } + assert {k for k, v in data.items() if "inputs" in v and "exposure" in v} == ledger_cases assert {k for k, v in data.items() if "selections" in v} == { "24-expansion-requested-excluded", "25-expansion-refused-by-bound", diff --git a/python/tests/test_pipeline.py b/python/tests/test_pipeline.py index 97a1ef8..93b13bc 100644 --- a/python/tests/test_pipeline.py +++ b/python/tests/test_pipeline.py @@ -449,3 +449,62 @@ def test_unrecognized_or_unparseable_labels_never_become_trusted(label, want): p.runtime.provenance_overrides = {"read_file": label} prov = run(p, "read_file", {"path": "/a"}).results[0].provenance assert (prov["content_kind"], prov["trust"], prov["trusted"]) == want + + +def _rec(input_id, trust, trace="t", derived=()): + return { + "input_id": input_id, + "content_kind": "user_request", + "trust": trust, + "source": {"kind": "operator", "id": "op"}, + "origin": "user:prompt", + "content_digest": "sha256:" + "a" * 64, + "trace_id": trace, + "parent_id": None, + "derived_from": list(derived), + } + + +def test_exposure_fails_closed_when_ledger_is_empty(): + pipe = default_pipeline() + run(pipe, "read_file", {"path": "/x"}) + assert pipe.runtime.seen_exposure == [ + {"request_id": "c1", "inputs": [], "floor": "external_untrusted"} + ] + + +def test_exposure_floor_is_least_trusted_and_unknown_ranks_external(): + pipe = default_pipeline() + pipe.register_input(_rec("a", "trusted_runtime")) + assert pipe.exposure_for("t") == {"inputs": ["a"], "floor": "trusted_runtime"} + pipe.register_input(_rec("b", "user_supplied")) + assert pipe.exposure_for("t")["floor"] == "user_supplied" + pipe.register_input(_rec("c", "not-a-level")) + assert pipe.exposure_for("t")["floor"] == "external_untrusted" + pipe.register_input(_rec("d", "trusted_runtime", trace="other")) + assert pipe.exposure_for("other") == {"inputs": ["d"], "floor": "trusted_runtime"} + + +def test_register_input_refuses_duplicate_id(): + pipe = default_pipeline() + pipe.register_input(_rec("a", "user_supplied")) + with pytest.raises(ValueError): + pipe.register_input(_rec("a", "trusted_runtime")) + assert [r["trust"] for r in pipe.inputs("t")] == ["user_supplied"] + + +def test_input_registration_is_not_reachable_from_an_envelope(): + pipe = default_pipeline() + env = { + "interplane_version": "0.1", + "message_id": "m1", + "trace_id": "t", + "parent_id": None, + "timestamp": "2026-01-01T00:00:00Z", + "source": {"kind": "model", "id": "m"}, + "destination": {"kind": "runtime", "id": "mock"}, + "payload": {"kind": "input_record", **_rec("x", "trusted_runtime")}, + } + result, _ = pipe.admit_envelope(env) + assert result.error.code == ErrorCode.MALFORMED_ENVELOPE + assert pipe.inputs("t") == [] diff --git a/python/tests/test_schemas.py b/python/tests/test_schemas.py index 79f2139..c4ec28d 100644 --- a/python/tests/test_schemas.py +++ b/python/tests/test_schemas.py @@ -31,7 +31,9 @@ def run_cases(): for step in case["steps"]: if "expand" in step: continue - if "envelope" in step: + if "input" in step and "dialect" not in step: + pipe.register_input(step["input"]) + elif "envelope" in step: results.append(pipe.admit_envelope(step["envelope"])[0]) else: results.extend( diff --git a/rust/crates/interplane-conformance/src/lib.rs b/rust/crates/interplane-conformance/src/lib.rs index 9d76539..5666871 100644 --- a/rust/crates/interplane-conformance/src/lib.rs +++ b/rust/crates/interplane-conformance/src/lib.rs @@ -24,6 +24,10 @@ pub struct CaseRun { pub results: Vec, /// The selection receipt after each `expand` step, in order. pub selections: Vec, + /// The trace's input ledger after the last step (0.3 cut P3), in registration order. + pub inputs: Vec, + /// `{request_id, inputs, floor}` the runtime saw in `CallContext` at `decide`, in order. + pub exposure: Vec, } /// Run one fixture document. @@ -39,6 +43,7 @@ pub fn run_case(fx: &Value) -> CaseRun { let mut turns = vec![]; let mut results = vec![]; let mut selections = vec![]; + let mut inputs: Vec = vec![]; let catalog = rt.catalog(); let mut sel = fx.get("selection").map(|spec| { let strings = |k: &str| -> Vec { @@ -96,6 +101,11 @@ pub fn run_case(fx: &Value) -> CaseRun { let (r, o) = p.admit_value(env); results.push(serde_json::to_value(&r).unwrap_or(Value::Null)); observed.push(o); + } else if step.get("input").is_some() && step.get("dialect").is_none() { + // Host-only input registration (0.3 cut P3): never reachable from model input. + if let Ok(rec) = serde_json::from_value(step["input"].clone()) { + let _ = p.register_input(rec); + } } else if let Some(d) = step["dialect"].as_str() { let model = step["model"].as_str().unwrap_or(""); let out = p.run_turn(d, model, &step["input"], &trace, turn); @@ -113,6 +123,14 @@ pub fn run_case(fx: &Value) -> CaseRun { observed.extend(out.records); } } + // Reported only for cases that assert them, so older verdicts keep their shape. + if fx["expected"].get("inputs").is_some() { + inputs = p + .inputs(&trace) + .iter() + .map(|r| serde_json::to_value(r).unwrap_or(Value::Null)) + .collect(); + } } CaseRun { case, @@ -122,6 +140,12 @@ pub fn run_case(fx: &Value) -> CaseRun { execute_calls: rt.execute_calls, results, selections, + inputs, + exposure: if fx["expected"].get("exposure").is_some() { + rt.seen_exposure.clone() + } else { + vec![] + }, } } @@ -187,6 +211,30 @@ pub fn compare(fx: &Value, run: &CaseRun) -> Vec { errs.push("selections differ from expected".to_string()); } } + if let Some(want) = exp.get("inputs").and_then(Value::as_array) { + // Subset match per record: a fixture may omit `content_digest` of an automatic record. + let ok = want.len() == run.inputs.len() + && want.iter().zip(&run.inputs).all(|(w, g)| { + w.as_object() + .is_some_and(|o| o.iter().all(|(k, v)| g.get(k) == Some(v))) + }); + if !ok { + errs.push(format!( + "inputs: expected {}, got {}", + canonicalize(&Value::Array(want.clone())), + canonicalize(&Value::Array(run.inputs.clone())) + )); + } + } + if let Some(want) = exp.get("exposure") { + if want != &Value::Array(run.exposure.clone()) { + errs.push(format!( + "exposure: expected {}, got {}", + canonicalize(want), + canonicalize(&Value::Array(run.exposure.clone())) + )); + } + } for c in exp["result_checks"].as_array().cloned().unwrap_or_default() { let rid = c["request_id"].as_str().unwrap_or(""); let path = c["path"].as_str().unwrap_or(""); @@ -225,6 +273,12 @@ pub fn verdict(run: &CaseRun, errs: &[String]) -> Value { if !run.selections.is_empty() { v["selections"] = Value::Array(run.selections.clone()); } + if !run.inputs.is_empty() { + v["inputs"] = Value::Array(run.inputs.clone()); + } + if !run.exposure.is_empty() { + v["exposure"] = Value::Array(run.exposure.clone()); + } v } diff --git a/rust/crates/interplane-conformance/tests/fixtures.rs b/rust/crates/interplane-conformance/tests/fixtures.rs index e34152d..fc386b1 100644 --- a/rust/crates/interplane-conformance/tests/fixtures.rs +++ b/rust/crates/interplane-conformance/tests/fixtures.rs @@ -44,7 +44,7 @@ fn verdicts_are_deterministic() { fn expanded_in_capability_is_still_denied_and_a_changed_selection_is_detected() { let dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../../conformance/fixtures"); let all = load_fixtures(&dir).unwrap(); - assert_eq!(all.len(), 27); + assert_eq!(all.len(), 30); let mut fx = all .into_iter() .find(|f| f["case"] == "24-expansion-requested-excluded") diff --git a/rust/crates/interplane-crossveil/src/lib.rs b/rust/crates/interplane-crossveil/src/lib.rs index 2d30e7b..7f8ce01 100644 --- a/rust/crates/interplane-crossveil/src/lib.rs +++ b/rust/crates/interplane-crossveil/src/lib.rs @@ -1,7 +1,7 @@ //! Crossveil: the authority boundary. A runtime adapter supplies `decide` and `execute`; the //! [`Pipeline`] enforces the CORE.md / CROSSVEIL.md invariants around them and never fabricates, //! caches, upgrades or reuses a decision. -use interplane_core::{CapabilityRequest, Catalog, Decision, Party, ToolResult}; +use interplane_core::{CapabilityRequest, Catalog, Decision, Exposure, Party, ToolResult}; use serde_json::Value; pub mod mock; @@ -19,6 +19,9 @@ pub struct CallContext { pub model: Party, /// Runtime-local session handle the adapter may attach. pub session: Option, + /// What the model could see when it produced this request (0.3 cut P3). Always computed by + /// the pipeline from its own input ledger, never read from the model or the envelope. + pub exposure: Option, } /// The two callbacks that touch a runtime, plus its catalog. diff --git a/rust/crates/interplane-crossveil/src/mock.rs b/rust/crates/interplane-crossveil/src/mock.rs index 916b5b7..dd968d6 100644 --- a/rust/crates/interplane-crossveil/src/mock.rs +++ b/rust/crates/interplane-crossveil/src/mock.rs @@ -125,6 +125,9 @@ pub struct MockRuntime { /// would. Set by the conformance runner from a fixture's `mock_provenance`; never read from /// arguments, extensions or envelopes. pub provenance_overrides: Map, + /// Harness-only: `{request_id, inputs, floor}` of the `CallContext.exposure` seen at each + /// `decide`, in order. + pub seen_exposure: Vec, } impl MockRuntime { @@ -175,8 +178,15 @@ impl RuntimeAuthority for MockRuntime { "mock" } - fn decide(&mut self, req: &CapabilityRequest, _ctx: &CallContext) -> Decision { + fn decide(&mut self, req: &CapabilityRequest, ctx: &CallContext) -> Decision { self.decide_calls += 1; + if let Some(e) = &ctx.exposure { + self.seen_exposure.push(json!({ + "request_id": req.request_id, + "inputs": e.inputs, + "floor": e.floor.as_str(), + })); + } let Some(spec) = SPECS.iter().find(|s| s.cap == req.capability) else { return self.decision( req, diff --git a/rust/crates/interplane-crossveil/src/pipeline.rs b/rust/crates/interplane-crossveil/src/pipeline.rs index fae3ee9..4e03683 100644 --- a/rust/crates/interplane-crossveil/src/pipeline.rs +++ b/rust/crates/interplane-crossveil/src/pipeline.rs @@ -6,7 +6,7 @@ use interplane_core::*; use interplane_crossaxis::{coerce_arguments, MappingTable}; use interplane_lenshift::{DialectRegistry, ParseContext, RejectedCall}; use serde::{Deserialize, Serialize}; -use serde_json::{Map, Value}; +use serde_json::{json, Map, Value}; use crate::{CallContext, RuntimeAuthority}; @@ -54,6 +54,27 @@ pub struct Pipeline<'a> { pub timestamp: String, seq: HashMap, turn: Option, + /// Per trace: every input that has been placed in front of the model, in order (cut P3). + inputs: HashMap>, +} + +/// Position in the trust order; `unknown` and anything unrecognized rank as `external_untrusted`. +fn trust_rank(t: &TrustLevel) -> u8 { + match t { + TrustLevel::TrustedRuntime => 3, + TrustLevel::UserSupplied => 2, + TrustLevel::WorkspaceUntrusted => 1, + _ => 0, + } +} + +fn rank_trust(rank: u8) -> TrustLevel { + match rank { + 3 => TrustLevel::TrustedRuntime, + 2 => TrustLevel::UserSupplied, + 1 => TrustLevel::WorkspaceUntrusted, + _ => TrustLevel::ExternalUntrusted, + } } fn rec( @@ -167,7 +188,76 @@ impl<'a> Pipeline<'a> { timestamp: "2026-01-01T00:00:00Z".into(), seq: HashMap::new(), turn: None, + inputs: HashMap::new(), + } + } + + /// Host-only: register an input (user request, workspace file, memory hit, skill, ...) placed + /// in front of the model on `rec.trace_id`, before the turn that can see it. This is not + /// reachable from model output or from an admitted envelope: those paths never call it. + /// Refuses a duplicate `input_id` on the trace. + pub fn register_input(&mut self, rec: InputRecord) -> Result<(), String> { + let ledger = self.inputs.entry(rec.trace_id.clone()).or_default(); + if ledger.iter().any(|r| r.input_id == rec.input_id) { + return Err(format!("duplicate input_id: {}", rec.input_id)); + } + ledger.push(rec); + Ok(()) + } + + /// The trace's input ledger, in registration order. + pub fn inputs(&self, trace: &str) -> &[InputRecord] { + self.inputs.get(trace).map(Vec::as_slice).unwrap_or(&[]) + } + + /// Exposure computed from the ledger. Fails closed: an empty ledger means the host told us + /// nothing about what the model saw, an input with unknown trust ranks as `external_untrusted`, + /// and an input derived from an id the ledger does not hold counts as `external_untrusted`. + pub fn exposure_for(&self, trace: &str) -> Exposure { + let ledger = self.inputs(trace); + let mut floor = if ledger.is_empty() { 0 } else { 3 }; + for r in ledger { + let traced = r + .derived_from + .iter() + .all(|d| ledger.iter().any(|o| &o.input_id == d)); + floor = floor.min(if traced { trust_rank(&r.trust) } else { 0 }); + } + Exposure { + inputs: ledger.iter().map(|r| r.input_id.clone()).collect(), + floor: rank_trust(floor), + extensions: Map::new(), + } + } + + /// Record a rendered result as an input of the trace (`parent_id` = its request id). The + /// trust and kind are the runtime's normalized provenance; absent means `unknown`. + fn record_result(&mut self, trace: &str, r: &ToolResult, rendered: &Value) { + let prov = r.provenance.as_ref(); + let ledger = self.inputs.entry(trace.to_string()).or_default(); + let mut n = ledger + .iter() + .filter(|o| o.input_id.starts_with("in-auto-")) + .count(); + while ledger.iter().any(|o| o.input_id == format!("in-auto-{n}")) { + n += 1; } + ledger.push(InputRecord { + input_id: format!("in-auto-{n}"), + content_kind: prov + .and_then(|p| p.content_kind.clone()) + .unwrap_or(ContentKind::Undetermined), + trust: prov + .and_then(|p| p.trust.clone()) + .unwrap_or(TrustLevel::Undetermined), + source: Party::new("runtime", self.runtime.runtime_id()), + origin: format!("runtime:{}", self.runtime.runtime_id()), + content_digest: digest(rendered), + trace_id: trace.to_string(), + parent_id: r.request_id.clone(), + derived_from: vec![], + extensions: Map::new(), + }); } fn emit(&mut self, trace: &str, event: EventKind, request_id: Option<&str>) { @@ -246,18 +336,19 @@ impl<'a> Pipeline<'a> { return self.reject(&trace, peek.as_deref(), ErrorCode::MalformedEnvelope, &msg); } }; - self.admit_checked(&env, Some(v)) + self.admit_checked(&env, Some(v), None) } /// Admit a parsed envelope. Order: version, structure, replay, duplicate, size, map, decide, execute. pub fn admit_envelope(&mut self, env: &Envelope) -> (ToolResult, ObservedRecord) { - self.admit_checked(env, None) + self.admit_checked(env, None, None) } fn admit_checked( &mut self, env: &Envelope, raw: Option<&Value>, + turn_exposure: Option<&Exposure>, ) -> (ToolResult, ObservedRecord) { let trace = env.trace_id.clone(); let raw_v = match raw { @@ -292,7 +383,7 @@ impl<'a> Pipeline<'a> { let msg = format!("replayed message_id: {}", env.message_id); return self.reject(&trace, peek.as_deref(), ErrorCode::ReplayedMessage, &msg); } - let req = match env.parse_payload() { + let mut req = match env.parse_payload() { Ok(Payload::ToolRequest(t)) => t, _ => { return self.reject( @@ -314,12 +405,24 @@ impl<'a> Pipeline<'a> { let msg = format!("arguments exceed {} bytes", self.limits.max_argument_bytes); return self.reject(&trace, Some(&rid), ErrorCode::OversizedArguments, &msg); } + // Exposure is the pipeline's own: whatever the model or envelope claimed is overwritten. + let exposure = match turn_exposure { + Some(e) => e.clone(), + None => self.exposure_for(&trace), + }; + req.provenance.extensions.insert( + "exposure".into(), + serde_json::to_value(&exposure).unwrap_or_else( + |_| json!({"inputs": [], "floor": TrustLevel::ExternalUntrusted.as_str()}), + ), + ); let ctx = CallContext { trace_id: trace.clone(), message_id: env.message_id.clone(), parent_id: env.parent_id.clone(), model: env.source.clone(), session: None, + exposure: Some(exposure), }; self.run_request(&req, &ctx) } @@ -558,6 +661,14 @@ impl<'a> Pipeline<'a> { return out; } }; + let mut parsed = parsed; + let exposure = self.exposure_for(trace_id); + for intent in &mut parsed.intents { + intent.provenance.extensions.insert( + "exposure".into(), + serde_json::to_value(&exposure).unwrap_or(Value::Null), + ); + } out.text = parsed.text.clone(); out.partial = parsed.partial; out.outcome = if !parsed.intents.is_empty() { @@ -626,7 +737,7 @@ impl<'a> Pipeline<'a> { Party::new("runtime", self.runtime.runtime_id()), serde_json::to_value(intent).unwrap_or(Value::Null), ); - self.admit_envelope(&env) + self.admit_checked(&env, None, Some(&exposure)) }; n += 1; out.rendered.push(self.render(dialect, &res, Some(intent))); @@ -635,6 +746,10 @@ impl<'a> Pipeline<'a> { } } } + // Everything rendered back to the model is visible to its next turn. + for (res, rendered) in out.results.clone().iter().zip(&out.rendered) { + self.record_result(trace_id, res, rendered); + } if out.intents.is_empty() && parsed.intents.is_empty() && parsed.rejected.is_empty() { self.emit(trace_id, EventKind::Complete, None); } diff --git a/rust/crates/interplane-crossveil/tests/pipeline.rs b/rust/crates/interplane-crossveil/tests/pipeline.rs index 5467c81..fc598e0 100644 --- a/rust/crates/interplane-crossveil/tests/pipeline.rs +++ b/rust/crates/interplane-crossveil/tests/pipeline.rs @@ -353,3 +353,67 @@ fn mock_table_shape() { assert!(t.catalog_digest.is_none()); assert!(mock_mapping_table_stale().catalog_digest.is_some()); } + +fn input_rec(id: &str, trust: &str, trace: &str) -> InputRecord { + serde_json::from_value(json!({ + "input_id": id, "content_kind": "user_request", "trust": trust, + "source": {"kind": "operator", "id": "op"}, "origin": "user:prompt", + "content_digest": format!("sha256:{}", "a".repeat(64)), + "trace_id": trace, "parent_id": null, "derived_from": [] + })) + .unwrap() +} + +#[test] +fn exposure_fails_closed_when_ledger_is_empty() { + let mut rt = MockRuntime::new(); + pipe(&mut rt).run_turn( + "openai", + "m", + &turn(vec![call("a", "read_file", json!({"path": "/x"}))]), + "t", + 0, + ); + assert_eq!( + rt.seen_exposure, + vec![json!({"request_id": "a", "inputs": [], "floor": "external_untrusted"})] + ); +} + +#[test] +fn exposure_floor_is_least_trusted_and_unknown_ranks_external() { + let mut rt = MockRuntime::new(); + let mut p = pipe(&mut rt); + p.register_input(input_rec("a", "trusted_runtime", "t")) + .unwrap(); + assert_eq!(p.exposure_for("t").floor, TrustLevel::TrustedRuntime); + p.register_input(input_rec("b", "user_supplied", "t")) + .unwrap(); + assert_eq!(p.exposure_for("t").floor, TrustLevel::UserSupplied); + p.register_input(input_rec("c", "not-a-level", "t")) + .unwrap(); + assert_eq!(p.exposure_for("t").floor, TrustLevel::ExternalUntrusted); + p.register_input(input_rec("d", "trusted_runtime", "other")) + .unwrap(); + assert_eq!(p.exposure_for("other").floor, TrustLevel::TrustedRuntime); + assert!(p + .register_input(input_rec("a", "user_supplied", "t")) + .is_err()); +} + +#[test] +fn input_registration_is_not_reachable_from_an_envelope() { + let mut rt = MockRuntime::new(); + let mut p = pipe(&mut rt); + let mut payload = serde_json::to_value(input_rec("x", "trusted_runtime", "t")).unwrap(); + payload["kind"] = json!("input_record"); + let env = json!({ + "interplane_version": "0.1", "message_id": "m1", "trace_id": "t", "parent_id": null, + "timestamp": "2026-01-01T00:00:00Z", + "source": {"kind": "model", "id": "m"}, "destination": {"kind": "runtime", "id": "mock"}, + "payload": payload + }); + let (res, _) = p.admit_value(&env); + assert_eq!(res.error.unwrap().code, ErrorCode::MalformedEnvelope); + assert!(p.inputs("t").is_empty()); +} diff --git a/spec/CORE.md b/spec/CORE.md index e742213..7d6c17c 100644 --- a/spec/CORE.md +++ b/spec/CORE.md @@ -218,7 +218,11 @@ One JSON file per case under `conformance/fixtures/NN-slug.json`: A `step` with `dialect` is parsed by Lenshift; the runner wraps each intent in an envelope with `message_id = "m---"`, `timestamp = "2026-01-01T00:00:00Z"`, source `{"kind":"model","id":}`, destination `{"kind":"runtime","id":"mock"}`. A step with -`envelope` is admitted as-is. Rendered results are fed back into the next step only when the step +`envelope` is admitted as-is. A step with `input` and no `dialect` is a host-only input +registration: the runner passes its `InputRecord` to the pipeline's `register_input` before the +next turn (0.3 cut P3). Two optional `expected` blocks: `inputs`, the trace's ledger after the last +step in order, each entry matched on the keys the fixture lists; and `exposure`, `[{request_id, inputs, floor}]` as seen in `CallContext` at each `decide`. +Verdict files carry `inputs` and `exposure` only for cases that assert them. Rendered results are fed back into the next step only when the step declares `"continues": true`. Lifecycle fixtures live under `conformance/fixtures/lifecycle/NN-slug.json` and drive the diff --git a/spec/CROSSVEIL.md b/spec/CROSSVEIL.md index 2fffded..de9ec8a 100644 --- a/spec/CROSSVEIL.md +++ b/spec/CROSSVEIL.md @@ -76,9 +76,15 @@ proposal are never flattened into indistinguishable text. Rules: inputs visible to the model when it produced the turn. Order: `trusted_runtime` > `user_supplied` > `workspace_untrusted` > `external_untrusted`; `unknown` counts as `external_untrusted`. The pipeline computes it from its own ledger; an `exposure` arriving inside - a model-produced or admitted envelope is discarded and recomputed, never read. In this version - (0.3 cut P2) both are types and schemas only: the pipeline does not yet record inputs or compute - exposure. + a model-produced or admitted envelope is discarded and recomputed, never read. Since 0.3 cut P3 + the pipeline computes it. Per trace it keeps a ledger of inputs: every result it renders back + to the model is recorded automatically (`parent_id` is the `request_id`, `trust` and + `content_kind` are the result's normalized provenance, `unknown` when it has none), and the + host adds any other input before a turn through a host-only registration call that model + output and envelopes cannot reach. All `tool_request`s of a turn, and the `CallContext` passed + to `decide` and `execute`, carry the ledger as it stood when the turn began. Exposure fails + closed: an empty ledger, an input of unknown or unrecognized trust, and an input whose + `derived_from` names an id the ledger does not hold all count as `external_untrusted`. Stage names used by this spec and their decision detail: INVALID is `REJECTED` with decision `invalid`; NOT_FOUND is `REJECTED` with decision `not_found`. A `capability_request` whose ```