aien-dev has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.
interplane-mv
INTERPLANE: open interoperability protocol between AI models and agent runtimes. Models express intent. Runtimes retain authority.
Brought by drakestapleton
GitHub aien-dev/interplane-mv#20 (code only)
Apply it
git checkout -b patch-4c88312c04ef75ab 426917a9c086e4b49e75e4948a29379dfb587f65 curl -fsSL https://interplane.io/drakestapleton/interplane-mv/patches/4c88312c04ef75ab.patch | git am
Provenance
github-import 1
aien-dev/interplane-mv
20
51bbb0a357d16253c7a400cd6cecf18ab64e6932
{"kind":"github-import","owner":"aien-dev","repo":"interplane-mv","number":20,"url":"https://github.com/aien-dev/interplane-mv/pull/20","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 1a270ca..a2f9a1c 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)!=30 else 0) + print('cases:',len(r),'mismatches:',bad); sys.exit(1 if bad or len(r)!=32 else 0) PY adapter-aien: runs-on: ubuntu-latest diff --git a/CHANGELOG.md b/CHANGELOG.md index b999e37..b30f780 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Unreleased (0.3, Trust lane) - 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. ## Unreleased (0.2, CrossAxis lane) diff --git a/STATUS.md b/STATUS.md index 9804cfe..d4b4fa2 100644 --- a/STATUS.md +++ b/STATUS.md @@ -7,7 +7,7 @@ byte-identical) · `qualified` (measured against a real model/backend). | Component | Rust | Python | Fixtures | Notes | |---|---|---|---|---| | Core schemas | specified | specified | validated | 10 schemas under spec/schemas, JSON Schema 2020-12 | -| Core types + validation + JCS | conformant | conformant | 25 cases + digest/jcs-01 | verdict files byte-identical | +| Core types + validation + JCS | conformant | conformant | 27 cases + digest/jcs-01 | verdict files byte-identical | | Lenshift openai | conformant | conformant | 8 dialect fixtures | | | Lenshift qwen35 | conformant, qualified | conformant, qualified | 10 dialect fixtures + real captures | real Qwen3.5-9B captures under qualification/captures | | Lenshift aien_legacy | tested | tested | 13 dialect fixtures, JCS-identical | aien-cli textual `<tool_call>` JSON (client.rs:381-419); unterminated calls rejected | @@ -16,10 +16,11 @@ byte-identical) · `qualified` (measured against a real model/backend). | CrossAxis Select (domain_match v1) | tested | tested, qualified | - | receipt: 71 -> 9 tools, 89% fewer first-turn prompt tokens (0.1 measure: rendered bytes + model-reported tokens) | | CrossAxis measure units (bytes, tokens_model_reported, tokens_endpoint_tokenizer, tokens_estimated) | tested | tested | schema-validated (selection.schema.json) | not yet qualified: Core ships BytesOnly + EstimatedTokens (estimator v1); live counters belong to the bench runner | | 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 | 25 cases | fails closed on adapter faults | +| 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 | | 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 | 30/30 both (25 cases + 5 lifecycle, verdicts byte-identical) | `--dump` writes canonical results per case | +| Conformance runner | implemented | implemented | 32/32 both (27 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/odysseus/README.md b/adapters/odysseus/README.md index 771c16b..47b6e0e 100644 --- a/adapters/odysseus/README.md +++ b/adapters/odysseus/README.md @@ -46,6 +46,16 @@ and needs no change (the `odysseus_text` dialect is registered adapter-locally). `workspace_untrusted` arms the gate), or set `external_context_seen=True` on the constructor. Odysseus itself treats a workspace read as arming the gate, so a later `send_email` in the same trace is `requires_approval`. +* **Result trust.** Odysseus's `ResultIntegrity` (`tool_capabilities.py:37-46`) has a `system` value that + is not an INTERPLANE `TrustLevel`; the pipeline used to fold it to `external_untrusted` silently. The + adapter now maps it explicitly: `system` (Odysseus's label for server-authored output) is + `trusted_runtime` unless Odysseus's own `tool_result_should_arm_gate` (`:506-528`) says the result + carries non-system content (the producer set `untrusted_content`), then `external_untrusted`. + `workspace_untrusted` and `external_untrusted` carry over; anything else is `external_untrusted`. + Limit: `system` is Odysseus's *default* for a registered tool, so a tool Odysseus registers without an + explicit integrity is labelled `trusted_runtime` through this adapter. None of the four tools the + adapter executes is `system` at 2992bf6 (all are `workspace_untrusted`), so no executed result + changes label today. * **Approval handle.** `odysseus-pending-<request_id>` is an opaque handle. Odysseus mints sealed `PendingToolApproval` objects only inside its agent loop (`tool_approvals.py:144`); the adapter does not, and 0.1 has no path that turns the handle into an authorization. diff --git a/adapters/odysseus/interplane_adapter_odysseus/authority.py b/adapters/odysseus/interplane_adapter_odysseus/authority.py index 518f148..4b70ed7 100644 --- a/adapters/odysseus/interplane_adapter_odysseus/authority.py +++ b/adapters/odysseus/interplane_adapter_odysseus/authority.py @@ -273,7 +273,7 @@ class OdysseusAuthority(RuntimeAuthority): except Exception as err: # noqa: BLE001 - reported as an execution error, not raised return self._error(rid, name, f"{name}: {type(err).__name__}") ms = int((time.monotonic() - started) * 1000) - trust = "trusted_runtime" if self.workspace_trusted else self._integrity(name, block.content) + trust = "trusted_runtime" if self.workspace_trusted else self._integrity(name, block.content, raw) sc = self._context_for(str(ctx.get("trace_id")), {}) sc.observe_tool_result(name, raw, block.content) # Odysseus decides what arms the gate ok = isinstance(raw, dict) and not raw.get("error") and raw.get("exit_code") in (None, 0) @@ -289,9 +289,23 @@ class OdysseusAuthority(RuntimeAuthority): trust=trust, duration_ms=ms, ) - def _integrity(self, name: str, content: str) -> str: - caps = self._ody.tool_capabilities.capabilities_for_action(name, content) - return caps.result_integrity.value # system | workspace_untrusted | external_untrusted + def _integrity(self, name: str, content: str, raw: Any = None) -> str: + """Odysseus's result integrity as a TrustLevel. + + ``workspace_untrusted`` and ``external_untrusted`` carry over. ``system`` is Odysseus's + label for server-authored output and its default for a registered tool + (tool_capabilities.py:37-46 at 2992bf6): it maps to ``trusted_runtime``, unless + Odysseus's own ``tool_result_should_arm_gate`` (:506-528) says this result carries + non-system content (the producer set ``untrusted_content``), then ``external_untrusted``. + Any other value is ``external_untrusted``. + """ + tc = self._ody.tool_capabilities + value = tc.capabilities_for_action(name, content).result_integrity.value + if value == "system": + if raw is not None and tc.tool_result_should_arm_gate(name, raw, content): + return "external_untrusted" + return "trusted_runtime" + return value if value in _UNTRUSTED else "external_untrusted" def _error(self, rid: str, name: str, message: str) -> ToolResult: return make_result( diff --git a/adapters/odysseus/tests/test_odysseus_pipeline.py b/adapters/odysseus/tests/test_odysseus_pipeline.py index 0da5334..cee1081 100644 --- a/adapters/odysseus/tests/test_odysseus_pipeline.py +++ b/adapters/odysseus/tests/test_odysseus_pipeline.py @@ -256,3 +256,17 @@ def test_importing_odysseus_does_not_write_inside_the_checkout(ody): import src.constants assert not os.path.realpath(src.constants.DATA_DIR).startswith(os.path.realpath(ody.root)) + + +def test_system_result_integrity_maps_to_a_trust_level(ody, workspace): + # Odysseus ResultIntegrity.SYSTEM (tool_capabilities.py:37-46 at 2992bf6) is not a + # TrustLevel. It is Odysseus's label for server-authored output, so it maps to + # trusted_runtime, unless Odysseus's own tool_result_should_arm_gate (:506-528) says the + # producer marked this result untrusted_content; then external_untrusted. + a = OdysseusAuthority(str(workspace), admin=True) + assert ody.tool_capabilities.capabilities_for_action("update_plan", "").result_integrity.value == "system" + assert a._integrity("update_plan", "") == "trusted_runtime" + assert a._integrity("update_plan", "", {"ok": True}) == "trusted_runtime" + assert a._integrity("update_plan", "", {"untrusted_content": True}) == "external_untrusted" + assert a._integrity("read_file", "") == "workspace_untrusted" + assert a._integrity("no_such_tool", "") == "external_untrusted" diff --git a/conformance/README.md b/conformance/README.md index d7fcc30..fb6b10c 100644 --- a/conformance/README.md +++ b/conformance/README.md @@ -7,7 +7,7 @@ was taken and is listed below. ## Layout -- `fixtures/NN-slug.json`: the 25 required cases (01-18 core; 19 valid write, 20 missing required argument, 21 stale capability mapping, 22 untrusted tool result, 23 untrusted memory result; 24 expansion by requested_excluded, 25 expansion refused by bound). `fixtures/digest/jcs-01.json`: the JCS digest check. `fixtures/lifecycle/NN-slug.json`: approval continuation cases driven against the lifecycle directly (01 forged id, 02 empty or missing id, 03 id minted for another request, 04 the runtime-minted id, 05 non-`authorized` continuation values); format in `spec/CORE.md`. +- `fixtures/NN-slug.json`: the 27 required cases (01-18 core; 19 valid write, 20 missing required argument, 21 stale capability mapping, 22 untrusted tool result, 23 untrusted memory result; 24 expansion by requested_excluded, 25 expansion refused by bound; 26 unrecognized content_kind, 27 absent, null and unrecognized trust). `fixtures/digest/jcs-01.json`: the JCS digest check. `fixtures/lifecycle/NN-slug.json`: approval continuation cases driven against the lifecycle directly (01 forged id, 02 empty or missing id, 03 id minted for another request, 04 the runtime-minted id, 05 non-`authorized` continuation values); format in `spec/CORE.md`. - `../dialects/fixtures/{openai,qwen35}/*.json`: Lenshift parse fixtures. - `runners/validate_fixtures.py`: checks every envelope and intent against `spec/schemas/`, fixture shape, runtime-count consistency, the JCS fixture, plus negative controls. Exit status is non-zero on failure. @@ -28,7 +28,8 @@ was taken and is listed below. 3. Compare. `expected.observed` is the ordered list of ObservedRecords across all steps. `expected.turns` covers Lenshift-parsed steps only. `expected.runtime` holds the decide/execute call counts. `expected.result_checks` (optional) asserts `path` (dotted, into the result payload) equals `equals` - for the result of `request_id`. + for the result of `request_id`. With `"round_trip": true` the value is read after the payload is + serialized to JCS and parsed back into the SDK's own result type, as a receiver sees it. 4. `result_digest` is `null` in fixtures: implementations compute it (digest of the canonical result payload with `provenance.duration_ms` null) and the cross-language comparison covers it. @@ -44,6 +45,16 @@ the `unknown_capability` that motivates a `requested_excluded` expansion is supp (the step's evidence), not produced by the pipeline. Case 24 then sends the call through the pipeline and expects `denied`: visibility is not authority. +## Fixture-level `mock_provenance` (cases 26, 27) + +`{<capability>: {content_kind?, trust?, trusted?}}`, copied into the mock runtime before the pipeline +runs; the mock's executed result for that capability reports these provenance values instead of its +defaults, the way a mislabelling adapter would. Harness configuration only: the mock never takes labels +from model content, and the catalog (and its digest) is unchanged. The cases check that unknown +provenance never becomes trusted: an unrecognized kind reads as `unknown`, absent or null trust as +`unknown` with `trusted` null, an unrecognized trust string as `external_untrusted` with `trusted` +false, and an adapter's `trusted: true` is ignored. Every check also runs after a JCS round trip. + ## Fixture-level `mapping_table` Absent means `mock-table`. Case 21 sets `"mapping_table": "mock-table-stale"` (same rules, wrong catalog digest), so CrossAxis must refuse with `stale_capability` before any runtime contact. diff --git a/conformance/fixtures/26-unrecognized-content-kind.json b/conformance/fixtures/26-unrecognized-content-kind.json new file mode 100644 index 0000000..ec5efae --- /dev/null +++ b/conformance/fixtures/26-unrecognized-content-kind.json @@ -0,0 +1,96 @@ +{ + "case": "26-unrecognized-content-kind", + "description": "read_file executes, and the runtime labels the result content_kind \"spreadsheet\", which is not a ContentKind value (harness-side mock_provenance, as a mislabelling adapter would). The pipeline reads an unrecognized kind as unknown (common.schema.json ContentKind) in both SDKs, as emitted and after a JCS round trip; trust stays unknown and trusted null.", + "limits": { + "max_argument_bytes": 65536 + }, + "trace_id": "trace-26", + "mock_provenance": { + "read_file": { + "content_kind": "spreadsheet" + } + }, + "steps": [ + { + "turn": 0, + "dialect": "openai", + "model": "mock-model", + "input": { + "role": "assistant", + "content": null, + "tool_calls": [ + { + "id": "call_26a", + "type": "function", + "function": { + "name": "read_file", + "arguments": "{\"path\":\"/tmp/a.txt\"}" + } + } + ] + } + } + ], + "expected": { + "observed": [ + { + "request_id": "call_26a", + "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": "" + } + ], + "runtime": { + "decide_calls": 1, + "execute_calls": 1 + }, + "result_checks": [ + { + "request_id": "call_26a", + "path": "provenance.content_kind", + "equals": "unknown" + }, + { + "request_id": "call_26a", + "path": "provenance.content_kind", + "equals": "unknown", + "round_trip": true + }, + { + "request_id": "call_26a", + "path": "provenance.trust", + "equals": "unknown" + }, + { + "request_id": "call_26a", + "path": "provenance.trust", + "equals": "unknown", + "round_trip": true + }, + { + "request_id": "call_26a", + "path": "provenance.trusted", + "equals": null + }, + { + "request_id": "call_26a", + "path": "provenance.trusted", + "equals": null, + "round_trip": true + } + ] + } +} diff --git a/conformance/fixtures/27-absent-null-unrecognized-trust.json b/conformance/fixtures/27-absent-null-unrecognized-trust.json new file mode 100644 index 0000000..baf4568 --- /dev/null +++ b/conformance/fixtures/27-absent-null-unrecognized-trust.json @@ -0,0 +1,183 @@ +{ + "case": "27-absent-null-unrecognized-trust", + "description": "Three executed results whose trust label the pipeline cannot take as given (harness-side mock_provenance): read_file with trust absent and the adapter claiming trusted true; list_dir with trust null and trusted true; append_note (normally trusted_runtime) relabelled with the unrecognized trust \"sorta_trusted\". Absent and null become unknown with trusted null; the unrecognized string becomes external_untrusted with trusted false; the adapter-supplied trusted flag is never read. Checked as emitted and after a JCS round trip.", + "limits": { + "max_argument_bytes": 65536 + }, + "trace_id": "trace-27", + "mock_provenance": { + "read_file": { + "trusted": true + }, + "list_dir": { + "trust": null, + "trusted": true + }, + "append_note": { + "trust": "sorta_trusted" + } + }, + "steps": [ + { + "turn": 0, + "dialect": "openai", + "model": "mock-model", + "input": { + "role": "assistant", + "content": null, + "tool_calls": [ + { + "id": "call_27a", + "type": "function", + "function": { + "name": "read_file", + "arguments": "{\"path\":\"/tmp/a.txt\"}" + } + }, + { + "id": "call_27b", + "type": "function", + "function": { + "name": "list_dir", + "arguments": "{\"path\":\"/tmp\"}" + } + }, + { + "id": "call_27c", + "type": "function", + "function": { + "name": "append_note", + "arguments": "{\"path\":\"/tmp/notes.md\",\"text\":\"hello\"}" + } + } + ] + } + } + ], + "expected": { + "observed": [ + { + "request_id": "call_27a", + "stage": "SUCCEEDED", + "decision": "authorized", + "status": "ok", + "error_code": null, + "decide_invoked": true, + "execute_invoked": true, + "result_digest": null + }, + { + "request_id": "call_27b", + "stage": "SUCCEEDED", + "decision": "authorized", + "status": "ok", + "error_code": null, + "decide_invoked": true, + "execute_invoked": true, + "result_digest": null + }, + { + "request_id": "call_27c", + "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": 3, + "rejected": 0, + "text": "" + } + ], + "runtime": { + "decide_calls": 3, + "execute_calls": 3 + }, + "result_checks": [ + { + "request_id": "call_27a", + "path": "provenance.trust", + "equals": "unknown" + }, + { + "request_id": "call_27a", + "path": "provenance.trust", + "equals": "unknown", + "round_trip": true + }, + { + "request_id": "call_27a", + "path": "provenance.trusted", + "equals": null + }, + { + "request_id": "call_27a", + "path": "provenance.trusted", + "equals": null, + "round_trip": true + }, + { + "request_id": "call_27b", + "path": "provenance.trust", + "equals": "unknown" + }, + { + "request_id": "call_27b", + "path": "provenance.trust", + "equals": "unknown", + "round_trip": true + }, + { + "request_id": "call_27b", + "path": "provenance.trusted", + "equals": null + }, + { + "request_id": "call_27b", + "path": "provenance.trusted", + "equals": null, + "round_trip": true + }, + { + "request_id": "call_27c", + "path": "provenance.trust", + "equals": "external_untrusted" + }, + { + "request_id": "call_27c", + "path": "provenance.trust", + "equals": "external_untrusted", + "round_trip": true + }, + { + "request_id": "call_27c", + "path": "provenance.trusted", + "equals": false + }, + { + "request_id": "call_27c", + "path": "provenance.trusted", + "equals": false, + "round_trip": true + }, + { + "request_id": "call_27c", + "path": "provenance.content_kind", + "equals": "workspace_content" + }, + { + "request_id": "call_27c", + "path": "provenance.content_kind", + "equals": "workspace_content", + "round_trip": true + } + ] + } +} diff --git a/conformance/runners/validate_fixtures.py b/conformance/runners/validate_fixtures.py index b571e0a..4f5293a 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, 25 required cases, filename == case slug + * fixture shape, 27 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 * the JCS digest fixture recomputes @@ -70,7 +70,8 @@ REQUIRED = { "10-multiple-sequential-calls","11-model-continuation","12-unsupported-dialect","13-unsupported-version", "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"} + "24-expansion-requested-excluded","25-expansion-refused-by-bound", + "26-unrecognized-content-kind","27-absent-null-unrecognized-trust"} OBS_KEYS = ["request_id","stage","decision","status","error_code","decide_invoked","execute_invoked","result_digest"] n_env = n_cases = 0 neg_done = False @@ -104,7 +105,7 @@ for p in sorted(glob.glob(os.path.join(FIX, "*.json"))): 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 c in exp.get("result_checks", []): - if set(c) != {"request_id", "path", "equals"} or c["request_id"] not in {o["request_id"] for o in obs}: + 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)) if ("selection" in f) != (name[:2] in ("24", "25")): fail("%s: selection block only in cases 24-25" % name) if "selection" in f: @@ -117,6 +118,15 @@ for p in sorted(glob.glob(os.path.join(FIX, "*.json"))): fail("%s: selections[%d] selection_digest does not recompute" % (name, i)) if i and sel.get("parent_digest") != sels[i - 1].get("selection_digest"): fail("%s: parent_digest chain broken at %d" % (name, i)) if ("mapping_table" in f) != name.startswith("21"): fail("%s: mapping_table present only in case 21" % name) + if ("mock_provenance" in f) != (name[:2] in ("26", "27")): fail("%s: mock_provenance present only in cases 26-27" % name) + for cap, o in f.get("mock_provenance", {}).items(): + if not set(o) <= {"content_kind", "trust", "trusted"}: fail("%s: mock_provenance.%s keys %s" % (name, cap, sorted(o))) + if name[:2] in ("26", "27"): + rt_paths = {(c["request_id"], c["path"]) for c in exp.get("result_checks", []) if c.get("round_trip")} + plain = {(c["request_id"], c["path"]) for c in exp.get("result_checks", []) if not c.get("round_trip")} + if not plain or rt_paths != plain: fail("%s: every provenance check must also be checked after a JCS round trip" % name) + for c in exp.get("result_checks", []): + if c["path"] == "provenance.trusted" and c["equals"] is True: fail("%s: trusted must never be true here" % name) if name.startswith("21") and f.get("mapping_table") != "mock-table-stale": fail("21: mapping_table must be mock-table-stale") if name[:2] in ("19", "22", "23", "20", "21"): want = {"19": ("SUCCEEDED", "ok"), "20": ("REJECTED", "rejected"), "21": ("REJECTED", "rejected"), diff --git a/python/interplane/conformance.py b/python/interplane/conformance.py index 6185e21..be64bdd 100644 --- a/python/interplane/conformance.py +++ b/python/interplane/conformance.py @@ -6,7 +6,7 @@ import sys from pathlib import Path from typing import Any, Optional -from .core import Decision, Lifecycle, LifecycleError, Limits, ProtocolError, jcs +from .core import Decision, Lifecycle, LifecycleError, Limits, ProtocolError, ToolResult, jcs from .crossaxis import expand, select from .crossveil import canonical_result_payload, default_pipeline @@ -27,6 +27,7 @@ def run_case(case: dict) -> dict: pipe = default_pipeline( Limits.from_dict(case.get("limits")), case.get("mapping_table", "mock-table") ) + pipe.runtime.provenance_overrides = case.get("mock_provenance", {}) name, trace_id = case["case"], case["trace_id"] observed: list = [] results: list = [] @@ -95,7 +96,11 @@ def run_case(case: dict) -> dict: for check in expected.get("result_checks", []): match = next((r for r in results if r.request_id == check["request_id"]), None) try: - actual = _dig(match.to_dict(), check["path"]) + payload = match.to_dict() + if check.get("round_trip") is True: + # as a receiver sees it: JCS bytes parsed back into the SDK's own result type + payload = ToolResult.from_dict(json.loads(jcs(payload))).to_dict() + actual = _dig(payload, check["path"]) except (AttributeError, KeyError, IndexError, ValueError): problems.append(f"result_check {check['request_id']} {check['path']}: missing") continue diff --git a/python/interplane/crossveil.py b/python/interplane/crossveil.py index 1619ccf..17254f3 100644 --- a/python/interplane/crossveil.py +++ b/python/interplane/crossveil.py @@ -184,13 +184,21 @@ def make_result( def _normalize_executed(res: ToolResult, rid: str, runtime_id: str, cap: str) -> ToolResult: - """Fit an adapter's execute() result to the canonical shape. Fails closed on trust.""" + """Fit an adapter's execute() result to the canonical shape. Fails closed on trust. + + content_kind: absent or null -> tool_result; unrecognized or not a string -> unknown. + trust: absent or null -> unknown; unrecognized or not a string -> external_untrusted. + The adapter's own ``trusted`` flag is never read; it is derived from ``trust``. + """ prov = res.provenance or {} kind, trust = prov.get("content_kind"), prov.get("trust") - kind = kind if kind in CONTENT_KINDS else DEFAULT_CONTENT_KIND + if kind is None: + kind = DEFAULT_CONTENT_KIND + elif not (isinstance(kind, str) and kind in CONTENT_KINDS): + kind = "unknown" if trust is None: trust = DEFAULT_TRUST - elif trust not in TRUST_LEVELS: + elif not (isinstance(trust, str) and trust in TRUST_LEVELS): trust = "external_untrusted" code = res.error.code if res.error else None out = make_result( @@ -713,10 +721,21 @@ class MockRuntime: def __init__(self) -> None: self.decide_calls = 0 self.execute_calls = 0 + # 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. + self.provenance_overrides: dict = {} def catalog(self) -> Catalog: return mock_catalog() + def execute(self, req: CapabilityRequest, decision: Decision, ctx: dict) -> ToolResult: + res = self._execute(req, decision, ctx) + override = self.provenance_overrides.get(req.capability) + if override and res.provenance is not None: + res.provenance = dict(res.provenance, **override) + return res + @staticmethod def _invalid_reason(args: dict, schema: dict) -> Optional[str]: for key in schema.get("required", []): @@ -759,7 +778,7 @@ class MockRuntime: return self._decision(req, "requires_approval", None, approval) return self._decision(req, "authorized") - def execute(self, req: CapabilityRequest, decision: Decision, ctx: dict) -> ToolResult: + def _execute(self, req: CapabilityRequest, decision: Decision, ctx: dict) -> ToolResult: self.execute_calls += 1 rid, cap, args = req.request_id, req.capability, req.arguments diff --git a/python/tests/test_conformance.py b/python/tests/test_conformance.py index e6a4855..9d64f84 100644 --- a/python/tests/test_conformance.py +++ b/python/tests/test_conformance.py @@ -35,7 +35,8 @@ def test_runner_writes_sorted_verdicts(tmp_path, capsys): } assert text == jcs({**data, **life}) + "\n" assert all(o["result_digest"] for v in data.values() for o in v["observed"]) - assert "30/30" in capsys.readouterr().out or len(CASES) + len(LIFECYCLE) != 30 + total = len(CASES) + len(LIFECYCLE) + assert f"{total}/{total}" in capsys.readouterr().out @pytest.mark.skipif(not LIFECYCLE, reason="no lifecycle fixtures") diff --git a/python/tests/test_pipeline.py b/python/tests/test_pipeline.py index 792d01d..97a1ef8 100644 --- a/python/tests/test_pipeline.py +++ b/python/tests/test_pipeline.py @@ -430,3 +430,22 @@ def test_untrusted_results_render_as_data(): "workspace_untrusted", "memory", ) + + +@pytest.mark.parametrize( + "label, want", + [ + ({"content_kind": "spreadsheet"}, ("unknown", "unknown", None)), + ({"content_kind": 7, "trust": ["trusted_runtime"]}, ("unknown", "external_untrusted", False)), + ({"content_kind": {"k": 1}, "trust": "sorta_trusted"}, ("unknown", "external_untrusted", False)), + ({"trust": None, "trusted": True}, ("tool_result", "unknown", None)), + ], +) +def test_unrecognized_or_unparseable_labels_never_become_trusted(label, want): + # An adapter's label the SDK cannot read: unrecognized or non-string content_kind is + # unknown (as in Rust, pipeline.rs normalize), unrecognized or non-string trust is + # external_untrusted, absent/null trust is unknown; the adapter's own trusted flag is ignored. + p = default_pipeline() + 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 diff --git a/rust/crates/interplane-conformance/src/lib.rs b/rust/crates/interplane-conformance/src/lib.rs index f398b4a..13d6fc9 100644 --- a/rust/crates/interplane-conformance/src/lib.rs +++ b/rust/crates/interplane-conformance/src/lib.rs @@ -2,7 +2,9 @@ //! mock runtime per case and compares the result with `expected`. use std::path::Path; -use interplane_core::{canonicalize, digest, Decision, Lifecycle, Limits, RequestLedger}; +use interplane_core::{ + canonicalize, digest, Decision, Lifecycle, Limits, RequestLedger, ToolResult, +}; use interplane_crossaxis::{expand, select}; use interplane_crossveil::{ mock_mapping_table, MockRuntime, ObservedRecord, Pipeline, RuntimeAuthority, @@ -30,6 +32,9 @@ pub fn run_case(fx: &Value) -> CaseRun { let trace = fx["trace_id"].as_str().unwrap_or("trace").to_string(); let limits: Limits = serde_json::from_value(fx["limits"].clone()).unwrap_or_default(); let mut rt = MockRuntime::new(); + if let Some(o) = fx["mock_provenance"].as_object() { + rt.provenance_overrides = o.clone(); + } let mut observed = vec![]; let mut turns = vec![]; let mut results = vec![]; @@ -185,11 +190,20 @@ pub fn compare(fx: &Value, run: &CaseRun) -> Vec<String> { 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(""); - let found = run + let result = run .results .iter() - .find(|r| r["request_id"].as_str() == Some(rid)) - .and_then(|r| dotted(r, path)); + .find(|r| r["request_id"].as_str() == Some(rid)); + // `round_trip`: read the value after JCS serialization and a parse back into the + // SDK's own result type, as a receiver would see it. + let parsed = if c["round_trip"] == json!(true) { + result + .and_then(|r| serde_json::from_str::<ToolResult>(&canonicalize(r)).ok()) + .and_then(|t| serde_json::to_value(t).ok()) + } else { + result.cloned() + }; + let found = parsed.as_ref().and_then(|r| dotted(r, path)); if found != Some(&c["equals"]) { errs.push(format!( "result_check {rid}:{path}: expected {}, got {:?}", diff --git a/rust/crates/interplane-conformance/tests/fixtures.rs b/rust/crates/interplane-conformance/tests/fixtures.rs index c2be2b6..8e83025 100644 --- a/rust/crates/interplane-conformance/tests/fixtures.rs +++ b/rust/crates/interplane-conformance/tests/fixtures.rs @@ -40,7 +40,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(), 25); + assert_eq!(all.len(), 27); let mut fx = all .into_iter() .find(|f| f["case"] == "24-expansion-requested-excluded") diff --git a/rust/crates/interplane-crossveil/src/mock.rs b/rust/crates/interplane-crossveil/src/mock.rs index 00088d2..916b5b7 100644 --- a/rust/crates/interplane-crossveil/src/mock.rs +++ b/rust/crates/interplane-crossveil/src/mock.rs @@ -120,6 +120,11 @@ fn build_table(catalog_digest: Option<String>) -> MappingTable { pub struct MockRuntime { pub decide_calls: u32, pub execute_calls: u32, + /// Harness-only: per capability, provenance keys (`content_kind`, `trust`, `trusted`) the + /// mock reports on an executed result in place of its defaults, as a mislabelling adapter + /// would. Set by the conformance runner from a fixture's `mock_provenance`; never read from + /// arguments, extensions or envelopes. + pub provenance_overrides: Map<String, Value>, } impl MockRuntime { @@ -308,7 +313,7 @@ impl RuntimeAuthority for MockRuntime { ), _ => (None, None), }; - r.provenance = Some(ResultProvenance { + let mut prov = ResultProvenance { runtime: Some("mock".into()), capability: Some(req.capability.clone()), duration_ms: Some(0), @@ -316,7 +321,19 @@ impl RuntimeAuthority for MockRuntime { trust, trusted: None, extensions: Map::new(), - }); + }; + if let Some(o) = self.provenance_overrides.get(&req.capability) { + if let Some(v) = o.get("content_kind") { + prov.content_kind = serde_json::from_value(v.clone()).ok().flatten(); + } + if let Some(v) = o.get("trust") { + prov.trust = serde_json::from_value(v.clone()).ok().flatten(); + } + if let Some(v) = o.get("trusted") { + prov.trusted = v.as_bool(); + } + } + r.provenance = Some(prov); r } diff --git a/spec/CORE.md b/spec/CORE.md index f2e2dec..e742213 100644 --- a/spec/CORE.md +++ b/spec/CORE.md @@ -103,7 +103,10 @@ forced to `null`. Before the runtime is reached, `provenance.runtime` and `capab execute (denied, requires_approval, not_found, invalid, unknown decision, decide fault), `provenance.runtime` and `capability` are set and `content_kind`, `trust` and `trusted` are `null`: no data was produced, so there is no content to classify. The defaults `tool_result` / `unknown` -apply only to executed results whose runtime said nothing about their content. +apply only to executed results whose runtime said nothing about their content (absent or null). +On an executed result, a `content_kind` the pipeline does not recognize (or a non-string) becomes +`unknown`, a `trust` it does not recognize (or a non-string) becomes `external_untrusted`, and an +adapter-supplied `trusted` is replaced by the value derived from `trust`. Error messages (pinned; `<x>` substituted; no other text): @@ -178,6 +181,13 @@ A second table `mock-table-stale` is identical but carries `catalog_digest: "sha which the mock runtime does **not** have, so the runtime answers `not_found`. Any other name is `unknown_capability`. +A fixture may carry `mock_provenance: {<capability>: {content_kind?, trust?, trusted?}}`. The +runner copies it into the mock before the pipeline runs, and the mock's executed result for that +capability reports those provenance values in place of the table's (a key present with `null` +sets null). It stands in for a mislabelling adapter. It is harness configuration, like +`mapping_table`: the mock never reads labels from arguments, `extensions` or envelopes, and the +catalog is unchanged. Only cases 26 and 27 use it. + The mock runtime validates `arguments` against the capability parameters (required keys present, declared types match) and answers `invalid` with `invalid_arguments` on failure. It counts `decide` and `execute` invocations; conformance records them. @@ -269,6 +279,8 @@ to null. Rust and Python runners must emit byte-identical `observed` arrays. | 21 | stale capability mapping (table built against catalog digest `sha256:0000…`) | `rejected`, `stale_capability`, decide 0 | | 22 | untrusted tool result (`web_fetch` content carries tool-call markup) | ok; `provenance.trust = external_untrusted`, `content_kind = web_content`; the rendered tool message contains the markup verbatim; a following `continues` turn parses the model's text only, and 0 new intents come from the result | | 23 | untrusted memory result (`recall_memory`) | ok; trust `workspace_untrusted`, kind `memory`; rendered as data | +| 26 | unrecognized `content_kind` (`read_file` labelled `spreadsheet` via `mock_provenance`) | ok; kind `unknown`, trust `unknown`, `trusted` null, also after a JCS round trip | +| 27 | absent, null and unrecognized trust (`read_file` trust absent with `trusted: true`; `list_dir` trust null; `append_note` trust `sorta_trusted`) | absent and null: `unknown`, `trusted` null; unrecognized: `external_untrusted`, `trusted` false; also after a JCS round trip | Plus Lenshift dialect fixtures under `dialects/fixtures/<dialect>/` with expected canonical output (see `LENSHIFT.md`) and one JCS digest fixture under `conformance/fixtures/digest/`. diff --git a/spec/CROSSVEIL.md b/spec/CROSSVEIL.md index 06df115..de210a5 100644 --- a/spec/CROSSVEIL.md +++ b/spec/CROSSVEIL.md @@ -23,7 +23,8 @@ Rules the pipeline enforces (and conformance tests): 5. Adapter exceptions in `decide` become `denied` with `runtime_unavailable`; in `execute` they become `error` with `execution_error`. Fail closed. 6. The adapter, not INTERPLANE, decides the trust class of the returned data - (`result.provenance.trust`, `origin`). Default when the adapter says nothing: `untrusted_tool_content` (fail closed). + (`result.provenance.trust` and `result.provenance.content_kind`). Defaults when the adapter says + nothing: `tool_result` + `unknown` (fail closed; see Crossveil Trust below). ## State record @@ -46,11 +47,19 @@ proposal are never flattened into indistinguishable text. Rules: 1. Absent or unparseable trust is `unknown`, which receivers treat like `external_untrusted`. Inability to determine trust is never converted into trust. 2. Adapters set `result.provenance.content_kind` and `trust` on every result. Defaults when the - runtime says nothing: `tool_result` + `unknown`. + runtime says nothing (absent or null): `tool_result` + `unknown`. A `content_kind` string the + receiver does not recognize, or a non-string value, is `unknown`. A `trust` string it does not + recognize, or a non-string value, is `external_untrusted`. `trusted` is always derived from + `trust` (CORE.md) and an adapter-supplied `trusted` is never read, so unknown provenance never + becomes trusted by being serialized and read back (conformance cases 26 and 27). 3. Results are rendered back to the model as data. The pipeline never parses tool-call markup inside a result into a new intent (conformance cases 22 and 23 carry such markup as an injection probe). -4. Odysseus's `metadata.trusted`/`source` and its `untrusted_context_message` map onto these axes; - AIEN's aegis-runtime has no equivalent today and the adapter fills in `unknown` honestly. +4. Odysseus's `metadata.trusted`/`source` and its `untrusted_context_message` map onto these axes. + Its `ResultIntegrity` maps explicitly: `workspace_untrusted` and `external_untrusted` carry over; + `system` (server-authored output) is `trusted_runtime` unless Odysseus's own + `tool_result_should_arm_gate` marks the result as carrying non-system content, then + `external_untrusted`. AIEN's aegis-runtime has no equivalent today and the adapter fills in + `unknown` honestly. 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 diff --git a/spec/VERSIONING.md b/spec/VERSIONING.md index 7eda91c..4635866 100644 --- a/spec/VERSIONING.md +++ b/spec/VERSIONING.md @@ -5,7 +5,7 @@ Protocol version is `MAJOR.MINOR` and appears in every envelope as `interplane_v | Change | Effect on version | Receiver behaviour | |---|---|---| | New optional field | MINOR | Older receivers ignore it. It must be safe to ignore. | -| New enum value in a non-authority enum (`event`, `ErrorCode`, `Origin`) | MINOR | Receivers tolerate unknown values where the spec says so. | +| New enum value in a non-authority enum (`event`, `ErrorCode`, `ContentKind`) | MINOR | Receivers tolerate unknown values where the spec says so. | | New value in an authority enum (`decision`, `TrustLevel`) | MAJOR | Unknown decision values are treated as `denied`. Unknown trust levels are treated as `external_untrusted`. Never default to authorization. | | Required field added or removed, field type changed, semantic change | MAJOR | Receiver rejects the envelope with `unsupported_version` if MAJOR differs from what it implements. | | Dialect parser change that alters canonical output for an existing fixture | parser_version MAJOR (per dialect) | Recorded in `provenance.parser_version`. Fixture expectations are re-pinned. | diff --git a/spec/schemas/common.schema.json b/spec/schemas/common.schema.json index 376fcea..daad053 100644 --- a/spec/schemas/common.schema.json +++ b/spec/schemas/common.schema.json @@ -238,7 +238,7 @@ "external_provider", "unknown" ], - "description": "What a piece of model-visible material is. Unknown values are treated as unknown." + "description": "What a piece of model-visible material is. On an executed result an absent or null kind is tool_result. A value the receiver does not recognize (or a non-string) is treated as unknown." }, "TrustLevel": { "type": "string", @@ -249,7 +249,7 @@ "external_untrusted", "unknown" ], - "description": "How much the runtime trusts the material. Only the runtime assigns it; a model cannot raise it. Inability to determine trust is `unknown`, never silently trusted. Unknown enum values are treated as external_untrusted." + "description": "How much the runtime trusts the material. Only the runtime assigns it; a model cannot raise it. Inability to determine trust (absent or null) is `unknown`, never silently trusted. A value the receiver does not recognize (or a non-string) is treated as external_untrusted. `trusted` is derived from this level and is never true for unknown or unrecognized values." } } } \ No newline at end of file