From 714c2c8701d22ced2ff5ae881b9c690f7048d2d5 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 21 Nov 2026 01:45:25 +0100 Subject: [PATCH] K27/K28 fix-up: promise_block reads her commitments without creating the field; a reaffirmation of a closed promise is refused as closed before any outside-put check Co-Authored-By: Claude Opus 5.5 --- crates/mind-body/src/projection/commit.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/mind-body/src/projection/commit.rs b/crates/mind-body/src/projection/commit.rs index d956964..bf5ce57 100644 --- a/crates/mind-body/src/projection/commit.rs +++ b/crates/mind-body/src/projection/commit.rs @@ -286,7 +286,7 @@ pub(crate) fn apply(state: &Value, record: &Value, prose: &str, key: &str, now: fn block_on_failed_reads(state: &mut Value, record: &Value, applied: &mut Applied) { let repo_of = |target: &str| target.split(['#', '?', '/', '@']).take(2).collect::>().join("/"); let failed: Vec<&Value> = record["interpreter"]["reads"].as_array().into_iter().flatten().filter(|read| read["ok"] == false && read["failure"] == "not_found").collect(); - for entry in state["commitments"].as_array_mut().into_iter().flatten().filter(|entry| entry["status"] == "open") { + for entry in state.get_mut("commitments").and_then(Value::as_array_mut).into_iter().flatten().filter(|entry| entry["status"] == "open") { let Some(needs) = entry["needs"].as_str().map(str::to_owned) else { continue }; let Some(read) = failed.iter().find(|read| { let target = read["request"]["target"].as_str().unwrap_or_default(); @@ -325,12 +325,12 @@ fn apply_one(state: &mut Value, proposal: &Proposal, record: &Value, prose: &str let listed = record["interpreter"]["promises"].as_array().into_iter().flatten().find(|shown| shown["id"].as_str() == Some(id.trim())).ok_or(Refusal::NoSuchPromise)?; let entries = state["commitments"].as_array_mut().expect("commitments is an array"); let entry = entries.iter_mut().find(|entry| entry["id"] == listed["entry"]).ok_or(Refusal::OutsidePutRemovedTarget)?; - if listed["held"] != *entry { - return Err(Refusal::OutsidePutChanged); - } if !matches!(entry["status"].as_str(), Some("open" | "blocked")) { return Err(Refusal::ReaffirmsClosed); } + if listed["held"] != *entry { + return Err(Refusal::OutsidePutChanged); + } if entry["to"] != json!(to) { return Err(Refusal::ReaffirmsAnother); }