K24 fix-up: the one-segment speech prompt is a test helper; the frame's tail is built before the prompt; a test's packet binding no longer shadows the helper
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
c7a6d8f2f8
commit
167d171469
2 changed files with 10 additions and 8 deletions
|
|
@ -400,6 +400,7 @@ struct Proposed {
|
|||
promises: Vec<ProposedPromise>,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) fn speech_prompt(packet: &Packet, narration: &str, prose: &str, tuning: &Tuning) -> String {
|
||||
speech_prompt_in(packet, narration, prose, tuning, "", &drafts(prose))
|
||||
}
|
||||
|
|
@ -463,10 +464,11 @@ pub(crate) fn speech_prompt_in(packet: &Packet, narration: &str, prose: &str, tu
|
|||
let reading = if packet.affordances.contains(&Affordance::Read) { format!("{}\n\n", read_frame(her)) } else { String::new() };
|
||||
// Her earlier segments this wake, already decided on: context, never hers to send again.
|
||||
let before = if before.is_empty() { String::new() } else { format!("Earlier in {} moment, already decided on (any draft in it is gone by):\n{before}\n\n", her.poss) };
|
||||
let tail = format!("{reading}{}", speech_frame_tail(her));
|
||||
format!(
|
||||
"{}\n\n{guidance}{}\n\nWho {} {}:\n{}\n\nWhat {} can do here:\n{}.\n\nThe room: {} ({}).\n{conversation}Who is in it, as label \u{2014} Matrix id:\n{people}\nWhat {} know{} privately, none of it to be said here:\n{private}\nLines in this room {} may reply to, as id \u{2014} who: line:\n{quotable}\n{poss} own lines in this room that {} may add to, as id \u{2014} line:\n{amendable}\n{poss} open promises, as id \u{2014} to whom: words:\n{promises}\n{domain}What reached {}:\n{}\n\n{poss} lived moment:\n{}\n\n{before}{poss} prose:\n{prose}\n\n{poss} drafts, by number:\n{numbered}",
|
||||
speech_frame_head(her),
|
||||
format!("{reading}{}", speech_frame_tail(her)),
|
||||
tail,
|
||||
her.subj,
|
||||
her.be,
|
||||
packet.name,
|
||||
|
|
|
|||
|
|
@ -776,21 +776,21 @@ fn asked(packet: &Packet, prose: &str, read: Value) -> Value {
|
|||
#[test]
|
||||
fn k24_a_read_is_what_her_thought_reaches_for_and_nothing_a_model_made_up() {
|
||||
let prose = "I want to see what Nibu actually changed in the knee. And that page at http://example.org/knee too.";
|
||||
let packet = reading_packet();
|
||||
let domain = asked(&packet, prose, json!({ "kind": "domain", "target": "d1", "quote": "I want to see what Nibu actually changed" }));
|
||||
let reading = reading_packet();
|
||||
let domain = asked(&reading, prose, json!({ "kind": "domain", "target": "d1", "quote": "I want to see what Nibu actually changed" }));
|
||||
assert_eq!((domain["read"]["request"].clone(), domain["read"]["what"].as_str()), (json!({ "kind": "repo", "target": "GameCult/Lodur" }), Some("GameCult/Lodur on the forge")), "{domain}");
|
||||
assert_eq!(domain["read"]["quote"], "I want to see what Nibu actually changed");
|
||||
let web = asked(&packet, prose, json!({ "kind": "web", "target": "http://example.org/knee", "quote": "that page at http://example.org/knee too" }));
|
||||
let web = asked(&reading, prose, json!({ "kind": "web", "target": "http://example.org/knee", "quote": "that page at http://example.org/knee too" }));
|
||||
assert_eq!(web["read"]["request"], json!({ "kind": "web", "target": "http://example.org/knee" }), "{web}");
|
||||
let invented = asked(&packet, prose, json!({ "kind": "web", "target": "http://evil.example/x", "quote": "I want to see what Nibu actually changed" }));
|
||||
let invented = asked(&reading, prose, json!({ "kind": "web", "target": "http://evil.example/x", "quote": "I want to see what Nibu actually changed" }));
|
||||
assert_eq!((invented["read"].clone(), invented["read_refused"][0]["why"].as_str()), (Value::Null, Some("web_address_not_in_front_of_her")), "{invented}");
|
||||
let unquoted = asked(&packet, prose, json!({ "kind": "domain", "target": "d1", "quote": "she should read the repo" }));
|
||||
let unquoted = asked(&reading, prose, json!({ "kind": "domain", "target": "d1", "quote": "she should read the repo" }));
|
||||
assert_eq!(unquoted["read_refused"][0]["why"], "quote_not_in_her_thought");
|
||||
let not_ours = asked(&packet, prose, json!({ "kind": "repo", "target": "Elsewhere/Lodur", "quote": "I want to see what Nibu actually changed" }));
|
||||
let not_ours = asked(&reading, prose, json!({ "kind": "repo", "target": "Elsewhere/Lodur", "quote": "I want to see what Nibu actually changed" }));
|
||||
assert_eq!(not_ours["read_refused"][0]["why"], "not_a_gamecult_repo");
|
||||
let cannot = asked(&packet(), prose, json!({ "kind": "domain", "target": "d1", "quote": "I want to see what Nibu actually changed" }));
|
||||
assert_eq!(cannot["read_refused"][0]["why"], "no_read_here", "{cannot}");
|
||||
let prompt = speech_prompt(&packet, "x", prose, &Tuning::default());
|
||||
let prompt = speech_prompt(&reading, "x", prose, &Tuning::default());
|
||||
assert!(prompt.contains("`read` names one thing he reaches for") && !speech_prompt(&packet(), "x", prose, &Tuning::default()).contains("`read` names"), "the read contract only on a turn that can read");
|
||||
assert!(SPEECH_SCHEMA.contains(r#""required":["say","gaps","amend","suggest","state","read"]"#));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue