Soul fix-ups on 63858db and the K9/K10 consistency holds
- An answer without `say` or `gaps` is not the speech contract: a failure, never a silence (Answer no longer defaults them; `amend` and `suggest` read as none when left out). - One draft goes one place by its words: two identical drafts are one, so "On it." twice posts once. The guard spans say, amend and suggest. - An amendment's draft meets the echo check too. - The people's guard counts its heading (select::people_guard): two bonds at the summary guard fit. - Gaps agree with what went out: only conditional, addressee and elsewhere name a draft; a reach or an unwritten line is always a passage of her thought; a gap naming, or quoting from, a draft that went somewhere is marked `acted`, kept for the trace and not told to her. - Someone else's words located in her thought are shown as her thought, never as words she wrote (test). - The simulation report's header describes drafts, not span citation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
0197963f1d
commit
3d8b4c1215
6 changed files with 107 additions and 21 deletions
|
|
@ -175,7 +175,7 @@ impl Refusal {
|
|||
match self {
|
||||
Self::NoRoom => "the turn has no room to speak in",
|
||||
Self::NoDraft => "it names no draft she set down",
|
||||
Self::Used => "one draft goes one place: it was already used",
|
||||
Self::Used => "one draft goes one place: its words were already used this turn",
|
||||
Self::Echo => "mostly words she heard: an echo, not her speech",
|
||||
Self::OverLines => "past the lines one turn may say",
|
||||
Self::NotAmendable => "it names no line of hers she may add to here",
|
||||
|
|
@ -247,6 +247,12 @@ impl GapKind {
|
|||
/// intent: whether it is her reach or her report of someone else's words was the Interpreter's reading;
|
||||
/// - `unlocated`: neither; the model's quote is kept for the trace and never shown to her.
|
||||
///
|
||||
/// - `acted`: it names, or quotes from, a draft that went somewhere this turn (said, added to a line, left for Self), so it
|
||||
/// contradicts what happened and is not shown to her (`decide` sets it).
|
||||
///
|
||||
/// Only the draft kinds (conditional, addressee, elsewhere) name a draft: a reach or an unwritten line is about words she
|
||||
/// did not set down, so it is always a passage of her thought, whatever draft the model names.
|
||||
///
|
||||
/// The model's `detail` is kept for the trace and is never what she is told.
|
||||
fn gap(prose: &str, found: &Drafts, raw: &Value) -> Value {
|
||||
let kind = GapKind::of(raw.get("kind").and_then(Value::as_str).unwrap_or_default());
|
||||
|
|
@ -254,7 +260,8 @@ fn gap(prose: &str, found: &Drafts, raw: &Value) -> Value {
|
|||
if kind == GapKind::Unresolved {
|
||||
gap["declared"] = raw.get("kind").cloned().unwrap_or_else(|| raw.clone());
|
||||
}
|
||||
if let Some(draft) = raw.get("draft").and_then(Value::as_i64).and_then(|n| found.numbered(n)) {
|
||||
let names_a_draft = !matches!(kind, GapKind::MissingAffordance | GapKind::Unwritten);
|
||||
if let Some(draft) = raw.get("draft").and_then(Value::as_i64).and_then(|n| found.numbered(n)).filter(|_| names_a_draft) {
|
||||
gap["from"] = json!("draft");
|
||||
gap["draft"] = json!(draft.n);
|
||||
gap["words"] = json!(draft.text);
|
||||
|
|
@ -277,12 +284,12 @@ fn gap(prose: &str, found: &Drafts, raw: &Value) -> Value {
|
|||
gap
|
||||
}
|
||||
|
||||
/// The answer's shape, decoded whole from the schema turn's structured output.
|
||||
/// The answer's shape, decoded whole from the schema turn's structured output. `say` and `gaps` are required: an answer
|
||||
/// without them is not the contract, a failure and never a silence. `amend` and `suggest` read as none when
|
||||
/// left out: an answer without them proposes no such act.
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct Answer {
|
||||
#[serde(default)]
|
||||
say: Vec<Proposed>,
|
||||
#[serde(default)]
|
||||
gaps: Vec<Value>,
|
||||
#[serde(default)]
|
||||
amend: Vec<ProposedAmend>,
|
||||
|
|
@ -400,7 +407,10 @@ pub(crate) fn decide(model: &dyn Model, request_id: &str, packet: &Packet, narra
|
|||
let shown = |id: &str| packet.people.iter().any(|(_, person)| person == id);
|
||||
let mut said: Vec<Value> = Vec::new();
|
||||
let mut refusals = Vec::new();
|
||||
let mut used: Vec<usize> = Vec::new();
|
||||
// One draft goes one place, and the same words go out once: a draft is used by its words, so two identical drafts
|
||||
// are one. `went` holds the drafts that went somewhere.
|
||||
let mut used: Vec<&str> = Vec::new();
|
||||
let mut went: Vec<&Draft> = Vec::new();
|
||||
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));
|
||||
|
|
@ -408,7 +418,7 @@ pub(crate) fn decide(model: &dyn Model, request_id: &str, packet: &Packet, narra
|
|||
};
|
||||
let reason = if room.is_none() {
|
||||
Some(Refusal::NoRoom)
|
||||
} else if used.contains(&draft.n) {
|
||||
} else if used.contains(&draft.text.as_str()) {
|
||||
Some(Refusal::Used)
|
||||
} else if echo(&draft.text, &packet.bodies) {
|
||||
Some(Refusal::Echo)
|
||||
|
|
@ -417,7 +427,7 @@ pub(crate) fn decide(model: &dyn Model, request_id: &str, packet: &Packet, narra
|
|||
} else {
|
||||
None
|
||||
};
|
||||
used.push(draft.n);
|
||||
used.push(&draft.text);
|
||||
if let Some(reason) = reason {
|
||||
refusals.push(refused(Act::Say, Some(draft), None, reason));
|
||||
continue;
|
||||
|
|
@ -428,6 +438,7 @@ pub(crate) fn decide(model: &dyn Model, request_id: &str, packet: &Packet, narra
|
|||
Some(id) => (None, Some(id)),
|
||||
None => (None, None),
|
||||
};
|
||||
went.push(draft);
|
||||
said.push(json!({ "room": room, "text": draft.text, "mentions": mentions, "reply_to": reply_to, "rests_on": { "draft": draft.n, "start_byte": draft.start, "end_byte": draft.end }, "dropped": { "mentions": unknown, "reply_to": unknown_reply } }));
|
||||
}
|
||||
// An amendment adds a whole draft after a line of hers listed as one she may add to; the actuator composes it, so
|
||||
|
|
@ -439,16 +450,21 @@ pub(crate) fn decide(model: &dyn Model, request_id: &str, packet: &Packet, narra
|
|||
continue;
|
||||
};
|
||||
let target = proposed.target.as_deref().and_then(|id| packet.amendable.iter().find(|line| line.id == id.trim()));
|
||||
let reason = if used.contains(&draft.n) {
|
||||
let reason = if used.contains(&draft.text.as_str()) {
|
||||
Some(Refusal::Used)
|
||||
} else if echo(&draft.text, &packet.bodies) {
|
||||
Some(Refusal::Echo)
|
||||
} else if !amended.is_empty() {
|
||||
Some(Refusal::SecondAmend)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
used.push(draft.n);
|
||||
used.push(&draft.text);
|
||||
match (reason, target) {
|
||||
(None, Some(line)) => amended.push(json!({ "target": line.id, "event": line.event, "room": line.room, "original": line.text, "added": draft.text, "draft": draft.n })),
|
||||
(None, Some(line)) => {
|
||||
went.push(draft);
|
||||
amended.push(json!({ "target": line.id, "event": line.event, "room": line.room, "original": line.text, "added": draft.text, "draft": draft.n }));
|
||||
}
|
||||
(reason, _) => refusals.push(refused(Act::Amend, Some(draft), None, reason.unwrap_or(Refusal::NotAmendable))),
|
||||
}
|
||||
}
|
||||
|
|
@ -460,7 +476,7 @@ pub(crate) fn decide(model: &dyn Model, request_id: &str, packet: &Packet, narra
|
|||
refusals.push(refused(Act::Suggest, None, proposed.draft, Refusal::NoDraft));
|
||||
continue;
|
||||
};
|
||||
let reason = if used.contains(&draft.n) {
|
||||
let reason = if used.contains(&draft.text.as_str()) {
|
||||
Some(Refusal::Used)
|
||||
} else if !suggestions.is_empty() {
|
||||
Some(Refusal::SecondNote)
|
||||
|
|
@ -469,7 +485,7 @@ pub(crate) fn decide(model: &dyn Model, request_id: &str, packet: &Packet, narra
|
|||
} else {
|
||||
None
|
||||
};
|
||||
used.push(draft.n);
|
||||
used.push(&draft.text);
|
||||
if let Some(reason) = reason {
|
||||
refusals.push(refused(Act::Suggest, Some(draft), None, reason));
|
||||
continue;
|
||||
|
|
@ -479,8 +495,18 @@ pub(crate) fn decide(model: &dyn Model, request_id: &str, packet: &Packet, narra
|
|||
Some(id) => (None, Some(id)),
|
||||
None => (None, None),
|
||||
};
|
||||
went.push(draft);
|
||||
suggestions.push(json!({ "kind": proposed.kind, "about": about, "room": room, "text": draft.text, "draft": draft.n, "dropped": { "about": dropped } }));
|
||||
}
|
||||
// A gap about a draft that went somewhere, or quoting from one, contradicts what happened: it is kept for the trace as
|
||||
// `acted` and never shown to her.
|
||||
for gap in decision["gaps"].as_array_mut().into_iter().flatten() {
|
||||
let named = gap["draft"].as_u64().is_some_and(|n| went.iter().any(|draft| draft.n as u64 == n)) && gap["from"] == "draft";
|
||||
let quoted = gap["from"] == "unlocated" && gap["quote"].as_str().is_some_and(|quote| !quote.is_empty() && went.iter().any(|draft| draft.text.contains(quote)));
|
||||
if named || quoted {
|
||||
gap["from"] = json!("acted");
|
||||
}
|
||||
}
|
||||
decision["amended"] = json!(amended);
|
||||
decision["suggestions"] = json!(suggestions);
|
||||
decision["room"] = json!(room);
|
||||
|
|
|
|||
|
|
@ -499,3 +499,37 @@ fn the_frame_offers_one_note_and_no_path_from_a_note_reaches_a_write() {
|
|||
let projection = include_str!("../../projection.rs");
|
||||
assert!(!projection.contains("persona_put") && !projection.contains(".admit("), "project holds the persona door read-only");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn soul_an_answer_without_say_or_gaps_is_a_failure_not_a_silence() {
|
||||
for text in ["{}", "{\"gaps\": []}", "{\"say\": []}"] {
|
||||
let model = Scripted::new(|_| String::new()).interpreting(move |_| text.into());
|
||||
let decision = decide(&model, "test", &packet(), "x", "<typed>Hi.</typed>", &Tuning::default());
|
||||
assert!(decision["failed"].as_str().is_some_and(|failed| failed.contains("not the speech contract")), "{text}: {decision}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn soul_the_same_words_go_out_once_whatever_their_draft_numbers() {
|
||||
let twice = decided("<typed>On it.</typed> I mean it. <typed>On it.</typed>", json!([{ "draft": 1 }, { "draft": 2 }]));
|
||||
assert_eq!(texts(&twice), ["On it."], "{twice}");
|
||||
assert!(refused_why(&twice).contains("one draft goes one place"), "{twice}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn soul_an_amendment_that_echoes_what_he_heard_is_refused() {
|
||||
let decision = answered(&amendable_packet(), "<typed>The economy is still the least-built part!</typed>", json!({ "say": [], "gaps": [], "amend": [{ "target": "a1", "draft": 1 }] }));
|
||||
assert_eq!((decision["amended"].as_array().unwrap().len(), decision["refused"][0]["reason"].as_str()), (0, Some("echo")), "{decision}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn soul_a_gap_never_contradicts_what_went_out() {
|
||||
let prose = "<typed>I'm fine, more or less.</typed> And I'll tell her the rest tomorrow, honestly.";
|
||||
let decision = answered(&packet(), prose, json!({ "say": [{ "draft": 1 }], "gaps": [
|
||||
{ "kind": "conditional", "draft": 1, "quote": null, "detail": "" },
|
||||
{ "kind": "unwritten", "draft": 1, "quote": "I'm fine, more or less.", "detail": "" },
|
||||
{ "kind": "unwritten", "draft": 1, "quote": "I'll tell her the rest tomorrow, honestly.", "detail": "" },
|
||||
] }));
|
||||
let from: Vec<&str> = decision["gaps"].as_array().unwrap().iter().map(|gap| gap["from"].as_str().unwrap()).collect();
|
||||
assert_eq!(from, ["acted", "acted", "thought"], "a gap on the sent draft, an unwritten quote from it, and an unwritten line of his thought whatever draft it names: {decision}");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -139,3 +139,18 @@ fn a_note_to_self_is_told_as_left_and_never_as_read() {
|
|||
assert!(second.contains(&"- He had already left Self a note that turn. He wrote: \"And the door.\"".to_owned()) && second.len() == 2, "{second:?}");
|
||||
assert!(left.iter().chain(&private).chain(&second).all(|line| !line.contains(" read it") || line.contains("next reads it")), "read is never claimed");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn soul_someone_elses_words_in_his_thought_are_shown_as_his_thought_never_as_his_words() {
|
||||
let prose = "Meta said, \"Nobody touches the release branch tonight.\" I keep turning that over.";
|
||||
let (lines, _) = told(&record(prose, json!({ "say": [], "gaps": [{ "kind": "unwritten", "draft": null, "quote": "Nobody touches the release branch tonight.", "detail": "" }] }), &[]));
|
||||
assert_eq!(lines.len(), 1, "{lines:?}");
|
||||
assert!(lines[0].ends_with("In his thought: \"Nobody touches the release branch tonight.\"") && !lines[0].contains("He wrote"), "{lines:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn soul_a_gap_that_contradicts_what_went_out_is_not_told() {
|
||||
let (lines, omitted) = told(&record("<typed>Hi Nibu.</typed>", json!({ "say": [{ "draft": 1 }], "gaps": [{ "kind": "conditional", "draft": 1, "quote": null, "detail": "" }] }), &["Hi Nibu."]));
|
||||
assert_eq!(lines, ["- He said in #minds:gamecult.org: \"Hi Nibu.\""]);
|
||||
assert!(omitted.iter().any(|why| why.contains("acted")), "{omitted:?}");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1382,11 +1382,18 @@ impl Section {
|
|||
/// and the trust and friction words.
|
||||
const BOND_HEAD_BYTES: usize = 80;
|
||||
|
||||
/// The guard of each section, in `Section` order (map 16.19.4, I16.8): the tuning's, and the people's derived from the
|
||||
/// bonds a packet shows in full. No section's guard is another's, so no section's content can displace another's.
|
||||
fn guards(tuning: &Tuning) -> [usize; SECTIONS] {
|
||||
/// The guard of each section, in `Section` order (map 16.19.4, I16.8): the tuning's, and the people's derived (`people_guard`).
|
||||
/// No section's guard is another's, so no section's content can displace another's.
|
||||
fn guards(tuning: &Tuning, her: Forms) -> [usize; SECTIONS] {
|
||||
let select = &tuning.select;
|
||||
[select.outcome_bytes, select.here_bytes, select.body_bytes, select.people_full.saturating_mul(select.bond_summary_bytes.saturating_add(BOND_HEAD_BYTES)), select.notes_bytes]
|
||||
[select.outcome_bytes, select.here_bytes, select.body_bytes, people_guard(tuning, her), select.notes_bytes]
|
||||
}
|
||||
|
||||
/// The people's guard: its heading and the bonds a packet shows in full, each a summary and its head with its newline.
|
||||
pub(crate) fn people_guard(tuning: &Tuning, her: Forms) -> usize {
|
||||
let select = &tuning.select;
|
||||
let bond = select.bond_summary_bytes.saturating_add(BOND_HEAD_BYTES).saturating_add(1);
|
||||
Section::People.heading(her).len().saturating_add(select.people_full.saturating_mul(bond))
|
||||
}
|
||||
|
||||
const SECTIONS: usize = 5;
|
||||
|
|
@ -1478,7 +1485,7 @@ pub(crate) fn select(inputs: &Inputs, tuning: &Tuning) -> Packet {
|
|||
// and the names of the people present without a bond line; the body; a bond line per person present while they fit;
|
||||
// the notes.
|
||||
let her = forms(inputs.state);
|
||||
let mut context = Context::new(guards(tuning), her);
|
||||
let mut context = Context::new(guards(tuning, her), her);
|
||||
// What came of her last turn, first and under its own guard, so nothing else can crowd it out. A line past the guard
|
||||
// keeps its sentence and has its quote clipped, leaving each later line room for its sentence and the least quote:
|
||||
// she is told every part, shortened when it must be.
|
||||
|
|
|
|||
|
|
@ -660,7 +660,7 @@ fn markdown(plan_path: &Path, plan: &SimFile, members: &[Member], group_state: O
|
|||
let _ = writeln!(out, "# Swarm simulation\n");
|
||||
let _ = writeln!(out, "> **State does not evolve during a run.** The Interpreter (C3b) and the commit (C3c) are not built, so every persona starts each turn from the state the plan gave her. `state_after_turn` in `projection/simulate.rs` is the seam where they will move it between rounds. Freshness carries over: each persona's earlier packets in the run count against repeating an item.\n");
|
||||
let _ = writeln!(out, "> **What came of her last turn opens her next packet.** Each persona's turn record (the Interpreter's decision and the lines the room appended for her) is carried to her next turn, as the commit's trace will carry it live; a turn's details show what she was told of it.\n");
|
||||
let _ = writeln!(out, "> **Speech is the Interpreter's.** What she says is decided from her prose by the Interpreter's speech step (C3b, one tool-less structured call), held by code to her prose: each line rests on a verbatim span of it, in a room she may speak in, and is never someone else's words. Its structured mentions and reply target are the only explicit addressees; an `@` in the text tags no one.\n");
|
||||
let _ = writeln!(out, "> **Speech is the Interpreter's.** What she says is decided from her prose by the Interpreter's speech step (C3b, one tool-less structured call), which chooses among the drafts she set down between `<typed>` marks: each line is one whole draft of hers, exactly as she typed it, in the one room she may speak in; whose words a draft carries is the Interpreter's judgement. Its structured mentions and reply target are the only explicit addressees; an `@` in the text tags no one.\n");
|
||||
let _ = writeln!(out, "- plan: `{}`", plan_path.display());
|
||||
let _ = writeln!(out, "- cast: {}", members.iter().map(|member| format!("{} (`{}`, `{}`, names from {})", member.entry.name, member.entry.id, member.entry.state.display(), member.names_from)).collect::<Vec<_>>().join(", "));
|
||||
let _ = writeln!(out, "- rooms: {}; rounds: {}; repeats: {}; seed: {}; minutes a round: {}; she is in a room's exchange when she spoke there within {} min", plan.rooms.join(", "), plan.rounds, plan.repeats, plan.seed, plan.round_minutes, plan.exchange_minutes);
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ fn within_guards(packet: &Packet, tuning: &Tuning) {
|
|||
let select = &tuning.select;
|
||||
let sections = &packet.sections;
|
||||
assert!(packet.identity().len() <= select.identity_bytes, "identity {}", packet.identity().len());
|
||||
for (name, bytes, guard) in [("outcome", sections.outcome, select.outcome_bytes), ("here", sections.here, select.here_bytes), ("body", sections.body, select.body_bytes), ("people", sections.people, select.people_full * (select.bond_summary_bytes + 80)), ("notes", sections.notes, select.notes_bytes)] {
|
||||
for (name, bytes, guard) in [("outcome", sections.outcome, select.outcome_bytes), ("here", sections.here, select.here_bytes), ("body", sections.body, select.body_bytes), ("people", sections.people, select::people_guard(tuning, packet.forms)), ("notes", sections.notes, select.notes_bytes)] {
|
||||
assert!(bytes <= guard, "{name}: {bytes} bytes over its guard of {guard}:\n{}", packet.context);
|
||||
}
|
||||
let shown: Vec<usize> = [sections.outcome, sections.here, sections.body, sections.people, sections.notes].into_iter().filter(|bytes| *bytes > 0).collect();
|
||||
|
|
@ -1339,12 +1339,16 @@ fn no_section_crowds_another() {
|
|||
for seed in 1..=20 {
|
||||
let packet = packet_of(TurnKind::Chat, &rich, &chat_room(), &History::default(), seed);
|
||||
assert!(packet.context.contains("- pronouns: Libby \u{2014} she/her; Kiko \u{2014} she/her"), "seed {seed}: {}", packet.context);
|
||||
assert!(packet.context.contains("- bond [bond-libby]") && packet.context.contains("- bond [bond-kiko]") && !packet.sections.bound.contains(&"people"), "two bonds at the summary guard fit the people's guard, heading and all (Soul): {}", packet.context);
|
||||
within_guards(&packet, &Tuning::default());
|
||||
}
|
||||
// A bond line that does not fit the people's guard names the person under here and now instead.
|
||||
// Libby's bond carries a kind at its full 80 bytes, so her line's head passes what the guard allows a head.
|
||||
let mut tuning = Tuning::default();
|
||||
tuning.select.bond_summary_bytes = 20;
|
||||
let packet = packet_tuned(TurnKind::Chat, &rich, &chat_room(), &History::default(), 1, &tuning);
|
||||
let mut wide = rich.clone();
|
||||
wide["affect"]["socialBonds"][0]["customRelationshipKind"] = json!("k".repeat(80));
|
||||
let packet = packet_tuned(TurnKind::Chat, &wide, &chat_room(), &History::default(), 1, &tuning);
|
||||
assert!(packet.context.contains("- bond [bond-kiko]") && !packet.context.contains("- bond [bond-libby]") && packet.context.contains("- also here: Libby"), "{}", packet.context);
|
||||
assert_eq!(packet.sections.bound, ["people"], "the people's guard bound, and only it");
|
||||
within_guards(&packet, &tuning);
|
||||
|
|
|
|||
Loading…
Reference in a new issue