Persona anchors: a link quoted in what she heard counts once

Soul's R10 item 3. targets_in_view split what she heard on whitespace, and the
JSON-quoted line gave a second copy of the address ending in `"`, so one link
counted as two and "the link" anchored nothing. A word is now taken as an
address only with the quotes and punctuation around it trimmed (link_of), for
the links in view and for whose link it is.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-11-21 19:49:29 +01:00
commit a71f2a9205
2 changed files with 22 additions and 2 deletions

View file

@ -772,7 +772,7 @@ fn reading(raw: &Value, packet: &Packet, prose: &str, found: &Drafts, wake: Wake
// A link is named too by the possessive of the one who posted it ("Deru's link"), when that person posted exactly
// one link in front of her (Soul's R9).
if let ReadRequest::Web(url) = &request {
let links = |line: &crate::projection::select::Quotable| line.text.split_whitespace().filter(|word| word.starts_with("http://") || word.starts_with("https://")).map(str::to_owned).collect::<BTreeSet<_>>();
let links = |line: &crate::projection::select::Quotable| line.text.split_whitespace().filter_map(link_of).map(str::to_owned).collect::<BTreeSet<_>>();
for line in packet.quotable.iter().filter(|line| links(line).contains(url)) {
let theirs: BTreeSet<String> = packet.quotable.iter().filter(|other| other.sender == line.sender).flat_map(links).collect();
if let (1, Some(first)) = (theirs.len(), line.who.split([',', ' ']).next().filter(|first| !first.is_empty())) {
@ -844,7 +844,7 @@ fn target_words(request: &ReadRequest) -> Vec<String> {
fn targets_in_view(request: &ReadRequest, packet: &Packet, prose: &str, reached: &[String]) -> BTreeSet<String> {
let words = || std::iter::once(prose).chain(reached.iter().map(String::as_str)).flat_map(str::split_whitespace);
match request {
ReadRequest::Web(_) => words().filter(|word| word.starts_with("http://") || word.starts_with("https://")).map(|url| ReadRequest::Web(url.to_owned()).normal()).collect(),
ReadRequest::Web(_) => words().filter_map(link_of).map(|url| ReadRequest::Web(url.to_owned()).normal()).collect(),
ReadRequest::Repo(_) | ReadRequest::Campaign(_) => {
let domain = packet.domain.iter().map(|line| match &line.about {
crate::projection::domain::About::Repo(repo) => ReadRequest::Repo(repo.clone()),
@ -857,6 +857,13 @@ fn targets_in_view(request: &ReadRequest, packet: &Packet, prose: &str, reached:
}
}
/// The web address a word of text is, without the quotes and punctuation around it (Soul's R10: a line quoted in what
/// she heard ends its address with `"`, which made one link two).
fn link_of(word: &str) -> Option<&str> {
let link = word.trim_matches(|c: char| matches!(c, '"' | '\'' | '`' | '<' | '>' | '(' | ')' | '[' | ']' | '{' | '}' | ',' | '.' | ';' | ':' | '!' | '?' | '\u{201c}' | '\u{201d}' | '\u{2018}' | '\u{2019}'));
(link.starts_with("http://") || link.starts_with("https://")).then_some(link)
}
/// Whether a sentence holds a word that only refers to a thing that can be read: "that page", "the diff".
fn refers(sentence: &str) -> bool {
const REFERENCES: [&str; 8] = ["link", "page", "diff", "file", "repo", "commit", "pr", "address"];

View file

@ -1092,3 +1092,16 @@ fn r10_a_promise_whose_needs_this_body_cannot_reach_is_blocked_with_a_gap() {
let words = answered(&packet(), notes, json!({ "say": [{ "draft": 1, "mentions": [], "in_reply_to": null, "promises": [{ "words": "release notes by tomorrow morning", "to": null, "doable": true, "reaffirms": null, "needs": "words_only" }] }], "gaps": [] }));
assert_eq!(words["state"][0]["doable"], true, "{words}");
}
/// Soul's R10 probe (F.2 r8, Aqua): the one link she heard, quoted in a line, is one link, not two (the quoted copy ended
/// in `"`), so "the link" anchors it.
#[test]
fn r10_one_link_heard_in_a_quoted_line_is_one_link() {
let mut aqua = reading_packet();
let said = "Aqua, Nibu: found this on physical modelling of plosives and waveguides, thought of you two https://ccrma.stanford.edu/~jos/pasp/";
aqua.heard = format!("Said to her:\n- Deru in #minds:gamecult.org: {}", serde_json::to_string(said).unwrap());
aqua.bodies = vec![said.to_owned()];
let prose = "The link is close to the stop work I just merged. I'll open it before I say more.";
let read = asked(&aqua, prose, json!({ "kind": "web", "target": "https://ccrma.stanford.edu/~jos/pasp/", "quote": "I'll open it before I say more" }));
assert_eq!(read["read"]["request"], json!({ "kind": "web", "target": "https://ccrma.stanford.edu/~jos/pasp/" }), "{read}");
}