From 9eae3af581fc99815f3ef0e8021c0952cad5c12e Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 21 Nov 2026 00:05:29 +0100 Subject: [PATCH] K24: the usage totals count every call of a reading wake: each continuation and each earlier Interpreter call carries its usage Co-Authored-By: Claude Opus 5.5 --- crates/mind-body/src/projection.rs | 9 +++++---- crates/mind-body/src/projection/harness/tests.rs | 14 ++++++++++++++ crates/mind-body/src/projection/interpret.rs | 6 ++++++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/crates/mind-body/src/projection.rs b/crates/mind-body/src/projection.rs index e2ba696..427fcee 100644 --- a/crates/mind-body/src/projection.rs +++ b/crates/mind-body/src/projection.rs @@ -413,7 +413,8 @@ fn narrate_one(model: &dyn Model, instance: &str, packet: &Packet, tuning: &tuni } }; let mut prose = cap_words(&first.answer.text, tuning.persona.words); - let mut usage = vec![json!(first.answer.usage)]; + // Each continuation's call, its usage under `usage` so the report's totals count it (Soul: 72 of 76 calls counted). + let mut continuations: Vec = Vec::new(); render["persona"] = json!({ "words": words(&prose), "cut_at_budget": words(&first.answer.text) > tuning.persona.words, "usage": first.answer.usage, "prose": prose }); if through != Through::Interpreter { return render; @@ -465,7 +466,7 @@ fn narrate_one(model: &dyn Model, instance: &str, packet: &Packet, tuning: &tuni }; let segment = cap_words(&continued.answer.text, tuning.persona.words); cut = words(&continued.answer.text) > tuning.persona.words; - usage.push(json!(continued.answer.usage)); + continuations.push(json!({ "usage": continued.answer.usage, "words": words(&segment), "cut_at_budget": cut })); turns.push(Turn::Assistant { text: segment.clone(), states: continued.states }); before = format!("{before}{}\n\n{bridge}\n\n", &prose[from..]); prose = format!("{prose}\n\n{segment}"); @@ -501,8 +502,8 @@ fn narrate_one(model: &dyn Model, instance: &str, packet: &Packet, tuning: &tuni } render["persona"]["prose"] = json!(prose); render["persona"]["words"] = json!(words(&prose)); - render["persona"]["segments"] = json!(usage.len()); - render["persona"]["usage_by_segment"] = json!(usage); + render["persona"]["segments"] = json!(1 + continuations.len()); + render["persona"]["continuations"] = json!(continuations); render["interpreter"] = decision; render } diff --git a/crates/mind-body/src/projection/harness/tests.rs b/crates/mind-body/src/projection/harness/tests.rs index 1fb00ee..03baa50 100644 --- a/crates/mind-body/src/projection/harness/tests.rs +++ b/crates/mind-body/src/projection/harness/tests.rs @@ -507,3 +507,17 @@ fn k24_the_reply_after_a_read_gets_her_whole_budget_and_a_cut_draft_is_not_hers( let told = crate::projection::outcome::outcome_of(&json!({ "interpreter": decision, "posted": [] })).unwrap().lines(crate::projection::select::forms(&control())); assert!(!told.iter().any(|line| line.contains("finished writing")), "{told:?}"); } + +/// Soul at F.1 (72 calls reported, 76 made): every call of a reading wake is in the usage totals, the continuations and +/// the earlier Interpreter calls too. +#[test] +fn k24_every_call_of_a_reading_wake_is_counted() { + let fixture = reading_room("quiet-beat.toml"); + let model = Scripted::new(|prompt| if prompt.contains("LOOP-READ") { "So the knee goes first.".into() } else { "I want to see what changed in GameCult/Lodur#12.".into() }).interpreting(|prompt| { + let read = if prompt.contains("Earlier in his moment") { Value::Null } else { json!({ "kind": "repo", "target": "GameCult/Lodur#12", "quote": "I want to see what changed" }) }; + json!({ "say": [], "gaps": [], "read": read }).to_string() + }); + let report = wake_of(&fixture, &model); + let counted: u64 = usage_total(std::slice::from_ref(&report)).values().map(|row| row["calls"]).sum(); + assert_eq!((counted, model.calls.borrow().len()), (5, 5), "projector, persona, interpreter, continuation, interpreter"); +} diff --git a/crates/mind-body/src/projection/interpret.rs b/crates/mind-body/src/projection/interpret.rs index f64ab70..e249bde 100644 --- a/crates/mind-body/src/projection/interpret.rs +++ b/crates/mind-body/src/projection/interpret.rs @@ -534,6 +534,12 @@ pub(crate) fn decide_in(model: &dyn Model, request_id: &str, packet: &Packet, na if let Some(reads) = wake.earlier.map(|earlier| earlier["reads"].clone()).filter(Value::is_array) { decision["reads"] = reads; } + // The earlier calls of this wake, each with its usage, so the report's totals count every call (Soul: 72 of 76). + if let Some(before) = wake.earlier { + let mut calls = before["earlier_calls"].as_array().cloned().unwrap_or_default(); + calls.push(json!({ "usage": before["usage"] })); + decision["earlier_calls"] = json!(calls); + } if let Some(open) = found.unfinished { decision["unfinished"] = json!(prose[open + DRAFT_OPEN.len()..].trim()); }