Persona cap: the draft boundary is decided on the raw text at the word cut, and a draft the cut leaves out, before it or after it, is told as cut by the length limit, never dropped silently (Soul's R6 P1, P3)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
3df69caa51
commit
d1ad7c6fb4
3 changed files with 52 additions and 13 deletions
|
|
@ -568,3 +568,26 @@ fn r5_the_cap_never_cuts_inside_a_draft() {
|
|||
let said = report["renders"][0]["interpreter"]["said"][0]["text"].as_str().unwrap_or_default().to_owned();
|
||||
assert!(said.starts_with("Meta, the list:") && said.ends_with("that is all."), "{}", report["renders"][0]["interpreter"]);
|
||||
}
|
||||
|
||||
/// Soul's R6 P1 and P3: the draft boundary is decided on the raw text at the word cut. A draft opening after a sentence
|
||||
/// end past 60% of the budget, its first sentence running past the budget, is kept whole to its closing mark; a draft that
|
||||
/// opens after the budget is not dropped silently but told as cut by the length limit.
|
||||
#[test]
|
||||
fn r6_no_draft_is_dropped_silently_at_the_cap() {
|
||||
let words = crate::projection::tuning::Tuning::default().persona.words;
|
||||
let thought: String = (1..=150).map(|n| format!("t{n} ")).collect::<String>().trim_end().to_owned() + ".";
|
||||
let draft: String = (1..=62).map(|n| format!("w{n} ")).collect();
|
||||
let late = format!("{thought} <typed>Meta, {draft}done</typed>");
|
||||
let capped = crate::projection::narrate::cap_prose(&late, words);
|
||||
assert!(capped.text.ends_with("done</typed>") && capped.cut_draft.is_none(), "kept whole to its closing mark: {capped:?}");
|
||||
let after: String = (1..=190).map(|n| format!("t{n} ")).collect();
|
||||
let beyond = crate::projection::narrate::cap_prose(&format!("{after}<typed>Meta, later words.</typed>"), words);
|
||||
assert_eq!((beyond.text.contains("<typed>"), beyond.cut_draft.as_deref()), (false, Some("Meta, later words.")), "{beyond:?}");
|
||||
// Through the turn: she is told the length limit cut it.
|
||||
let fixture = room("operator-warm.toml");
|
||||
let reply = format!("{after}<typed>Meta, later words.</typed>");
|
||||
let model = Scripted::new(move |_| reply.clone());
|
||||
let report = wake_of(&fixture, &model);
|
||||
let told = crate::projection::outcome::outcome_of(&json!({ "interpreter": report["renders"][0]["interpreter"], "posted": [] })).unwrap().lines(crate::projection::select::forms(&control()));
|
||||
assert!(told.iter().any(|line| line.contains("the length limit cut it before he finished writing it") && line.contains("Meta, later words.")), "{told:?}");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -401,16 +401,29 @@ pub(crate) struct Capped {
|
|||
|
||||
pub(crate) fn cap_prose(text: &str, max: usize) -> Capped {
|
||||
let text = text.trim();
|
||||
let capped = cap_words(text, max);
|
||||
let cut = capped.len() < text.len();
|
||||
let open = capped.rfind(DRAFT_OPEN).filter(|open| !capped[*open..].contains(DRAFT_CLOSE));
|
||||
let Some(open) = open else { return Capped { text: capped, cut, cut_draft: None } };
|
||||
let close = text[open..].find(DRAFT_CLOSE).map(|at| open + at + DRAFT_CLOSE.len());
|
||||
if let Some(close) = close.filter(|close| words(&text[..*close]) <= max.saturating_mul(2)) {
|
||||
return Capped { text: text[..close].to_owned(), cut: close < text.len(), cut_draft: None };
|
||||
}
|
||||
let partial = capped[open + DRAFT_OPEN.len()..].trim();
|
||||
Capped { text: text[..open].trim_end().to_owned(), cut: true, cut_draft: (!partial.is_empty()).then(|| partial.to_owned()) }
|
||||
let Some(&over) = word_starts(text).get(max) else { return Capped { text: text.to_owned(), cut: false, cut_draft: None } };
|
||||
// The draft boundary is decided on the raw text at the word cut (Soul's R6 P1), before any sentence back-off.
|
||||
let open_at_cut = text[..over].rfind(DRAFT_OPEN).filter(|open| !text[*open..over].contains(DRAFT_CLOSE));
|
||||
let end = match open_at_cut {
|
||||
Some(open) => text[open..]
|
||||
.find(DRAFT_CLOSE)
|
||||
.map(|at| open + at + DRAFT_CLOSE.len())
|
||||
.filter(|close| words(&text[..*close]) <= max.saturating_mul(2))
|
||||
.unwrap_or_else(|| text[..open].trim_end().len()),
|
||||
// Outside a draft: back off to a sentence end as `cap_words` does, never past a draft that opens before the cut.
|
||||
None => {
|
||||
let within = text[..over].trim_end();
|
||||
match last_sentence_end(within) {
|
||||
Some(end) if words(&within[..end]) as f64 >= SENTENCE_CUT_FLOOR * max as f64 && !within[end..].contains(DRAFT_OPEN) => end,
|
||||
_ => within.len(),
|
||||
}
|
||||
}
|
||||
};
|
||||
// The first draft the cut leaves out, opened before the cut or after it: never dropped silently, but told to her as cut
|
||||
// by the length limit, its words up to her budget.
|
||||
let rest = &text[end..];
|
||||
let cut_draft = rest.find(DRAFT_OPEN).map(|open| cap_words(rest[open + DRAFT_OPEN.len()..].split(DRAFT_CLOSE).next().unwrap_or_default(), max)).filter(|words| !words.is_empty());
|
||||
Capped { text: text[..end].trim_end().to_owned(), cut: end < text.len(), cut_draft }
|
||||
}
|
||||
|
||||
/// The byte just past the last sentence end in `text`: a `.`, `!`, `?` or `…` with any closing quotes or brackets after
|
||||
|
|
|
|||
|
|
@ -62,7 +62,8 @@ enum Part {
|
|||
Promise { room: String, text: String },
|
||||
Refused { reason: Refusal, room: Option<String>, text: String },
|
||||
Gap { kind: GapKind, room: Option<String>, quote: Quote },
|
||||
Unfinished { room: Option<String>, text: String },
|
||||
/// A draft she did not finish: the turn ended first, or the length limit cut it (`by_limit`, Soul's R6).
|
||||
Unfinished { room: Option<String>, text: String, by_limit: bool },
|
||||
/// An edited receipt with no refusal: her words were added after a line of hers; `promise` when a
|
||||
/// `missing_affordance` gap names the addition's draft (map 16.21).
|
||||
Amended { room: String, added: String, promise: bool },
|
||||
|
|
@ -252,7 +253,8 @@ pub(crate) fn outcome_of(record: &Value) -> Option<Outcome> {
|
|||
}
|
||||
}
|
||||
if let Some(text) = words(&decision["unfinished"]) {
|
||||
outcome.parts.push(Part::Unfinished { room: room.clone(), text });
|
||||
let by_limit = decision["cut_by_cap"].as_array().is_some_and(|cut| !cut.is_empty());
|
||||
outcome.parts.push(Part::Unfinished { room: room.clone(), text, by_limit });
|
||||
}
|
||||
// What the commit did with her promises (`commit::apply`): each close it applied, and each close it refused for a
|
||||
// reason she can be told. An open is told by the promise's own section from her next packet on.
|
||||
|
|
@ -364,7 +366,8 @@ impl Part {
|
|||
Self::Gap { kind: GapKind::Elsewhere, quote, .. } => after(format!("{cap_subj} meant this for another room or another time, and nothing carries it there; it arrives only if {subj} send{s} it there"), quote),
|
||||
Self::Gap { kind: GapKind::MissingAffordance, quote, .. } => format!(" {cap_subj} reached for something {subj} {has} no way to do from here, now or later, and it will not happen by itself. {} That {subj} wanted it is kept in {poss} record; no one has taken it up.", shown(quote)),
|
||||
Self::Gap { quote, .. } => format!(" {cap_subj} meant to say something and wrote no words to send. {}", shown(quote)),
|
||||
Self::Unfinished { text, .. } => format!(" the turn ended before {subj} finished writing it. {}", shown(&Quote::Wrote(text.clone()))),
|
||||
Self::Unfinished { text, by_limit: false, .. } => format!(" the turn ended before {subj} finished writing it. {}", shown(&Quote::Wrote(text.clone()))),
|
||||
Self::Unfinished { text, by_limit: true, .. } => format!(" the length limit cut it before {subj} finished writing it. {}", shown(&Quote::Wrote(text.clone()))),
|
||||
Self::NotAmended { refusal: None, added, .. } => format!(" the line {subj} meant to add to is not one {subj} can add to here. {}", shown(&Quote::Wrote(added.clone()))),
|
||||
Self::NotAmended { refusal: Some(refusal), added, .. } => {
|
||||
let why = match refusal {
|
||||
|
|
|
|||
Loading…
Reference in a new issue