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#86 (code only)
Apply it
git checkout -b patch-83e1ba9167d39c2f 26b74656870dcc5b4985dffd85439dcd32b7b052 curl -fsSL https://interplane.io/drakestapleton/interplane-mv/patches/83e1ba9167d39c2f.patch | git am
Provenance
github-import 1
aien-dev/interplane-mv
86
58c5b4d3ba4669fee684729f783df5468c22ebdb
{"kind":"github-import","owner":"aien-dev","repo":"interplane-mv","number":86,"url":"https://github.com/aien-dev/interplane-mv/pull/86","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:40:13Z","metadata":"unavailable","state_derived":true}
Changes
diff --git a/provenance/BINDING.md b/provenance/BINDING.md index 964babf..d62f3f6 100644 --- a/provenance/BINDING.md +++ b/provenance/BINDING.md @@ -94,7 +94,9 @@ about correctness of the text. own request id, and the ids are inside the MAC-bound approval key. 9. Intent and ack: intent names the grant and repeats its `proposal_sha256`, `path`, `target`, `content_sha256`, `prior_sha256`; `tool` is `write_file`; the grant's `target` is `workspace + "/" - + path`; ack names the intent and the grant, `state` is `DONE`, and its `content_sha256` and + + path`; no ack after the intent is `FAIL effect_interrupted`; ack names the intent and the grant, + `state` is `DONE` (`NOT_DONE` is `FAIL effect_not_done`, `UNRESOLVED` is `FAIL effect_unresolved`, see + "Recovery outcomes"), and its `content_sha256` and `disk_sha256` equal the grant's `content_sha256`. 10. **Same process.** `claim.executor.{pid,start}` equals `daemon_run.{pid,start_ticks}`; `daemon_run.workspace` equals the grant's workspace; `daemon_run.executable_sha256` equals @@ -244,3 +246,38 @@ verifier detects inconsistent or altered evidence, not a producer that fabricate Does not prove: that the tests are good, that the proposal came from a model (it is scripted: `link:model_turn` stays missing), that the harness is honest, or that nothing else touched the workspace between the ack and the second test run. + +## Recovery outcomes: effects the ledger does not show as landed (VAC M4d) + +Status: implemented in `src/ledger.rs` (`unlanded`); tested in `tests/recovery_verdicts.rs` on the +committed real slice (`real-waldo-aien-chain`) and the synthetic fixtures, mutated and restamped. + +**Behaviour before M4d [O, from `tests/effect_binding.rs`]:** an ack with `state: NOT_DONE` was +`FAIL binding_mismatch: ledger_ack.state`; an intent with no ack in the manifest was +`FAIL missing_record_entry: ledger_ack`; `UNRESOLVED` took the same path as `NOT_DONE` [I, same code +line]. None could pass, but all three were indistinguishable from a tampered bundle. + +**Now**, in the checks' fixed order (step 9, after the intent and ack are tied to the grant): + +| Ledger shows | Verdict | Meaning | +|---|---|---| +| ack `DONE` | as before | the daemon read the file back and it matched | +| ack `NOT_DONE` | `FAIL effect_not_done` | the daemon read the world back and the write did not land | +| ack `UNRESOLVED` | `FAIL effect_unresolved` | the daemon could not tell whether the write landed | +| intent, no `ledger_ack` in the bundle | `FAIL effect_interrupted` | the executor was interrupted after the intent; the write may or may not have landed | +| any other ack state | `FAIL binding_mismatch: ledger_ack.state=<x>` | not a daemon state | + +Why FAIL and not `PASS_LABELLED_INCOMPLETE`: a labelled-missing link says "an otherwise valid chain +lacks a link". Here the claimed effect is the link, and the ledger says it is absent or unknown. A PASS +of any kind would let a reader take the effect as having happened. The three codes are checked after the +records before them agree (a forged claim next to a missing ack is reported as the forgery) and before the +INTERPLANE call checks. + +**A test run cannot certify a write that did not land.** When the bundle carries a `test_run` section or +any of `task`, `source_pin`, `test_run_record`, each of the three cases above is instead +`FAIL test_run_on_unlanded_effect: <effect code>: <detail>`. + +Limits: the verifier does not re-derive that a recovery was correct, only that the exported ack says +what it says. An interrupted run's ack may never be written, and then the bundle is unrecoverable as +evidence of the effect, by design. The NOT_DONE and UNRESOLVED fixtures are synthetic (the real DONE ack +with `state` changed); a bundle exported from a real daemon after an interruption was not produced. diff --git a/provenance/README.md b/provenance/README.md index 7b00a53..598be61 100644 --- a/provenance/README.md +++ b/provenance/README.md @@ -43,7 +43,7 @@ truncated write), `digest_mismatch`, `unlabelled_missing`, `completeness_mismatc `conversion_mismatch`, `incompatible`, `load_support_mismatch`, `load_unsupported`, `invalid_envelope`, `not_in_trace`, `synthetic_complete`, `canonicalization_mismatch`, `unsupported_binding`, and for the fix-the-test slice (BINDING.md): `test_run_missing`, -`test_run_mismatch`, `unsupported_test_run`, `source_pin_mismatch`, `native_claim_contradicted`. +`test_run_mismatch`, `unsupported_test_run`, `source_pin_mismatch`, `native_claim_contradicted`; and for effects the ledger does not show as landed (BINDING.md "Recovery outcomes"): `effect_not_done`, `effect_unresolved`, `effect_interrupted`, `test_run_on_unlanded_effect`. A complete verdict whose AIEN link names no frozen candidate manifest (`candidate_id: null`) ends with `candidate=none`. Reading is strict: every JSON input (the manifest, each record, the JSON diff --git a/provenance/src/ledger.rs b/provenance/src/ledger.rs index 1d68547..6f661d5 100644 --- a/provenance/src/ledger.rs +++ b/provenance/src/ledger.rs @@ -109,6 +109,7 @@ pub fn check( t: &Value, aien: &Value, call: Option<&Call>, + claims_test_run: bool, ) -> Result<(), Fail> { if s(e, &["approval_binding"]) != Some(APPROVAL_BINDING) { return fail( @@ -119,8 +120,9 @@ pub fn check( ), ); } + // An intent without an ack is an interrupted effect (checked below), not a missing record. for n in SLICE.iter().chain([&DAEMON_RUN]) { - if !a.has(n) { + if *n != "ledger_ack" && !a.has(n) { return fail("missing_record_entry", *n); } } @@ -128,8 +130,6 @@ pub fn check( let committed = view(a, "ledger_committed", "effect")?; let grant = view(a, "ledger_grant", "authorization")?; let intent = view(a, "ledger_intent", "effect")?; - let ack = view(a, "ledger_ack", "effect")?; - // Record kinds. eq( st(&claim, "ledger_claim", "approved_submission")?, @@ -151,6 +151,14 @@ pub fn check( "intent", "ledger_intent.phase", )?; + if !a.has("ledger_ack") { + return unlanded( + "effect_interrupted", + "ledger_intent is the last record: no ack, the write may or may not have landed", + claims_test_run, + ); + } + let ack = view(a, "ledger_ack", "effect")?; eq(st(&ack, "ledger_ack", "phase")?, "ack", "ledger_ack.phase")?; // Ledger order: claim < committed < grant < intent < ack. @@ -298,7 +306,22 @@ pub fn check( true, "ledger_ack.links", )?; - eq(st(&ack, "ledger_ack", "state")?, "DONE", "ledger_ack.state")?; + match st(&ack, "ledger_ack", "state")? { + "DONE" => {} + "NOT_DONE" => return unlanded( + "effect_not_done", + "ledger_ack.state=NOT_DONE: the daemon read the world back and the write did not land", + claims_test_run, + ), + "UNRESOLVED" => { + return unlanded( + "effect_unresolved", + "ledger_ack.state=UNRESOLVED: the daemon could not tell whether the write landed", + claims_test_run, + ) + } + other => return fail("binding_mismatch", format!("ledger_ack.state={other}")), + } eq( st(&ack, "ledger_ack", "content_sha256")?, g("content_sha256")?, @@ -454,3 +477,13 @@ pub fn facts(a: &Archive) -> Result<Facts, Fail> { disk_sha256: st(&ack, "ledger_ack", "disk_sha256")?.to_string(), }) } + +/// An effect the daemon's own ledger does not show as landed. The code names which of the three +/// cases it is. A bundle that also carries a test run is refused as `test_run_on_unlanded_effect` +/// instead: a test cannot certify a write that did not land, and the state is in the detail. +fn unlanded<T>(code: &str, detail: &str, claims_test_run: bool) -> Result<T, Fail> { + if claims_test_run { + return fail("test_run_on_unlanded_effect", format!("{code}: {detail}")); + } + fail(code, detail) +} diff --git a/provenance/src/lib.rs b/provenance/src/lib.rs index cc2a4cf..03d6ecb 100644 --- a/provenance/src/lib.rs +++ b/provenance/src/lib.rs @@ -382,7 +382,14 @@ fn verify_inner(dir: &Path) -> Result<(BTreeSet<String>, Option<EffectLabel>, bo } None => return fail("malformed_companion", "effect.proposal_origin"), }; - ledger::check(&archive, e, t, aien, call.as_ref())?; + ledger::check( + &archive, + e, + t, + aien, + call.as_ref(), + testrun::claims_test_run(&archive, &m), + )?; if origin == modelturn::GENERATED { modelturn::check(&archive, t, call.as_ref())?; } diff --git a/provenance/src/testrun.rs b/provenance/src/testrun.rs index 6e864eb..e97ba41 100644 --- a/provenance/src/testrun.rs +++ b/provenance/src/testrun.rs @@ -44,6 +44,14 @@ pub fn implied_missing(m: &Value) -> BTreeSet<String> { out } +/// True when the bundle carries a test run or the records of one (a task, a source pin). +pub fn claims_test_run(a: &Archive, m: &Value) -> bool { + m.get("test_run").is_some_and(|v| !v.is_null()) + || ["task", "source_pin", "test_run_record"] + .iter() + .any(|n| a.has(n)) +} + fn rec_json(a: &Archive, name: &str, code: &str) -> Result<Value, Fail> { if !a.has(name) { return fail(code, format!("record {name} absent")); diff --git a/provenance/tests/effect_binding.rs b/provenance/tests/effect_binding.rs index bfa4b83..656d84f 100644 --- a/provenance/tests/effect_binding.rs +++ b/provenance/tests/effect_binding.rs @@ -244,7 +244,7 @@ fn altered_intent() { fn altered_ack() { let d = scratch(SYN, "alter_ack"); edit_text(&d, "ledger_ack", |t| t["state"] = json!("NOT_DONE")); - assert_eq!(verify(&d), "FAIL binding_mismatch: ledger_ack.state"); + assert_eq!(verify(&d), "FAIL effect_not_done: ledger_ack.state=NOT_DONE: the daemon read the world back and the write did not land"); let d = scratch(SYN, "alter_ack_disk"); edit_text(&d, "ledger_ack", |t| { t["disk_sha256"] = json!("c".repeat(64)) @@ -287,7 +287,7 @@ fn ledger_record_removed_from_the_manifest() { let mut c = companion(&d); c["records"].as_object_mut().unwrap().remove("ledger_ack"); write_companion(&d, &c); - assert_eq!(verify(&d), "FAIL missing_record_entry: ledger_ack"); + assert_eq!(verify(&d), "FAIL effect_interrupted: ledger_intent is the last record: no ack, the write may or may not have landed"); } // ---------- INTERPLANE call against the ledger ---------- diff --git a/provenance/tests/recovery_verdicts.rs b/provenance/tests/recovery_verdicts.rs new file mode 100644 index 0000000..a3b746a --- /dev/null +++ b/provenance/tests/recovery_verdicts.rs @@ -0,0 +1,139 @@ +//! Recovery outcomes through the verifier (VAC M4d). An effect the daemon's ledger does not show +//! as landed must never verify as the DONE run does, and each of the three cases has its own +//! named refusal. The fixtures are the committed real and synthetic ones, mutated and restamped, +//! so the only difference from the passing bundle is the ack state (or the ack's absence). +//! The mutations are SYNTHETIC: the ack texts are the DONE ack with `state` changed, not an ack +//! the daemon wrote after a real interruption. Specification: provenance/BINDING.md. + +mod common; + +use common::*; +use interplane_provenance::verify; +use serde_json::{json, Value}; +use std::path::Path; + +const REAL: &str = "fixtures/real-waldo-aien-chain"; +const FIX: &str = "fixtures/synthetic-fix-the-test"; +const SYN: &str = "fixtures/synthetic-full-chain"; + +fn set_state(d: &Path, state: &str) { + let p = path_of(d, "ledger_ack"); + let mut v: Value = serde_json::from_slice(&std::fs::read(&p).unwrap()).unwrap(); + let mut t: Value = serde_json::from_str(v["text"].as_str().unwrap()).unwrap(); + t["state"] = json!(state); + v["text"] = json!(t.to_string()); + std::fs::write(&p, serde_json::to_vec_pretty(&v).unwrap()).unwrap(); + restamp(d, "ledger_ack"); +} + +/// Intent with no ack: the ack is neither in the manifest nor on disk. +fn drop_ack(d: &Path) { + let p = path_of(d, "ledger_ack"); + let mut c = companion(d); + c["records"].as_object_mut().unwrap().remove("ledger_ack"); + write_companion(d, &c); + std::fs::remove_file(p).unwrap(); +} + +fn starts(d: &Path, want: &str) -> String { + let v = verify(d); + assert!(v.starts_with(want), "wanted {want}, got {v}"); + v +} + +#[test] +fn real_slice_done_is_pass_complete_and_the_three_unlanded_cases_are_not() { + let done = verify(&scratch(REAL, "m4d-real-done")); + assert!(done.starts_with("PASS complete"), "{done}"); + + let d = scratch(REAL, "m4d-real-notdone"); + set_state(&d, "NOT_DONE"); + let nd = starts(&d, "FAIL effect_not_done:"); + + let d = scratch(REAL, "m4d-real-unresolved"); + set_state(&d, "UNRESOLVED"); + let un = starts(&d, "FAIL effect_unresolved:"); + + let d = scratch(REAL, "m4d-real-noack"); + drop_ack(&d); + let ni = starts(&d, "FAIL effect_interrupted:"); + + // Four different verdicts, none of them a PASS. + let all = [done, nd, un, ni]; + for i in 0..all.len() { + for j in 0..i { + assert_ne!(all[i], all[j]); + } + } +} + +#[test] +fn synthetic_slice_has_the_same_three_refusals() { + let d = scratch(SYN, "m4d-syn-notdone"); + set_state(&d, "NOT_DONE"); + starts(&d, "FAIL effect_not_done:"); + let d = scratch(SYN, "m4d-syn-unresolved"); + set_state(&d, "UNRESOLVED"); + starts(&d, "FAIL effect_unresolved:"); + let d = scratch(SYN, "m4d-syn-noack"); + drop_ack(&d); + starts(&d, "FAIL effect_interrupted:"); +} + +#[test] +fn a_test_run_on_top_of_an_unlanded_effect_is_refused() { + let ok = verify(&scratch(FIX, "m4d-fix-done")); + assert!(ok.starts_with("PASS_LABELLED_INCOMPLETE"), "{ok}"); + for (name, state) in [ + ("nd", Some("NOT_DONE")), + ("un", Some("UNRESOLVED")), + ("ni", None), + ] { + let d = scratch(FIX, &format!("m4d-fix-{name}")); + match state { + Some(s) => set_state(&d, s), + None => drop_ack(&d), + } + let v = verify(&d); + assert!(v.starts_with("FAIL test_run_on_unlanded_effect:"), "{v}"); + let inner = match state { + Some("NOT_DONE") => "effect_not_done", + Some(_) => "effect_unresolved", + None => "effect_interrupted", + }; + assert!(v.contains(inner), "{v}"); + } +} + +#[test] +fn test_records_without_a_section_on_an_unlanded_effect_are_still_refused_as_such() { + let d = scratch(FIX, "m4d-fix-nosection"); + set_state(&d, "NOT_DONE"); + let mut c = companion(&d); + c.as_object_mut().unwrap().remove("test_run"); + write_companion(&d, &c); + starts(&d, "FAIL test_run_on_unlanded_effect:"); +} + +#[test] +fn an_unknown_ack_state_is_still_a_generic_mismatch() { + for s in ["OPEN", "done", "WRITTEN"] { + let d = scratch(REAL, &format!("m4d-real-{s}")); + set_state(&d, s); + let v = verify(&d); + assert_eq!(v, format!("FAIL binding_mismatch: ledger_ack.state={s}")); + } +} + +#[test] +fn an_interrupted_bundle_still_needs_its_earlier_records_to_agree() { + // A forged claim next to a missing ack is reported as the forgery, not as an interruption. + let d = scratch(REAL, "m4d-real-noack-badintent"); + drop_ack(&d); + let p = path_of(&d, "ledger_intent"); + let mut v: Value = serde_json::from_slice(&std::fs::read(&p).unwrap()).unwrap(); + v["verified"] = json!(false); + std::fs::write(&p, serde_json::to_vec_pretty(&v).unwrap()).unwrap(); + restamp(&d, "ledger_intent"); + starts(&d, "FAIL binding_mismatch: ledger_intent.verified"); +}