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#91 (code only)
Apply it
git checkout -b patch-510f217182d72a63 1b71f6b76d52c2d0d2b64edf720fb3f80f170077 curl -fsSL https://interplane.io/drakestapleton/interplane-mv/patches/510f217182d72a63.patch | git am
Provenance
github-import 1
aien-dev/interplane-mv
91
e73478c49f454ba19bb098d953b5e985efaf223a
{"kind":"github-import","owner":"aien-dev","repo":"interplane-mv","number":91,"url":"https://github.com/aien-dev/interplane-mv/pull/91","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:40:14Z","metadata":"unavailable","state_derived":true}
Changes
diff --git a/CHANGELOG.md b/CHANGELOG.md index 50cd3ab..043564a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased (0.3, Trust lane) +- VAC M5 with a REAL model turn (`adapters/aien/scripts/test-m5-model-turn.sh`, evidence `adapters/aien/evidence/m5-model-turn-2026-10-09/`): the daemon's own loaded Llama-3.2-1B-Instruct (CPU, `StreamTurn`) writes the tool call that proposes the README change; the same independent judge, approved path and rollback follow. The bundle's `model-turn/2` record names the request and response bytes, weights digest, backend line and times, and `provenance` checks each against the retained bytes and the daemon's own generation record (`modelturn.rs`, 11 tests in `provenance/tests/model_turn_link.rs`). Verdict `PASS complete ... proposal=model_generation/2`; a turn that does not chain is a `FAIL`, one declared scripted stays `PASS_LABELLED_INCOMPLETE missing=link:model_turn`. New adapter pieces: `LedgerClient::stream_turn`, `ComposeLedgerAuthority::set_before_ack`, hook switch `M5_PROPOSAL_FILE`. Restart rows `row12` (a daemon restart does not make a spent approval spendable) and `row13` (a daemon killed between intent and ack leaves the adapter receipt `UNRESOLVED` and the ledger intent OPEN, undecided). One model turn is not a learning system. - Provenance companion manifest v0 (`provenance/`, ADR 0004, outside Core, no protocol change): offline verifier and fixtures binding corpus BOM and license assertions, WALDO run, export, a structural AIEN load-support check, the AIEN candidate and load line, an INTERPLANE trace and the aien-cli effect receipt by retained bytes and existing digests. Real WALDO smoke export verifies and is labelled incomplete (its byte tokenizer is not loadable by AIEN); the full chain is synthetic. 21 verdict tests, each a literal verdict line. - Spec clarification, issue #57 (closed as option C, keep fail-closed): `spec/CORE.md` (non-executed results in the exposure ledger) and `spec/CROSSVEIL.md` rule 6 now say that a denied, requires_approval, not_found or rejected result (a runtime `invalid` decision gives `rejected`), an unknown decision value, a decide fault, and an executed `error` or `timed_out` result are rendered to the model and recorded `unknown` (executed ones `tool_result` + `unknown`), so each counts as `external_untrusted` and the floor stays there for the rest of the trace; this is intended, hosts that read the floor will hold later effects. Reason: a refusal body can carry echoed model text, adapter reason text and adapter-minted ids. No fixture outcome, schema or code changes, so by `spec/VERSIONING.md` and CONTRIBUTING no version bump (a MINOR bump is required only when an expected fixture outcome changes). Analysis `docs/analysis/ISSUE-57-refusal-exposure.md`; tests `python/tests/test_refusal_exposure.py` and `rust/crates/interplane-crossveil/tests/refusal_exposure.rs` (9 each, including one that pins the documented rule). Options R and V (relaxing it) are issue #80. diff --git a/adapters/aien/README.md b/adapters/aien/README.md index 5b1bbb3..df0434f 100644 --- a/adapters/aien/README.md +++ b/adapters/aien/README.md @@ -460,3 +460,15 @@ cargo fmt --check && cargo clippy --offline --all-targets -- -D warnings Building `aegis` runs its `build.rs`, which writes `mojo/libaegis_simd.so` into the pinned aegis clone as an untracked file. This crate is its own Cargo workspace and is not a member of `rust/Cargo.toml`. + +### The same cycle with a real model turn + +`scripts/test-m5-model-turn.sh` (same inputs as `test-m5-rsi.sh`, plus the two restart rows) replaces the +deterministic proposer with the model the daemon loaded: the harness sends one `StreamTurn` (CPU), the daemon +generates the `write_file` tool call and writes its own generation record, and the same judge, approval and +rollback follow. The bundle carries a `model-turn/2` record (request and response bytes, weights digest, the +backend line, times). The verifier compares each with the retained bytes and the daemon's record, so the +verdict is `PASS complete ... proposal=model_generation/2` only when the digests chain; a turn that does not +chain is a `FAIL`, and a bundle that says its turn was scripted stays `PASS_LABELLED_INCOMPLETE +missing=link:model_turn`. Limits: one 1B model turn with a worked example in the prompt is not a learning +system; the request bytes and times are the harness's own; the generation record is unsigned. diff --git a/adapters/aien/evidence/m5-model-turn-2026-10-09/README.md b/adapters/aien/evidence/m5-model-turn-2026-10-09/README.md new file mode 100644 index 0000000..6e74eb1 --- /dev/null +++ b/adapters/aien/evidence/m5-model-turn-2026-10-09/README.md @@ -0,0 +1,24 @@ +# M5 model-turn evidence (2026-10-09) + +Written by `adapters/aien/scripts/test-m5-model-turn.sh` on a clean tree and committed unedited: +`receipt.json`, `negative-verdicts.txt`, `live.log`, `rows/`, `bundle/`. + +## Re-verify + + adapters/aien/evidence/m5-model-turn-2026-10-09/reverify.sh <model_dir> + +`<model_dir>` is the Llama-3.2-1B-Instruct snapshot the daemon loaded +(`5a8abab4a5d6f164389b1079fb721cfab8d7126c`), holding `model.safetensors`, `tokenizer.json`, +`config.json`. The committed bundle leaves those three files out (2.4 GB), so verifying it as-is +gives `FAIL missing_record: export_config`. The script copies them into a scratch copy of the bundle, +refuses if a digest differs from the manifest, and runs the offline verifier. Expected last line: +`PASS complete effect=aien-ledger-slice/1:strong proposal=model_generation/2 candidate=none`. + +The script reads the judge public key and the policy pin from `receipt.json`, so it checks internal +consistency only. For a real audit, pin both from a source you trust and call the verifier directly. + +## Note on `negative-verdicts.txt` + +That file is the script's output as run. The first counterfeit there is named `response_text_replaced`. +The gate script now names it `response_text_replaced_refused_by_generation_record_binding`, because the +daemon's generation record is what refuses it. The committed file keeps the old name by design. diff --git a/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/COMPANION.json b/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/COMPANION.json new file mode 100644 index 0000000..a1d5a80 --- /dev/null +++ b/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/COMPANION.json @@ -0,0 +1,171 @@ +{ + "aien": { + "candidate_id": null, + "executable": "aien-cli", + "executable_sha256": "920324dad6a12115e14795a2820c224d9f656d9af1c6dd611faf72908c4e31ec", + "native": { + "claimed": true, + "omega_sha": "6c6180cf378075b61291f4565d226eba38b4decd" + }, + "note": "no frozen AIEN candidate: no candidate_manifest record; CPU-reference backend as printed in the daemon log; whether the compose library was native-linked is reported only when the daemon returns compose_native (sovereign-core #346); aien.native then names it" + }, + "completeness": { + "missing": [], + "reason": "the proposal text was generated by the model this daemon loaded; the daemon's own generation record, the request and response bytes, the weights digest and the parsed request all chain to the effect", + "state": "complete" + }, + "effect": { + "approval_binding": "aien.approval.v2", + "binding": "aien-ledger-slice/1", + "proposal_origin": "model_generation/2" + }, + "evaluation": { + "binding": "rsi-eval/2", + "note": "the change was proposed by the model turn and evaluated by the separate judge process; the judge's public key is supplied to the verifier out of band", + "policy": "evaluation_policy", + "receipt": "evaluation_receipt" + }, + "export": { + "chat_template": null, + "format": "huggingface" + }, + "fixture": { + "class": "real", + "note": "Real daemon; the ledger records are the daemon's own ComposeRecall output (pretty-printed only); daemon_run.json and the 3-message trace are written by the test harness, including their timestamps. The model turn is REAL: the daemon generated the tool-call text (StreamTurn) and wrote its own generation record; the request bytes and timestamps are the harness's." + }, + "interplane": { + "request_id": "ledger:t0:c0", + "trace_id": "ledger" + }, + "kind": "interplane-provenance-companion", + "lineage": { + "kind": "unknown_pretraining", + "origin": { + "model_id": "unsloth/Llama-3.2-1B-Instruct", + "model_id_source": "caller-asserted (AIEN_LEDGER_MODEL_ID or default; not checked against the model directory)", + "note": "weights as downloaded; no training evidence is held", + "revision": "5a8abab4a5d6f164389b1079fb721cfab8d7126c" + } + }, + "load_support": { + "declared": "supported_structural" + }, + "records": { + "aien_load_log": { + "bytes": 1557, + "path": "records/aien/daemon-load.log", + "sha256": "c31af16184d49068897ec7e1a63441b46604057df70bdd622ac0f864e8daaa8f" + }, + "compose_recall": { + "bytes": 14161, + "path": "records/aien/compose-recall.json", + "sha256": "0dfe94dd212adc48abf51173e5ee194053d7671331c4dd7a9773faab0b2e970a" + }, + "daemon_run": { + "bytes": 499, + "path": "records/aien/daemon-run.json", + "sha256": "ea3aa3eaa6d0cf0be1fb8e5a8db5d345962a48f237192309e127315909b7b9ea" + }, + "evaluation_policy": { + "bytes": 399, + "path": "records/evaluation/policy.json", + "sha256": "81cfeb99a2f1dcbe833012290c4a017d213d5b770e58e4fcc3766e77eae1b4f3" + }, + "evaluation_receipt": { + "bytes": 2750, + "path": "records/evaluation/receipt.json", + "sha256": "48b80ffd13e9daf1df75f42f4d8e9e92c1c4dfb8e43eb4c823536d8f003da854" + }, + "export_config": { + "bytes": 894, + "path": "records/export/config.json", + "sha256": "dfb67fd8afe73a1c75245824ef9d64a6ba8983025447e3bf76aa1ea57ee46152" + }, + "export_tokenizer": { + "bytes": 17209920, + "path": "records/export/tokenizer.json", + "sha256": "6b9e4e7fb171f92fd137b777cc2714bf87d11576700a1dcd7a399e7bbe39537b" + }, + "export_weights": { + "bytes": 2471645608, + "path": "records/export/model.safetensors", + "sha256": "1ff795ff6a07e6a68085d206fb84417da2f083f68391c2843cd2b8ac6df8538f" + }, + "interplane_trace": { + "bytes": 6321, + "path": "records/interplane/trace.json", + "sha256": "af7725e5093acaefe570f74d1a715eafa8ba4d8e9c860cb62a6f9d97342a0434" + }, + "ledger_ack": { + "bytes": 775, + "path": "records/aien/ledger-ack.json", + "sha256": "39c7c18bf9147884f774540060c95707b661f2dce6b4ae067dcd36cc9ebdb531" + }, + "ledger_claim": { + "bytes": 543, + "path": "records/aien/ledger-claim.json", + "sha256": "28c8c062f0dc49c42d16298a4119684f5bdd120c12b060b3894f7aabd179716b" + }, + "ledger_committed": { + "bytes": 482, + "path": "records/aien/ledger-committed.json", + "sha256": "44957ad402b4ce1cad56e75441a88d09976c2a0364503a0a94059ec332201658" + }, + "ledger_generation": { + "bytes": 1388, + "path": "records/aien/ledger-generation.json", + "sha256": "1ed85efdf80282c9240d1281ddb16a98e19d610ee39eefd65005d589ca9ddb67" + }, + "ledger_grant": { + "bytes": 1233, + "path": "records/aien/ledger-grant.json", + "sha256": "6751da4cdeac437ae030378d2d1ba2d07064b5731e31730ff67bcdf017f5657b" + }, + "ledger_intent": { + "bytes": 814, + "path": "records/aien/ledger-intent.json", + "sha256": "b3eaf5caa60909644a4311164a6c533c4c28dc690e1ee911b7e800fb262b0d4e" + }, + "model_request": { + "bytes": 1107, + "path": "records/model/request.json", + "sha256": "64b5e18a282638663fa897a3822d84b65d09b74d413dd7dee51286426f61c346" + }, + "model_turn": { + "bytes": 1197, + "path": "records/interplane/model-turn.json", + "sha256": "49b5555f022ff94a439eab07c479d3382e44f163ff4837b6d30bdc76004c9c93" + }, + "source_pin": { + "bytes": 232, + "path": "records/task/source-pin.json", + "sha256": "e315c920e664b551eb752c6aa50b025e2e437b399611129c531360ed4c980979" + }, + "task": { + "bytes": 239, + "path": "records/task/task.json", + "sha256": "31448cac17a70fcfbacf71ae771c88f10e788b2f414dc9f739cb9619c33822a1" + }, + "test_run_record": { + "bytes": 814, + "path": "records/task/test-run.json", + "sha256": "22da61ecc67641900be908985d87821df7a36730068dd24f3e02868f75d9aadf" + }, + "test_stderr": { + "bytes": 0, + "path": "records/task/test-stderr.txt", + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "test_stdout": { + "bytes": 115, + "path": "records/task/test-stdout.txt", + "sha256": "e4b442ba923bff2b9f7fef266120fe8b99c1562b834cab3452f49b7e83d89e32" + } + }, + "schema": 0, + "test_run": { + "binding": "vac-test-run/1", + "record": "test_run_record", + "task_id": "vac/m5-rsi-dashes-1" + } +} \ No newline at end of file diff --git a/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/aien/compose-recall.json b/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/aien/compose-recall.json new file mode 100644 index 0000000..4c3432c --- /dev/null +++ b/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/aien/compose-recall.json @@ -0,0 +1,405 @@ +{ + "cited": [ + { + "cls": 6, + "digest": "4739fbfc86ac017229264600565a9b61c00c7fb910d318a0f1bc26ab8d678ba7", + "id": 7, + "kind": 65554, + "links": [ + 0, + 0, + 0, + 0 + ], + "note": "effect", + "subject": 0, + "tag": 4, + "text": "{\"approval_id\":\"aien-approval:ledger:t0:c0:1e254965876f60c4\",\"approval_key\":\"87a956a8147814a6bba44043d64adf1c539c430364842fdba36428f2cee7a918\",\"approved_submission\":\"accepted\",\"executor\":{\"pid\":1032374,\"start\":26226924},\"request_id\":\"ledger:t0:c0\",\"trace_id\":\"ledger\"}", + "verified": true + }, + { + "cls": 6, + "digest": "d306f069eeaf45b1c26072cdde7f7d9ff1ff844316a41a41b879493feda3f4b0", + "id": 8, + "kind": 65554, + "links": [ + 7, + 0, + 0, + 0 + ], + "note": "effect", + "subject": 0, + "tag": 4, + "text": "{\"approved_submission\":\"in_flight\",\"claim\":7}", + "verified": true + }, + { + "cls": 3, + "digest": "4af2d6fa58691b8dc59a2b3bd318afa38398b01a127385a25922de7b814d13db", + "id": 9, + "kind": 65537, + "links": [ + 0, + 0, + 0, + 0 + ], + "note": null, + "subject": 1, + "tag": 2, + "text": null, + "verified": true + }, + { + "cls": 4, + "digest": "15d2f06f0bb4e1b61c0ea14baf6f22d5caf1b02c7cb3866534f2b3a07941e924", + "id": 10, + "kind": 65540, + "links": [ + 9, + 1, + 5, + 0 + ], + "note": null, + "subject": 3, + "tag": 3, + "text": null, + "verified": true + }, + { + "cls": 4, + "digest": "ce2dae156f61ddfab9a89809cb1098fc113fa7e32dc50f5c3d03552d59e5218d", + "id": 11, + "kind": 65540, + "links": [ + 9, + 1, + 5, + 0 + ], + "note": null, + "subject": 2, + "tag": 3, + "text": null, + "verified": true + }, + { + "cls": 4, + "digest": "4227583f9ce0eda10fa1dd856089e733053c2182d930cb01e50fe096875c2d94", + "id": 12, + "kind": 65540, + "links": [ + 11, + 1, + 2, + 3 + ], + "note": null, + "subject": 4, + "tag": 3, + "text": null, + "verified": true + }, + { + "cls": 4, + "digest": "e9ebe36c698d7cf8da95470848829ad2ca721ece1ce7a208e009cad895285002", + "id": 13, + "kind": 65540, + "links": [ + 12, + 4, + 0, + 0 + ], + "note": null, + "subject": 5, + "tag": 3, + "text": null, + "verified": true + }, + { + "cls": 2, + "digest": "1b7a79c5310b787af8b1a27ae3bd9754a4eec594ed02c80194f5b9c36fc9d747", + "id": 14, + "kind": 65553, + "links": [ + 11, + 9, + 0, + 0 + ], + "note": null, + "subject": 5, + "tag": 9, + "text": null, + "verified": true + }, + { + "cls": 2, + "digest": "89d4eac64b58b5729db97697e8cd5fe5e6867ccf02c85f6968b318e599b2f0bb", + "id": 15, + "kind": 65553, + "links": [ + 10, + 9, + 0, + 0 + ], + "note": null, + "subject": 5, + "tag": 9, + "text": null, + "verified": true + }, + { + "cls": 6, + "digest": "9c9552a2f42133e46dbb03f3283f82472673f5445ecf8c769be495a486c2cf91", + "id": 16, + "kind": 65554, + "links": [ + 12, + 14, + 15, + 13 + ], + "note": null, + "subject": 5, + "tag": 9, + "text": null, + "verified": true + }, + { + "cls": 6, + "digest": "9bfad5d59fd398422b8a21093372845d20ff79c1dbae4528814b214fd94dd767", + "id": 17, + "kind": 65555, + "links": [ + 14, + 16, + 0, + 0 + ], + "note": null, + "subject": 5, + "tag": 0, + "text": null, + "verified": true + }, + { + "cls": 6, + "digest": "da9404db58b796a6407fd0c62963d525bd454e7d9ee6b665e02b7f3c207534d7", + "id": 18, + "kind": 65556, + "links": [ + 15, + 16, + 0, + 0 + ], + "note": null, + "subject": 5, + "tag": 1, + "text": null, + "verified": true + }, + { + "cls": 6, + "digest": "53daab672eea11df7671d99f2bf1db7dc6777cda9fc144ea3b707f5ae8ee2e29", + "id": 19, + "kind": 65554, + "links": [ + 7, + 0, + 0, + 0 + ], + "note": "effect", + "subject": 0, + "tag": 4, + "text": "{\"approved_submission\":\"committed\",\"claim\":7,\"evidence\":{\"compose_proposal_sha256\":\"1af7be7a3ee53ce8c275d533b705b574ab5c0844a1c49b0d75297d61fb14dc9f\",\"cx_evidence\":16,\"cx_promotion\":17,\"task\":11070280916336830953}}", + "verified": true + }, + { + "cls": 6, + "digest": "a5b1416a708a2761771e81557ced8f372b29655a9c282b496bf1bf15bcc0b74b", + "id": 20, + "kind": 65556, + "links": [ + 17, + 16, + 7, + 0 + ], + "note": "authorization", + "subject": 0, + "tag": 3, + "text": "{\"approval_id\":\"aien-approval:ledger:t0:c0:1e254965876f60c4\",\"approval_key\":\"87a956a8147814a6bba44043d64adf1c539c430364842fdba36428f2cee7a918\",\"approved_grant\":1,\"approved_proposal_sha256\":\"0c8ac735e87e5eea8c1e5d0d839086fe6c3d60a0b4ffcbf75067cd7743a6e74f\",\"approver\":\"drake\",\"content_sha256\":\"d4965fdde4501d20dc04cead7e3cdec8a1053d561f10c45c8ffbc233cf24105a\",\"cx_evidence\":16,\"cx_promotion\":17,\"desk_key_id\":\"173ad004b48706f3\",\"path\":\"README.md\",\"prior_sha256\":\"97d16a1b1081f0f6c940d223e58231cd036ff34782178ec4ceaa3a11e495497f\",\"proposal_sha256\":\"1af7be7a3ee53ce8c275d533b705b574ab5c0844a1c49b0d75297d61fb14dc9f\",\"provenance\":{\"allen_agent\":\"none\",\"generation_record\":null},\"replay_claim\":7,\"request_id\":\"ledger:t0:c0\",\"target\":\"/home/drakestapleton/.claude/jobs/300ce471/tmp/gate4/rows/m5mt/ws/README.md\",\"trace_id\":\"ledger\",\"workspace\":\"/home/drakestapleton/.claude/jobs/300ce471/tmp/gate4/rows/m5mt/ws\"}", + "verified": true + }, + { + "cls": 6, + "digest": "60d49c0a68b53c51bb28c94e0cb73391c512a142cd99a3733f824e0ce6284f31", + "id": 21, + "kind": 65554, + "links": [ + 20, + 0, + 0, + 0 + ], + "note": "effect", + "subject": 0, + "tag": 4, + "text": "{\"authorization\":20,\"content_sha256\":\"d4965fdde4501d20dc04cead7e3cdec8a1053d561f10c45c8ffbc233cf24105a\",\"executor\":{\"pid\":1032351,\"start\":26226923},\"path\":\"README.md\",\"phase\":\"intent\",\"prior_sha256\":\"97d16a1b1081f0f6c940d223e58231cd036ff34782178ec4ceaa3a11e495497f\",\"proposal_sha256\":\"1af7be7a3ee53ce8c275d533b705b574ab5c0844a1c49b0d75297d61fb14dc9f\",\"provenance\":{\"allen_agent\":\"none\",\"generation_record\":null},\"target\":\"/home/drakestapleton/.claude/jobs/300ce471/tmp/gate4/rows/m5mt/ws/README.md\",\"tool\":\"write_file\"}", + "verified": true + }, + { + "cls": 6, + "digest": "9a2f31ae0072ee2e5cd2ac536dcefb5e589d44d5442c74463a2cda93ab0a7c13", + "id": 22, + "kind": 65554, + "links": [ + 21, + 20, + 0, + 0 + ], + "note": "effect", + "subject": 0, + "tag": 4, + "text": "{\"authorization\":20,\"content_sha256\":\"d4965fdde4501d20dc04cead7e3cdec8a1053d561f10c45c8ffbc233cf24105a\",\"disk_error\":null,\"disk_sha256\":\"d4965fdde4501d20dc04cead7e3cdec8a1053d561f10c45c8ffbc233cf24105a\",\"executor_reported\":{\"bytes\":193,\"error\":null,\"written_sha256\":\"d4965fdde4501d20dc04cead7e3cdec8a1053d561f10c45c8ffbc233cf24105a\"},\"intent\":21,\"path\":\"README.md\",\"phase\":\"ack\",\"provenance\":{\"allen_agent\":\"none\",\"generation_record\":null},\"state\":\"DONE\",\"tool\":\"write_file\"}", + "verified": true + } + ], + "compose_dir": "/home/drakestapleton/.claude/jobs/300ce471/tmp/gate4/rows/m5mt/compose", + "compose_native": true, + "host": [ + { + "cls": 6, + "digest": "dd59a93f2a758e19b261722e9ee197172e8e1d053d50beb6faa22d7b224f22d5", + "id": 6, + "kind": 65554, + "links": [ + 0, + 0, + 0, + 0 + ], + "note": "effect", + "subject": 0, + "tag": 4, + "text": "{\"daemon\":{\"pid\":1032374,\"start_ticks\":26226924,\"started_unix_ms\":\"1791548576939\"},\"decoding\":{\"greedy_tokens\":85,\"mode\":\"greedy\",\"sampled_tokens\":0},\"finish_reason\":\"eos\",\"generation\":1,\"model_path\":\"/home/drakestapleton/.cache/huggingface/hub/models--unsloth--Llama-3.2-1B-Instruct/blobs/1ff795ff6a07e6a68085d206fb84417da2f083f68391c2843cd2b8ac6df8538f\",\"model_sha256\":\"1ff795ff6a07e6a68085d206fb84417da2f083f68391c2843cd2b8ac6df8538f\",\"operation_id\":\"1791548582580247466\",\"output_text_sha256\":\"0cb56db283d14d54d3e1f0ece3db024ed26f653d08f53d1a0f14120139690fdf\",\"output_token_ids_sha256\":\"0760d756e37b8ff794777ee3f35855f9959b9bcc2d24ef19b03fbbae484c0f72\",\"output_tokens\":84,\"prompt_ids_sha256\":\"a08ecf1dd4222e681c449d8fca129c4fd69c0ad4c41c44cb0af946f33ba7173d\",\"request_id\":1791548582580,\"tokenizer_path\":\"/home/drakestapleton/.cache/huggingface/hub/models--unsloth--Llama-3.2-1B-Instruct/blobs/6b9e4e7fb171f92fd137b777cc2714bf87d11576700a1dcd7a399e7bbe39537b\",\"tokenizer_sha256\":\"6b9e4e7fb171f92fd137b777cc2714bf87d11576700a1dcd7a399e7bbe39537b\",\"total_tokens\":358,\"v\":1}", + "verified": true + }, + { + "cls": 6, + "digest": "4739fbfc86ac017229264600565a9b61c00c7fb910d318a0f1bc26ab8d678ba7", + "id": 7, + "kind": 65554, + "links": [ + 0, + 0, + 0, + 0 + ], + "note": "effect", + "subject": 0, + "tag": 4, + "text": "{\"approval_id\":\"aien-approval:ledger:t0:c0:1e254965876f60c4\",\"approval_key\":\"87a956a8147814a6bba44043d64adf1c539c430364842fdba36428f2cee7a918\",\"approved_submission\":\"accepted\",\"executor\":{\"pid\":1032374,\"start\":26226924},\"request_id\":\"ledger:t0:c0\",\"trace_id\":\"ledger\"}", + "verified": true + }, + { + "cls": 6, + "digest": "d306f069eeaf45b1c26072cdde7f7d9ff1ff844316a41a41b879493feda3f4b0", + "id": 8, + "kind": 65554, + "links": [ + 7, + 0, + 0, + 0 + ], + "note": "effect", + "subject": 0, + "tag": 4, + "text": "{\"approved_submission\":\"in_flight\",\"claim\":7}", + "verified": true + }, + { + "cls": 6, + "digest": "53daab672eea11df7671d99f2bf1db7dc6777cda9fc144ea3b707f5ae8ee2e29", + "id": 19, + "kind": 65554, + "links": [ + 7, + 0, + 0, + 0 + ], + "note": "effect", + "subject": 0, + "tag": 4, + "text": "{\"approved_submission\":\"committed\",\"claim\":7,\"evidence\":{\"compose_proposal_sha256\":\"1af7be7a3ee53ce8c275d533b705b574ab5c0844a1c49b0d75297d61fb14dc9f\",\"cx_evidence\":16,\"cx_promotion\":17,\"task\":11070280916336830953}}", + "verified": true + }, + { + "cls": 6, + "digest": "a5b1416a708a2761771e81557ced8f372b29655a9c282b496bf1bf15bcc0b74b", + "id": 20, + "kind": 65556, + "links": [ + 17, + 16, + 7, + 0 + ], + "note": "authorization", + "subject": 0, + "tag": 3, + "text": "{\"approval_id\":\"aien-approval:ledger:t0:c0:1e254965876f60c4\",\"approval_key\":\"87a956a8147814a6bba44043d64adf1c539c430364842fdba36428f2cee7a918\",\"approved_grant\":1,\"approved_proposal_sha256\":\"0c8ac735e87e5eea8c1e5d0d839086fe6c3d60a0b4ffcbf75067cd7743a6e74f\",\"approver\":\"drake\",\"content_sha256\":\"d4965fdde4501d20dc04cead7e3cdec8a1053d561f10c45c8ffbc233cf24105a\",\"cx_evidence\":16,\"cx_promotion\":17,\"desk_key_id\":\"173ad004b48706f3\",\"path\":\"README.md\",\"prior_sha256\":\"97d16a1b1081f0f6c940d223e58231cd036ff34782178ec4ceaa3a11e495497f\",\"proposal_sha256\":\"1af7be7a3ee53ce8c275d533b705b574ab5c0844a1c49b0d75297d61fb14dc9f\",\"provenance\":{\"allen_agent\":\"none\",\"generation_record\":null},\"replay_claim\":7,\"request_id\":\"ledger:t0:c0\",\"target\":\"/home/drakestapleton/.claude/jobs/300ce471/tmp/gate4/rows/m5mt/ws/README.md\",\"trace_id\":\"ledger\",\"workspace\":\"/home/drakestapleton/.claude/jobs/300ce471/tmp/gate4/rows/m5mt/ws\"}", + "verified": true + }, + { + "cls": 6, + "digest": "60d49c0a68b53c51bb28c94e0cb73391c512a142cd99a3733f824e0ce6284f31", + "id": 21, + "kind": 65554, + "links": [ + 20, + 0, + 0, + 0 + ], + "note": "effect", + "subject": 0, + "tag": 4, + "text": "{\"authorization\":20,\"content_sha256\":\"d4965fdde4501d20dc04cead7e3cdec8a1053d561f10c45c8ffbc233cf24105a\",\"executor\":{\"pid\":1032351,\"start\":26226923},\"path\":\"README.md\",\"phase\":\"intent\",\"prior_sha256\":\"97d16a1b1081f0f6c940d223e58231cd036ff34782178ec4ceaa3a11e495497f\",\"proposal_sha256\":\"1af7be7a3ee53ce8c275d533b705b574ab5c0844a1c49b0d75297d61fb14dc9f\",\"provenance\":{\"allen_agent\":\"none\",\"generation_record\":null},\"target\":\"/home/drakestapleton/.claude/jobs/300ce471/tmp/gate4/rows/m5mt/ws/README.md\",\"tool\":\"write_file\"}", + "verified": true + }, + { + "cls": 6, + "digest": "9a2f31ae0072ee2e5cd2ac536dcefb5e589d44d5442c74463a2cda93ab0a7c13", + "id": 22, + "kind": 65554, + "links": [ + 21, + 20, + 0, + 0 + ], + "note": "effect", + "subject": 0, + "tag": 4, + "text": "{\"authorization\":20,\"content_sha256\":\"d4965fdde4501d20dc04cead7e3cdec8a1053d561f10c45c8ffbc233cf24105a\",\"disk_error\":null,\"disk_sha256\":\"d4965fdde4501d20dc04cead7e3cdec8a1053d561f10c45c8ffbc233cf24105a\",\"executor_reported\":{\"bytes\":193,\"error\":null,\"written_sha256\":\"d4965fdde4501d20dc04cead7e3cdec8a1053d561f10c45c8ffbc233cf24105a\"},\"intent\":21,\"path\":\"README.md\",\"phase\":\"ack\",\"provenance\":{\"allen_agent\":\"none\",\"generation_record\":null},\"state\":\"DONE\",\"tool\":\"write_file\"}", + "verified": true + } + ], + "machine_id": "15c5f2abb32debab524526f4d06e3aedb5570953bdb9473b885f0f30b0667629", + "missing": [], + "omega_sha": "6c6180cf378075b61291f4565d226eba38b4decd", + "prefix": null, + "prefix_digest": null, + "records_total": 22 +} \ No newline at end of file diff --git a/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/aien/daemon-load.log b/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/aien/daemon-load.log new file mode 100644 index 0000000..c5f0966 --- /dev/null +++ b/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/aien/daemon-load.log @@ -0,0 +1,15 @@ +⚡ Starting AIEN Sovereign Runtime Daemon... + KV pool: 8589934592 bytes (8.00 GiB) = 8192 blocks x 16 tokens x 16 layers x 8 kv heads x 64 head_dim x 2 (K,V) x 4 bytes; context 131072 tokens from model max_sequence_length (config.json max_position_embeddings) + KV pool memory check: needs 8589934592 bytes (8.00 GiB), MemAvailable 104481579008 bytes (97.31 GiB) + Backend: NativeTransformerBackend/CPU-reference (Omega GPU engine not linked, explicit fallback) + Model: checkpoint loaded from /home/drakestapleton/.cache/huggingface/hub/models--unsloth--Llama-3.2-1B-Instruct/snapshots/5a8abab4a5d6f164389b1079fb721cfab8d7126c/model.safetensors (tokenizer loaded, model_id=5a8abab4a5d6f164389b1079fb721cfab8d7126c, config=unsloth/Llama-3.2-1B-Instruct (config.json), model_sha256=1ff795ff6a07e6a68085d206fb84417da2f083f68391c2843cd2b8ac6df8538f, tokenizer_sha256=6b9e4e7fb171f92fd137b777cc2714bf87d11576700a1dcd7a399e7bbe39537b) + KV: one pooled KV shared by runtime and backend + Tokenizer: llama3 (Llama 3 instruct) chat template, stop ids [128001, 128008, 128009] +✓ Binding socket at /home/drakestapleton/.claude/jobs/300ce471/tmp/gate4/rows/m5mt/aien.sock + Warm-up: 1 token in 4688 ms over 124 prompt tokens (discarded) +Authorize MAC: off (authorize is authenticated by the OS user only) +Compose: native (omega 6c6180cf378075b61291f4565d226eba38b4decd) +Reconcile: no compose home yet +Replay reconcile: no compose home yet +ALLEN: not engaged (AIEN_ALLEN_SUBJECT unset); no identity claim +Cortex mark: mark created for a new home (seq 1, records 5) diff --git a/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/aien/daemon-run.json b/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/aien/daemon-run.json new file mode 100644 index 0000000..5d9edb7 --- /dev/null +++ b/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/aien/daemon-run.json @@ -0,0 +1,10 @@ +{ + "boot_id": "8ff5f413-7f55-4bfa-999b-a80f3145d5de", + "executable_sha256": "920324dad6a12115e14795a2820c224d9f656d9af1c6dd611faf72908c4e31ec", + "kind": "aien-daemon-run", + "note": "written by the run harness from /proc/<pid>/stat and the spawned child pid, not by the daemon", + "pid": 1032374, + "socket": "/home/drakestapleton/.claude/jobs/300ce471/tmp/gate4/rows/m5mt/aien.sock", + "start_ticks": 26226924, + "workspace": "/home/drakestapleton/.claude/jobs/300ce471/tmp/gate4/rows/m5mt/ws" +} \ No newline at end of file diff --git a/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/aien/ledger-ack.json b/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/aien/ledger-ack.json new file mode 100644 index 0000000..e138113 --- /dev/null +++ b/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/aien/ledger-ack.json @@ -0,0 +1,17 @@ +{ + "cls": 6, + "digest": "9a2f31ae0072ee2e5cd2ac536dcefb5e589d44d5442c74463a2cda93ab0a7c13", + "id": 22, + "kind": 65554, + "links": [ + 21, + 20, + 0, + 0 + ], + "note": "effect", + "subject": 0, + "tag": 4, + "text": "{\"authorization\":20,\"content_sha256\":\"d4965fdde4501d20dc04cead7e3cdec8a1053d561f10c45c8ffbc233cf24105a\",\"disk_error\":null,\"disk_sha256\":\"d4965fdde4501d20dc04cead7e3cdec8a1053d561f10c45c8ffbc233cf24105a\",\"executor_reported\":{\"bytes\":193,\"error\":null,\"written_sha256\":\"d4965fdde4501d20dc04cead7e3cdec8a1053d561f10c45c8ffbc233cf24105a\"},\"intent\":21,\"path\":\"README.md\",\"phase\":\"ack\",\"provenance\":{\"allen_agent\":\"none\",\"generation_record\":null},\"state\":\"DONE\",\"tool\":\"write_file\"}", + "verified": true +} \ No newline at end of file diff --git a/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/aien/ledger-claim.json b/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/aien/ledger-claim.json new file mode 100644 index 0000000..5e1754e --- /dev/null +++ b/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/aien/ledger-claim.json @@ -0,0 +1,17 @@ +{ + "cls": 6, + "digest": "4739fbfc86ac017229264600565a9b61c00c7fb910d318a0f1bc26ab8d678ba7", + "id": 7, + "kind": 65554, + "links": [ + 0, + 0, + 0, + 0 + ], + "note": "effect", + "subject": 0, + "tag": 4, + "text": "{\"approval_id\":\"aien-approval:ledger:t0:c0:1e254965876f60c4\",\"approval_key\":\"87a956a8147814a6bba44043d64adf1c539c430364842fdba36428f2cee7a918\",\"approved_submission\":\"accepted\",\"executor\":{\"pid\":1032374,\"start\":26226924},\"request_id\":\"ledger:t0:c0\",\"trace_id\":\"ledger\"}", + "verified": true +} \ No newline at end of file diff --git a/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/aien/ledger-committed.json b/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/aien/ledger-committed.json new file mode 100644 index 0000000..632bfb5 --- /dev/null +++ b/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/aien/ledger-committed.json @@ -0,0 +1,17 @@ +{ + "cls": 6, + "digest": "53daab672eea11df7671d99f2bf1db7dc6777cda9fc144ea3b707f5ae8ee2e29", + "id": 19, + "kind": 65554, + "links": [ + 7, + 0, + 0, + 0 + ], + "note": "effect", + "subject": 0, + "tag": 4, + "text": "{\"approved_submission\":\"committed\",\"claim\":7,\"evidence\":{\"compose_proposal_sha256\":\"1af7be7a3ee53ce8c275d533b705b574ab5c0844a1c49b0d75297d61fb14dc9f\",\"cx_evidence\":16,\"cx_promotion\":17,\"task\":11070280916336830953}}", + "verified": true +} \ No newline at end of file diff --git a/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/aien/ledger-generation.json b/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/aien/ledger-generation.json new file mode 100644 index 0000000..87c7a32 --- /dev/null +++ b/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/aien/ledger-generation.json @@ -0,0 +1,17 @@ +{ + "cls": 6, + "digest": "dd59a93f2a758e19b261722e9ee197172e8e1d053d50beb6faa22d7b224f22d5", + "id": 6, + "kind": 65554, + "links": [ + 0, + 0, + 0, + 0 + ], + "note": "effect", + "subject": 0, + "tag": 4, + "text": "{\"daemon\":{\"pid\":1032374,\"start_ticks\":26226924,\"started_unix_ms\":\"1791548576939\"},\"decoding\":{\"greedy_tokens\":85,\"mode\":\"greedy\",\"sampled_tokens\":0},\"finish_reason\":\"eos\",\"generation\":1,\"model_path\":\"/home/drakestapleton/.cache/huggingface/hub/models--unsloth--Llama-3.2-1B-Instruct/blobs/1ff795ff6a07e6a68085d206fb84417da2f083f68391c2843cd2b8ac6df8538f\",\"model_sha256\":\"1ff795ff6a07e6a68085d206fb84417da2f083f68391c2843cd2b8ac6df8538f\",\"operation_id\":\"1791548582580247466\",\"output_text_sha256\":\"0cb56db283d14d54d3e1f0ece3db024ed26f653d08f53d1a0f14120139690fdf\",\"output_token_ids_sha256\":\"0760d756e37b8ff794777ee3f35855f9959b9bcc2d24ef19b03fbbae484c0f72\",\"output_tokens\":84,\"prompt_ids_sha256\":\"a08ecf1dd4222e681c449d8fca129c4fd69c0ad4c41c44cb0af946f33ba7173d\",\"request_id\":1791548582580,\"tokenizer_path\":\"/home/drakestapleton/.cache/huggingface/hub/models--unsloth--Llama-3.2-1B-Instruct/blobs/6b9e4e7fb171f92fd137b777cc2714bf87d11576700a1dcd7a399e7bbe39537b\",\"tokenizer_sha256\":\"6b9e4e7fb171f92fd137b777cc2714bf87d11576700a1dcd7a399e7bbe39537b\",\"total_tokens\":358,\"v\":1}", + "verified": true +} \ No newline at end of file diff --git a/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/aien/ledger-grant.json b/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/aien/ledger-grant.json new file mode 100644 index 0000000..f94d1c0 --- /dev/null +++ b/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/aien/ledger-grant.json @@ -0,0 +1,17 @@ +{ + "cls": 6, + "digest": "a5b1416a708a2761771e81557ced8f372b29655a9c282b496bf1bf15bcc0b74b", + "id": 20, + "kind": 65556, + "links": [ + 17, + 16, + 7, + 0 + ], + "note": "authorization", + "subject": 0, + "tag": 3, + "text": "{\"approval_id\":\"aien-approval:ledger:t0:c0:1e254965876f60c4\",\"approval_key\":\"87a956a8147814a6bba44043d64adf1c539c430364842fdba36428f2cee7a918\",\"approved_grant\":1,\"approved_proposal_sha256\":\"0c8ac735e87e5eea8c1e5d0d839086fe6c3d60a0b4ffcbf75067cd7743a6e74f\",\"approver\":\"drake\",\"content_sha256\":\"d4965fdde4501d20dc04cead7e3cdec8a1053d561f10c45c8ffbc233cf24105a\",\"cx_evidence\":16,\"cx_promotion\":17,\"desk_key_id\":\"173ad004b48706f3\",\"path\":\"README.md\",\"prior_sha256\":\"97d16a1b1081f0f6c940d223e58231cd036ff34782178ec4ceaa3a11e495497f\",\"proposal_sha256\":\"1af7be7a3ee53ce8c275d533b705b574ab5c0844a1c49b0d75297d61fb14dc9f\",\"provenance\":{\"allen_agent\":\"none\",\"generation_record\":null},\"replay_claim\":7,\"request_id\":\"ledger:t0:c0\",\"target\":\"/home/drakestapleton/.claude/jobs/300ce471/tmp/gate4/rows/m5mt/ws/README.md\",\"trace_id\":\"ledger\",\"workspace\":\"/home/drakestapleton/.claude/jobs/300ce471/tmp/gate4/rows/m5mt/ws\"}", + "verified": true +} \ No newline at end of file diff --git a/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/aien/ledger-intent.json b/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/aien/ledger-intent.json new file mode 100644 index 0000000..954254b --- /dev/null +++ b/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/aien/ledger-intent.json @@ -0,0 +1,17 @@ +{ + "cls": 6, + "digest": "60d49c0a68b53c51bb28c94e0cb73391c512a142cd99a3733f824e0ce6284f31", + "id": 21, + "kind": 65554, + "links": [ + 20, + 0, + 0, + 0 + ], + "note": "effect", + "subject": 0, + "tag": 4, + "text": "{\"authorization\":20,\"content_sha256\":\"d4965fdde4501d20dc04cead7e3cdec8a1053d561f10c45c8ffbc233cf24105a\",\"executor\":{\"pid\":1032351,\"start\":26226923},\"path\":\"README.md\",\"phase\":\"intent\",\"prior_sha256\":\"97d16a1b1081f0f6c940d223e58231cd036ff34782178ec4ceaa3a11e495497f\",\"proposal_sha256\":\"1af7be7a3ee53ce8c275d533b705b574ab5c0844a1c49b0d75297d61fb14dc9f\",\"provenance\":{\"allen_agent\":\"none\",\"generation_record\":null},\"target\":\"/home/drakestapleton/.claude/jobs/300ce471/tmp/gate4/rows/m5mt/ws/README.md\",\"tool\":\"write_file\"}", + "verified": true +} \ No newline at end of file diff --git a/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/evaluation/policy.json b/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/evaluation/policy.json new file mode 100644 index 0000000..28bc2d7 --- /dev/null +++ b/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/evaluation/policy.json @@ -0,0 +1,18 @@ +{ + "policy_id": "vac-m5-readme-dashes", + "holdout_set_sha256": "662163365703186910d3b9364e2761c82ca55200487d534ec04287d03554be36", + "min_holdout_pass_ratio": 1.0, + "require_admitted": true, + "allowed_targets": [ + "README.md" + ], + "protected_paths": [ + "src", + "Cargo.toml", + "Cargo.lock", + "TASK.md", + ".cargo", + ".gitignore" + ], + "non_inferiority_margin_pct": 200.0 +} diff --git a/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/evaluation/receipt.json b/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/evaluation/receipt.json new file mode 100644 index 0000000..e680c5d --- /dev/null +++ b/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/evaluation/receipt.json @@ -0,0 +1,80 @@ +{ + "cycle_id": "m5-20261009T122350Z-1036048", + "candidate_id": "model-gen-6", + "parent_id": "1c376da0f25b1c68fc89539536859d7c6d81ab69", + "evaluated_at": "2026-10-09T12:23:51.694237253+00:00", + "evaluator_version": "0.1.0", + "passed_all_hard_invariants": true, + "passed_statistical_gates": true, + "admitted": true, + "layer_results": [ + { + "layer_name": "Correctness", + "is_hard_invariant": true, + "passed": true, + "score": 1.0, + "summary": "Correctness: compile=OK, abi=STABLE, unit=2/2, integ=0/0", + "violations": [] + }, + { + "layer_name": "Security", + "is_hard_invariant": true, + "passed": true, + "score": 1.0, + "summary": "Security: root_of_trust=PASS, zero_disk_secrets=PASS, network_isolation=PASS", + "violations": [] + }, + { + "layer_name": "Style", + "is_hard_invariant": true, + "passed": true, + "score": 1.0, + "summary": "Style: em_dashes=0, en_dashes=0, buzzwords=0, tropes=0", + "violations": [] + }, + { + "layer_name": "Performance", + "is_hard_invariant": false, + "passed": true, + "score": 1.0, + "summary": "Performance: delta=-5.37%, p_val=0.4124, p95_ci_upper=7.39%, p99_ci_upper=5.04%, sig=NO", + "violations": [] + }, + { + "layer_name": "ResourceEfficiency", + "is_hard_invariant": false, + "passed": true, + "score": 1.0, + "summary": "ResourceEfficiency: rss_growth=0.00%, limit_mb_ok=true, ctxt_delta=4", + "violations": [] + }, + { + "layer_name": "LongitudinalReplay", + "is_hard_invariant": true, + "passed": true, + "score": 1.0, + "summary": "LongitudinalReplay: passed=4/4, regressions=0", + "violations": [] + } + ], + "metrics_summary": { + "latency_delta_pct": -5.369460526343269, + "p_value": 0.4124, + "p95_ci_upper_degradation_pct": 7.391175809133686, + "p99_ci_upper_degradation_pct": 5.041006509817817, + "rss_growth_pct": 0.0, + "candidate_resident_mb": 2 + }, + "receipt_digest": "d3c734ee7f9b32c40ee4052d9e6895af9cd4b9344a754a612ba939950de35f86", + "signature": "tpm2-p256:c8272cc3092e5394ffc3215b265fda7fe1273a368e35fe2d0c223db9257cbfc5f2addec75140b08a4abb0e77f4894e3c4cd009f1d86b105c635fb634190a8da2", + "format_version": 2, + "binding": { + "subject_path": "README.md", + "subject_sha256": "d4965fdde4501d20dc04cead7e3cdec8a1053d561f10c45c8ffbc233cf24105a", + "holdout_set_sha256": "662163365703186910d3b9364e2761c82ca55200487d534ec04287d03554be36", + "holdouts_total": 4, + "holdouts_passed": 4, + "policy_sha256": "81cfeb99a2f1dcbe833012290c4a017d213d5b770e58e4fcc3766e77eae1b4f3", + "evaluator_binary_sha256": "00c8e8c769acbb69862c363eb9fb836ea66525957e8d75c631c45d9cbab08504" + } +} diff --git a/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/interplane/model-turn.json b/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/interplane/model-turn.json new file mode 100644 index 0000000..d00275c --- /dev/null +++ b/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/interplane/model-turn.json @@ -0,0 +1,23 @@ +{ + "backend": "Backend: NativeTransformerBackend/CPU-reference (Omega GPU engine not linked, explicit fallback)", + "dialect": "aien_legacy", + "generation_record_id": 6, + "generation_record_source": "TurnFinished.generation_record", + "input": "<tool_call>\n{\"name\": \"write_file\", \"arguments\": {\"path\": \"README.md\", \"content\": \"# rsi-dashes\\n\\nA tiny fixture, small on purpose. The judge runs its holdout command and reads the answers; the proposer never sees them.\\nIt covers pages 1 to 3 of the VAC M5 note, nothing more.\\n\"}}\n</tool_call>", + "model": "llama-3.2-1b-instruct", + "model_id": "unsloth/Llama-3.2-1B-Instruct", + "record": "model-turn/2", + "request_record": "model_request", + "request_sha256": "64b5e18a282638663fa897a3822d84b65d09b74d413dd7dee51286426f61c346", + "response_sha256": "0cb56db283d14d54d3e1f0ece3db024ed26f653d08f53d1a0f14120139690fdf", + "sampling": { + "max_tokens": 512, + "temperature": 0.0, + "total_tokens": 358 + }, + "stream_finished": "2026-10-09T12:23:50Z", + "stream_started": "2026-10-09T12:23:02Z", + "trace_id": "ledger", + "turn": 0, + "weights_sha256": "1ff795ff6a07e6a68085d206fb84417da2f083f68391c2843cd2b8ac6df8538f" +} \ No newline at end of file diff --git a/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/interplane/trace.json b/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/interplane/trace.json new file mode 100644 index 0000000..dde1fb1 --- /dev/null +++ b/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/interplane/trace.json @@ -0,0 +1,182 @@ +[ + { + "destination": { + "id": "aien", + "kind": "runtime" + }, + "interplane_version": "0.1", + "message_id": "m-1", + "payload": { + "arguments": { + "content": "# rsi-dashes\n\nA tiny fixture, small on purpose. The judge runs its holdout command and reads the answers; the proposer never sees them.\nIt covers pages 1 to 3 of the VAC M5 note, nothing more.\n", + "path": "README.md" + }, + "kind": "tool_request", + "provenance": { + "coercion": "none", + "dialect": "aien_legacy", + "dialect_version": "1", + "exposure": { + "floor": "user_supplied", + "inputs": [ + "in-user" + ] + }, + "model": "llama-3.2-1b-instruct", + "parser_version": "1.0.0", + "raw_name": "write_file", + "source_digest": "sha256:0cb56db283d14d54d3e1f0ece3db024ed26f653d08f53d1a0f14120139690fdf", + "source_turn": 0 + }, + "request_id": "ledger:t0:c0", + "tool": { + "name": "write_file", + "namespace": null + } + }, + "source": { + "id": "llama-3.2-1b-instruct", + "kind": "model" + }, + "timestamp": "2026-10-09T12:23:51Z", + "trace_id": "ledger" + }, + { + "destination": { + "id": "llama-3.2-1b-instruct", + "kind": "model" + }, + "interplane_version": "0.1", + "message_id": "m-2", + "parent_id": "m-1", + "payload": { + "data": null, + "decision": { + "approval": { + "approval_id": "aien-approval:ledger:t0:c0:1e254965876f60c4", + "expires_at": null, + "scope": "1e254965876f60c4d2982f081770cefe5adc3869fe95327e718dc5ec92a23162" + }, + "authority": { + "decision_id": null, + "policy_engine": "aien-mcp.EffectClassAuthority", + "runtime": "aien" + }, + "capability": "write_file", + "constraints": [], + "decision": "requires_approval", + "kind": "decision", + "reason": "tool `write_file` needs approval (effect bits 0x8)", + "request_id": "ledger:t0:c0", + "runtime_state": { + "values": [ + "effect_class=WorldMutation", + "staged=true", + "intent_digest=1e254965876f60c4d2982f081770cefe5adc3869fe95327e718dc5ec92a23162" + ], + "vocabulary": "aien.effect_intent" + } + }, + "error": { + "code": "approval_required", + "message": "approval required: aien-approval:ledger:t0:c0:1e254965876f60c4", + "retryable": false + }, + "kind": "result", + "provenance": { + "capability": "write_file", + "content_kind": null, + "duration_ms": null, + "runtime": "aien", + "trust": null, + "trusted": null + }, + "request_id": "ledger:t0:c0", + "status": "requires_approval" + }, + "source": { + "id": "aien", + "kind": "runtime" + }, + "timestamp": "2026-10-09T12:23:51Z", + "trace_id": "ledger" + }, + { + "destination": { + "id": "llama-3.2-1b-instruct", + "kind": "model" + }, + "interplane_version": "0.1", + "message_id": "m-3", + "parent_id": "m-1", + "payload": { + "data": { + "receipt": { + "ack_digest": "9a2f31ae0072ee2e5cd2ac536dcefb5e589d44d5442c74463a2cda93ab0a7c13", + "ack_record_id": 22, + "approval_id": "aien-approval:ledger:t0:c0:1e254965876f60c4", + "approved_proposal_sha256": "0c8ac735e87e5eea8c1e5d0d839086fe6c3d60a0b4ffcbf75067cd7743a6e74f", + "approver": "drake", + "boundary": "boundary = authenticated daemon handoff (ComposeApprovedProposal: desk MAC, durable replay claim) -> compose verify + AEGIS -> J-Space branch -> World commit -> Cortex promotion/evidence -> daemon-written grant on compose_proposal_sha256 -> effect intent -> write -> ack; the production effect path, not WALDO provenance", + "compose_proposal_sha256": "1af7be7a3ee53ce8c275d533b705b574ab5c0844a1c49b0d75297d61fb14dc9f", + "content_sha256": "d4965fdde4501d20dc04cead7e3cdec8a1053d561f10c45c8ffbc233cf24105a", + "disk_sha256": "d4965fdde4501d20dc04cead7e3cdec8a1053d561f10c45c8ffbc233cf24105a", + "grant_digest": "a5b1416a708a2761771e81557ced8f372b29655a9c282b496bf1bf15bcc0b74b", + "grant_id": 20, + "handoff": { + "aegis_pass_mask": 1, + "approval_key": "87a956a8147814a6bba44043d64adf1c539c430364842fdba36428f2cee7a918", + "approved_grant": 20, + "branch_count": 1, + "committed": true, + "cx_evidence": 16, + "cx_goal": 9, + "cx_promotion": 17, + "desk_key_id": "173ad004b48706f3", + "grant_links": [ + 17, + 16 + ], + "outcome": 1, + "proposer": "hook:approved-proposal", + "record_digest": "69fa04f9762cdbe64088683f257e91eb35f2ea3d0a2fc1a221904dde08bb4212", + "replay_claim": 7, + "state": "COMMITTED", + "target": "/home/drakestapleton/.claude/jobs/300ce471/tmp/gate4/rows/m5mt/ws/README.md", + "task": 11070280916336830953, + "winner": 0, + "winner_digest": "0777ee947837c873efaff7c03db8aea7de0142cf47a88a567c81621c921726b4" + }, + "intent_digest": "60d49c0a68b53c51bb28c94e0cb73391c512a142cd99a3733f824e0ce6284f31", + "intent_id": 21, + "path": "README.md", + "prior_sha256": "97d16a1b1081f0f6c940d223e58231cd036ff34782178ec4ceaa3a11e495497f", + "proposal_sha256": "1af7be7a3ee53ce8c275d533b705b574ab5c0844a1c49b0d75297d61fb14dc9f", + "request_id": "ledger:t0:c0", + "state": "DONE", + "target": "/home/drakestapleton/.claude/jobs/300ce471/tmp/gate4/rows/m5mt/ws/README.md", + "trace_id": "ledger" + } + }, + "decision": null, + "error": null, + "kind": "result", + "provenance": { + "capability": "write_file", + "content_kind": "tool_result", + "duration_ms": 0, + "runtime": "aien", + "trust": "trusted_runtime", + "trusted": true + }, + "request_id": "ledger:t0:c0", + "status": "ok" + }, + "source": { + "id": "aien", + "kind": "runtime" + }, + "timestamp": "2026-10-09T12:23:51Z", + "trace_id": "ledger" + } +] \ No newline at end of file diff --git a/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/model/request.json b/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/model/request.json new file mode 100644 index 0000000..580cf64 --- /dev/null +++ b/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/model/request.json @@ -0,0 +1 @@ +[{"content":"You are a file editing assistant. You never write prose. You answer every request with exactly one tool call in this form and nothing else:\n<tool_call>\n{\"name\": \"write_file\", \"arguments\": {\"path\": \"FILE\", \"content\": \"FULL NEW TEXT\"}}\n</tool_call>\nLine breaks inside the text are written as \\n. The new text must contain no em dash (—) and no en dash (–): write a comma where an em dash was, and the word to where an en dash was.","role":"system"},{"content":"File NOTES.md contains:\n# Plan\n\nA small tool—fast on purpose.\nIt covers pages 4–6—nothing more.\n","role":"user"},{"content":"<tool_call>\n{\"name\": \"write_file\", \"arguments\": {\"path\": \"NOTES.md\", \"content\": \"# Plan\\n\\nA small tool, fast on purpose.\\nIt covers pages 4 to 6, nothing more.\\n\"}}\n</tool_call>","role":"assistant"},{"content":"File README.md contains:\n# rsi-dashes\n\nA tiny fixture—small on purpose. The judge runs its holdout command and\nreads the answers; the proposer never sees them.\n\nIt covers pages 1–3 of the VAC M5 note—nothing more.\n","role":"user"}] \ No newline at end of file diff --git a/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/task/source-pin.json b/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/task/source-pin.json new file mode 100644 index 0000000..5e09cb9 --- /dev/null +++ b/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/task/source-pin.json @@ -0,0 +1,7 @@ +{ + "commit": "1c376da0f25b1c68fc89539536859d7c6d81ab69", + "kind": "vac-source-pin", + "repo": "rsi_dashes", + "target_blob_sha256": "97d16a1b1081f0f6c940d223e58231cd036ff34782178ec4ceaa3a11e495497f", + "target_path": "README.md" +} \ No newline at end of file diff --git a/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/task/task.json b/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/task/task.json new file mode 100644 index 0000000..61cf084 --- /dev/null +++ b/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/task/task.json @@ -0,0 +1,13 @@ +{ + "kind": "vac-task", + "repo_commit": "1c376da0f25b1c68fc89539536859d7c6d81ab69", + "target_path": "README.md", + "task_id": "vac/m5-rsi-dashes-1", + "test_cmd": [ + "cargo", + "test", + "--offline", + "--locked", + "-q" + ] +} \ No newline at end of file diff --git a/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/task/test-run.json b/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/task/test-run.json new file mode 100644 index 0000000..8e861e0 --- /dev/null +++ b/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/task/test-run.json @@ -0,0 +1,25 @@ +{ + "argv": [ + "cargo", + "test", + "--offline", + "--locked", + "-q" + ], + "before": { + "stderr_sha256": "7b1f5d41b607c2552bd3afa9745f6ee796109268b2a956fd6851f7dbeb08052c", + "stdout_sha256": "529911fac03facaca20f466251670d3424bfde3440581cc652a339e394284b82" + }, + "cwd_rel": ".", + "duration_ms": 147, + "exit_code": 0, + "kind": "vac-test-run", + "started_unix_ms": 1791548631887, + "stderr_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "stdout_sha256": "e4b442ba923bff2b9f7fef266120fe8b99c1562b834cab3452f49b7e83d89e32", + "target_blob_sha256_after": "d4965fdde4501d20dc04cead7e3cdec8a1053d561f10c45c8ffbc233cf24105a", + "task_id": "vac/m5-rsi-dashes-1", + "test_exit_before": 101, + "tree_commit_after": "025adb4ca4cbe606d582a202616f7526c4c502e3", + "v": 1 +} \ No newline at end of file diff --git a/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/task/test-stderr.txt b/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/task/test-stderr.txt new file mode 100644 index 0000000..e69de29 diff --git a/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/task/test-stdout.txt b/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/task/test-stdout.txt new file mode 100644 index 0000000..174360f --- /dev/null +++ b/adapters/aien/evidence/m5-model-turn-2026-10-09/bundle/records/task/test-stdout.txt @@ -0,0 +1,5 @@ + +running 2 tests +.. +test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s + diff --git a/adapters/aien/evidence/m5-model-turn-2026-10-09/live.log b/adapters/aien/evidence/m5-model-turn-2026-10-09/live.log new file mode 100644 index 0000000..a82231e --- /dev/null +++ b/adapters/aien/evidence/m5-model-turn-2026-10-09/live.log @@ -0,0 +1,12 @@ + Compiling interplane-provenance v0.0.1 (/home/drakestapleton/workspace/interplane-c793fc-mt/provenance) + Compiling interplane-adapter-aien v0.1.0 (/home/drakestapleton/workspace/interplane-c793fc-mt/adapters/aien) + Finished `test` profile [unoptimized + debuginfo] target(s) in 2.99s + Running tests/compose_ledger.rs (/home/drakestapleton/.claude/jobs/300ce471/tmp/target-ip/debug/deps/compose_ledger-e07b2d101ab9ed54) + +running 3 tests +test m5_model_turn_proposal_is_judged_lands_and_chains ... ok +test row12_daemon_restart_does_not_make_a_spent_approval_spendable ... ok +test row13_restart_between_intent_and_ack_is_unresolved_not_success ... ok + +test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 14 filtered out; finished in 280.32s + diff --git a/adapters/aien/evidence/m5-model-turn-2026-10-09/negative-verdicts.txt b/adapters/aien/evidence/m5-model-turn-2026-10-09/negative-verdicts.txt new file mode 100644 index 0000000..9502a56 --- /dev/null +++ b/adapters/aien/evidence/m5-model-turn-2026-10-09/negative-verdicts.txt @@ -0,0 +1,11 @@ +control PASS complete effect=aien-ledger-slice/1:strong proposal=model_generation/2 candidate=none +response_text_replaced FAIL binding_mismatch: generation record output_text_sha256 != sha256(model_turn.input) +weights_digest_substituted FAIL binding_mismatch: model_turn.weights_sha256 != export_weights +backend_not_in_load_log FAIL binding_mismatch: model_turn.backend (not a line of aien_load_log) +request_digest_substituted FAIL binding_mismatch: model_turn.request_sha256 != sha256(model_request) +generation_record_other FAIL binding_mismatch: model_turn.generation_record_id != ledger_generation.id +generation_record_dropped FAIL missing_record_entry: ledger_generation +model_turn_dropped FAIL missing_record_entry: model_turn +scripted_downgrade PASS_LABELLED_INCOMPLETE missing=link:model_turn effect=aien-ledger-slice/1:strong proposal=scripted_turn +scripted_but_declared_complete FAIL unlabelled_missing: link:model_turn (declared complete) +edited_subject FAIL evaluation_signature_bad: receipt_digest does not match the receipt's fields diff --git a/adapters/aien/evidence/m5-model-turn-2026-10-09/receipt.json b/adapters/aien/evidence/m5-model-turn-2026-10-09/receipt.json new file mode 100644 index 0000000..3ba2850 --- /dev/null +++ b/adapters/aien/evidence/m5-model-turn-2026-10-09/receipt.json @@ -0,0 +1,97 @@ +{ + "kind": "interplane-aien-m5-model-turn-receipt", + "adapter_commit": "fee5824210197bd1853133301efcbfd1a8a74c6d", + "adapter_dirty": false, + "aien_cli_sha256": "920324dad6a12115e14795a2820c224d9f656d9af1c6dd611faf72908c4e31ec", + "verifier_sha256": "57099e49312134bc2616e2fd637da9d160a35386a20d06f4656a40d775292c26", + "spark_rsi_judge_sha256": "00c8e8c769acbb69862c363eb9fb836ea66525957e8d75c631c45d9cbab08504", + "judge_public_key": "045695a73ec66bbeb2974f41836ff19237515e17e61282216d9b6fd8b8a3469e1d73bf7a8c057762abca9c5cb5b3cde89715f4be4c020e962bdc8cc106f2ed3354", + "operator_policy_sha256": "81cfeb99a2f1dcbe833012290c4a017d213d5b770e58e4fcc3766e77eae1b4f3", + "sovereign_core_rev": "47f1014a1aa0cf54b732132c6958bc142e91c20b", + "backend": "CPU reference (as printed in the daemon log)", + "task": { + "task_id": "vac/m5-rsi-dashes-1", + "proposal_id": "model-gen-6", + "request_id": "ledger:t0:c0", + "model_turn": { + "finished_at": "2026-10-09T12:23:50Z", + "generation_record": 6, + "request_sha256": "64b5e18a282638663fa897a3822d84b65d09b74d413dd7dee51286426f61c346", + "response_sha256": "0cb56db283d14d54d3e1f0ece3db024ed26f653d08f53d1a0f14120139690fdf", + "started_at": "2026-10-09T12:23:02Z", + "total_tokens": 358 + }, + "source_commit": "1c376da0f25b1c68fc89539536859d7c6d81ab69", + "tree_commit_after": "025adb4ca4cbe606d582a202616f7526c4c502e3", + "test_exit_before": 101, + "test_exit_after": 0, + "target_blob_sha256_before": "97d16a1b1081f0f6c940d223e58231cd036ff34782178ec4ceaa3a11e495497f", + "target_blob_sha256_after": "d4965fdde4501d20dc04cead7e3cdec8a1053d561f10c45c8ffbc233cf24105a", + "evaluation_receipt_sha256": "48b80ffd13e9daf1df75f42f4d8e9e92c1c4dfb8e43eb4c823536d8f003da854", + "evaluation_policy_sha256": "81cfeb99a2f1dcbe833012290c4a017d213d5b770e58e4fcc3766e77eae1b4f3", + "rollback": { + "disk_sha256": "97d16a1b1081f0f6c940d223e58231cd036ff34782178ec4ceaa3a11e495497f", + "test_exit_after_rollback": 101 + } + }, + "chain": { + "model_id": "unsloth/Llama-3.2-1B-Instruct", + "weights_sha256": "1ff795ff6a07e6a68085d206fb84417da2f083f68391c2843cd2b8ac6df8538f", + "backend": "Backend: NativeTransformerBackend/CPU-reference (Omega GPU engine not linked, explicit fallback)", + "request_sha256": "64b5e18a282638663fa897a3822d84b65d09b74d413dd7dee51286426f61c346", + "response_sha256": "0cb56db283d14d54d3e1f0ece3db024ed26f653d08f53d1a0f14120139690fdf", + "generation_record_id": 6, + "generation_output_text_sha256": "0cb56db283d14d54d3e1f0ece3db024ed26f653d08f53d1a0f14120139690fdf", + "generation_model_sha256": "1ff795ff6a07e6a68085d206fb84417da2f083f68391c2843cd2b8ac6df8538f", + "stream_started": "2026-10-09T12:23:02Z", + "stream_finished": "2026-10-09T12:23:50Z", + "grant_id": 20, + "grant_content_sha256": "d4965fdde4501d20dc04cead7e3cdec8a1053d561f10c45c8ffbc233cf24105a", + "evaluation_subject_sha256": "d4965fdde4501d20dc04cead7e3cdec8a1053d561f10c45c8ffbc233cf24105a", + "intent_id": 21, + "ack_id": 22, + "ack_disk_sha256": "d4965fdde4501d20dc04cead7e3cdec8a1053d561f10c45c8ffbc233cf24105a" + }, + "verdict": "PASS complete effect=aien-ledger-slice/1:strong proposal=model_generation/2 candidate=none", + "verdict_without_judge_key": "FAIL evaluation_untrusted: no judge public key supplied; a receipt never carries the key that verifies it", + "restart_rows": { + "daemon_restart_replay": { + "records_after_restart": 26, + "records_after_replays": 26, + "daemon_replay_state": "ALREADY_COMMITTED", + "second_intent": "EFFECT_REFUSED AlreadySpent: authorization #19 was spent by intent #20 (DONE); a new effect needs a new authorization" + }, + "restart_between_intent_and_ack": { + "adapter_state": "UNRESOLVED", + "intent_id": 20, + "effects_after_restart": 1, + "second_intent": "EFFECT_REFUSED ReconciliationRequired: intent #20 for authorization #19 is OPEN; run aien compose reconcile", + "restart_reconcile": "Reconcile: checked 1 unsettled effect(s): DONE 0, NOT_DONE 0, UNRESOLVED 0 recorded, 1 left as they were; [{\"intent\":20,\"authorization\":19,\"state\":\"OPEN\",\"disk_sha256\":null,\"record\":null,\"note\":\"executor pid 1032351 still running; not decided\"}]" + } + }, + "negative_checks": [ + "control PASS complete effect=aien-ledger-slice/1:strong proposal=model_generation/2 candidate=none", + "response_text_replaced FAIL binding_mismatch: generation record output_text_sha256 != sha256(model_turn.input)", + "weights_digest_substituted FAIL binding_mismatch: model_turn.weights_sha256 != export_weights", + "backend_not_in_load_log FAIL binding_mismatch: model_turn.backend (not a line of aien_load_log)", + "request_digest_substituted FAIL binding_mismatch: model_turn.request_sha256 != sha256(model_request)", + "generation_record_other FAIL binding_mismatch: model_turn.generation_record_id != ledger_generation.id", + "generation_record_dropped FAIL missing_record_entry: ledger_generation", + "model_turn_dropped FAIL missing_record_entry: model_turn", + "scripted_downgrade PASS_LABELLED_INCOMPLETE missing=link:model_turn effect=aien-ledger-slice/1:strong proposal=scripted_turn", + "scripted_but_declared_complete FAIL unlabelled_missing: link:model_turn (declared complete)", + "edited_subject FAIL evaluation_signature_bad: receipt_digest does not match the receipt's fields" + ], + "started": "2026-10-09T12:22:35Z", + "finished": "2026-10-09T12:28:29Z", + "limits": [ + "one model turn is not a learning system: a 1B instruction model, greedy decoding, one prompt (a worked example on another file is part of the retained request), no feedback loop", + "several prompts were tried before this one (the model copied the placeholder; the model kept the dashes): only the run that landed is retained", + "the request bytes and the timestamps are the harness own; the daemon generation record carries only the token-id digest of the prompt, which the offline verifier cannot recompute without the tokenizer", + "the generation record is unsigned and the weights digest is of the file at load time (hash-then-load gap), as in provenance/REAL-CHAIN.md", + "the judge key is readable by the operator account (sudo): separation holds against the proposer, not the operator", + "the holdout cases are in this public repository: integrity is pinned by digest, secrecy is not claimed", + "the speed allowance of the pinned policy is 200 percent (see the committed scripted M5 evidence)", + "CPU evidence only, not a frozen candidate (candidate_id null), not the minted flow" + ] +} diff --git a/adapters/aien/evidence/m5-model-turn-2026-10-09/reverify.sh b/adapters/aien/evidence/m5-model-turn-2026-10-09/reverify.sh new file mode 100755 index 0000000..11917f7 --- /dev/null +++ b/adapters/aien/evidence/m5-model-turn-2026-10-09/reverify.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +# Re-verify the committed M5 model-turn bundle offline. +# Usage: reverify.sh <model_dir> (a folder holding model.safetensors, tokenizer.json, config.json) +# The committed bundle omits those three files (2.4 GB). This copies them (real copies, not symlinks) +# into a scratch copy of the bundle, refuses if any digest differs from the manifest, then runs the +# offline verifier and prints its verdict. Nothing in the repo is changed. +set -euo pipefail +here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +repo="$(cd "$here/../../../.." && pwd)" +model_dir="${1:?usage: reverify.sh <model_dir>}" +command -v jq >/dev/null || { echo "reverify: jq is required" >&2; exit 2; } +scratch="$(mktemp -d)"; trap 'rm -rf "$scratch"' EXIT +cp -r "$here/bundle" "$scratch/bundle" +mkdir -p "$scratch/bundle/records/export" +for pair in export_weights:model.safetensors export_tokenizer:tokenizer.json export_config:config.json; do + rec="${pair%%:*}"; file="${pair#*:}" + want="$(jq -r ".records.$rec.sha256" "$scratch/bundle/COMPANION.json")" + dst="$scratch/bundle/$(jq -r ".records.$rec.path" "$scratch/bundle/COMPANION.json")" + [ -f "$model_dir/$file" ] || { echo "reverify: REFUSED, missing $model_dir/$file" >&2; exit 1; } + cp -L "$model_dir/$file" "$dst" + got="$(sha256sum "$dst" | cut -d' ' -f1)" + [ "$got" = "$want" ] || { echo "reverify: REFUSED, $file digest $got != manifest $want" >&2; exit 1; } + echo "reverify: $file matches manifest ($want)" +done +# The judge public key and the operator policy pin are read from the committed receipt. For a real +# audit pin them out of band instead (see README.md). +jq -r .judge_public_key "$here/receipt.json" >"$scratch/judge.pub" +policy_pin="$(jq -r .operator_policy_sha256 "$here/receipt.json")" +vbin="${VERIFIER:-}" +if [ -z "$vbin" ]; then + (cd "$repo/provenance" && cargo build -q --locked --release) + vbin="${CARGO_TARGET_DIR:-$repo/provenance/target}/release/interplane-provenance" +fi +"$vbin" verify "$scratch/bundle" --judge-key "$scratch/judge.pub" --policy-sha256 "$policy_pin" 2>&1 | tail -1 | sed 's/^/reverify verdict: /' diff --git a/adapters/aien/evidence/m5-model-turn-2026-10-09/rows/m5mt/attempt/request.json b/adapters/aien/evidence/m5-model-turn-2026-10-09/rows/m5mt/attempt/request.json new file mode 100644 index 0000000..580cf64 --- /dev/null +++ b/adapters/aien/evidence/m5-model-turn-2026-10-09/rows/m5mt/attempt/request.json @@ -0,0 +1 @@ +[{"content":"You are a file editing assistant. You never write prose. You answer every request with exactly one tool call in this form and nothing else:\n<tool_call>\n{\"name\": \"write_file\", \"arguments\": {\"path\": \"FILE\", \"content\": \"FULL NEW TEXT\"}}\n</tool_call>\nLine breaks inside the text are written as \\n. The new text must contain no em dash (—) and no en dash (–): write a comma where an em dash was, and the word to where an en dash was.","role":"system"},{"content":"File NOTES.md contains:\n# Plan\n\nA small tool—fast on purpose.\nIt covers pages 4–6—nothing more.\n","role":"user"},{"content":"<tool_call>\n{\"name\": \"write_file\", \"arguments\": {\"path\": \"NOTES.md\", \"content\": \"# Plan\\n\\nA small tool, fast on purpose.\\nIt covers pages 4 to 6, nothing more.\\n\"}}\n</tool_call>","role":"assistant"},{"content":"File README.md contains:\n# rsi-dashes\n\nA tiny fixture—small on purpose. The judge runs its holdout command and\nreads the answers; the proposer never sees them.\n\nIt covers pages 1–3 of the VAC M5 note—nothing more.\n","role":"user"}] \ No newline at end of file diff --git a/adapters/aien/evidence/m5-model-turn-2026-10-09/rows/m5mt/attempt/response.txt b/adapters/aien/evidence/m5-model-turn-2026-10-09/rows/m5mt/attempt/response.txt new file mode 100644 index 0000000..0d568f5 --- /dev/null +++ b/adapters/aien/evidence/m5-model-turn-2026-10-09/rows/m5mt/attempt/response.txt @@ -0,0 +1,3 @@ +<tool_call> +{"name": "write_file", "arguments": {"path": "README.md", "content": "# rsi-dashes\n\nA tiny fixture, small on purpose. The judge runs its holdout command and reads the answers; the proposer never sees them.\nIt covers pages 1 to 3 of the VAC M5 note, nothing more.\n"}} +</tool_call> \ No newline at end of file diff --git a/adapters/aien/evidence/m5-model-turn-2026-10-09/rows/m5mt/judge-receipt.json b/adapters/aien/evidence/m5-model-turn-2026-10-09/rows/m5mt/judge-receipt.json new file mode 100644 index 0000000..e680c5d --- /dev/null +++ b/adapters/aien/evidence/m5-model-turn-2026-10-09/rows/m5mt/judge-receipt.json @@ -0,0 +1,80 @@ +{ + "cycle_id": "m5-20261009T122350Z-1036048", + "candidate_id": "model-gen-6", + "parent_id": "1c376da0f25b1c68fc89539536859d7c6d81ab69", + "evaluated_at": "2026-10-09T12:23:51.694237253+00:00", + "evaluator_version": "0.1.0", + "passed_all_hard_invariants": true, + "passed_statistical_gates": true, + "admitted": true, + "layer_results": [ + { + "layer_name": "Correctness", + "is_hard_invariant": true, + "passed": true, + "score": 1.0, + "summary": "Correctness: compile=OK, abi=STABLE, unit=2/2, integ=0/0", + "violations": [] + }, + { + "layer_name": "Security", + "is_hard_invariant": true, + "passed": true, + "score": 1.0, + "summary": "Security: root_of_trust=PASS, zero_disk_secrets=PASS, network_isolation=PASS", + "violations": [] + }, + { + "layer_name": "Style", + "is_hard_invariant": true, + "passed": true, + "score": 1.0, + "summary": "Style: em_dashes=0, en_dashes=0, buzzwords=0, tropes=0", + "violations": [] + }, + { + "layer_name": "Performance", + "is_hard_invariant": false, + "passed": true, + "score": 1.0, + "summary": "Performance: delta=-5.37%, p_val=0.4124, p95_ci_upper=7.39%, p99_ci_upper=5.04%, sig=NO", + "violations": [] + }, + { + "layer_name": "ResourceEfficiency", + "is_hard_invariant": false, + "passed": true, + "score": 1.0, + "summary": "ResourceEfficiency: rss_growth=0.00%, limit_mb_ok=true, ctxt_delta=4", + "violations": [] + }, + { + "layer_name": "LongitudinalReplay", + "is_hard_invariant": true, + "passed": true, + "score": 1.0, + "summary": "LongitudinalReplay: passed=4/4, regressions=0", + "violations": [] + } + ], + "metrics_summary": { + "latency_delta_pct": -5.369460526343269, + "p_value": 0.4124, + "p95_ci_upper_degradation_pct": 7.391175809133686, + "p99_ci_upper_degradation_pct": 5.041006509817817, + "rss_growth_pct": 0.0, + "candidate_resident_mb": 2 + }, + "receipt_digest": "d3c734ee7f9b32c40ee4052d9e6895af9cd4b9344a754a612ba939950de35f86", + "signature": "tpm2-p256:c8272cc3092e5394ffc3215b265fda7fe1273a368e35fe2d0c223db9257cbfc5f2addec75140b08a4abb0e77f4894e3c4cd009f1d86b105c635fb634190a8da2", + "format_version": 2, + "binding": { + "subject_path": "README.md", + "subject_sha256": "d4965fdde4501d20dc04cead7e3cdec8a1053d561f10c45c8ffbc233cf24105a", + "holdout_set_sha256": "662163365703186910d3b9364e2761c82ca55200487d534ec04287d03554be36", + "holdouts_total": 4, + "holdouts_passed": 4, + "policy_sha256": "81cfeb99a2f1dcbe833012290c4a017d213d5b770e58e4fcc3766e77eae1b4f3", + "evaluator_binary_sha256": "00c8e8c769acbb69862c363eb9fb836ea66525957e8d75c631c45d9cbab08504" + } +} diff --git a/adapters/aien/evidence/m5-model-turn-2026-10-09/rows/m5mt/proposal.json b/adapters/aien/evidence/m5-model-turn-2026-10-09/rows/m5mt/proposal.json new file mode 100644 index 0000000..07bab7e --- /dev/null +++ b/adapters/aien/evidence/m5-model-turn-2026-10-09/rows/m5mt/proposal.json @@ -0,0 +1,10 @@ +{ + "created_at": "2026-10-09T12:23:50Z", + "description": "proposed by a model turn", + "id": "model-gen-6", + "kind": "Style", + "proposed_patch": "# rsi-dashes\n\nA tiny fixture, small on purpose. The judge runs its holdout command and reads the answers; the proposer never sees them.\nIt covers pages 1 to 3 of the VAC M5 note, nothing more.\n", + "sandbox_path": null, + "target_file": "README.md", + "title": "README without dashes" +} \ No newline at end of file diff --git a/adapters/aien/evidence/m5-model-turn-2026-10-09/rows/m5mt/receipt.json b/adapters/aien/evidence/m5-model-turn-2026-10-09/rows/m5mt/receipt.json new file mode 100644 index 0000000..9f136da --- /dev/null +++ b/adapters/aien/evidence/m5-model-turn-2026-10-09/rows/m5mt/receipt.json @@ -0,0 +1,209 @@ +{ + "boundary": "boundary = authenticated daemon handoff (ComposeApprovedProposal: desk MAC, durable replay claim) -> compose verify + AEGIS -> J-Space branch -> World commit -> Cortex promotion/evidence -> daemon-written grant on compose_proposal_sha256 -> effect intent -> write -> ack; the production effect path, not WALDO provenance", + "daemon": { + "aien_bin": "aien-cli", + "home": "compose", + "log": "daemon.log", + "start_ms": 23546 + }, + "evaluation_policy_sha256": "81cfeb99a2f1dcbe833012290c4a017d213d5b770e58e4fcc3766e77eae1b4f3", + "evaluation_receipt_sha256": "48b80ffd13e9daf1df75f42f4d8e9e92c1c4dfb8e43eb4c823536d8f003da854", + "journal": [ + { + "digest": "a5b1416a708a2761771e81557ced8f372b29655a9c282b496bf1bf15bcc0b74b", + "id": 20, + "note": "authorization", + "text": { + "approval_id": "aien-approval:ledger:t0:c0:1e254965876f60c4", + "approval_key": "87a956a8147814a6bba44043d64adf1c539c430364842fdba36428f2cee7a918", + "approved_grant": 1, + "approved_proposal_sha256": "0c8ac735e87e5eea8c1e5d0d839086fe6c3d60a0b4ffcbf75067cd7743a6e74f", + "approver": "drake", + "content_sha256": "d4965fdde4501d20dc04cead7e3cdec8a1053d561f10c45c8ffbc233cf24105a", + "cx_evidence": 16, + "cx_promotion": 17, + "desk_key_id": "173ad004b48706f3", + "path": "README.md", + "prior_sha256": "97d16a1b1081f0f6c940d223e58231cd036ff34782178ec4ceaa3a11e495497f", + "proposal_sha256": "1af7be7a3ee53ce8c275d533b705b574ab5c0844a1c49b0d75297d61fb14dc9f", + "provenance": { + "allen_agent": "none", + "generation_record": null + }, + "replay_claim": 7, + "request_id": "ledger:t0:c0", + "target": "/home/drakestapleton/.claude/jobs/300ce471/tmp/gate4/rows/m5mt/ws/README.md", + "trace_id": "ledger", + "workspace": "/home/drakestapleton/.claude/jobs/300ce471/tmp/gate4/rows/m5mt/ws" + }, + "verified": true + }, + { + "digest": "60d49c0a68b53c51bb28c94e0cb73391c512a142cd99a3733f824e0ce6284f31", + "id": 21, + "note": "effect", + "text": { + "authorization": 20, + "content_sha256": "d4965fdde4501d20dc04cead7e3cdec8a1053d561f10c45c8ffbc233cf24105a", + "executor": { + "pid": 1032351, + "start": 26226923 + }, + "path": "README.md", + "phase": "intent", + "prior_sha256": "97d16a1b1081f0f6c940d223e58231cd036ff34782178ec4ceaa3a11e495497f", + "proposal_sha256": "1af7be7a3ee53ce8c275d533b705b574ab5c0844a1c49b0d75297d61fb14dc9f", + "provenance": { + "allen_agent": "none", + "generation_record": null + }, + "target": "/home/drakestapleton/.claude/jobs/300ce471/tmp/gate4/rows/m5mt/ws/README.md", + "tool": "write_file" + }, + "verified": true + }, + { + "digest": "9a2f31ae0072ee2e5cd2ac536dcefb5e589d44d5442c74463a2cda93ab0a7c13", + "id": 22, + "note": "effect", + "text": { + "authorization": 20, + "content_sha256": "d4965fdde4501d20dc04cead7e3cdec8a1053d561f10c45c8ffbc233cf24105a", + "disk_error": null, + "disk_sha256": "d4965fdde4501d20dc04cead7e3cdec8a1053d561f10c45c8ffbc233cf24105a", + "executor_reported": { + "bytes": 193, + "error": null, + "written_sha256": "d4965fdde4501d20dc04cead7e3cdec8a1053d561f10c45c8ffbc233cf24105a" + }, + "intent": 21, + "path": "README.md", + "phase": "ack", + "provenance": { + "allen_agent": "none", + "generation_record": null + }, + "state": "DONE", + "tool": "write_file" + }, + "verified": true + } + ], + "model_turn": { + "finished_at": "2026-10-09T12:23:50Z", + "generation_record": 6, + "request_sha256": "64b5e18a282638663fa897a3822d84b65d09b74d413dd7dee51286426f61c346", + "response_sha256": "0cb56db283d14d54d3e1f0ece3db024ed26f653d08f53d1a0f14120139690fdf", + "started_at": "2026-10-09T12:23:02Z", + "total_tokens": 358 + }, + "proposal_id": "model-gen-6", + "receipt": { + "ack_digest": "9a2f31ae0072ee2e5cd2ac536dcefb5e589d44d5442c74463a2cda93ab0a7c13", + "ack_record_id": 22, + "approval_id": "aien-approval:ledger:t0:c0:1e254965876f60c4", + "approved_proposal_sha256": "0c8ac735e87e5eea8c1e5d0d839086fe6c3d60a0b4ffcbf75067cd7743a6e74f", + "approver": "drake", + "boundary": "boundary = authenticated daemon handoff (ComposeApprovedProposal: desk MAC, durable replay claim) -> compose verify + AEGIS -> J-Space branch -> World commit -> Cortex promotion/evidence -> daemon-written grant on compose_proposal_sha256 -> effect intent -> write -> ack; the production effect path, not WALDO provenance", + "compose_proposal_sha256": "1af7be7a3ee53ce8c275d533b705b574ab5c0844a1c49b0d75297d61fb14dc9f", + "content_sha256": "d4965fdde4501d20dc04cead7e3cdec8a1053d561f10c45c8ffbc233cf24105a", + "disk_sha256": "d4965fdde4501d20dc04cead7e3cdec8a1053d561f10c45c8ffbc233cf24105a", + "grant_digest": "a5b1416a708a2761771e81557ced8f372b29655a9c282b496bf1bf15bcc0b74b", + "grant_id": 20, + "handoff": { + "aegis_pass_mask": 1, + "approval_key": "87a956a8147814a6bba44043d64adf1c539c430364842fdba36428f2cee7a918", + "approved_grant": 20, + "branch_count": 1, + "committed": true, + "cx_evidence": 16, + "cx_goal": 9, + "cx_promotion": 17, + "desk_key_id": "173ad004b48706f3", + "grant_links": [ + 17, + 16 + ], + "outcome": 1, + "proposer": "hook:approved-proposal", + "record_digest": "69fa04f9762cdbe64088683f257e91eb35f2ea3d0a2fc1a221904dde08bb4212", + "replay_claim": 7, + "state": "COMMITTED", + "target": "/home/drakestapleton/.claude/jobs/300ce471/tmp/gate4/rows/m5mt/ws/README.md", + "task": 11070280916336830953, + "winner": 0, + "winner_digest": "0777ee947837c873efaff7c03db8aea7de0142cf47a88a567c81621c921726b4" + }, + "intent_digest": "60d49c0a68b53c51bb28c94e0cb73391c512a142cd99a3733f824e0ce6284f31", + "intent_id": 21, + "path": "README.md", + "prior_sha256": "97d16a1b1081f0f6c940d223e58231cd036ff34782178ec4ceaa3a11e495497f", + "proposal_sha256": "1af7be7a3ee53ce8c275d533b705b574ab5c0844a1c49b0d75297d61fb14dc9f", + "request_id": "ledger:t0:c0", + "state": "DONE", + "target": "/home/drakestapleton/.claude/jobs/300ce471/tmp/gate4/rows/m5mt/ws/README.md", + "trace_id": "ledger" + }, + "records_after": 22, + "records_before": 6, + "request_id": "ledger:t0:c0", + "rollback": { + "disk_sha256": "97d16a1b1081f0f6c940d223e58231cd036ff34782178ec4ceaa3a11e495497f", + "receipt": { + "ack_digest": "76d4d0d17466600364613555886a3f708e4b85e258da0f4ef489bf4de66a2297", + "ack_record_id": 38, + "approval_id": "aien-approval:w2:9aef7fc8e1281e99", + "approved_proposal_sha256": "b0af594a1396714381c17b7bce03d1fffe9af12da8e8e5878d5e29515eed1ca3", + "approver": "drake", + "boundary": "boundary = authenticated daemon handoff (ComposeApprovedProposal: desk MAC, durable replay claim) -> compose verify + AEGIS -> J-Space branch -> World commit -> Cortex promotion/evidence -> daemon-written grant on compose_proposal_sha256 -> effect intent -> write -> ack; the production effect path, not WALDO provenance", + "compose_proposal_sha256": "0dfe91ff8303809dabbe2d92179c3c4a628a7a4a0d067d937ed8546f4105e2cc", + "content_sha256": "97d16a1b1081f0f6c940d223e58231cd036ff34782178ec4ceaa3a11e495497f", + "disk_sha256": "97d16a1b1081f0f6c940d223e58231cd036ff34782178ec4ceaa3a11e495497f", + "grant_digest": "3491e253992b0001c5ef4e653c3bf39d220ac0fabe12e83120f1419b7ac962c6", + "grant_id": 36, + "handoff": { + "aegis_pass_mask": 1, + "approval_key": "b163086d13c5220e85dec97c18e123a5c0533cf2067ccc47429f08554bf9e318", + "approved_grant": 36, + "branch_count": 1, + "committed": true, + "cx_evidence": 32, + "cx_goal": 25, + "cx_promotion": 33, + "desk_key_id": "173ad004b48706f3", + "grant_links": [ + 33, + 32 + ], + "outcome": 1, + "proposer": "hook:approved-proposal", + "record_digest": "0120acf1d6924eb1713b368f47e42c4ad4a1d0db191cc97b3e5510d6d20c05cb", + "replay_claim": 23, + "state": "COMMITTED", + "target": "/home/drakestapleton/.claude/jobs/300ce471/tmp/gate4/rows/m5mt/ws/README.md", + "task": 6481301319216114673, + "winner": 0, + "winner_digest": "cfca8c0b3df64df1ea5bf0c9dbe358be7cb8ffebc78cc18a597c34fa2fa77154" + }, + "intent_digest": "340de9598d23dc37dcf4241d84b46b15add880679276270b0501724548afd7aa", + "intent_id": 37, + "path": "README.md", + "prior_sha256": "d4965fdde4501d20dc04cead7e3cdec8a1053d561f10c45c8ffbc233cf24105a", + "proposal_sha256": "0dfe91ff8303809dabbe2d92179c3c4a628a7a4a0d067d937ed8546f4105e2cc", + "request_id": "w2", + "state": "DONE", + "target": "/home/drakestapleton/.claude/jobs/300ce471/tmp/gate4/rows/m5mt/ws/README.md", + "trace_id": "ledger" + }, + "test_exit_after_rollback": 101 + }, + "row": "m5mt", + "source_commit": "1c376da0f25b1c68fc89539536859d7c6d81ab69", + "target_blob_sha256_after": "d4965fdde4501d20dc04cead7e3cdec8a1053d561f10c45c8ffbc233cf24105a", + "target_blob_sha256_before": "97d16a1b1081f0f6c940d223e58231cd036ff34782178ec4ceaa3a11e495497f", + "task_id": "vac/m5-rsi-dashes-1", + "test_exit_after": 0, + "test_exit_before": 101, + "tree_commit_after": "025adb4ca4cbe606d582a202616f7526c4c502e3", + "verdict": "PASS" +} \ No newline at end of file diff --git a/adapters/aien/evidence/m5-model-turn-2026-10-09/rows/row12/receipt.json b/adapters/aien/evidence/m5-model-turn-2026-10-09/rows/row12/receipt.json new file mode 100644 index 0000000..7d1327e --- /dev/null +++ b/adapters/aien/evidence/m5-model-turn-2026-10-09/rows/row12/receipt.json @@ -0,0 +1,82 @@ +{ + "boundary": "boundary = authenticated daemon handoff (ComposeApprovedProposal: desk MAC, durable replay claim) -> compose verify + AEGIS -> J-Space branch -> World commit -> Cortex promotion/evidence -> daemon-written grant on compose_proposal_sha256 -> effect intent -> write -> ack; the production effect path, not WALDO provenance", + "daemon": { + "aien_bin": "aien-cli", + "home": "compose", + "log": "daemon-restart-1.log", + "start_ms": 23535 + }, + "daemon_replay": { + "approval_id": "aien-approval:r1:c32f6a1235828648", + "approval_key": "f3cd9c3730a8fa8392cc29fee5bd50fcb1b32b36f913fe349b29e0fe0dab6a8a", + "approved_grant": null, + "approved_proposal_sha256": "f76658a79c36626ae9b8c536e94201cff36bd33c81281fd32fb42d9005cc66cb", + "approver": "drake", + "compose_proposal_sha256": "356b6665b6c4a451bef4117a31874887bd1289eda6585527f2adff72934659c0", + "content_sha256": "7a65c4e950042829f746638a08944dc94888a23cab75f9f8babf07a92f12fdc4", + "desk_key_id": "a51a658e13f20763", + "grant_links": [ + 16, + 15 + ], + "path": "summary.txt", + "replay_claim": 6, + "request_id": "r1", + "state": "ALREADY_COMMITTED", + "target": null, + "task": null, + "trace_id": "ledger" + }, + "receipt": { + "ack_digest": "21d4c84191cf95bb211abb3e9131f35549e1857e501663c45e9d3eab15a57911", + "ack_record_id": 21, + "approval_id": "aien-approval:r1:c32f6a1235828648", + "approved_proposal_sha256": "f76658a79c36626ae9b8c536e94201cff36bd33c81281fd32fb42d9005cc66cb", + "approver": "drake", + "boundary": "boundary = authenticated daemon handoff (ComposeApprovedProposal: desk MAC, durable replay claim) -> compose verify + AEGIS -> J-Space branch -> World commit -> Cortex promotion/evidence -> daemon-written grant on compose_proposal_sha256 -> effect intent -> write -> ack; the production effect path, not WALDO provenance", + "compose_proposal_sha256": "356b6665b6c4a451bef4117a31874887bd1289eda6585527f2adff72934659c0", + "content_sha256": "7a65c4e950042829f746638a08944dc94888a23cab75f9f8babf07a92f12fdc4", + "disk_sha256": "7a65c4e950042829f746638a08944dc94888a23cab75f9f8babf07a92f12fdc4", + "grant_digest": "7896a22e3fe75877053250f96fd6de03dd38923776a30b7e128364fa37e2132c", + "grant_id": 19, + "handoff": { + "aegis_pass_mask": 1, + "approval_key": "f3cd9c3730a8fa8392cc29fee5bd50fcb1b32b36f913fe349b29e0fe0dab6a8a", + "approved_grant": 19, + "branch_count": 1, + "committed": true, + "cx_evidence": 15, + "cx_goal": 8, + "cx_promotion": 16, + "desk_key_id": "a51a658e13f20763", + "grant_links": [ + 16, + 15 + ], + "outcome": 1, + "proposer": "hook:approved-proposal", + "record_digest": "fda153383fc2b85743c0548bf70c178b5d09d9ea74f7a5ac21bf9572ac01143c", + "replay_claim": 6, + "state": "COMMITTED", + "target": "/home/drakestapleton/.claude/jobs/300ce471/tmp/gate4/rows/row12/ws/summary.txt", + "task": 15725113504646448803, + "winner": 0, + "winner_digest": "f6382e48ddc50299e07e8efc73dc538fac44ef76d856f15b3d3c5ccb4f84592e" + }, + "intent_digest": "324af68ff5311d5a9e74d47b4f5d47a47bb8a768dd46b11b751657b9a66fbef5", + "intent_id": 20, + "path": "summary.txt", + "prior_sha256": null, + "proposal_sha256": "356b6665b6c4a451bef4117a31874887bd1289eda6585527f2adff72934659c0", + "request_id": "r1", + "state": "DONE", + "target": "/home/drakestapleton/.claude/jobs/300ce471/tmp/gate4/rows/row12/ws/summary.txt", + "trace_id": "ledger" + }, + "records_after_replays": 26, + "records_after_restart": 26, + "row": "row12", + "same_approval_new_request": "REPLAY_REFUSED AlreadyCommitted: claim #6 (request r1, approval aien-approval:r1:c32f6a1235828648, key f3cd9c3730a8fa8392cc29fee5bd50fcb1b32b36f913fe349b29e0fe0dab6a8a) is COMMITTED: committed; the original result is attached", + "second_intent": "EFFECT_REFUSED AlreadySpent: authorization #19 was spent by intent #20 (DONE); a new effect needs a new authorization", + "verdict": "PASS" +} \ No newline at end of file diff --git a/adapters/aien/evidence/m5-model-turn-2026-10-09/rows/row13/daemon-restart-1.log b/adapters/aien/evidence/m5-model-turn-2026-10-09/rows/row13/daemon-restart-1.log new file mode 100644 index 0000000..f848bf6 --- /dev/null +++ b/adapters/aien/evidence/m5-model-turn-2026-10-09/rows/row13/daemon-restart-1.log @@ -0,0 +1,14 @@ +⚡ Starting AIEN Sovereign Runtime Daemon... + KV pool: 8589934592 bytes (8.00 GiB) = 8192 blocks x 16 tokens x 16 layers x 8 kv heads x 64 head_dim x 2 (K,V) x 4 bytes; context 131072 tokens from model max_sequence_length (config.json max_position_embeddings) + KV pool memory check: needs 8589934592 bytes (8.00 GiB), MemAvailable 107973963776 bytes (100.56 GiB) + Backend: NativeTransformerBackend/CPU-reference (Omega GPU engine not linked, explicit fallback) + Model: checkpoint loaded from /home/drakestapleton/.cache/huggingface/hub/models--unsloth--Llama-3.2-1B-Instruct/snapshots/5a8abab4a5d6f164389b1079fb721cfab8d7126c/model.safetensors (tokenizer loaded, model_id=5a8abab4a5d6f164389b1079fb721cfab8d7126c, config=unsloth/Llama-3.2-1B-Instruct (config.json), model_sha256=1ff795ff6a07e6a68085d206fb84417da2f083f68391c2843cd2b8ac6df8538f, tokenizer_sha256=6b9e4e7fb171f92fd137b777cc2714bf87d11576700a1dcd7a399e7bbe39537b) + KV: one pooled KV shared by runtime and backend + Tokenizer: llama3 (Llama 3 instruct) chat template, stop ids [128001, 128008, 128009] +✓ Binding socket at /home/drakestapleton/.claude/jobs/300ce471/tmp/gate4/rows/row13/aien.sock + Warm-up: 1 token in 4515 ms over 124 prompt tokens (discarded) +Authorize MAC: off (authorize is authenticated by the OS user only) +Compose: native (omega 6c6180cf378075b61291f4565d226eba38b4decd) +ALLEN: not engaged (AIEN_ALLEN_SUBJECT unset); no identity claim +Reconcile: checked 1 unsettled effect(s): DONE 0, NOT_DONE 0, UNRESOLVED 0 recorded, 1 left as they were; [{"intent":20,"authorization":19,"state":"OPEN","disk_sha256":null,"record":null,"note":"executor pid 1032351 still running; not decided"}] +Replay reconcile: 1 claims, 0 -> NOT_EXECUTED, 0 -> UNCERTAIN diff --git a/adapters/aien/evidence/m5-model-turn-2026-10-09/rows/row13/receipt.json b/adapters/aien/evidence/m5-model-turn-2026-10-09/rows/row13/receipt.json new file mode 100644 index 0000000..b7d7adc --- /dev/null +++ b/adapters/aien/evidence/m5-model-turn-2026-10-09/rows/row13/receipt.json @@ -0,0 +1,84 @@ +{ + "adapter_state": "UNRESOLVED", + "approved_sha256": "7a65c4e950042829f746638a08944dc94888a23cab75f9f8babf07a92f12fdc4", + "boundary": "boundary = authenticated daemon handoff (ComposeApprovedProposal: desk MAC, durable replay claim) -> compose verify + AEGIS -> J-Space branch -> World commit -> Cortex promotion/evidence -> daemon-written grant on compose_proposal_sha256 -> effect intent -> write -> ack; the production effect path, not WALDO provenance", + "daemon": { + "aien_bin": "aien-cli", + "home": "compose", + "log": "daemon-restart-1.log", + "start_ms": 24028 + }, + "daemon_replay": { + "approval_id": "aien-approval:u1:11d432d024c7f93c", + "approval_key": "1e49d69b09b1fffb100cb32b7c13f29ff8e81ac7560003ad4849bb14bbb5b16f", + "approved_grant": null, + "approved_proposal_sha256": "6ca762b2ced47bd166d3699c38bff8a9c9164552976d070a71d04a1cb6f43ada", + "approver": "drake", + "compose_proposal_sha256": "4ef1a09d0399c175bdc9dcd33b9c0e6b092764bad832968cb8f3c332dbb3a2ec", + "content_sha256": "7a65c4e950042829f746638a08944dc94888a23cab75f9f8babf07a92f12fdc4", + "desk_key_id": "f96024c7f54832dd", + "grant_links": [ + 16, + 15 + ], + "path": "unacked.txt", + "replay_claim": 6, + "request_id": "u1", + "state": "ALREADY_COMMITTED", + "target": null, + "task": null, + "trace_id": "ledger" + }, + "disk_sha256_after_crash": "7a65c4e950042829f746638a08944dc94888a23cab75f9f8babf07a92f12fdc4", + "effects_after_restart": 1, + "intent_id": 20, + "receipt": { + "ack_error": "receive: Connection reset by peer (os error 104)", + "approval_id": "aien-approval:u1:11d432d024c7f93c", + "approved_proposal_sha256": "6ca762b2ced47bd166d3699c38bff8a9c9164552976d070a71d04a1cb6f43ada", + "approver": "drake", + "boundary": "boundary = authenticated daemon handoff (ComposeApprovedProposal: desk MAC, durable replay claim) -> compose verify + AEGIS -> J-Space branch -> World commit -> Cortex promotion/evidence -> daemon-written grant on compose_proposal_sha256 -> effect intent -> write -> ack; the production effect path, not WALDO provenance", + "compose_proposal_sha256": "4ef1a09d0399c175bdc9dcd33b9c0e6b092764bad832968cb8f3c332dbb3a2ec", + "content_sha256": "7a65c4e950042829f746638a08944dc94888a23cab75f9f8babf07a92f12fdc4", + "disk_sha256": "7a65c4e950042829f746638a08944dc94888a23cab75f9f8babf07a92f12fdc4", + "grant_digest": "6ddc4c696ce4cf834aad0a86e7ebef01b040dc26fe3a2306fe6c345631612150", + "grant_id": 19, + "handoff": { + "aegis_pass_mask": 1, + "approval_key": "1e49d69b09b1fffb100cb32b7c13f29ff8e81ac7560003ad4849bb14bbb5b16f", + "approved_grant": 19, + "branch_count": 1, + "committed": true, + "cx_evidence": 15, + "cx_goal": 8, + "cx_promotion": 16, + "desk_key_id": "f96024c7f54832dd", + "grant_links": [ + 16, + 15 + ], + "outcome": 1, + "proposer": "hook:approved-proposal", + "record_digest": "7146200d6c19090fc88154cbb4b6d7111dc76393cc9db63c0e9717f0bb639afe", + "replay_claim": 6, + "state": "COMMITTED", + "target": "/home/drakestapleton/.claude/jobs/300ce471/tmp/gate4/rows/row13/ws/unacked.txt", + "task": 3269272596051554689, + "winner": 0, + "winner_digest": "3e2b92ef3c2e2e7e498fb7aaebaf2f7fba37fdbc7cadcac129408a6dbf714e12" + }, + "intent_digest": "b84e364f1b95740d0768f3bf4070c25e2e3f9b0d1f5c89ed66093b5b1e6a5749", + "intent_id": 20, + "path": "unacked.txt", + "prior_sha256": null, + "proposal_sha256": "4ef1a09d0399c175bdc9dcd33b9c0e6b092764bad832968cb8f3c332dbb3a2ec", + "request_id": "u1", + "state": "UNRESOLVED", + "target": "/home/drakestapleton/.claude/jobs/300ce471/tmp/gate4/rows/row13/ws/unacked.txt", + "trace_id": "ledger" + }, + "restart_reconcile": "Reconcile: checked 1 unsettled effect(s): DONE 0, NOT_DONE 0, UNRESOLVED 0 recorded, 1 left as they were; [{\"intent\":20,\"authorization\":19,\"state\":\"OPEN\",\"disk_sha256\":null,\"record\":null,\"note\":\"executor pid 1032351 still running; not decided\"}]", + "row": "row13", + "second_intent": "EFFECT_REFUSED ReconciliationRequired: intent #20 for authorization #19 is OPEN; run aien compose reconcile", + "verdict": "PASS" +} \ No newline at end of file diff --git a/adapters/aien/scripts/m5-propose-and-judge.sh b/adapters/aien/scripts/m5-propose-and-judge.sh index ffb1cc2..4bceb9f 100755 --- a/adapters/aien/scripts/m5-propose-and-judge.sh +++ b/adapters/aien/scripts/m5-propose-and-judge.sh @@ -11,6 +11,7 @@ # binary) inside its mode-700 home, builds both trees itself into a fresh target directory, # runs the holdouts in the jail and signs a version 2 receipt with its own key. # +# M5_PROPOSAL_FILE=<file>: judge a model-turn proposal instead of running `spark-rsi propose`. # Environment: SPARK_RSI_DIR (holds release `spark-rsi` and `spark-rsi-judge`), M5_POLICY (the # pinned policy file), M5_HOLDOUTS (holdout suite directory); JUDGE_USER, RSI_USER, JUDGE_HOME. # Negative tests only (the gate script uses these to make counterfeit evidence, never the row): @@ -62,10 +63,18 @@ export_commit "$stage/view" [ -z "$(find "$stage/view" -type l -print -quit)" ] || die "the task commit contains a symlink: refused" chmod -R a+rX,a-w "$stage/view" "$stage/bin" -# 1. Propose, as the RSI account, from a read-only view. -sudo -n -u "$rsi_user" env -i HOME=/nonexistent PATH=/usr/bin:/bin \ - "$stage/bin/spark-rsi" propose "$stage/view" >"$out/proposal.json" \ - || die "spark-rsi propose failed" +# 1. Propose. Normally the RSI account, from a read-only view. With M5_PROPOSAL_FILE (the model-turn +# row) the proposal is the whole-file change a real model turn produced, written by the harness as +# a proposal.json-shaped file. Every later step is the same: the target check, the candidate tree +# and the judge, which builds and evaluates the exact bytes on holdouts the proposer cannot read. +if [ -n "${M5_PROPOSAL_FILE:-}" ]; then + [ -f "$M5_PROPOSAL_FILE" ] || die "M5_PROPOSAL_FILE is not a file: $M5_PROPOSAL_FILE" + cp "$M5_PROPOSAL_FILE" "$out/proposal.json" +else + sudo -n -u "$rsi_user" env -i HOME=/nonexistent PATH=/usr/bin:/bin \ + "$stage/bin/spark-rsi" propose "$stage/view" >"$out/proposal.json" \ + || die "spark-rsi propose failed" +fi # 2. Only the task's file. got="$(jq -r '.target_file // "none"' "$out/proposal.json")" [ "$got" = "$target" ] || die "RSI proposed a change to $got; only $target is allowed: refused" diff --git a/adapters/aien/scripts/test-m5-model-turn.sh b/adapters/aien/scripts/test-m5-model-turn.sh new file mode 100755 index 0000000..680e78e --- /dev/null +++ b/adapters/aien/scripts/test-m5-model-turn.sh @@ -0,0 +1,167 @@ +#!/usr/bin/env bash +# VAC M5 with a REAL model turn: the gate for the row `m5_model_turn_proposal_is_judged_lands_and_chains` +# plus the two restart rows (row12, row13). +# +# The loaded model (daemon StreamTurn, CPU) writes the tool call that proposes the README change; the +# separate judge evaluates the exact bytes; the change lands through ComposeApprovedProposal; the +# bundle is checked by the offline verifier with the operator's pinned judge key and policy. The +# verdict must be `PASS complete ... proposal=model_generation/2` (or, when the daemon does not +# report a native compose library, the same with `missing=link:native`), and each counterfeit of the +# model turn must be refused or labelled. It cannot pass vacuously: a missing row, bundle or verdict +# fails it. No process is killed except the test's own daemon inside the restart rows. +# +# Inputs (environment): AIEN_BIN, OUT (fresh), SPARK_RSI_DIR (release spark-rsi-judge), M5_JUDGE_KEY +# (the operator's pinned judge public key file), AIEN_LEDGER_MODEL_DIR, SOVEREIGN_CORE_REV. +set -euo pipefail +here="$(cd "$(dirname "$0")" && pwd)" +adapter="$(cd "$here/.." && pwd)" +repo="$(cd "$adapter/../.." && pwd)" +die() { echo "M5 MODEL-TURN GATE FAIL: $*" >&2; exit 1; } +: "${AIEN_BIN:?AIEN_BIN must name the aien-cli binary}" +: "${OUT:?OUT must name the output directory}" +: "${SPARK_RSI_DIR:?SPARK_RSI_DIR must hold release spark-rsi and spark-rsi-judge}" +: "${M5_JUDGE_KEY:?M5_JUDGE_KEY must name the pinned judge public key file}" +for b in "$AIEN_BIN" "$SPARK_RSI_DIR/spark-rsi" "$SPARK_RSI_DIR/spark-rsi-judge"; do + [ -x "$b" ] || die "not executable: $b" +done +[ -s "$M5_JUDGE_KEY" ] || die "no pinned judge key at $M5_JUDGE_KEY" +command -v jq >/dev/null || die "jq is required" +model_dir="${AIEN_LEDGER_MODEL_DIR:-$HOME/.cache/huggingface/hub/models--unsloth--Llama-3.2-1B-Instruct/snapshots/5a8abab4a5d6f164389b1079fb721cfab8d7126c}" +if command -v quietlock >/dev/null && ! quietlock check >/dev/null 2>&1; then + die "quiet flag is held (quietlock check): no long run now" +fi +# CPU only: a GPU backend would change what the evidence means. +unset AIEN_GPU_BACKEND AIEN_REQUIRE_BLACKWELL AIEN_OMEGA_DIR +mkdir -p "$OUT"; OUT="$(cd "$OUT" && pwd)" +[ ! -e "$OUT/rows" ] || die "$OUT/rows exists: use a fresh OUT" +started="$(date -u +%FT%TZ)" +export SPARK_RSI_DIR M5_JUDGE_KEY +export M5_POLICY="$adapter/m5/policy.json" M5_HOLDOUTS="$adapter/m5/holdouts" M5_HOOK="$here/m5-propose-and-judge.sh" +pinned="$(jq -r .holdout_set_sha256 "$M5_POLICY")" +actual="$("$SPARK_RSI_DIR/spark-rsi-judge" --holdouts-dir "$M5_HOLDOUTS" --print-holdout-digest)" +[ "$pinned" = "$actual" ] || die "policy pins holdout set $pinned but $M5_HOLDOUTS is $actual" + +# 1. The live rows. +log="$OUT/live.log" +set +e +(cd "$adapter" && AIEN_BIN="$AIEN_BIN" AIEN_LEDGER_MODEL_DIR="$model_dir" LEDGER_OUT="$OUT/rows" \ + cargo test --locked --test compose_ledger -- --ignored --test-threads=1 \ + m5_model_turn row12_daemon_restart row13_restart) >"$log" 2>&1 +rc=$? +set -e +[ "$rc" -eq 0 ] || { tail -8 "$log" >&2; die "live rows exited $rc (log $log)"; } +for t in m5_model_turn_proposal_is_judged_lands_and_chains row12_daemon_restart_does_not_make_a_spent_approval_spendable \ + row13_restart_between_intent_and_ack_is_unresolved_not_success; do + grep -q "^test $t \.\.\. ok$" "$log" || die "row $t did not run and pass" +done +row="$OUT/rows/m5mt"; bundle="$row/bundle" +[ -f "$bundle/COMPANION.json" ] || die "the row exported no bundle" +jq -e '.effect.proposal_origin == "model_generation/2"' "$bundle/COMPANION.json" >/dev/null || die "bundle does not claim a model generation" + +# 2. The verifier. +(cd "$repo/provenance" && cargo build -q --locked --release) || die "verifier build failed" +vbin="${CARGO_TARGET_DIR:-$repo/provenance/target}/release/interplane-provenance" +policy_pin="$(sha256sum "$M5_POLICY" | cut -d' ' -f1)" +verify() { "$vbin" verify "$1" --judge-key "${2:-$M5_JUDGE_KEY}" --policy-sha256 "$policy_pin" 2>&1 | tail -1 || true; } +strong="effect=aien-ledger-slice/1:strong proposal=model_generation/2" +case "$(jq -r '.aien.native.claimed // "absent"' "$bundle/COMPANION.json")" in + true) want="PASS complete $strong candidate=none";; + *) want="PASS_LABELLED_INCOMPLETE missing=link:native $strong";; +esac +verdict="$(verify "$bundle")" +[ "$verdict" = "$want" ] || die "unexpected verdict: $verdict (wanted: $want)" +nokey="$("$vbin" verify "$bundle" 2>&1 | tail -1 || true)" +case "$nokey" in "FAIL evaluation_untrusted:"*) ;; *) die "without the judge key the bundle must be untrusted, got: $nokey";; esac +jq -e '.verdict == "PASS" and .test_exit_after == 0 and .test_exit_before != 0 + and .rollback.disk_sha256 == .target_blob_sha256_before' "$row/receipt.json" >/dev/null || die "row receipt does not show red-before, green-after and a restoring rollback" + +# 3. Counterfeits of the model turn. Edits go to hard-linked copies (a changed file is written fresh). +neg="$OUT/negative"; mkdir -p "$neg"; : >"$neg/verdicts.txt" +fork() { rm -rf "$neg/$1"; cp -al "$bundle" "$neg/$1"; } +manifest() { local d="$1"; shift; jq "$@" "$d/COMPANION.json" >"$d/COMPANION.tmp" && mv "$d/COMPANION.tmp" "$d/COMPANION.json"; } +recpath() { jq -r ".records.$2.path" "$1/COMPANION.json"; } +restamp() { local d="$1" n="$2" p; p="$(recpath "$d" "$n")" + manifest "$d" '.records[$n].sha256=$s | .records[$n].bytes=$b' --arg n "$n" \ + --arg s "$(sha256sum "$d/$p" | cut -d' ' -f1)" --argjson b "$(wc -c <"$d/$p")"; } +editrec() { local d="$1" n="$2" f="$3" p; shift 3; p="$(recpath "$d" "$n")" + jq "$@" "$f" "$d/$p" >"$d/$p.new"; rm "$d/$p"; mv "$d/$p.new" "$d/$p"; restamp "$d" "$n"; } +expect() { # name bundle code + local v; v="$(verify "$2")" + case "$v" in "FAIL $3:"*) echo "negative $1: $v";; *) die "negative $1: wanted FAIL $3, got: $v";; esac + echo "$1 $v" >>"$neg/verdicts.txt"; } +fork control; [ "$(verify "$neg/control")" = "$verdict" ] || die "negative control: an untouched copy no longer verifies" +echo "control $verdict" >>"$neg/verdicts.txt" +# Refused by the generation-record binding: the daemon record holds the real output digest. +fork resp; editrec "$neg/resp" model_turn '.input = "<tool_call>\n{\"name\": \"write_file\", \"arguments\": {\"path\": \"README.md\", \"content\": \"# rsi-dashes\\n\"}}\n</tool_call>" | .response_sha256 = "0000000000000000000000000000000000000000000000000000000000000000"' +expect response_text_replaced_refused_by_generation_record_binding "$neg/resp" binding_mismatch +fork wts; editrec "$neg/wts" model_turn '.weights_sha256 = "9999999999999999999999999999999999999999999999999999999999999999"' +expect weights_digest_substituted "$neg/wts" binding_mismatch +fork bk; editrec "$neg/bk" model_turn '.backend = "Backend: CUDA"' +expect backend_not_in_load_log "$neg/bk" binding_mismatch +fork reqid; editrec "$neg/reqid" model_turn '.request_sha256 = "9999999999999999999999999999999999999999999999999999999999999999"' +expect request_digest_substituted "$neg/reqid" binding_mismatch +fork gen; editrec "$neg/gen" model_turn '.generation_record_id = 1' +expect generation_record_other "$neg/gen" binding_mismatch +fork nogen; manifest "$neg/nogen" 'del(.records.ledger_generation)' +expect generation_record_dropped "$neg/nogen" missing_record_entry +fork nomt; manifest "$neg/nomt" 'del(.records.model_turn)' +v="$(verify "$neg/nomt")"; case "$v" in "FAIL "*) echo "negative model_turn_dropped: $v";; *) die "model_turn dropped must FAIL, got: $v";; esac +echo "model_turn_dropped $v" >>"$neg/verdicts.txt" +# The honest downgrade: the same bytes declared scripted can never be PASS complete. +fork scr; manifest "$neg/scr" '.effect.proposal_origin = "scripted_turn" | .completeness = {state: "incomplete", missing: ["link:model_turn"]}' +v="$(verify "$neg/scr")"; case "$v" in "PASS_LABELLED_INCOMPLETE missing=link:model_turn"*"proposal=scripted_turn"*) echo "negative scripted_downgrade: $v";; *) die "scripted downgrade must be labelled incomplete, got: $v";; esac +echo "scripted_downgrade $v" >>"$neg/verdicts.txt" +fork scrc; manifest "$neg/scrc" '.effect.proposal_origin = "scripted_turn"' +expect scripted_but_declared_complete "$neg/scrc" unlabelled_missing +# A model turn for other bytes: the generated README replaced on disk-bound records is already +# covered by the ledger checks; here the approved content differs from what the model wrote. +fork subj; editrec "$neg/subj" evaluation_receipt '.binding.subject_sha256 = "9999999999999999999999999999999999999999999999999999999999999999"' +expect edited_subject "$neg/subj" evaluation_signature_bad + +# 4. Receipt. +finished="$(date -u +%FT%TZ)" +dirty=false; [ -z "$(git -C "$repo" status --porcelain -- adapters provenance 2>/dev/null)" ] || dirty=true +jq -n \ + --arg adapter_commit "$(git -C "$repo" rev-parse HEAD)" --argjson adapter_dirty "$dirty" \ + --arg bin_sha "$(sha256sum "$AIEN_BIN" | cut -d' ' -f1)" --arg verifier_sha "$(sha256sum "$vbin" | cut -d' ' -f1)" \ + --arg judge_sha "$(sha256sum "$SPARK_RSI_DIR/spark-rsi-judge" | cut -d' ' -f1)" \ + --arg judge_pub "$(cat "$M5_JUDGE_KEY")" --arg policy_pin "$policy_pin" \ + --arg sc_rev "${SOVEREIGN_CORE_REV:-UNVERIFIED}" --arg verdict "$verdict" --arg nokey "$nokey" \ + --argjson run "$(jq '{task_id, proposal_id, request_id, model_turn, source_commit, tree_commit_after, test_exit_before, test_exit_after, target_blob_sha256_before, target_blob_sha256_after, evaluation_receipt_sha256, evaluation_policy_sha256, rollback: {disk_sha256: .rollback.disk_sha256, test_exit_after_rollback: .rollback.test_exit_after_rollback}}' "$row/receipt.json")" \ + --argjson chain "$(jq -n \ + --slurpfile mt "$bundle/$(jq -r .records.model_turn.path "$bundle/COMPANION.json")" \ + --slurpfile ev "$bundle/$(jq -r .records.evaluation_receipt.path "$bundle/COMPANION.json")" \ + --slurpfile gr "$bundle/$(jq -r .records.ledger_grant.path "$bundle/COMPANION.json")" \ + --slurpfile ak "$bundle/$(jq -r .records.ledger_ack.path "$bundle/COMPANION.json")" \ + --slurpfile ig "$bundle/$(jq -r .records.ledger_intent.path "$bundle/COMPANION.json")" \ + --slurpfile gn "$bundle/$(jq -r .records.ledger_generation.path "$bundle/COMPANION.json")" \ + '{model_id: $mt[0].model_id, weights_sha256: $mt[0].weights_sha256, backend: $mt[0].backend, + request_sha256: $mt[0].request_sha256, response_sha256: $mt[0].response_sha256, + generation_record_id: $mt[0].generation_record_id, + generation_output_text_sha256: ($gn[0].text | fromjson | .output_text_sha256), + generation_model_sha256: ($gn[0].text | fromjson | .model_sha256), + stream_started: $mt[0].stream_started, stream_finished: $mt[0].stream_finished, + grant_id: $gr[0].id, grant_content_sha256: ($gr[0].text | fromjson | .content_sha256 // null), + evaluation_subject_sha256: $ev[0].binding.subject_sha256, + intent_id: $ig[0].id, ack_id: $ak[0].id, + ack_disk_sha256: ($ak[0].text | fromjson | .disk_sha256 // null)}')" \ + --arg restart_a "$(jq -c '{records_after_restart, records_after_replays, daemon_replay_state: .daemon_replay.state, second_intent}' "$OUT/rows/row12/receipt.json")" \ + --arg restart_b "$(jq -c '{adapter_state, intent_id, effects_after_restart, second_intent, restart_reconcile}' "$OUT/rows/row13/receipt.json")" \ + --arg negatives "$(cat "$neg/verdicts.txt")" --arg started "$started" --arg finished "$finished" \ + '{kind: "interplane-aien-m5-model-turn-receipt", adapter_commit: $adapter_commit, adapter_dirty: $adapter_dirty, + aien_cli_sha256: $bin_sha, verifier_sha256: $verifier_sha, spark_rsi_judge_sha256: $judge_sha, + judge_public_key: $judge_pub, operator_policy_sha256: $policy_pin, sovereign_core_rev: $sc_rev, + backend: "CPU reference (as printed in the daemon log)", + task: $run, chain: $chain, verdict: $verdict, verdict_without_judge_key: $nokey, + restart_rows: {daemon_restart_replay: ($restart_a | fromjson? // $restart_a), restart_between_intent_and_ack: ($restart_b | fromjson? // $restart_b)}, + negative_checks: ($negatives | split("\n") | map(select(length>0))), + started: $started, finished: $finished, + limits: ["one model turn is not a learning system: a 1B instruction model, greedy decoding, one prompt (a worked example on another file is part of the retained request), no feedback loop", + "several prompts were tried before this one (the model copied the placeholder; the model kept the dashes): only the run that landed is retained", + "the request bytes and the timestamps are the harness own; the daemon generation record carries only the token-id digest of the prompt, which the offline verifier cannot recompute without the tokenizer", + "the generation record is unsigned and the weights digest is of the file at load time (hash-then-load gap), as in provenance/REAL-CHAIN.md", + "the judge key is readable by the operator account (sudo): separation holds against the proposer, not the operator", + "the holdout cases are in this public repository: integrity is pinned by digest, secrecy is not claimed", + "the speed allowance of the pinned policy is 200 percent (see the committed scripted M5 evidence)", + "CPU evidence only, not a frozen candidate (candidate_id null), not the minted flow"]}' >"$OUT/receipt.json" +echo "M5 MODEL-TURN GATE PASS: verdict: $verdict; receipt $OUT/receipt.json" diff --git a/adapters/aien/src/compose_ledger.rs b/adapters/aien/src/compose_ledger.rs index 504e117..684ee31 100644 --- a/adapters/aien/src/compose_ledger.rs +++ b/adapters/aien/src/compose_ledger.rs @@ -255,6 +255,15 @@ pub fn self_executor() -> (u32, u64) { static OPERATION: AtomicU64 = AtomicU64::new(0); +/// What the daemon returned for one `StreamTurn`: its own text and the id of its own generation +/// record (sovereign-core `DAEMON_GENERATION_RECORD.md`). +#[derive(Clone, Debug)] +pub struct ModelTurn { + pub text: String, + pub generation_record: u64, + pub total_tokens: u64, +} + /// Newline-JSON client for the daemon's control socket (`aien-runtime` client.rs framing). #[derive(Clone, Debug)] pub struct LedgerClient { @@ -306,6 +315,64 @@ impl LedgerClient { } } + /// One `StreamTurn` (the generation path `aien-cli chat` uses) on the daemon's loaded model. + /// The daemon answers with a stream of lines and ends with `TurnFinished`; the request is sent + /// as `messages` exactly as given and the returned [`ModelTurn`] carries the daemon's own text + /// and the id of its generation record (`TurnFinished.generation_record`). `Err` when the + /// stream ends without `TurnFinished`, carries an `Error`, or names no generation record: no + /// record means no claim, so this never invents one. + pub fn stream_turn( + &self, + messages: &Value, + max_tokens: u64, + temperature: f64, + ) -> Result<ModelTurn, String> { + let me = fs::metadata("/proc/self").map_err(|e| e.to_string())?.uid(); + let owner = fs::metadata(&self.socket) + .map_err(|e| format!("socket {}: {e}", self.socket.display()))? + .uid(); + if owner != me { + return Err(format!( + "refusing socket {}: owned by uid {owner}", + self.socket.display() + )); + } + let mut s = UnixStream::connect(&self.socket) + .map_err(|e| format!("connect {}: {e}", self.socket.display()))?; + s.set_read_timeout(Some(Duration::from_secs(1800))) + .map_err(|e| e.to_string())?; + let now = SystemTime::now() + .duration_since(UNIX_EPOCH) + .unwrap_or_default(); + let op = now.as_nanos() as u64 + OPERATION.fetch_add(1, Ordering::SeqCst); + let env = json!({"protocol_version": 1, "request_id": now.as_millis() as u64, + "operation_id": op, "operator_session": 1, + "command": {"StreamTurn": {"messages": messages, "max_tokens": max_tokens, + "temperature": temperature}}}); + s.write_all(format!("{env}\n").as_bytes()) + .map_err(|e| format!("send: {e}"))?; + for line in BufReader::new(&s).lines() { + let line = line.map_err(|e| format!("receive: {e}"))?; + let v: Value = + serde_json::from_str(line.trim()).map_err(|e| format!("response: {e}: {line}"))?; + if let Some(e) = v.get("Error") { + return Err(e.as_str().map_or_else(|| e.to_string(), str::to_string)); + } + if let Some(f) = v.get("TurnFinished") { + let text = f["text"].as_str().ok_or("TurnFinished without text")?; + let generation_record = f["generation_record"] + .as_u64() + .ok_or("the daemon returned no generation_record: no record means no claim")?; + return Ok(ModelTurn { + text: text.to_string(), + generation_record, + total_tokens: f["total_tokens"].as_u64().unwrap_or(0), + }); + } + } + Err("StreamTurn ended without TurnFinished".into()) + } + fn body(&self, command: Value, variant: &str) -> Result<Value, String> { let v = self.send(command)?; v.get(variant) @@ -405,6 +472,7 @@ struct LedgerState { desk_key: PathBuf, approvers: HashMap<String, String>, before_intent: Option<Hook>, + before_ack: Option<Hook>, grants_minted: u32, receipts: Vec<Value>, } @@ -455,6 +523,7 @@ impl ComposeLedgerAuthority { desk_key, approvers: HashMap::new(), before_intent: None, + before_ack: None, grants_minted: 0, receipts: vec![], })), @@ -482,6 +551,13 @@ impl ComposeLedgerAuthority { self.state.borrow().receipts.clone() } + /// Fault-injection seam for the window between the written bytes and the acknowledgement: runs + /// after the intent record exists and the bytes are on disk, just before `ComposeEffectAck`. + /// A daemon that dies here leaves an intent without an ack: the receipt must say `UNRESOLVED`. + pub fn set_before_ack(&self, hook: impl FnMut(&Path) + 'static) { + self.state.borrow_mut().before_ack = Some(Box::new(hook)); + } + /// Fault-injection seam (the analogue of aien-cli's `fault_hold("before_intent")`): runs after /// the grant is recorded and before the intent is asked for, with the absolute target. pub fn set_before_intent(&self, hook: impl FnMut(&Path) + 'static) { @@ -737,6 +813,11 @@ impl ComposeLedgerAuthority { rc["intent_id"] = json!(intent_id); rc["intent_digest"] = intent["digest"].clone(); rc["disk_sha256"] = reported["written_sha256"].clone(); + let hook = self.state.borrow_mut().before_ack.take(); + if let Some(mut h) = hook { + h(&target); + self.state.borrow_mut().before_ack = Some(h); + } let ack = client.ack(intent_id, &reported); let state = match &ack { Ok(a) => { diff --git a/adapters/aien/src/lib.rs b/adapters/aien/src/lib.rs index c817962..9e9c24a 100644 --- a/adapters/aien/src/lib.rs +++ b/adapters/aien/src/lib.rs @@ -34,7 +34,7 @@ pub mod fix_the_test; pub mod provenance_export; pub mod rsi_m5; pub use compose_ledger::{ - hmac_sha256, ApprovalBinding, ComposeLedgerAuthority, DeskKey, LedgerClient, + hmac_sha256, ApprovalBinding, ComposeLedgerAuthority, DeskKey, LedgerClient, ModelTurn, APPROVAL_BINDING_VERSION, BOUND_REQUIREMENTS, DEFAULT_APPROVER, LEDGER_BOUNDARY, REQUIREMENTS_TAG_V1, }; diff --git a/adapters/aien/src/provenance_export.rs b/adapters/aien/src/provenance_export.rs index acb5c27..b359a42 100644 --- a/adapters/aien/src/provenance_export.rs +++ b/adapters/aien/src/provenance_export.rs @@ -55,6 +55,25 @@ pub struct LiveRun<'a> { /// The M5 slice: the independent judge's signed receipt and the policy it ran under, as the /// exact bytes the judge wrote and the operator pinned (never re-serialized). pub evaluation: Option<&'a Evaluation>, + /// A real model turn: the daemon generated the proposal on the model it loaded. When set the + /// bundle says `proposal_origin: model_generation/2` and retains the request, the response and + /// the daemon's own generation record; the `model_label` is the id the trace names as sender. + pub model_turn: Option<&'a ModelTurnRun>, +} + +/// One real model turn as the harness saw it (see `LedgerClient::stream_turn`). All bytes are kept +/// exactly: `request` is the JSON `messages` array sent to the daemon, `response` the text it +/// returned. +#[derive(Debug, Clone)] +pub struct ModelTurnRun { + pub request: Vec<u8>, + pub response: String, + pub generation_record: u64, + pub total_tokens: u64, + pub max_tokens: u64, + pub temperature: f64, + pub started_at: String, + pub finished_at: String, } /// The judge's evidence for one change (`rsi-eval/2`, spark-rsi docs/RECEIPT-V2.md). @@ -429,13 +448,85 @@ pub fn export_bundle(run: &LiveRun<'_>) -> Result<ExportReport, String> { ); } - let mut missing = vec!["link:model_turn"]; + // A real model turn: the request and response bytes, the daemon's own record of the + // generation (exported with its own read command) and a model-turn/2 record that names the + // digests that tie them to the weights and to the trace. + if let Some(t) = run.model_turn { + let log_text = std::fs::read_to_string(run.daemon_log).unwrap_or_default(); + let backend_line = log_text + .lines() + .find(|l| l.contains("Backend:")) + .map(|l| l.trim().to_string()) + .ok_or("the daemon log names no Backend: line; the turn's backend would be a guess")?; + let gview = run.client.recall(&[t.generation_record], None)?; + if !gview["missing"].as_array().is_some_and(|m| m.is_empty()) { + return Err(format!( + "ComposeRecall has no generation record {}: {}", + t.generation_record, gview["missing"] + )); + } + let gcited = gview["cited"].as_array().ok_or("ComposeRecall: no cited")?; + put( + run.out, + &mut records, + "ledger_generation", + "records/aien/ledger-generation.json", + pretty(&view(gcited, t.generation_record)?), + )?; + put( + run.out, + &mut records, + "model_request", + "records/model/request.json", + t.request.clone(), + )?; + let weights = records["export_weights"]["sha256"] + .as_str() + .ok_or("export_weights not recorded")? + .to_string(); + let turn = json!({"record": "model-turn/2", "dialect": "aien_legacy", + "model": run.model_label, "model_id": run.model_origin.0, + "trace_id": run.trace_id, "turn": 0, + "input": t.response, + "generation_record_id": t.generation_record, + "generation_record_source": "TurnFinished.generation_record", + "request_record": "model_request", + "request_sha256": sha256_hex(&t.request), + "response_sha256": sha256_hex(t.response.as_bytes()), + "weights_sha256": weights, + "backend": backend_line, + "sampling": {"max_tokens": t.max_tokens, "temperature": t.temperature, + "total_tokens": t.total_tokens}, + "stream_started": t.started_at, "stream_finished": t.finished_at}); + put( + run.out, + &mut records, + "model_turn", + "records/interplane/model-turn.json", + pretty(&turn), + )?; + } + + let mut missing: Vec<&str> = if run.model_turn.is_some() { + vec![] + } else { + vec!["link:model_turn"] + }; if run.slice.is_some() && native.as_ref().is_none_or(|n| n["claimed"] != true) { missing.push("link:native"); } + let (origin, fixture_note, reason) = if run.model_turn.is_some() { + ("model_generation/2", + "Real daemon; the ledger records are the daemon's own ComposeRecall output (pretty-printed only); daemon_run.json and the 3-message trace are written by the test harness, including their timestamps. The model turn is REAL: the daemon generated the tool-call text (StreamTurn) and wrote its own generation record; the request bytes and timestamps are the harness's.", + "the proposal text was generated by the model this daemon loaded; the daemon's own generation record, the request and response bytes, the weights digest and the parsed request all chain to the effect") + } else { + ("scripted_turn", + "Real daemon; the five ledger records are the daemon's own ComposeRecall output (pretty-printed only); daemon_run.json and the 3-message trace are written by the test harness, including their timestamps. The model turn is SCRIPTED by the test (the tool call is a test constant), so authorship of the proposal is not claimed; the model only loaded.", + "the INTERPLANE model turn is scripted by the test: nothing links this model to the effect's content") + }; let mut companion = json!({ "kind": "interplane-provenance-companion", "schema": 0, - "fixture": {"class": "real", "note": "Real daemon; the five ledger records are the daemon's own ComposeRecall output (pretty-printed only); daemon_run.json and the 3-message trace are written by the test harness, including their timestamps. The model turn is SCRIPTED by the test (the tool call is a test constant), so authorship of the proposal is not claimed; the model only loaded."}, + "fixture": {"class": "real", "note": fixture_note}, "lineage": {"kind": "unknown_pretraining", "origin": {"model_id": run.model_origin.0, "model_id_source": "caller-asserted (AIEN_LEDGER_MODEL_ID or default; not checked against the model directory)", "revision": run.model_origin.1, "note": "weights as downloaded; no training evidence is held"}}, @@ -445,9 +536,9 @@ pub fn export_bundle(run: &LiveRun<'_>) -> Result<ExportReport, String> { "note": "no frozen AIEN candidate: no candidate_manifest record; CPU-reference backend as printed in the daemon log; whether the compose library was native-linked is reported only when the daemon returns compose_native (sovereign-core #346); aien.native then names it"}, "interplane": {"trace_id": run.trace_id, "request_id": request_id}, "effect": {"binding": "aien-ledger-slice/1", "approval_binding": "aien.approval.v2", - "proposal_origin": "scripted_turn"}, - "completeness": {"state": "incomplete", "missing": missing, - "reason": "the INTERPLANE model turn is scripted by the test: nothing links this model to the effect's content"}, + "proposal_origin": origin}, + "completeness": {"state": if missing.is_empty() { "complete" } else { "incomplete" }, "missing": missing, + "reason": reason}, "records": Value::Object(records), }); if let Some(n) = native { @@ -460,7 +551,7 @@ pub fn export_bundle(run: &LiveRun<'_>) -> Result<ExportReport, String> { if run.evaluation.is_some() { companion["evaluation"] = json!({"binding": "rsi-eval/2", "receipt": "evaluation_receipt", "policy": "evaluation_policy", - "note": "the change was proposed by spark-rsi and evaluated by the separate judge process; the judge's public key is supplied to the verifier out of band"}); + "note": if run.model_turn.is_some() { "the change was proposed by the model turn and evaluated by the separate judge process; the judge's public key is supplied to the verifier out of band" } else { "the change was proposed by spark-rsi and evaluated by the separate judge process; the judge's public key is supplied to the verifier out of band" }}); } write(run.out, "COMPANION.json", &pretty(&companion))?; Ok(ExportReport { @@ -514,6 +605,7 @@ mod tests { t_done: "t", slice: None, evaluation: None, + model_turn: None, }); assert!(r.unwrap_err().contains("never rewritten")); } diff --git a/adapters/aien/src/rsi_m5.rs b/adapters/aien/src/rsi_m5.rs index 004bcb6..2d438ad 100644 --- a/adapters/aien/src/rsi_m5.rs +++ b/adapters/aien/src/rsi_m5.rs @@ -62,6 +62,30 @@ pub fn propose_and_judge( ws: &Path, out: &Path, pinned_policy: &[u8], +) -> Result<Judged, String> { + run_hook(hook, ws, out, pinned_policy, None) +} + +/// The same hook and the same checks, for a proposal a real model turn produced: `proposal` is a +/// `proposal.json`-shaped file the harness wrote from the model's tool call (`id`, `target_file`, +/// `proposed_patch`). The hook skips `spark-rsi propose`; the judge still builds and evaluates the +/// exact bytes, and the receipt and policy are checked as for any other proposal. +pub fn judge_model_proposal( + hook: &Path, + ws: &Path, + out: &Path, + pinned_policy: &[u8], + proposal: &Path, +) -> Result<Judged, String> { + run_hook(hook, ws, out, pinned_policy, Some(proposal)) +} + +fn run_hook( + hook: &Path, + ws: &Path, + out: &Path, + pinned_policy: &[u8], + proposal: Option<&Path>, ) -> Result<Judged, String> { if out.exists() { return Err(format!( @@ -75,6 +99,11 @@ pub fn propose_and_judge( for v in NEGATIVE_ONLY_ENV { cmd.env_remove(v); } + // Only the model-turn row may redirect the proposal; the RSI row never does. + cmd.env_remove("M5_PROPOSAL_FILE"); + if let Some(p) = proposal { + cmd.env("M5_PROPOSAL_FILE", p); + } let run = cmd .output() .map_err(|e| format!("{}: {e}", hook.display()))?; diff --git a/adapters/aien/tests/compose_ledger.rs b/adapters/aien/tests/compose_ledger.rs index ea870aa..97057cd 100644 --- a/adapters/aien/tests/compose_ledger.rs +++ b/adapters/aien/tests/compose_ledger.rs @@ -38,6 +38,8 @@ use std::time::{Duration, Instant}; const NOW: &str = "2026-10-06T00:00:00Z"; const TRACE: &str = "ledger"; +/// The id the trace names as sender of a real model turn (the model the daemon loaded). +const MODEL_LABEL: &str = "llama-3.2-1b-instruct"; const EXPECTED: &str = "Decisions: ship v0.3 on Friday.\nOwners: Ada (release), Lin (docs).\n"; const MODEL_SNAPSHOT: &str = ".cache/huggingface/hub/models--unsloth--Llama-3.2-1B-Instruct/snapshots/5a8abab4a5d6f164389b1079fb721cfab8d7126c"; @@ -383,6 +385,7 @@ fn export_provenance( t_done: &str, slice: Option<&fix_the_test::TestRunEvidence>, evaluation: Option<&provenance_export::Evaluation>, + model_turn: Option<&provenance_export::ModelTurnRun>, ) { if std::env::var("LEDGER_OUT").is_err() { return; @@ -405,7 +408,11 @@ fn export_provenance( workspace: &d.ws(), model_dir: &d.model, model_origin: (&model_id, &revision), - model_label: "scripted-test-model", + model_label: if model_turn.is_some() { + MODEL_LABEL + } else { + "scripted-test-model" + }, trace_id: TRACE, intent, pending, @@ -414,6 +421,7 @@ fn export_provenance( t_done, slice, evaluation, + model_turn, }) .expect("provenance export"); println!("PROVENANCE_BUNDLE {}", rep.dir.display()); @@ -511,7 +519,7 @@ fn row1_approved_write_lands_and_is_done() { "receipt": rc, "journal": recs, "file_sha256": hex(&written), "expected_sha256": hex(EXPECTED.as_bytes())}), ); export_provenance( - &d, &intent_v, &pending_v, &res, &t_request, &t_done, None, None, + &d, &intent_v, &pending_v, &res, &t_request, &t_done, None, None, None, ); } @@ -1415,6 +1423,7 @@ fn slice1_fix_the_test_lands_and_tests_pass() { &t_done, Some(&evidence), None, + None, ); } @@ -1518,6 +1527,7 @@ fn m5_rsi_judged_change_lands_and_rolls_back() { &t_done, Some(&evidence), Some(&judged.evaluation), + None, ); // Rollback: a second approved write restores the pinned source bytes, with its own records. @@ -1572,3 +1582,461 @@ fn m5_rsi_judged_change_lands_and_rolls_back() { "test_exit_after_rollback": rollback_run.exit_code}}), ); } + +/// The prompt of the model-turn row: a system message with the reply form and the style rule, one +/// worked example on another file (so the format and the two replacements are shown once), and the +/// task with the README exactly as it is. Prompts that failed before this one (the model copied +/// the placeholder; the model kept the dashes) are not retained: this is the fourth tried. +fn model_turn_messages(readme: &str) -> Value { + let system = "You are a file editing assistant. You never write prose. You answer every request with \ + exactly one tool call in this form and nothing else:\n<tool_call>\n{\"name\": \"write_file\", \ + \"arguments\": {\"path\": \"FILE\", \"content\": \"FULL NEW TEXT\"}}\n</tool_call>\nLine breaks inside \ + the text are written as \\n. The new text must contain no em dash (\u{2014}) and no en dash \ + (\u{2013}): write a comma where an em dash was, and the word to where an en dash was."; + json!([ + {"role": "system", "content": system}, + {"role": "user", "content": "File NOTES.md contains:\n# Plan\n\nA small tool\u{2014}fast on purpose.\nIt covers pages 4\u{2013}6\u{2014}nothing more.\n"}, + {"role": "assistant", "content": "<tool_call>\n{\"name\": \"write_file\", \"arguments\": {\"path\": \"NOTES.md\", \"content\": \"# Plan\\n\\nA small tool, fast on purpose.\\nIt covers pages 4 to 6, nothing more.\\n\"}}\n</tool_call>"}, + {"role": "user", "content": format!("File README.md contains:\n{readme}")} + ]) +} + +/// VAC M5 with a REAL model turn: the daemon's own loaded model (StreamTurn, CPU) writes the +/// tool call that proposes the README change. The change then takes the same road as the scripted +/// M5 row: the separate judge builds and evaluates the exact bytes and signs a version 2 receipt, +/// the harness refuses to propose unless the receipt binds those bytes, the change lands through +/// ComposeApprovedProposal with the normal approval, the tests pass, and a second approved write +/// rolls it back. The bundle names the model turn (request and response bytes, the daemon's own +/// generation record, weights digest, backend, times) so the verifier can chain it to the effect. +/// If the model's text does not parse into one README write, or the judge does not admit it, the +/// row FAILS: nothing is repaired or replaced by a scripted turn. +#[test] +#[ignore = "NOT_RUN unless AIEN_BIN, M5_HOOK and M5_JUDGE_KEY are set: run with --ignored"] +fn m5_model_turn_proposal_is_judged_lands_and_chains() { + let _g = lock(); + let (Ok(hook), Ok(key_file)) = (std::env::var("M5_HOOK"), std::env::var("M5_JUDGE_KEY")) else { + panic!("NOT_RUN m5mt: M5_HOOK and M5_JUDGE_KEY must be set"); + }; + let key = interplane_provenance::evaluation::parse_judge_key( + &std::fs::read_to_string(&key_file).expect("M5_JUDGE_KEY file"), + ) + .expect("judge key"); + let Some(d) = daemon("m5mt") else { return }; + let c = d.client(); + let fixture = Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures/rsi_dashes"); + let task = fix_the_test::prepare_task(&fixture, &d.ws(), rsi_m5::TARGET, "rsi_dashes") + .expect("prepare the task workspace"); + let before_run = fix_the_test::run_tests(&task).expect("tests before"); + assert_ne!(before_run.exit_code, 0, "the task must start red"); + let pinned_policy = + std::fs::read(Path::new(env!("CARGO_MANIFEST_DIR")).join("m5/policy.json")).unwrap(); + + // 1. The model turn: the daemon generates; the harness keeps the exact bytes either way. + let readme = std::fs::read_to_string(d.ws().join(&task.target)).unwrap(); + let messages = model_turn_messages(&readme); + let request = serde_json::to_vec(&messages).unwrap(); + let (max_tokens, temperature) = (512u64, 0.0f64); + let started_at = provenance_export::now_rfc3339(); + let turn = c.stream_turn(&messages, max_tokens, temperature); + let finished_at = provenance_export::now_rfc3339(); + let attempt = d.root.join("attempt"); + std::fs::create_dir_all(&attempt).unwrap(); + std::fs::write(attempt.join("request.json"), &request).unwrap(); + let turn = turn.unwrap_or_else(|e| panic!("the model turn failed: {e}")); + std::fs::write(attempt.join("response.txt"), turn.text.as_bytes()).unwrap(); + let mt = provenance_export::ModelTurnRun { + request, + response: turn.text.clone(), + generation_record: turn.generation_record, + total_tokens: turn.total_tokens, + max_tokens, + temperature, + started_at, + finished_at, + }; + + // 2. The proposal is exactly what the dialect parses from that text; nothing is repaired. + let parsed = DialectRegistry::with_defaults() + .get("aien_legacy") + .expect("aien_legacy") + .parse( + &json!(turn.text), + &interplane_lenshift::ParseContext { + trace_id: TRACE.into(), + turn: 0, + model: MODEL_LABEL.into(), + }, + ); + assert!( + parsed.intents.len() == 1 && parsed.rejected.is_empty() && !parsed.partial, + "MODEL_TURN_NOT_A_PROPOSAL: the text parses to {} request(s), {} rejected; response in {}", + parsed.intents.len(), + parsed.rejected.len(), + attempt.display() + ); + let args = serde_json::to_value(&parsed.intents[0].arguments).unwrap(); + assert_eq!(parsed.intents[0].tool.name, "write_file"); + let (path, content) = ( + args["path"].as_str().expect("path").to_string(), + args["content"].as_str().expect("content").to_string(), + ); + assert_eq!(path, task.target, "the model must write the task's README"); + let proposal_file = d.root.join("model-proposal.json"); + std::fs::write( + &proposal_file, + serde_json::to_vec_pretty( + &json!({"id": format!("model-gen-{}", turn.generation_record), + "title": "README without dashes", "description": "proposed by a model turn", + "target_file": path, "proposed_patch": content, "kind": "Style", + "created_at": provenance_export::now_rfc3339(), "sandbox_path": null}), + ) + .unwrap(), + ) + .unwrap(); + + // 3. The same judge, the same gate before the write. + let judged = rsi_m5::judge_model_proposal( + Path::new(&hook), + &task.ws, + &d.root.join("judged"), + &pinned_policy, + &proposal_file, + ) + .expect("the judge must admit the model's change (a refusal fails the row)"); + assert_eq!( + judged.content, content, + "the judge evaluated the model's bytes" + ); + interplane_provenance::evaluation::precheck( + &judged.evaluation.receipt, + &judged.evaluation.policy, + &key, + &interplane_provenance::evaluation::Expect { + path: &task.target, + content: judged.content.as_bytes(), + parent_commit: &task.commit, + policy_sha256: Some(&hex(&pinned_policy)), + }, + ) + .expect("the judge's receipt must bind the proposed bytes"); + + // 4. The approved write of the model's own tool call. + let before = count(&c); + let l = ledger(&d); + let mut rt = l.clone(); + let mut p = pipe(&mut rt, &l); + let out = p.run_turn("aien_legacy", MODEL_LABEL, &json!(turn.text), TRACE, 0); + assert_eq!(out.results.len(), 1, "{out:?}"); + assert_eq!(out.results[0].status, ResultStatus::RequiresApproval); + let rid = out.intents[0].request_id.clone(); + let intent_v = serde_json::to_value(&out.intents[0]).unwrap(); + let pending_v = serde_json::to_value(&out.results[0]).unwrap(); + let t_request = provenance_export::now_rfc3339(); + let (res, _) = approve(&mut p, &l, &rid); + assert_eq!(res.status, ResultStatus::Ok, "{res:?}"); + let t_done = provenance_export::now_rfc3339(); + let rc = res.data["receipt"].clone(); + assert_eq!(rc["state"], "DONE"); + let written = std::fs::read(d.ws().join(&task.target)).unwrap(); + assert_eq!( + written, + judged.content.as_bytes(), + "the daemon wrote the judged bytes" + ); + assert_eq!(rc["disk_sha256"], json!(hex(judged.content.as_bytes()))); + let ids: Vec<u64> = ["grant_id", "intent_id", "ack_record_id"] + .iter() + .map(|k| rc[*k].as_u64().unwrap()) + .collect(); + let recs = records(&c, &ids); + assert!(recs.iter().all(|r| r["verified"] == true)); + assert_eq!( + recs[0]["text"]["prior_sha256"], + json!(task.target_blob_sha256) + ); + let after_run = fix_the_test::run_tests(&task).expect("tests after"); + assert_eq!(after_run.exit_code, 0, "the task must end green"); + let evidence = fix_the_test::evidence(&task, &before_run, &after_run).unwrap(); + let after = count(&c); + export_provenance( + &d, + &intent_v, + &pending_v, + &res, + &t_request, + &t_done, + Some(&evidence), + Some(&judged.evaluation), + Some(&mt), + ); + + // 5. Rollback: a second approved write restores the pinned source bytes. + let prior = std::fs::read(fixture.join(&task.target)).unwrap(); + assert_eq!(hex(&prior), task.target_blob_sha256); + propose( + &mut p, + 1, + "w2", + &task.target, + std::str::from_utf8(&prior).unwrap(), + ); + let (res2, _) = approve(&mut p, &l, "w2"); + assert_eq!(res2.status, ResultStatus::Ok, "{res2:?}"); + let rc2 = res2.data["receipt"].clone(); + assert_eq!(rc2["state"], "DONE"); + let restored = std::fs::read(d.ws().join(&task.target)).unwrap(); + assert_eq!(restored, prior, "rollback restored the pinned bytes"); + let rollback_run = fix_the_test::run_tests(&task).expect("tests after rollback"); + assert_ne!( + rollback_run.exit_code, 0, + "the restored README fails its test again" + ); + save( + &d, + "m5mt", + json!({"verdict": "PASS", "records_before": before, "records_after": after, + "receipt": rc, "journal": recs, "task_id": evidence.task_id, + "proposal_id": judged.proposal_id, "request_id": rid, + "model_turn": {"generation_record": turn.generation_record, "total_tokens": turn.total_tokens, + "request_sha256": hex(&mt.request), "response_sha256": hex(mt.response.as_bytes()), + "started_at": mt.started_at, "finished_at": mt.finished_at}, + "evaluation_receipt_sha256": hex(&judged.evaluation.receipt), + "evaluation_policy_sha256": hex(&judged.evaluation.policy), + "test_exit_before": evidence.exit_before, "test_exit_after": evidence.exit_after, + "source_commit": task.commit, "tree_commit_after": evidence.tree_commit_after, + "target_blob_sha256_before": task.target_blob_sha256, "target_blob_sha256_after": hex(&written), + "rollback": {"receipt": rc2, "disk_sha256": hex(&restored), + "test_exit_after_rollback": rollback_run.exit_code}}), + ); +} + +/// Kill the test's own daemon and start a new one on the SAME home (same compose ledger, same +/// state directory, same desk key). The old log stays where it was; the new daemon writes +/// `daemon-restart-<n>.log`, and `d.log` points at it. Waits for the declared warm-up line. +fn restart(d: &mut Daemon, n: u32) { + let _ = d.child.kill(); + let _ = d.child.wait(); + let bin = std::env::var("AIEN_BIN").expect("AIEN_BIN"); + let _ = std::fs::remove_file(&d.sock); + let log = d.root.join(format!("daemon-restart-{n}.log")); + d.child = Command::new(&bin) + .arg("daemon") + .env_remove("AIEN_GPU_BACKEND") + .env_remove("AIEN_REQUIRE_BLACKWELL") + .env("AIEN_MODEL_PATH", d.model.join("model.safetensors")) + .env("AIEN_TOKENIZER_PATH", d.model.join("tokenizer.json")) + .env("AIEN_REQUIRE_CHECKPOINT", "1") + .env("AIEN_COMPOSE_DIR", d.root.join("compose")) + .env("AIEN_RUNTIME_STATE_DIR", d.root.join("state")) + .env("AIEN_PROVENANCE_DIR", d.root.join("prov")) + .env("AIEN_RUNTIME_SOCK", &d.sock) + .stdin(Stdio::null()) + .stdout(std::fs::File::create(&log).unwrap()) + .stderr(std::fs::File::create(d.root.join(format!("daemon-restart-{n}.err"))).unwrap()) + .spawn() + .expect("respawn aien-cli daemon"); + d.log = log.clone(); + let t0 = Instant::now(); + loop { + let text = std::fs::read_to_string(&log).unwrap_or_default(); + if d.sock.exists() && text.contains("Warm-up:") { + break; + } + if let Ok(Some(st)) = d.child.try_wait() { + panic!("DAEMON_NOT_RESTARTED: exited {st}; log {}", log.display()); + } + assert!( + t0.elapsed() < Duration::from_secs(600), + "no warm-up after restart" + ); + std::thread::sleep(Duration::from_millis(500)); + } + std::thread::sleep(Duration::from_millis(500)); +} + +/// The exact approval of request `id` handed to the daemon again (same desk MAC, same bytes). +fn rehandoff( + d: &Daemon, + c: &LedgerClient, + rc: &Value, + id: &str, + path: &str, + content: &str, +) -> Result<Value, String> { + let key = DeskKey::load(&d.desk()).unwrap(); + let b = binding( + d, + id, + rc["approval_id"].as_str().unwrap(), + "drake", + path, + content, + ); + c.approved(&handoff(Some(&key), &b, content), d.ws().to_str().unwrap()) +} + +/// A daemon restart does not make a spent approval spendable again. The write lands and is +/// acknowledged; the daemon process is killed and a new one starts on the same ledger. The same +/// approval handed over again returns the ORIGINAL result and runs nothing (same replay claim); +/// a second intent on the spent grant is refused; the same approval id under a fresh request id is +/// refused by the durable replay ledger. No restart, no replay appends a record or touches the file. +#[test] +#[ignore = "NOT_RUN unless AIEN_BIN names an aien-cli binary: run with --ignored"] +fn row12_daemon_restart_does_not_make_a_spent_approval_spendable() { + let _g = lock(); + let Some(mut d) = daemon("row12") else { return }; + let l = ledger(&d); + let mut rt = l.clone(); + let mut p = pipe(&mut rt, &l); + propose(&mut p, 0, "r1", "summary.txt", EXPECTED); + let (res, _) = approve(&mut p, &l, "r1"); + assert_eq!(res.status, ResultStatus::Ok, "{res:?}"); + let rc = res.data["receipt"].clone(); + let sha_before = hex(&std::fs::read(d.ws().join("summary.txt")).unwrap()); + let (claim, _) = claim_grant(&rc); + let ids: Vec<u64> = (claim..=rc["ack_record_id"].as_u64().unwrap()).collect(); + let recs_before = records(&d.client(), &ids); + restart(&mut d, 1); + let c = d.client(); + assert_eq!( + records(&c, &ids), + recs_before, + "every record of the write survived the restart byte for byte (digests included)" + ); + // The daemon appends its own start-up records; the baseline for the replays is after them. + let before = count(&c); + let again = rehandoff(&d, &c, &rc, "r1", "summary.txt", EXPECTED).expect("original result"); + assert_eq!(again["state"], "ALREADY_COMMITTED"); + assert!( + again["task"].is_null(), + "a replay must not run the task again" + ); + assert_eq!(again["replay_claim"], rc["handoff"]["replay_claim"]); + let second_intent = c + .intent( + rc["grant_id"].as_u64().unwrap(), + rc["proposal_sha256"].as_str().unwrap(), + "summary.txt", + rc["target"].as_str().unwrap(), + rc["content_sha256"].as_str().unwrap(), + (std::process::id(), 1), + ) + .unwrap_err(); + assert!( + second_intent.contains("EFFECT_REFUSED AlreadySpent"), + "{second_intent}" + ); + let reminted = rehandoff(&d, &c, &rc, "r1-again", "summary.txt", EXPECTED).unwrap_err(); + assert!( + reminted.starts_with("REPLAY_REFUSED AlreadyCommitted"), + "{reminted}" + ); + assert_eq!( + count(&c), + before, + "no replay after the restart appends a record" + ); + assert_eq!( + hex(&std::fs::read(d.ws().join("summary.txt")).unwrap()), + sha_before + ); + save( + &d, + "row12", + json!({"verdict": "PASS", "records_after_restart": before, "records_after_replays": count(&c), + "daemon_replay": again, "second_intent": second_intent, "same_approval_new_request": reminted, + "receipt": rc}), + ); +} + +/// The daemon dies after the intent record exists and the bytes are on disk, before the ack. The +/// adapter must not report success: the receipt is `UNRESOLVED` and the result is an error. After a +/// restart the ledger holds the intent and no ack, the grant is spent (a second intent is refused), +/// and the same approval handed over again returns the original result (no second run). Whether the +/// bytes on disk are the approved ones is a fact only a read of the file can state (they are, here, +/// and are reported as such), never something the missing ack proves. +#[test] +#[ignore = "NOT_RUN unless AIEN_BIN names an aien-cli binary: run with --ignored"] +fn row13_restart_between_intent_and_ack_is_unresolved_not_success() { + let _g = lock(); + let Some(mut d) = daemon("row13") else { return }; + let l = ledger(&d); + let pid = d.child.id(); + l.set_before_ack(move |_| { + // The daemon dies here: intent recorded, bytes written, no ack sent yet. + let _ = Command::new("kill") + .args(["-KILL", &pid.to_string()]) + .status(); + std::thread::sleep(Duration::from_millis(500)); + }); + let mut rt = l.clone(); + let mut p = pipe(&mut rt, &l); + propose(&mut p, 0, "u1", "unacked.txt", EXPECTED); + let (res, _) = approve(&mut p, &l, "u1"); + assert_ne!( + res.status, + ResultStatus::Ok, + "ATTACK SUCCEEDED: success without an ack: {res:?}" + ); + let rc = l.receipts().pop().unwrap(); + assert_eq!(rc["state"], "UNRESOLVED", "{rc}"); + assert!(rc.get("ack_record_id").is_none(), "{rc}"); + let intent_id = rc["intent_id"].as_u64().expect("the intent exists"); + let grant = rc["grant_id"].as_u64().unwrap(); + let on_disk = std::fs::read(d.ws().join("unacked.txt")).unwrap(); + restart(&mut d, 1); + let c = d.client(); + let recs = records(&c, &[intent_id]); + assert_eq!(recs[0]["verified"], true); + assert_eq!( + effects_for(&c, grant).len(), + 1, + "the ledger holds the intent and no ack after the restart" + ); + // The restarted daemon looked at the open intent and DID NOT DECIDE it (its executor, this test + // process, is still running): it is neither done nor not-done in the ledger. + let boot = std::fs::read_to_string(&d.log).unwrap(); + let reconcile = boot + .lines() + .find(|l| l.starts_with("Reconcile:")) + .expect("a Reconcile line") + .to_string(); + assert!( + reconcile.contains("checked 1 unsettled effect(s): DONE 0"), + "{reconcile}" + ); + assert!(reconcile.contains("\"state\":\"OPEN\""), "{reconcile}"); + let before = count(&c); + let second_intent = c + .intent( + grant, + rc["proposal_sha256"].as_str().unwrap(), + "unacked.txt", + rc["target"].as_str().unwrap(), + rc["content_sha256"].as_str().unwrap(), + (std::process::id(), 1), + ) + .unwrap_err(); + assert!( + second_intent.contains("EFFECT_REFUSED ReconciliationRequired") + && second_intent.contains("is OPEN"), + "{second_intent}" + ); + let again = rehandoff(&d, &c, &rc, "u1", "unacked.txt", EXPECTED).expect("original result"); + assert_eq!(again["state"], "ALREADY_COMMITTED"); + assert!(again["task"].is_null()); + assert_eq!( + count(&c), + before, + "replays after the restart append nothing" + ); + save( + &d, + "row13", + json!({"verdict": "PASS", "adapter_state": rc["state"], "intent_id": intent_id, + "effects_after_restart": effects_for(&c, grant).len(), + "disk_sha256_after_crash": hex(&on_disk), "approved_sha256": hex(EXPECTED.as_bytes()), + "second_intent": second_intent, "daemon_replay": again, "restart_reconcile": reconcile, + "receipt": rc}), + ); +} diff --git a/provenance/src/modelturn.rs b/provenance/src/modelturn.rs index bc3c5d7..171c28c 100644 --- a/provenance/src/modelturn.rs +++ b/provenance/src/modelturn.rs @@ -239,5 +239,102 @@ pub fn check(a: &Archive, t: &Value, call: Option<&Call>) -> Result<(), Fail> { "trace request source vs model_turn.model", ); } + check_turn_record(a)?; + Ok(()) +} + +fn is_rfc3339_utc(x: &str) -> bool { + let b = x.as_bytes(); + b.len() == 20 + && b[19] == b'Z' + && [4, 7].iter().all(|&i| b[i] == b'-') + && b[10] == b'T' + && [13, 16].iter().all(|&i| b[i] == b':') + && b.iter() + .enumerate() + .all(|(i, c)| [4, 7, 10, 13, 16, 19].contains(&i) || c.is_ascii_digit()) +} + +/// `model-turn/2`: the retained model turn names the exact request and response bytes, the model +/// and the weights digest, the backend and the times, and each one is compared with what the +/// bundle retains. Runs only for a turn that declares `record: "model-turn/2"`; a turn without +/// the marker keeps the older, weaker checks above and is not read as carrying these links. +/// Compared, never trusted: the request bytes are the harness's own (the daemon's record holds +/// only the token-id digest of the prompt, which this offline check cannot recompute), and the +/// backend line is the daemon's log line quoted by the harness. +fn check_turn_record(a: &Archive) -> Result<(), Fail> { + let Some(turn) = a.json("model_turn")? else { + return fail("missing_record", "model_turn (not retained)"); + }; + if s(&turn, &["record"]) != Some("model-turn/2") { + return Ok(()); + } + let bad = + |what: &str| -> Result<(), Fail> { fail("binding_mismatch", format!("model_turn.{what}")) }; + let hex64 = |x: Option<&str>| { + x.is_some_and(|h| h.len() == 64 && h.bytes().all(|b| b.is_ascii_hexdigit())) + }; + // Request bytes: the retained record is exactly the bytes whose digest the turn names. + if s(&turn, &["request_record"]) != Some("model_request") { + return bad("request_record"); + } + if !a.has("model_request") { + return fail("missing_record_entry", "model_request"); + } + let Some(req) = a.bytes("model_request")? else { + return fail("missing_record", "model_request (not retained)"); + }; + let req_sha = sha256_hex(req); + if !hex64(s(&turn, &["request_sha256"])) || s(&turn, &["request_sha256"]) != Some(&req_sha) { + return bad("request_sha256 != sha256(model_request)"); + } + if a.sha("model_request")? != req_sha { + return bad("request_sha256 != record digest"); + } + // The request is a messages array that really asks for something (not an empty shell). + match crate::strict::parse(req) { + Some(Value::Array(m)) if !m.is_empty() => {} + _ => return bad("model_request (not a non-empty messages array)"), + } + // Response bytes: the exact text the dialect parsed. + let Some(text) = s(&turn, &["input"]) else { + return bad("input"); + }; + if s(&turn, &["response_sha256"]) != Some(sha256_hex(text.as_bytes()).as_str()) { + return bad("response_sha256 != sha256(input)"); + } + // Weights: the digest the turn names is the exported file the daemon's record also names. + if s(&turn, &["weights_sha256"]) != Some(a.sha("export_weights")?) { + return bad("weights_sha256 != export_weights"); + } + for k in ["model_id", "backend"] { + if s(&turn, &[k]).is_none_or(str::is_empty) { + return bad(k); + } + } + // The backend line is quoted from the load log the bundle retains. + let backend = s(&turn, &["backend"]).unwrap_or(""); + let log = a + .bytes("aien_load_log")? + .map(|b| String::from_utf8_lossy(b).into_owned()) + .unwrap_or_default(); + if !log.lines().any(|l| l.trim() == backend) { + return bad("backend (not a line of aien_load_log)"); + } + // Times: well formed, ordered, and the model finished before the request was admitted. + let (Some(t0), Some(t1)) = ( + s(&turn, &["stream_started"]), + s(&turn, &["stream_finished"]), + ) else { + return bad("stream_started/stream_finished"); + }; + if !is_rfc3339_utc(t0) || !is_rfc3339_utc(t1) || t0 > t1 { + return bad("stream_started/stream_finished (order or form)"); + } + let trace = a.json("interplane_trace")?.unwrap_or(Value::Null); + match trace.get(0).and_then(|e| s(e, &["timestamp"])) { + Some(req_t) if t1 <= req_t => {} + _ => return bad("stream_finished is after the trace request"), + } Ok(()) } diff --git a/provenance/tests/model_turn_link.rs b/provenance/tests/model_turn_link.rs new file mode 100644 index 0000000..dea14e9 --- /dev/null +++ b/provenance/tests/model_turn_link.rs @@ -0,0 +1,209 @@ +//! `model-turn/2`: the retained model turn names the exact request and response bytes, the model +//! and weights digests, the backend and the times, and each is compared with what the bundle +//! retains. The base is the real daemon-generated chain (`fixtures/real-waldo-aien-chain`) upgraded +//! in a copy with the new request record and fields, so the committed fixture is never rewritten. +//! Every expected verdict is a literal. A turn that does not chain never yields `PASS`: it is +//! `FAIL`, or, when the bundle honestly says the turn is not a model's, the INCOMPLETE label. +mod common; +use common::*; +use interplane_provenance::gojson::sha256_hex; +use interplane_provenance::verify; +use serde_json::{json, Value}; +use std::path::Path; + +const REAL: &str = "fixtures/real-waldo-aien-chain"; +const COMPLETE: &str = + "PASS complete effect=aien-ledger-slice/1:strong proposal=model_generation/2 candidate=none"; +const REQUEST: &[u8] = + b"[{\"role\":\"user\",\"content\":\"Save the meeting summary to summary.txt.\"}]"; + +fn edit_json(d: &Path, rec: &str, f: impl FnOnce(&mut Value)) { + let p = path_of(d, rec); + let mut v: Value = serde_json::from_slice(&std::fs::read(&p).unwrap()).unwrap(); + f(&mut v); + std::fs::write(&p, serde_json::to_vec_pretty(&v).unwrap()).unwrap(); + restamp(d, rec); +} + +/// A copy of the real chain whose model turn is a `model-turn/2` record with a retained request. +fn v2(name: &str) -> std::path::PathBuf { + let d = scratch(REAL, name); + std::fs::create_dir_all(d.join("records/model")).unwrap(); + std::fs::write(d.join("records/model/request.json"), REQUEST).unwrap(); + let mut c = companion(&d); + c["records"]["model_request"] = json!({"path": "records/model/request.json", + "sha256": sha256_hex(REQUEST), "bytes": REQUEST.len()}); + let weights = c["records"]["export_weights"]["sha256"].clone(); + write_companion(&d, &c); + let log = std::fs::read_to_string(path_of(&d, "aien_load_log")).unwrap(); + let backend = log + .lines() + .find(|l| l.contains("Backend:")) + .unwrap() + .trim() + .to_string(); + edit_json(&d, "model_turn", |t| { + let input = t["input"].as_str().unwrap().to_string(); + t["record"] = json!("model-turn/2"); + t["model_id"] = json!("toolcall-tiny"); + t["request_record"] = json!("model_request"); + t["request_sha256"] = json!(sha256_hex(REQUEST)); + t["response_sha256"] = json!(sha256_hex(input.as_bytes())); + t["weights_sha256"] = weights; + t["backend"] = json!(backend); + }); + d +} + +fn failed(d: &Path, code: &str, why: &str) { + let v = verify(d); + assert!( + v.starts_with(&format!("FAIL {code}:")) && !v.starts_with("PASS"), + "{why}: {v}" + ); +} + +#[test] +fn a_model_turn_that_chains_by_digest_is_complete() { + let d = v2("mt-ok"); + assert_eq!(verify(&d), COMPLETE); +} + +#[test] +fn request_bytes_changed_after_the_digest_was_named_are_refused() { + let d = v2("mt-req"); + std::fs::write( + d.join("records/model/request.json"), + b"[{\"role\":\"user\",\"content\":\"other\"}]", + ) + .unwrap(); + restamp(&d, "model_request"); + failed( + &d, + "binding_mismatch", + "request bytes differ from request_sha256", + ); +} + +#[test] +fn a_request_that_is_not_a_messages_array_is_refused() { + let d = v2("mt-req-shape"); + std::fs::write(d.join("records/model/request.json"), b"{}").unwrap(); + restamp(&d, "model_request"); + edit_json(&d, "model_turn", |t| { + t["request_sha256"] = json!(sha256_hex(b"{}")) + }); + failed(&d, "binding_mismatch", "request is not a messages array"); +} + +#[test] +fn a_request_record_that_is_not_listed_is_refused() { + let d = v2("mt-req-unlisted"); + let mut c = companion(&d); + c["records"] + .as_object_mut() + .unwrap() + .remove("model_request"); + write_companion(&d, &c); + failed( + &d, + "missing_record_entry", + "request record dropped from the manifest", + ); +} + +#[test] +fn a_response_that_is_not_the_named_response_is_refused() { + let d = v2("mt-resp"); + edit_json(&d, "model_turn", |t| { + t["response_sha256"] = json!(sha256_hex(b"other")) + }); + failed(&d, "binding_mismatch", "response_sha256 differs"); +} + +#[test] +fn weights_digest_not_the_exported_file_is_refused() { + let d = v2("mt-weights"); + edit_json(&d, "model_turn", |t| { + t["weights_sha256"] = json!(sha256_hex(b"other weights")) + }); + failed(&d, "binding_mismatch", "weights_sha256 differs"); +} + +#[test] +fn a_backend_the_load_log_does_not_name_is_refused() { + let d = v2("mt-backend"); + edit_json(&d, "model_turn", |t| t["backend"] = json!("Backend: CUDA")); + failed(&d, "binding_mismatch", "backend not in the log"); +} + +#[test] +fn times_out_of_order_or_after_the_request_are_refused() { + let d = v2("mt-time-order"); + edit_json(&d, "model_turn", |t| { + t["stream_started"] = json!("2026-10-08T02:00:00Z"); + t["stream_finished"] = json!("2026-10-08T01:00:00Z"); + }); + failed(&d, "binding_mismatch", "finished before started"); + let d = v2("mt-time-late"); + edit_json(&d, "model_turn", |t| { + t["stream_started"] = json!("2026-10-08T03:00:00Z"); + t["stream_finished"] = json!("2026-10-08T03:00:01Z"); + }); + failed( + &d, + "binding_mismatch", + "generation finished after the request", + ); +} + +#[test] +fn a_turn_for_other_bytes_does_not_chain_to_the_effect() { + // The response text is replaced by a different tool call and every digest is restamped to + // match: the daemon's generation record and the trace request still name the old text. + let d = v2("mt-other-text"); + edit_json(&d, "model_turn", |t| { + let other = "<tool_call>\n{\"name\": \"write_file\", \"arguments\": {\"path\": \"summary.txt\", \"content\": \"other\\n\"}}\n</tool_call><|im_end|>\n"; + t["input"] = json!(other); + t["response_sha256"] = json!(sha256_hex(other.as_bytes())); + }); + failed( + &d, + "binding_mismatch", + "text differs from the daemon's generation record", + ); +} + +#[test] +fn a_missing_model_turn_is_a_refusal_and_a_scripted_one_is_labelled_incomplete() { + // Declared as a model's, not retained: refused. + let d = v2("mt-dropped"); + let mut c = companion(&d); + c["records"].as_object_mut().unwrap().remove("model_turn"); + write_companion(&d, &c); + assert!(verify(&d).starts_with("FAIL "), "{}", verify(&d)); + // The honest downgrade: the same bundle says the turn was scripted. Never PASS complete. + let d = v2("mt-scripted"); + let mut c = companion(&d); + c["effect"]["proposal_origin"] = json!("scripted_turn"); + c["completeness"] = json!({"state": "incomplete", "missing": ["link:model_turn"]}); + write_companion(&d, &c); + assert_eq!( + verify(&d), + "PASS_LABELLED_INCOMPLETE missing=link:model_turn effect=aien-ledger-slice/1:strong proposal=scripted_turn" + ); + // A scripted turn that claims completeness is refused. + let mut c = companion(&d); + c["completeness"] = json!({"state": "complete", "missing": []}); + write_companion(&d, &c); + failed(&d, "unlabelled_missing", "scripted but declared complete"); +} + +#[test] +fn the_version_one_turn_keeps_its_old_checks_and_is_not_read_as_having_the_new_links() { + let d = scratch(REAL, "mt-v1"); + assert_eq!(verify(&d), COMPLETE); + let t: Value = + serde_json::from_slice(&std::fs::read(path_of(&d, "model_turn")).unwrap()).unwrap(); + assert!(t.get("record").is_none() && t.get("request_sha256").is_none()); +}