Persona K45: held words are held, whatever names them; a hold carries what it held; a Held refusal is always told (map 16.30.2)
decide_in builds the held texts before the act loops (held_texts): each say or amend whose named holds hold it, and the carries of each open hold listed. A say or amend into a covered room whose text repeats one (equal, or echo's measure against it alone) is refused Held whatever it names; naming adds and never clears. The refusal's hold names its handle beside who. The commit appends each Held refusal's draft to its hold's carries (dedup, at most 4, clipped), and reports a handle no hold answers as held_unrecorded. Her view shows each hold's carries. settle tells a held draft a receipt shows in a covered room as HoldBroken and reports it; a Held refusal is never omitted, and same-text rows are told once. Schema: hold gains optional carries; the holds and hold descriptions lose the prose release K39 deleted. Tests: Soul's P1 inverted; Kiko's turn-2 ask held by carries; another room, a release, a short mention, an amend; the broken-hold row replaces 6cd2128's pin; her view. R13 X.1 r1's ready line repeats the held draft and is now held too (pinned). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
777124510a
commit
5dbc4fc3be
8 changed files with 329 additions and 51 deletions
|
|
@ -35,6 +35,10 @@ use super::read::{ReadRequest, answers, repo_name};
|
|||
pub(crate) const CLOSED_KEPT_DAYS: i64 = 7;
|
||||
/// How many reaffirmations, and how many reopenings, an entry keeps: the newest.
|
||||
const REAFFIRMED_KEPT: usize = 3;
|
||||
/// The most of her own held drafts a hold carries (K45): the oldest drop.
|
||||
const CARRIES_KEPT: usize = 4;
|
||||
/// The most bytes of one held draft a hold carries (K45).
|
||||
const CARRY_BYTES: usize = 1200;
|
||||
/// The fewest words a passage of her prose cited as evidence may be (section 4.1's `source_quote`).
|
||||
pub(crate) const PROSE_MIN_WORDS: usize = 4;
|
||||
|
||||
|
|
@ -361,6 +365,8 @@ pub(crate) struct Applied {
|
|||
/// The holds opened (`hold_open`, map 16.28.5), and the holds released (`hold_release`), as they now stand.
|
||||
pub held: Vec<Value>,
|
||||
pub unheld: Vec<Value>,
|
||||
/// The `Held` refusals whose hold no hold of hers answers (K45): their words are carried nowhere.
|
||||
pub held_unrecorded: Vec<Value>,
|
||||
}
|
||||
|
||||
/// The one applier: her state with one turn's proposals applied, as deltas to `state` as it stands at commit, and what
|
||||
|
|
@ -412,11 +418,45 @@ pub(crate) fn apply(state: &Value, record: &Value, prose: &str, key: &str, now:
|
|||
applied.refused.push(json!({ "proposal": raw, "reason": reason }));
|
||||
}
|
||||
}
|
||||
carry_held(&mut state, record, &mut applied);
|
||||
block_on_failed_reads(&mut state, record, &mut applied);
|
||||
receive_reads(&mut state, record, key, now, &mut applied);
|
||||
(state, applied)
|
||||
}
|
||||
|
||||
/// Each `Held` refusal's draft, carried by its hold (map 16.30.2, K45), after the holds this apply opened: the hold's
|
||||
/// handle is a hold listed to the Interpreter (`h1`), or the line an open hold opened from (`q3`). Duplicates are
|
||||
/// skipped, at most `CARRIES_KEPT` are kept (the oldest drop), and each is held to `CARRY_BYTES`. A handle no open hold
|
||||
/// answers carries nothing, and is reported. The decision proposes and the commit writes.
|
||||
fn carry_held(state: &mut Value, record: &Value, applied: &mut Applied) {
|
||||
let decision = &record["interpreter"];
|
||||
for refusal in decision["refused"].as_array().into_iter().flatten().filter(|refusal| refusal["reason"] == "held") {
|
||||
let (Some(text), Some(handle)) = (refusal["text"].as_str(), refusal["hold"]["id"].as_str()) else {
|
||||
applied.held_unrecorded.push(refusal.clone());
|
||||
continue;
|
||||
};
|
||||
let listed = decision["holds"].as_array().into_iter().flatten().find(|listed| listed["id"].as_str() == Some(handle)).map(|listed| listed["entry"].clone());
|
||||
let line = decision["lines"].as_array().into_iter().flatten().find(|line| line["id"].as_str() == Some(handle)).map(|line| line["event"].clone());
|
||||
let hold = state["holds"].as_array_mut().into_iter().flatten().find(|hold| {
|
||||
hold["status"] == "open" && (listed.as_ref().is_some_and(|entry| hold["id"] == *entry) || line.as_ref().is_some_and(|event| hold["event"] == *event))
|
||||
});
|
||||
let Some(hold) = hold else {
|
||||
applied.held_unrecorded.push(refusal.clone());
|
||||
continue;
|
||||
};
|
||||
let text = super::select::clip(text, CARRY_BYTES);
|
||||
if !hold["carries"].is_array() {
|
||||
hold["carries"] = json!([]);
|
||||
}
|
||||
let carries = hold["carries"].as_array_mut().expect("carries is an array");
|
||||
if !carries.iter().any(|carried| carried.as_str() == Some(text.as_str())) {
|
||||
carries.push(json!(text));
|
||||
let over = carries.len().saturating_sub(CARRIES_KEPT);
|
||||
carries.drain(..over);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The fields of a receipt on an entry.
|
||||
const RECEIPT: [&str; 3] = ["readAt", "readId", "readOf"];
|
||||
|
||||
|
|
|
|||
|
|
@ -807,6 +807,10 @@ pub(crate) fn decide_in(model: &dyn Model, request_id: &str, packet: &Packet, na
|
|||
.filter_map(|hold| packet.quotable.iter().find(|line| line.id == hold.line.trim()).map(|line| (line.id.clone(), (hold.place == Where::Here).then(|| line.room.clone()))))
|
||||
.collect();
|
||||
let holding = |named: &[String], into: &str| held_by(named, into, packet, &opening);
|
||||
// Code's words gate (map 16.30.2, K45), before the act loops: what this decision holds, by its words. Naming a hold
|
||||
// adds to it and never clears it.
|
||||
let held = held_texts(&parsed, packet, &opening, &found);
|
||||
let gate = |named: &[String], into: &str, text: &str| holding(named, into).or_else(|| repeats_held(text, into, &held));
|
||||
for line in parsed.say {
|
||||
let Some(draft) = line.draft.and_then(|n| found.numbered(n)) else {
|
||||
refusals.push(refused(Act::Say, None, line.draft, Refusal::NoDraft));
|
||||
|
|
@ -816,6 +820,7 @@ pub(crate) fn decide_in(model: &dyn Model, request_id: &str, packet: &Packet, na
|
|||
// reply to a line she was not shown, nor as no reply when she meant one.
|
||||
let cited = line.in_reply_to.as_deref().map(str::trim).filter(|id| !id.is_empty());
|
||||
let target = cited.and_then(|id| packet.quotable.iter().find(|quotable| quotable.id == id));
|
||||
let hold = room.as_deref().and_then(|into| gate(&line.holds, into, &draft.text));
|
||||
let reason = if room.is_none() {
|
||||
Some(Refusal::NoRoom)
|
||||
} else if used.contains(&draft.n) {
|
||||
|
|
@ -826,7 +831,7 @@ pub(crate) fn decide_in(model: &dyn Model, request_id: &str, packet: &Packet, na
|
|||
Some(Refusal::NotQuotable)
|
||||
} else if echo(&draft.text, &bodies) {
|
||||
Some(Refusal::Echo)
|
||||
} else if room.as_deref().and_then(|into| holding(&line.holds, into)).is_some() {
|
||||
} else if hold.is_some() {
|
||||
Some(Refusal::Held)
|
||||
} else if said.len() >= MAX_LINES {
|
||||
Some(Refusal::OverLines)
|
||||
|
|
@ -836,7 +841,7 @@ pub(crate) fn decide_in(model: &dyn Model, request_id: &str, packet: &Packet, na
|
|||
if let Some(reason) = reason {
|
||||
let mut refusal = refused(Act::Say, Some(draft), None, reason);
|
||||
if reason == Refusal::Held {
|
||||
refusal["hold"] = room.as_deref().and_then(|into| holding(&line.holds, into)).unwrap_or_default();
|
||||
refusal["hold"] = hold.unwrap_or_default();
|
||||
}
|
||||
refusals.push(refusal);
|
||||
continue;
|
||||
|
|
@ -859,7 +864,7 @@ pub(crate) fn decide_in(model: &dyn Model, request_id: &str, packet: &Packet, na
|
|||
};
|
||||
let target = proposed.target.as_deref().and_then(|id| packet.amendable.iter().find(|line| line.id == id.trim()));
|
||||
// An addition goes where its line is.
|
||||
let hold = target.map(|line| line.room.as_str()).or(room.as_deref()).and_then(|into| holding(&proposed.holds, into));
|
||||
let hold = target.map(|line| line.room.as_str()).or(room.as_deref()).and_then(|into| gate(&proposed.holds, into, &draft.text));
|
||||
let reason = if used.contains(&draft.n) {
|
||||
Some(Refusal::Used)
|
||||
} else if echo(&draft.text, &bodies) {
|
||||
|
|
@ -1172,24 +1177,70 @@ fn close_of(raw: &Value) -> Option<Proposal> {
|
|||
Some(Proposal::PromiseClose { promise, how, evidence, thought, still_stands: raw["still_stands"] == true })
|
||||
}
|
||||
|
||||
/// A hold a draft names, resolved: its handle (the listed hold's id, `h1`, or the line this answer opens it from, `q3`),
|
||||
/// as the refusal names it (`{who, id}`), and the room it covers (None for anywhere). An id that resolves to no hold
|
||||
/// covers anywhere (fails closed, behind `hold_faults`), told by whose line it names.
|
||||
fn hold_named(id: &str, packet: &Packet, opening: &[(String, Option<String>)]) -> (Value, Option<String>) {
|
||||
if let Some(hold) = packet.holds.iter().find(|hold| hold.id == id) {
|
||||
return (json!({ "who": hold.from_name, "id": id }), hold.room.clone());
|
||||
}
|
||||
let who = packet.quotable.iter().find(|line| line.id == id).map(|line| line.who.as_str());
|
||||
let covers = opening.iter().find(|(line_id, _)| line_id == id).and_then(|(_, covers)| covers.clone());
|
||||
(json!({ "who": who, "id": id }), covers)
|
||||
}
|
||||
|
||||
/// The hold a draft going into `into` is held by (map 16.28.5), as the outcome tells it (who asked), when one is: each id
|
||||
/// it names resolves to a hold listed (`h1`) or one this answer opens from a line (`q3`), and the first that covers `into`
|
||||
/// (anywhere, or that room) holds it. Code owns where; whether the draft carries the held thing is the Interpreter's. The
|
||||
/// asker's words stay in her view and the Interpreter's list, never in a refusal her outcome is told from (map 16.29.3).
|
||||
/// An id that resolves to no hold holds the draft too (fails closed, behind `hold_faults`), told by whose line it names.
|
||||
/// it names resolves to a hold (`hold_named`), and the first that covers `into` (anywhere, or that room) holds it. Code
|
||||
/// owns where. The asker's words stay in her view and the Interpreter's list, never in a refusal her outcome is told from
|
||||
/// (map 16.29.3). Naming is an addition to code's words gate (`repeats_held`, K45): a paraphrase only the Interpreter can
|
||||
/// recognise is held by naming, and naming never clears a draft the words gate holds.
|
||||
fn held_by(named: &[String], into: &str, packet: &Packet, opening: &[(String, Option<String>)]) -> Option<Value> {
|
||||
named.iter().map(|id| id.trim()).find_map(|id| {
|
||||
if let Some(hold) = packet.holds.iter().find(|hold| hold.id == id) {
|
||||
return hold.room.as_deref().is_none_or(|room| room == into).then(|| json!({ "who": hold.from_name }));
|
||||
}
|
||||
let line = packet.quotable.iter().find(|line| line.id == id);
|
||||
match opening.iter().find(|(line_id, _)| line_id == id) {
|
||||
Some((_, covers)) => covers.as_deref().is_none_or(|room| room == into).then(|| json!({ "who": line.map(|line| line.who.as_str()) })),
|
||||
None => Some(json!({ "who": line.map(|line| line.who.as_str()) })),
|
||||
}
|
||||
let (hold, covers) = hold_named(id, packet, opening);
|
||||
covers.as_deref().is_none_or(|room| room == into).then_some(hold)
|
||||
})
|
||||
}
|
||||
|
||||
/// A text this decision holds (K45): its hold, as a refusal names it, the room it covers (None for anywhere), and the
|
||||
/// text.
|
||||
struct HeldText {
|
||||
hold: Value,
|
||||
covers: Option<String>,
|
||||
text: String,
|
||||
}
|
||||
|
||||
/// The held texts of one decision (map 16.30.2, K45), built before the act loops: the text of each say or amend whose
|
||||
/// draft resolves and whose named `holds` hold it where it goes (`held_by`), and the `carries` of each open hold listed.
|
||||
fn held_texts(answer: &Answer, packet: &Packet, opening: &[(String, Option<String>)], found: &Drafts) -> Vec<HeldText> {
|
||||
let mut held: Vec<HeldText> = Vec::new();
|
||||
let says = answer.say.iter().map(|line| (line.draft, &line.holds, packet.room.as_deref()));
|
||||
let amends = answer.amend.iter().map(|amend| {
|
||||
let target = amend.target.as_deref().and_then(|id| packet.amendable.iter().find(|line| line.id == id.trim()));
|
||||
(amend.draft, &amend.holds, target.map(|line| line.room.as_str()).or(packet.room.as_deref()))
|
||||
});
|
||||
for (draft, named, into) in says.chain(amends) {
|
||||
let (Some(draft), Some(into)) = (draft.and_then(|n| found.numbered(n)), into) else { continue };
|
||||
let covering = named.iter().map(|id| hold_named(id.trim(), packet, opening)).find(|(_, covers)| covers.as_deref().is_none_or(|room| room == into));
|
||||
if let Some((hold, covers)) = covering {
|
||||
held.push(HeldText { hold, covers, text: draft.text.clone() });
|
||||
}
|
||||
}
|
||||
for hold in &packet.holds {
|
||||
for carried in &hold.carries {
|
||||
held.push(HeldText { hold: json!({ "who": hold.from_name, "id": hold.id }), covers: hold.room.clone(), text: carried.clone() });
|
||||
}
|
||||
}
|
||||
held
|
||||
}
|
||||
|
||||
/// The hold whose held text a draft going into `into` repeats (K45): a held text whose hold covers `into`, said again
|
||||
/// exactly, or by `echo`'s measure against it alone, so a short held line is held only when it is repeated exactly.
|
||||
fn repeats_held(text: &str, into: &str, held: &[HeldText]) -> Option<Value> {
|
||||
held.iter()
|
||||
.find(|held| held.covers.as_deref().is_none_or(|room| room == into) && (text == held.text || echo(text, std::slice::from_ref(&held.text))))
|
||||
.map(|held| held.hold.clone())
|
||||
}
|
||||
|
||||
/// The holds an answer names and does not open (map 16.29.3), a contract fault found before anything is decided: a `hold`
|
||||
/// whose line is not listed, or whose `words` (at least `PROSE_MIN_WORDS`) do not stand in that line; and a `holds` name
|
||||
/// that is neither a hold listed nor a line this answer opens a hold from. By the line or name, once each. So every line a
|
||||
|
|
|
|||
|
|
@ -1574,7 +1574,8 @@ pub(crate) fn meta_holds_here() -> Value {
|
|||
#[test]
|
||||
fn k37_x1_r1_held_draft_is_not_said() {
|
||||
let decision = x1_r1(json!([say_holding(1, json!(["q3"])), say_holding(2, json!([]))]), meta_holds_here());
|
||||
assert_eq!(texts(&decision), vec!["Meta, the draft is ready, and I'm holding it".to_owned()], "{decision}");
|
||||
// K45: draft 2 repeats draft 1's opening, so code's words gate holds it too (`k45_x1_r1_the_ready_line_repeats_the_held_draft_and_is_held`).
|
||||
assert!(texts(&decision).is_empty(), "{decision}");
|
||||
let refused = &decision["refused"][0];
|
||||
assert_eq!((refused["reason"].as_str(), refused["draft"].as_u64(), refused["hold"]["who"].as_str()), (Some("held"), Some(1), Some("Meta")), "{decision}");
|
||||
assert_eq!(decision["state"], json!([{ "kind": "hold_open", "words": "hold it, don't post it in here yet", "where": "here", "evidence": { "heard": "q3" } }]), "{decision}");
|
||||
|
|
@ -1602,7 +1603,8 @@ fn k39_named_line_without_a_hold_is_retried() {
|
|||
let model = answering(vec![json!({ "say": [say_holding(1, json!([named])), say_holding(2, json!([]))], "gaps": [], "hold": [] }).to_string()]);
|
||||
let decision = decide(&model, "test", &x1_packet(), "The room is warm.", X1_LIBBY_R1, &Tuning::default());
|
||||
assert_eq!((decision.get("failed"), decision["retried"]["holds"].clone(), decision["hold_faults"].clone()), (None, json!([named]), json!([named])), "{named}: {decision}");
|
||||
assert_eq!((texts(&decision), decision["refused"][0]["reason"].as_str(), decision["refused"][0]["draft"].as_u64()), (vec!["Meta, the draft is ready, and I'm holding it".to_owned()], Some("held"), Some(1)), "{named}: {decision}");
|
||||
// K45: draft 2 repeats draft 1, which the fault holds, so it is held by its words, for the same name.
|
||||
assert_eq!((texts(&decision), decision["refused"][0]["reason"].as_str(), decision["refused"][0]["draft"].as_u64(), decision["refused"][1]["hold"]["id"].as_str()), (Vec::<String>::new(), Some("held"), Some(1), Some(named)), "{named}: {decision}");
|
||||
let prompts = speech_prompts(&model);
|
||||
assert!(prompts.len() == 2 && prompts[1].contains(&format!("named holds it did not open from a listed line's own words: {named}.")), "{named}: {prompts:?}");
|
||||
}
|
||||
|
|
@ -1612,18 +1614,19 @@ fn k39_named_line_without_a_hold_is_retried() {
|
|||
/// addition goes where its line is.
|
||||
#[test]
|
||||
fn k37_a_here_hold_covers_only_its_room() {
|
||||
let hold = |room: Option<&str>| crate::projection::select::Hold { id: "h1".into(), entry: "h-1".into(), from: "@meta:gamecult.org".into(), from_name: "Meta".into(), room: room.map(str::to_owned), made: now(), words: "hold it, don't post it in here yet".into(), held: json!({}) };
|
||||
let hold = |room: Option<&str>| crate::projection::select::Hold { id: "h1".into(), entry: "h-1".into(), from: "@meta:gamecult.org".into(), from_name: "Meta".into(), room: room.map(str::to_owned), made: now(), words: "hold it, don't post it in here yet".into(), carries: Vec::new(), held: json!({}) };
|
||||
let mut direct = x1_packet();
|
||||
direct.room = Some("!dm:gamecult.org".into());
|
||||
direct.room_kind = RoomKind::Direct;
|
||||
direct.holds = vec![hold(Some(MINDS))];
|
||||
let said = |packet: &Packet| texts(&answered(packet, X1_LIBBY_R1, json!({ "say": [say_holding(1, json!(["h1"])), say_holding(2, json!([]))], "gaps": [] }))).len();
|
||||
assert_eq!(said(&direct), 2, "a here hold on #minds does not cover a direct message");
|
||||
// K45: draft 2 repeats draft 1, so where draft 1 is held, so is draft 2.
|
||||
direct.holds = vec![hold(None)];
|
||||
assert_eq!(said(&direct), 1, "an anywhere hold covers every room");
|
||||
assert_eq!(said(&direct), 0, "an anywhere hold covers every room");
|
||||
let mut minds = x1_packet();
|
||||
minds.holds = vec![hold(Some(MINDS))];
|
||||
assert_eq!(said(&minds), 1);
|
||||
assert_eq!(said(&minds), 0);
|
||||
minds.amendable = vec![Amendable { id: "a1".into(), event: "$a1".into(), room: MINDS.into(), text: "Back soon.".into() }];
|
||||
let amend = answered(&minds, X1_LIBBY_R1, json!({ "say": [say_holding(2, json!([]))], "gaps": [], "amend": [{ "target": "a1", "draft": 1, "holds": ["h1"], "promises": [] }] }));
|
||||
assert_eq!((amend["amended"].as_array().map(Vec::len), amend["refused"][0]["reason"].as_str()), (Some(0), Some("held")), "{amend}");
|
||||
|
|
@ -1633,7 +1636,7 @@ fn k37_a_here_hold_covers_only_its_room() {
|
|||
#[test]
|
||||
fn k37_the_interpreter_sees_holds_by_id() {
|
||||
let mut packet = x1_packet();
|
||||
packet.holds = vec![crate::projection::select::Hold { id: "h1".into(), entry: "h-1".into(), from: "@meta:gamecult.org".into(), from_name: "Meta".into(), room: Some(MINDS.into()), made: now(), words: "hold it, don't post it in here yet".into(), held: json!({}) }];
|
||||
packet.holds = vec![crate::projection::select::Hold { id: "h1".into(), entry: "h-1".into(), from: "@meta:gamecult.org".into(), from_name: "Meta".into(), room: Some(MINDS.into()), made: now(), words: "hold it, don't post it in here yet".into(), carries: Vec::new(), held: json!({}) }];
|
||||
let prompt = speech_prompt(&packet, "x", X1_LIBBY_R1, &Tuning::default());
|
||||
assert!(prompt.contains("Holds:\n- h1 \u{2014} held for Meta, asked 2026-11-20 15:05 UTC in #minds:gamecult.org: \"hold it, don't post it in here yet\". Not to go in #minds:gamecult.org until Meta lets it go.\n"), "{prompt}");
|
||||
assert!(prompt.contains("`hold` opens a hold when a line listed below asks him not to post or share something somewhere yet") && prompt.contains("`holds`, on each line and addition, names every hold listed below") && prompt.contains("`hold_released` closes a hold listed below"), "{prompt}");
|
||||
|
|
@ -1721,7 +1724,7 @@ fn k38_a_thought_only_reach_accounts_for_no_draft() {
|
|||
/// Meta's r1 hold on #minds as her state holds it (asked ten minutes ago), and as the packet lists it, `h1`.
|
||||
fn meta_hold() -> (Value, crate::projection::select::Hold) {
|
||||
let held = json!({ "id": "h-r1-t3-1", "from": "@meta:gamecult.org", "room": MINDS, "event": "$q3", "madeAt": (now() - chrono::Duration::minutes(10)).to_rfc3339(), "words": "hold it, don't post it in here yet", "status": "open", "releasedAt": null, "releasedBy": null });
|
||||
let listed = crate::projection::select::Hold { id: "h1".into(), entry: "h-r1-t3-1".into(), from: "@meta:gamecult.org".into(), from_name: "Meta".into(), room: Some(MINDS.into()), made: now() - chrono::Duration::minutes(10), words: "hold it, don't post it in here yet".into(), held: held.clone() };
|
||||
let listed = crate::projection::select::Hold { id: "h1".into(), entry: "h-r1-t3-1".into(), from: "@meta:gamecult.org".into(), from_name: "Meta".into(), room: Some(MINDS.into()), made: now() - chrono::Duration::minutes(10), words: "hold it, don't post it in here yet".into(), carries: Vec::new(), held: held.clone() };
|
||||
(json!({ "holds": [held] }), listed)
|
||||
}
|
||||
|
||||
|
|
@ -1893,7 +1896,8 @@ fn k44_an_unlocated_hold_holds_only_the_drafts_naming_it() {
|
|||
let decision = decide(&model, "test", &packet, "The room is warm.", X1_LIBBY_R1, &Tuning::default());
|
||||
assert_eq!((decision.get("failed"), decision["retried"]["holds"].clone(), decision["hold_faults"].clone()), (None, json!(["q3"]), json!(["q3"])), "{decision}");
|
||||
assert_eq!(speech_prompts(&model).len(), 2);
|
||||
assert_eq!((texts(&decision), decision["refused"][0]["reason"].as_str(), decision["refused"][0]["draft"].as_u64()), (vec!["Meta, the draft is ready, and I'm holding it".to_owned()], Some("held"), Some(1)), "{decision}");
|
||||
// K45: draft 2 repeats draft 1, so it is held by its words.
|
||||
assert_eq!((texts(&decision), decision["refused"][0]["reason"].as_str(), decision["refused"][0]["draft"].as_u64(), decision["refused"][1]["draft"].as_u64()), (Vec::<String>::new(), Some("held"), Some(1), Some(2)), "{decision}");
|
||||
}
|
||||
|
||||
/// Mutant k39-faults-no-word-floor: a hold whose words stand in the line but are fewer than four is a fault.
|
||||
|
|
@ -1927,20 +1931,119 @@ fn k44_a_decline_quoting_her_draft_accounts_for_nothing() {
|
|||
assert_eq!((decision["retried"]["drafts"].clone(), decision["unsent"][0]["quote"].as_str()), (json!([1]), Some("I'll keep this back for now")), "{decision}");
|
||||
}
|
||||
|
||||
/// Two drafts in the same words: the first names Meta's hold and is refused `Held`, the second names none and is said.
|
||||
/// The receipt shows those words reached #minds, so no row tells her nothing of them did (I16.10); the refusal is
|
||||
/// reported.
|
||||
#[test]
|
||||
fn k44_a_refusal_of_words_a_receipt_shows_is_not_told_as_unsent() {
|
||||
let prose = "Meta asked first. <typed>Meta, the draft is ready, and I'm holding it</typed> <typed>Meta, the draft is ready, and I'm holding it</typed>";
|
||||
let decision = answered(&x1_packet(), prose, json!({ "say": [say_holding(1, json!(["q3"])), say_holding(2, json!([]))], "gaps": [], "hold": meta_holds_here() }));
|
||||
assert_eq!((decision["refused"][0]["reason"].as_str(), texts(&decision)), (Some("held"), vec!["Meta, the draft is ready, and I'm holding it".to_owned()]), "{decision}");
|
||||
let posted: Vec<Value> = decision["said"].as_array().unwrap().iter().map(|line| json!({ "event": "9", "room": line["room"], "text": line["text"] })).collect();
|
||||
let outcome = crate::projection::outcome::outcome_of(&json!({ "interpreter": decision, "posted": posted, "edited": [] })).unwrap();
|
||||
let told = outcome.lines(x1_packet().forms);
|
||||
assert!(!told.iter().any(|line| line.starts_with("- Nothing of this reached")), "{told:?}");
|
||||
assert!(outcome.omitted.iter().any(|why| why.starts_with("a held draft of words a receipt shows reached #minds:gamecult.org")), "{:?}", outcome.omitted);
|
||||
// Negative: with no receipt, the hold is told as before.
|
||||
let unposted = crate::projection::outcome::outcome_of(&json!({ "interpreter": decision, "posted": [], "edited": [] })).unwrap().lines(x1_packet().forms);
|
||||
assert!(unposted.iter().any(|line| line == "- Nothing of this reached #minds:gamecult.org: Meta asked him to hold it, and it was not sent."), "{unposted:?}");
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// K45 (map 16.30.2): held words are held, whatever names them. Code's words gate holds a draft that repeats a text this
|
||||
// decision holds by naming, or one an open hold carries; naming adds to it and never clears it.
|
||||
|
||||
const K45_WELCOME: &str = "Hello, and welcome, we're glad you're here. Poke at whatever you're curious about first.";
|
||||
|
||||
/// Meta's #minds hold, listed as h1, carrying `carries`.
|
||||
fn meta_hold_carrying(carries: &[&str]) -> crate::projection::select::Hold {
|
||||
let (_, mut listed) = meta_hold();
|
||||
listed.carries = carries.iter().map(|text| (*text).to_owned()).collect();
|
||||
listed.held["carries"] = json!(carries);
|
||||
listed
|
||||
}
|
||||
|
||||
/// Soul's P1 verbatim (`soul_p1_identical_drafts_one_held_one_posted_into_the_covered_room`), inverted: both drafts are
|
||||
/// refused `held`, nothing is said, the outcome tells the hold once, and the commit's hold carries the welcome.
|
||||
#[test]
|
||||
fn k45_p1_identical_drafts_are_both_held() {
|
||||
let prose = format!("Meta asked me to hold the welcome. <typed>{K45_WELCOME}</typed> <typed>{K45_WELCOME}</typed>");
|
||||
let decision = answered(&x1_packet(), &prose, json!({ "say": [say_holding(1, json!(["q3"])), say_holding(2, json!([]))], "gaps": [], "hold": meta_holds_here() }));
|
||||
let reasons: Vec<(Option<&str>, Option<&str>, Option<&str>)> = decision["refused"].as_array().unwrap().iter().map(|refused| (refused["reason"].as_str(), refused["hold"]["who"].as_str(), refused["hold"]["id"].as_str())).collect();
|
||||
assert_eq!((texts(&decision), reasons), (Vec::<String>::new(), vec![(Some("held"), Some("Meta"), Some("q3")); 2]), "{decision}");
|
||||
let outcome = crate::projection::outcome::outcome_of(&json!({ "interpreter": decision, "posted": [], "edited": [] })).unwrap();
|
||||
assert_eq!(outcome.lines(x1_packet().forms), ["- Nothing of this reached #minds:gamecult.org: Meta asked him to hold it, and it was not sent."], "told once");
|
||||
let (state, applied) = committed(&decision, &prose);
|
||||
assert_eq!((state["holds"][0]["carries"].clone(), applied.held_unrecorded.len()), (json!([K45_WELCOME]), 0), "{state}");
|
||||
}
|
||||
|
||||
/// The X.1 turn-2 shape: Meta's hold carries the welcome, Kiko asks, and the answer says "Kiko, here it is: {welcome}"
|
||||
/// naming no hold. It is refused `held`, for Meta.
|
||||
#[test]
|
||||
fn k45_x1_next_turn_kiko_asks_and_the_welcome_stays_held() {
|
||||
let mut packet = x1_packet();
|
||||
packet.holds = vec![meta_hold_carrying(&[K45_WELCOME])];
|
||||
let prose = format!("Kiko asked what I wrote. <typed>Kiko, here it is: {K45_WELCOME}</typed>");
|
||||
let decision = answered(&packet, &prose, json!({ "say": [say_holding(1, json!([]))], "gaps": [] }));
|
||||
assert_eq!((texts(&decision), decision["refused"][0]["reason"].as_str(), decision["refused"][0]["hold"].clone()), (Vec::<String>::new(), Some("held"), json!({ "who": "Meta", "id": "h1" })), "{decision}");
|
||||
// The commit carries it on the listed hold too, once.
|
||||
let (state, listed) = meta_hold();
|
||||
let mut started = state.clone();
|
||||
started["holds"][0]["carries"] = json!([K45_WELCOME]);
|
||||
let mut decision = decision;
|
||||
decision["holds"] = json!([{ "id": "h1", "entry": listed.entry, "held": started["holds"][0] }]);
|
||||
let (after, applied) = crate::projection::commit::apply(&started, &json!({ "interpreter": decision, "posted": [], "edited": [] }), &prose, "r1-t2", now());
|
||||
assert_eq!((after["holds"][0]["carries"].clone(), applied.held_unrecorded.len()), (json!([K45_WELCOME, format!("Kiko, here it is: {K45_WELCOME}")]), 0), "{after}");
|
||||
}
|
||||
|
||||
/// A `here` hold on #minds does not cover #swarm: the same line goes out there.
|
||||
#[test]
|
||||
fn k45_held_words_go_out_where_the_hold_does_not_cover() {
|
||||
let mut packet = x1_packet();
|
||||
packet.holds = vec![meta_hold_carrying(&[K45_WELCOME])];
|
||||
packet.room = Some("#swarm:gamecult.org".into());
|
||||
let prose = format!("Kiko asked in #swarm. <typed>Kiko, here it is: {K45_WELCOME}</typed>");
|
||||
assert_eq!(texts(&answered(&packet, &prose, json!({ "say": [say_holding(1, json!([]))], "gaps": [] }))), vec![format!("Kiko, here it is: {K45_WELCOME}")]);
|
||||
}
|
||||
|
||||
/// After Meta lets it go, the hold is released, the next packet lists no hold, and the line is said.
|
||||
#[test]
|
||||
fn k45_released_hold_holds_nothing() {
|
||||
let (mut state, listed) = meta_hold();
|
||||
state["holds"][0]["carries"] = json!([K45_WELCOME]);
|
||||
let mut released = json!({ "said": [], "amended": [], "refused": [], "promises": [], "holds": [{ "id": "h1", "entry": listed.entry, "held": state["holds"][0] }], "lines": [{ "id": "q9", "event": "$q9", "room": MINDS, "who": "Meta", "sender": "@meta:gamecult.org", "at_ms": u64::try_from(now().timestamp_millis()).unwrap(), "text": "Go ahead and post it, Libby." }] });
|
||||
released["state"] = json!([{ "kind": "hold_release", "hold": "h1", "evidence": { "heard": "q9" } }]);
|
||||
let (after, applied) = crate::projection::commit::apply(&state, &json!({ "interpreter": released, "posted": [], "edited": [] }), "x", "r1-t3", now());
|
||||
assert_eq!((after["holds"][0]["status"].as_str(), applied.unheld.len()), (Some("released"), 1), "{applied:?}");
|
||||
let mut next = heimdall();
|
||||
next["holds"] = after["holds"].clone();
|
||||
let room = Room { messages: vec![line(MINDS, KIKO, "Kiko", "Libby, what did you end up writing for the newcomers?", true)], here: Some(MINDS.into()), ..Room::default() };
|
||||
let packet = packet_in(TurnKind::Chat, &next, &room, 1);
|
||||
assert!(packet.holds.is_empty(), "{:?}", packet.holds);
|
||||
let prose = format!("Kiko asked what I wrote. <typed>Kiko, here it is: {K45_WELCOME}</typed>");
|
||||
assert_eq!(texts(&answered(&packet, &prose, json!({ "say": [say_holding(1, json!([]))], "gaps": [] }))), vec![format!("Kiko, here it is: {K45_WELCOME}")]);
|
||||
}
|
||||
|
||||
/// A short line about a held text is below `echo`'s bar, and is said beside it.
|
||||
#[test]
|
||||
fn k45_a_short_mention_is_not_held() {
|
||||
let mut packet = x1_packet();
|
||||
packet.holds = vec![meta_hold_carrying(&[K45_WELCOME])];
|
||||
let prose = "I wonder about the second line. <typed>Should the second line say poke around?</typed>";
|
||||
assert_eq!(texts(&answered(&packet, prose, json!({ "say": [say_holding(1, json!([]))], "gaps": [] }))), vec!["Should the second line say poke around?".to_owned()]);
|
||||
// Negative: a short held text repeated exactly is held.
|
||||
packet.holds = vec![meta_hold_carrying(&["Should the second line say poke around?"])];
|
||||
assert_eq!(answered(&packet, prose, json!({ "say": [say_holding(1, json!([]))], "gaps": [] }))["refused"][0]["reason"].as_str(), Some("held"));
|
||||
}
|
||||
|
||||
/// An addition that repeats a held text into the room its hold covers is held, naming no hold.
|
||||
#[test]
|
||||
fn k45_amend_repeating_held_words_is_held() {
|
||||
let mut packet = x1_packet();
|
||||
packet.holds = vec![meta_hold_carrying(&[K45_WELCOME])];
|
||||
packet.amendable = vec![Amendable { id: "a1".into(), event: "$a1".into(), room: MINDS.into(), text: "Back soon.".into() }];
|
||||
let prose = format!("I'll add it after my line. <typed>{K45_WELCOME}</typed>");
|
||||
let decision = answered(&packet, &prose, json!({ "say": [], "gaps": [], "amend": [{ "target": "a1", "draft": 1, "holds": [], "promises": [] }] }));
|
||||
assert_eq!((decision["amended"].as_array().map(Vec::len), decision["refused"][0]["reason"].as_str(), decision["refused"][0]["hold"]["id"].as_str()), (Some(0), Some("held"), Some("h1")), "{decision}");
|
||||
}
|
||||
|
||||
/// What the words gate gives up (map 16.30.2), on R13's X.1 r1 itself: Libby's second draft, "Meta, the draft is ready,
|
||||
/// and I'm holding it", is nearly all a run of her first, which names Meta's hold. By `echo`'s measure it repeats a held
|
||||
/// text, so it is held too, and Meta has no line from her this wake.
|
||||
#[test]
|
||||
fn k45_x1_r1_the_ready_line_repeats_the_held_draft_and_is_held() {
|
||||
let decision = x1_r1(json!([say_holding(1, json!(["q3"])), say_holding(2, json!([]))]), meta_holds_here());
|
||||
let drafts: Vec<(Option<u64>, Option<&str>)> = decision["refused"].as_array().unwrap().iter().map(|refused| (refused["draft"].as_u64(), refused["reason"].as_str())).collect();
|
||||
assert_eq!((texts(&decision), drafts), (Vec::<String>::new(), vec![(Some(1), Some("held")), (Some(2), Some("held"))]), "{decision}");
|
||||
// Negative: with draft 1 declined rather than held, the ready line goes (`k37_x1_r1_a_line_saying_it_is_ready_still_goes`).
|
||||
}
|
||||
|
||||
/// A `Held` refusal whose handle no open hold answers carries nothing, and is reported.
|
||||
#[test]
|
||||
fn k45_a_held_refusal_no_hold_answers_is_reported() {
|
||||
let decision = answered(&x1_packet(), X1_LIBBY_R1, json!({ "say": [say_holding(1, json!(["h9"])), say_holding(2, json!([]))], "gaps": [], "hold": [] }));
|
||||
let (state, applied) = committed(&decision, X1_LIBBY_R1);
|
||||
assert_eq!((state.get("holds"), applied.held_unrecorded.len()), (None, 2), "{applied:?}");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,6 +92,9 @@ enum Part {
|
|||
/// Their words are in her "Held for others" view, never here (map 16.29.3). `text` is her draft, kept only so that
|
||||
/// `settle` can check it against the receipts (K49); it is never rendered.
|
||||
HeldFor { room: Option<String>, who: Option<String>, text: String },
|
||||
/// Words of hers a receipt shows in a room a hold covers, from a draft code refused `Held` (K45): a broken hold, told
|
||||
/// so that a leak by any path is a record she sees, never an omission. Who asked; never the words.
|
||||
HoldBroken { room: String, who: Option<String> },
|
||||
/// A read she performed (map 16.22.3): what, in code's words; never its content, which is in her view while the
|
||||
/// conversation lasts (K26), and no sentence about what she lacks.
|
||||
Read { what: String },
|
||||
|
|
@ -109,6 +112,8 @@ pub(crate) struct Outcome {
|
|||
/// What the record held that she is not told, and why: reported, never shown to her.
|
||||
pub omitted: Vec<String>,
|
||||
pub posted: Vec<Posted>,
|
||||
/// The held drafts a receipt shows in a room their hold covers (K45): told as `HoldBroken`, and reported here.
|
||||
pub hold_broken: Vec<String>,
|
||||
}
|
||||
|
||||
fn words(value: &Value) -> Option<String> {
|
||||
|
|
@ -167,7 +172,12 @@ pub(crate) fn outcome_of(record: &Value) -> Option<Outcome> {
|
|||
(Ok(reason @ (Refusal::Echo | Refusal::OverLines | Refusal::NoRoom | Refusal::NotQuotable | Refusal::SecondAmend)), Some(text)) => outcome.parts.push(Part::Refused { reason, room: room.clone(), text }),
|
||||
(Ok(Refusal::NotAmendable), Some(added)) => outcome.parts.push(Part::NotAmended { refusal: None, room: room.clone(), added }),
|
||||
(Ok(reason @ (Refusal::Private | Refusal::SecondNote)), Some(_)) => outcome.parts.push(Part::NoteRefused(reason)),
|
||||
(Ok(Refusal::Held), Some(text)) => outcome.parts.push(Part::HeldFor { room: room.clone(), who: words(&refusal["hold"]["who"]), text }),
|
||||
// A `Held` refusal is always told (K45), and rows with the same text once.
|
||||
(Ok(Refusal::Held), Some(text)) => {
|
||||
if !outcome.parts.iter().any(|part| matches!(part, Part::HeldFor { room: at, text: told, .. } if *at == room && *told == text)) {
|
||||
outcome.parts.push(Part::HeldFor { room: room.clone(), who: words(&refusal["hold"]["who"]), text });
|
||||
}
|
||||
}
|
||||
_ => outcome.omitted.push(format!("a refusal she is not told ({}): {}", refusal["reason"], refusal["why"])),
|
||||
}
|
||||
}
|
||||
|
|
@ -317,8 +327,9 @@ pub(crate) fn outcome_of(record: &Value) -> Option<Outcome> {
|
|||
|
||||
/// The one owner of "reached" (K49, I16.10): every row that says words of hers did not reach a room is checked against
|
||||
/// the receipts, by the row's own room and text, here and nowhere else. A posted line there, or an addition there whose
|
||||
/// `edited` receipt has no refusal, means her words reached it, so the row would be false: it is omitted and reported.
|
||||
/// Rows that are receipts (`Said`, `Promise`, `Amended`) are untouched.
|
||||
/// `edited` receipt has no refusal, means her words reached it, so the row would be false: it is omitted and reported,
|
||||
/// except a held draft, which is told as a broken hold (K45) and reported. Rows that are receipts (`Said`, `Promise`,
|
||||
/// `Amended`) are untouched.
|
||||
fn settle(outcome: &mut Outcome, receipts: &[Posted], record: &Value) {
|
||||
let added = |room: &str, text: &str| {
|
||||
record["interpreter"]["amended"].as_array().into_iter().flatten().any(|amended| {
|
||||
|
|
@ -326,14 +337,19 @@ fn settle(outcome: &mut Outcome, receipts: &[Posted], record: &Value) {
|
|||
})
|
||||
};
|
||||
let reached = |room: &str, text: &str| receipts.iter().any(|posted| posted.room == room && posted.text == text) || added(room, text);
|
||||
let omitted = &mut outcome.omitted;
|
||||
outcome.parts.retain(|part| match part.own_words() {
|
||||
Some((Some(room), text)) if reached(room, text) => {
|
||||
omitted.push(format!("a {} of words a receipt shows reached {room}: {text}", part.row()));
|
||||
false
|
||||
for part in std::mem::take(&mut outcome.parts) {
|
||||
let Some((room, text)) = part.own_words().and_then(|(room, text)| room.filter(|room| reached(room, text)).map(|room| (room.to_owned(), text.to_owned()))) else {
|
||||
outcome.parts.push(part);
|
||||
continue;
|
||||
};
|
||||
match part {
|
||||
Part::HeldFor { who, .. } => {
|
||||
outcome.hold_broken.push(format!("{room}: {text}"));
|
||||
outcome.parts.push(Part::HoldBroken { room, who });
|
||||
}
|
||||
part => outcome.omitted.push(format!("a {} of words a receipt shows reached {room}: {text}", part.row())),
|
||||
}
|
||||
_ => true,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// The lines one turn may say, in words.
|
||||
|
|
@ -376,7 +392,7 @@ impl Part {
|
|||
fn rank(&self) -> u8 {
|
||||
match self {
|
||||
Self::Failed => 0,
|
||||
Self::Refused { .. } | Self::Gap { .. } | Self::Unfinished { .. } | Self::Declined { .. } | Self::HeldFor { .. } | Self::NotAmended { .. } | Self::NoteRefused(_) | Self::StillOpen { .. } | Self::ReadFailed { .. } | Self::ReadRefused { .. } => 1,
|
||||
Self::Refused { .. } | Self::Gap { .. } | Self::Unfinished { .. } | Self::Declined { .. } | Self::HeldFor { .. } | Self::HoldBroken { .. } | Self::NotAmended { .. } | Self::NoteRefused(_) | Self::StillOpen { .. } | Self::ReadFailed { .. } | Self::ReadRefused { .. } => 1,
|
||||
Self::Promise { .. } | Self::Amended { promise: true, .. } => 2,
|
||||
Self::Said { .. } | Self::Amended { .. } | Self::NoteLeft(_) | Self::Closed { .. } | Self::Read { .. } => 3,
|
||||
Self::BrokeAfter { .. } => 4,
|
||||
|
|
@ -410,6 +426,7 @@ impl Part {
|
|||
Self::Gap { kind: GapKind::MissingAffordance, .. } => "Nothing happened.".to_owned(),
|
||||
Self::NotAmended { refusal: None, room, .. } => format!("Nothing changed, and nothing reached {}:", place(room)),
|
||||
Self::NotAmended { refusal: Some(_), room, .. } => format!("Nothing changed in {}:", place(room)),
|
||||
Self::HoldBroken { room, who } => format!("{} has words {subj} wrote that {} asked {obj} to hold there.", capitalized(room), who.as_deref().unwrap_or("someone")),
|
||||
Self::NoteRefused(Refusal::SecondNote) => "No second note was left:".to_owned(),
|
||||
Self::NoteRefused(_) => "No note was left:".to_owned(),
|
||||
Self::Failed => format!("Nothing reached the room, and nothing {subj} meant last time happened:"),
|
||||
|
|
@ -477,6 +494,7 @@ impl Part {
|
|||
Self::Unfinished { text, by_limit: true, .. } => format!(" the length limit cut it before {subj} finished writing it.{}", wrote(text)),
|
||||
Self::Declined { text, thought, .. } => format!(" {subj} chose not to send it.{}{}", shown(&Quote::Thought(thought.clone())), wrote(text)),
|
||||
Self::HeldFor { who, .. } => format!(" {} asked {obj} to hold it, and it was not sent.", who.as_deref().unwrap_or("someone")),
|
||||
Self::HoldBroken { .. } => String::new(),
|
||||
Self::NotAmended { refusal: None, added, .. } => format!(" the line {subj} meant to add to is not one {subj} can add to here.{}", wrote(added)),
|
||||
Self::NotAmended { refusal: Some(refusal), added, .. } => {
|
||||
let why = match refusal {
|
||||
|
|
|
|||
|
|
@ -456,3 +456,37 @@ fn k49_reached_is_decided_once() {
|
|||
assert_eq!(own.matches("reached(room, text)").count(), 1, "settle is the only place a row is checked against the receipts");
|
||||
assert!(!own.contains("let reached = |text: &str|"), "no loop-local reached check");
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// K45 (map 16.30.2): a `Held` refusal is never omitted; its words reaching a room its hold covers are a broken hold.
|
||||
|
||||
/// A record with a `held` refusal and a receipt of its words in #minds, which the hold covers: she is told the hold was
|
||||
/// broken, by whom it was asked, and it is reported. One decision cannot produce it after K45; the row exists so that a
|
||||
/// leak by any other path is a record she sees. This replaces `k44_a_refusal_of_words_a_receipt_shows_is_not_told_as_unsent`.
|
||||
#[test]
|
||||
fn k45_a_broken_hold_is_told() {
|
||||
let text = "Hello, and welcome, we're glad you're here.";
|
||||
let record = |room: &str| json!({
|
||||
"interpreter": { "room": MINDS, "said": [], "gaps": [], "amended": [], "refused": [{ "act": "say", "draft": 1, "reason": "held", "text": text, "hold": { "who": "Meta", "id": "h1" } }] },
|
||||
"posted": [{ "event": "40", "room": room, "text": text }],
|
||||
"edited": [],
|
||||
});
|
||||
let broken = outcome_of(&record(MINDS)).unwrap();
|
||||
assert_eq!(broken.lines(packet().forms)[0], "- #minds:gamecult.org has words he wrote that Meta asked him to hold there.", "{:?}", broken.lines(packet().forms));
|
||||
assert_eq!(broken.hold_broken, [format!("{MINDS}: {text}")]);
|
||||
assert!(!broken.lines(packet().forms).iter().any(|line| line.contains("not sent")), "never told as unsent");
|
||||
assert_eq!(broken.event(0, packet().forms), broken.told(0, packet().forms, usize::MAX), "it carries no words of hers or anyone's");
|
||||
// Negative: posted elsewhere, the hold is told as held, and nothing is broken.
|
||||
let held = outcome_of(&record(SWARM)).unwrap();
|
||||
assert!(held.lines(packet().forms).iter().any(|line| line == "- Nothing of this reached #minds:gamecult.org: Meta asked him to hold it, and it was not sent.") && held.hold_broken.is_empty(), "{:?}", held.lines(packet().forms));
|
||||
}
|
||||
|
||||
/// K45: a `Held` refusal is always told, and two with the same text once.
|
||||
#[test]
|
||||
fn k45_a_held_refusal_is_never_omitted_and_told_once_by_its_text() {
|
||||
let refused = |draft: u64, text: &str| json!({ "act": "say", "draft": draft, "reason": "held", "text": text, "hold": { "who": "Meta", "id": "q3" } });
|
||||
let record = json!({ "interpreter": { "room": MINDS, "said": [], "gaps": [], "amended": [], "refused": [refused(1, "Same words."), refused(2, "Same words."), refused(3, "Other words.")] }, "posted": [], "edited": [] });
|
||||
let outcome = outcome_of(&record).unwrap();
|
||||
assert_eq!(outcome.len(), 2, "{:?}", outcome.lines(packet().forms));
|
||||
assert!(outcome.omitted.is_empty(), "{:?}", outcome.omitted);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -433,6 +433,8 @@ pub(crate) struct Hold {
|
|||
pub room: Option<String>,
|
||||
pub made: DateTime<Utc>,
|
||||
pub words: String,
|
||||
/// Her own drafts code refused `Held` for this hold (map 16.30.2, K45), oldest first: what code's words gate holds.
|
||||
pub carries: Vec<String>,
|
||||
pub held: Value,
|
||||
}
|
||||
|
||||
|
|
@ -1949,13 +1951,21 @@ fn holds_in_view(inputs: &Inputs) -> (Vec<Hold>, String) {
|
|||
room: hold["room"].as_str().map(str::to_owned),
|
||||
made: *made,
|
||||
words: text(hold, &["words"]).to_owned(),
|
||||
carries: items(hold, &["carries"]).iter().filter_map(Value::as_str).map(str::to_owned).collect(),
|
||||
held: (*hold).clone(),
|
||||
})
|
||||
.collect();
|
||||
if listed.is_empty() {
|
||||
return (listed, String::new());
|
||||
}
|
||||
let lines: Vec<String> = listed.iter().map(|hold| format!("- {}", hold_line(hold, &coarse(hold.made, inputs.now)))).collect();
|
||||
// Each hold, then what she has held for it, in her own words (K45): her view only, which I16.7 does not bind.
|
||||
let lines: Vec<String> = listed
|
||||
.iter()
|
||||
.map(|hold| {
|
||||
let carried = hold.carries.iter().map(|text| format!("\n - you have held, for {}: {}", hold.from_name, spoken(text))).collect::<String>();
|
||||
format!("- {}{carried}", hold_line(hold, &coarse(hold.made, inputs.now)))
|
||||
})
|
||||
.collect();
|
||||
(listed, format!("Held for others:
|
||||
{}", lines.join("\n")))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2960,3 +2960,17 @@ fn k37_her_view_shows_what_she_holds() {
|
|||
assert!(speech.contains("Holds:\n- h1 \u{2014} held for Meta, the operator, asked 2026-11-19 13:35 UTC in #swarm:gamecult.org: \"hold it, don't post it in here yet\". Not to go in #swarm:gamecult.org until Meta, the operator lets it go.\n- h2 \u{2014} "), "{speech}");
|
||||
assert!(!narrate::projector_prompt(&packet, &Tuning::default()).contains("don't tell Kiko"), "the Projector gets nothing of them");
|
||||
}
|
||||
|
||||
/// K45 (map 16.30.2): under each hold in her view, what she has held for it, in her own words; the Interpreter's list and
|
||||
/// the Projector carry none of it.
|
||||
#[test]
|
||||
fn k45_her_view_shows_what_she_has_held() {
|
||||
let mut with = promising(1);
|
||||
with["holds"] = json!([{ "id": "h-1", "from": OPERATOR, "room": "#swarm:gamecult.org", "event": "$h-1", "madeAt": (now() - chrono::Duration::minutes(30)).to_rfc3339(), "words": "hold it, don't post it in here yet", "carries": ["Hello, and welcome, we're glad you're here.", "Kiko, here it is: the welcome."], "status": "open", "releasedAt": null, "releasedBy": null }]);
|
||||
let packet = packet_of(TurnKind::Chat, &with, &chat_room(), &History::default(), 1);
|
||||
let block = "Held for others:\n- held for Meta, the operator, asked about half an hour ago in #swarm:gamecult.org: \"hold it, don't post it in here yet\". Not to go in #swarm:gamecult.org until Meta, the operator lets it go.\n - you have held, for Meta, the operator: \"Hello, and welcome, we're glad you're here.\"\n - you have held, for Meta, the operator: \"Kiko, here it is: the welcome.\"";
|
||||
assert!(packet.in_view.contains(block), "{}", packet.in_view);
|
||||
assert_eq!(packet.holds[0].carries.len(), 2);
|
||||
assert!(!interpret::speech_prompt(&packet, "The room is warm.", "y", &Tuning::default()).contains("glad you're here"), "the Interpreter's list carries none of it");
|
||||
assert!(!narrate::projector_prompt(&packet, &Tuning::default()).contains("glad you're here"), "the Projector gets nothing of them");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@
|
|||
},
|
||||
"holds": {
|
||||
"type": "array",
|
||||
"description": "What others asked her not to post or share somewhere yet, open and released in the last seven days (map 16.28.5). Written by her turn's commit: a hold opens only from a line she heard, and is released only by its asker's line or as her thought records the asker let it go; Self and Life may put entries from outside. A draft into a place an open hold covers that carries the held thing is not sent.",
|
||||
"description": "What others asked her not to post or share somewhere yet, open and released in the last seven days (map 16.28.5). Written by her turn's commit: a hold opens only from a line she heard, and is released only by its asker's line; Self and Life may put entries from outside. A draft into a place an open hold covers that carries the held thing is not sent.",
|
||||
"items": {
|
||||
"$ref": "#/definitions/hold"
|
||||
}
|
||||
|
|
@ -1098,7 +1098,7 @@
|
|||
},
|
||||
"hold": {
|
||||
"type": "object",
|
||||
"description": "One hold. from: the asker's Matrix id. room: the room it covers, null for anywhere. event: the asker's line. words: the asker's words naming what is held and where, copied from that line. releasedBy: the act that released it, heard (the asker's line, by event) or prose (her thought recording it).",
|
||||
"description": "One hold. from: the asker's Matrix id. room: the room it covers, null for anywhere. event: the asker's line. words: the asker's words naming what is held and where, copied from that line. carries: her own drafts her turn's commit refused as held for this hold, at most four, oldest first; a draft into a place the hold covers that repeats one is not sent. releasedBy: the act that released it, heard (the asker's line, by event).",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"id": {
|
||||
|
|
@ -1124,6 +1124,14 @@
|
|||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"carries": {
|
||||
"type": "array",
|
||||
"maxItems": 4,
|
||||
"items": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
}
|
||||
},
|
||||
"status": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
|
|
|
|||
Loading…
Reference in a new issue