projector: a long tendency is clipped to the room left and reported, not the section emptied (s1.tendencies-vanish-silently)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
f9f85890ac
commit
e365113179
2 changed files with 38 additions and 9 deletions
|
|
@ -67,7 +67,10 @@ const FEELINGS_SHOWN: usize = 2;
|
|||
const FEELING_MIN: f64 = 0.25;
|
||||
/// A standing tendency shows above this value; `TENDENCIES_BYTES` holds the lot, heading included.
|
||||
const TENDENCY_MIN: f64 = 0.3;
|
||||
const TENDENCIES_BYTES: usize = 360;
|
||||
pub(crate) const TENDENCIES_BYTES: usize = 360;
|
||||
/// The fewest bytes a tendency line is clipped to when the room left is short; with less, it is left out. Either way its
|
||||
/// id is reported as clipped.
|
||||
const TENDENCY_LEAST: usize = 48;
|
||||
/// The most a bond line's clauses take of her read of the person and of what last moved the bond: each is left out, with the
|
||||
/// other, when the line with them would pass what the people's guard allows one bond (`bond_allowance`).
|
||||
const READ_SUMMARY_BYTES: usize = 120;
|
||||
|
|
@ -2217,13 +2220,14 @@ fn guarded_outcome(len: usize, line: &dyn Fn(usize, usize) -> String, room: usiz
|
|||
|
||||
/// Her standing tendencies (`affect.socialBiases` over `TENDENCY_MIN`, the strongest first) in words, for her identity: each
|
||||
/// by its name, how strong it is, its summary and its behavioural pull, under a stance's privacy (`scope`), the lot within
|
||||
/// `TENDENCIES_BYTES`, a line that would pass it left out whole. With the words of those shown as known privately.
|
||||
fn tendencies(inputs: &Inputs, present: &BTreeSet<String>) -> (String, Vec<String>) {
|
||||
/// `TENDENCIES_BYTES`, a line that would pass it clipped to the room left (`TENDENCY_LEAST`), its id reported as clipped.
|
||||
/// With the words of those shown as known privately.
|
||||
fn tendencies(inputs: &Inputs, present: &BTreeSet<String>) -> (String, Vec<String>, Vec<String>) {
|
||||
let her = forms(inputs.state);
|
||||
let heading = format!("{} standing tendencies:", capitalized(her.poss));
|
||||
let mut biases: Vec<(f64, &Value)> = items(inputs.state, &["affect", "socialBiases"]).iter().filter(|bias| live(bias)).filter_map(|bias| number(bias, &["value"]).filter(|value| *value > TENDENCY_MIN).map(|value| (value, bias))).collect();
|
||||
biases.sort_by(|a, b| b.0.total_cmp(&a.0));
|
||||
let (mut lines, mut private, mut used) = (Vec::new(), Vec::new(), heading.len());
|
||||
let (mut lines, mut private, mut clipped, mut used) = (Vec::new(), Vec::new(), Vec::new(), heading.len());
|
||||
for (value, bias) in biases {
|
||||
let scope = scope(inputs, concerns(&inputs.people, bias).as_ref(), present);
|
||||
let said = [text(bias, &["summary"]), text(bias, &["behavioralPull"])].into_iter().filter(|part| !part.is_empty()).map(|part| capitalized(&ended(&one_line(part)))).collect::<Vec<_>>().join(" ");
|
||||
|
|
@ -2234,9 +2238,16 @@ fn tendencies(inputs: &Inputs, present: &BTreeSet<String>) -> (String, Vec<Strin
|
|||
};
|
||||
let name = clip(&one_line(text(bias, &["name"])), NAME_BYTES);
|
||||
let line = if said.is_empty() { format!("- {name}, {}", strength_words(value)) } else { format!("- {name}, {}: {said}", strength_words(value)) };
|
||||
if used + 1 + line.len() > TENDENCIES_BYTES {
|
||||
break;
|
||||
}
|
||||
let room = TENDENCIES_BYTES.saturating_sub(used + 1);
|
||||
let line = if line.len() <= room {
|
||||
line
|
||||
} else {
|
||||
clipped.push(text(bias, &["id"]).to_owned());
|
||||
if room < TENDENCY_LEAST {
|
||||
continue;
|
||||
}
|
||||
clip(&line, room)
|
||||
};
|
||||
used += 1 + line.len();
|
||||
if scope == Scope::Framed {
|
||||
private.push(one_line(&said));
|
||||
|
|
@ -2245,7 +2256,7 @@ fn tendencies(inputs: &Inputs, present: &BTreeSet<String>) -> (String, Vec<Strin
|
|||
}
|
||||
(if lines.is_empty() { String::new() } else { format!("{heading}
|
||||
{}", lines.join("
|
||||
")) }, private)
|
||||
")) }, private, clipped)
|
||||
}
|
||||
|
||||
pub(crate) fn select(inputs: &Inputs, tuning: &Tuning) -> Packet {
|
||||
|
|
@ -2507,7 +2518,8 @@ pub(crate) fn select(inputs: &Inputs, tuning: &Tuning) -> Packet {
|
|||
sections.domain = domain_view.len();
|
||||
let now_ms = u64::try_from(inputs.now.timestamp_millis()).unwrap_or_default();
|
||||
let readers = here.filter(|room| room_kind(inputs, room) == RoomKind::Direct).map(|room| readers(inputs, room)).unwrap_or_default();
|
||||
let (tendencies, tendencies_private) = tendencies(inputs, &present_ids);
|
||||
let (tendencies, tendencies_private, tendencies_clipped) = tendencies(inputs, &present_ids);
|
||||
private.extend(tendencies_private);
|
||||
clipped.extend(tendencies_clipped);
|
||||
Packet { kind: inputs.kind, seed: inputs.seed, lens, name, voice, tendencies, context: context.render(), sections, stimulus, heard, bridged, elsewhere, elsewhere_shown, overflow, present: present_names, ids, selected, forms: her, people: people_in_view(inputs, tuning).iter().map(|line| (name_of(line, inputs), line.sender.clone())).collect(), affordances: inputs.affordances.to_vec(), room: turn_room(inputs).map(str::to_owned), room_kind: turn_room(inputs).map_or(RoomKind::Public, |room| room_kind(inputs, room)), readers, bodies, private, clipped, amendable, quotable, domain, domain_shown, in_view, now_ms, own_sender: inputs.people.own_sender.to_owned(), already_read, refused_reads, arrival, speaking: conversation.speaking.unwrap_or_default(), unshown, memories }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -119,6 +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());
|
||||
assert!(packet.tendencies.len() <= select::TENDENCIES_BYTES, "tendencies {}", packet.tendencies.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_guard(tuning, packet.forms)), ("domain", sections.domain, select.domain_bytes), ("notes", sections.notes, select.notes_bytes)] {
|
||||
assert!(bytes <= guard, "{name}: {bytes} bytes over its guard of {guard}:\n{}", packet.context);
|
||||
}
|
||||
|
|
@ -471,6 +472,22 @@ fn t_s1_bias_in_identity() {
|
|||
assert!(chat_with(&tended).tendencies.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_long_tendency_is_clipped_not_the_section_emptied() {
|
||||
let mut tended = state();
|
||||
let long = "She holds the line when anyone pushes on the trace, and keeps holding it. ".repeat(8);
|
||||
tended["affect"]["socialBiases"] = json!([
|
||||
{ "id": "b-long", "name": "holds the line", "value": 0.9, "summary": long, "behavioralPull": "holds", "status": "active" },
|
||||
{ "id": "b-defer", "name": "defers to the operator", "value": 0.6, "summary": "She yields when the operator rules.", "behavioralPull": "yields", "status": "active" },
|
||||
]);
|
||||
let packet = chat_with(&tended);
|
||||
assert!(packet.tendencies.starts_with("Her standing tendencies:\n- holds the line, "), "{}", packet.tendencies);
|
||||
assert!(packet.tendencies.contains('…'), "{}", packet.tendencies);
|
||||
assert!(packet.tendencies.len() <= select::TENDENCIES_BYTES, "{}", packet.tendencies.len());
|
||||
assert!(packet.clipped.contains(&"b-long".to_owned()), "{:?}", packet.clipped);
|
||||
within_guards(&packet, &Tuning::default());
|
||||
}
|
||||
|
||||
const DERU: &str = "@deru:gamecult.org";
|
||||
const DM_DERU: &str = "!dm-deru:gamecult.org";
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue