Persona live organ: one-turn, drain, wake-humans-pace, turn memory (squash of hands/persona-live-drain) #83
3 changed files with 27 additions and 19 deletions
Persona T7 fix: recorded root and mind reads say titles-only as live does; a rulings list marks only the rows that lack text (Soul s1)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
commit
70417d2de2
|
|
@ -451,12 +451,19 @@ impl ReadSource for ReadFixture {
|
|||
}
|
||||
match self.0.iter().find(|entry| request_of(entry).is_some_and(|recorded| recorded.normal() == key)) {
|
||||
Some(ReadEntry { refused: Some(why), .. }) => Err(*why),
|
||||
Some(ReadEntry { text: Some(text), .. }) => Ok(text.clone()),
|
||||
Some(entry @ ReadEntry { text: Some(text), .. }) => Ok(if lists_titles(entry) && !text.ends_with(TITLES_ONLY) { format!("{text}
|
||||
{TITLES_ONLY}") } else { text.clone() }),
|
||||
_ => Err(ReadFailure::NotFound),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether a recorded read is one whose live answer is titles only, so the simulator says what live says: a mind recall
|
||||
/// (headers), and a repo's root (its recent pull requests by title).
|
||||
fn lists_titles(entry: &ReadEntry) -> bool {
|
||||
entry.kind == "mind" || (entry.kind == "repo" && entry.target.strip_prefix("GameCult/").is_some_and(|rest| !rest.contains(['/', '#', '@', '?'])))
|
||||
}
|
||||
|
||||
/// A search of a repo by its recorded pull requests and issues: each whose title (first line) or body (the rest) the
|
||||
/// search finds (`search_finds`), as `- #n title`; none, and nothing was found.
|
||||
fn fixture_search(entries: &[ReadEntry], request: &ReadRequest) -> Option<String> {
|
||||
|
|
@ -552,15 +559,10 @@ impl LiveReads {
|
|||
pub(crate) const TITLES_ONLY: &str = "Only titles were returned here; the contents were not read.";
|
||||
|
||||
/// What a campaign read shows, live and in the simulator alike (map 16.25.8): each ruling, newest first, at most
|
||||
/// `RULINGS_SHOWN`, as `- {title}: {ruling}`, or `- {title}` when no ruling text is held. None is not found.
|
||||
/// `RULINGS_SHOWN`, as `- {title}: {ruling}`, or `- {title} (title only: ...)` when no ruling text is held. None is not found.
|
||||
pub(crate) fn rulings_text<'a>(rulings: impl IntoIterator<Item = (&'a str, Option<&'a str>)>) -> Result<String, ReadFailure> {
|
||||
let rulings: Vec<(&str, Option<&str>)> = rulings.into_iter().take(RULINGS_SHOWN as usize).collect();
|
||||
let shown: Vec<String> = rulings.iter().map(|(title, ruling)| ruling.map_or_else(|| format!("- {title}"), |ruling| format!("- {title}: {ruling}"))).collect();
|
||||
if shown.is_empty() {
|
||||
return Err(ReadFailure::NotFound);
|
||||
}
|
||||
let titled = rulings.iter().any(|(_, ruling)| ruling.is_none());
|
||||
Ok(if titled { format!("{}\n{TITLES_ONLY}", shown.join("\n")) } else { shown.join("\n") })
|
||||
let shown: Vec<String> = rulings.into_iter().take(RULINGS_SHOWN as usize).map(|(title, ruling)| ruling.map_or_else(|| format!("- {title} (title only: the ruling was not read)"), |ruling| format!("- {title}: {ruling}"))).collect();
|
||||
if shown.is_empty() { Err(ReadFailure::NotFound) } else { Ok(shown.join("\n")) }
|
||||
}
|
||||
|
||||
fn forge_text(forge: &dyn ForgeGet, path: &str) -> Result<String, ReadFailure> {
|
||||
|
|
|
|||
|
|
@ -198,18 +198,26 @@ Prove both." }])).unwrap();
|
|||
}
|
||||
|
||||
/// R19, Heimdall: he described a pull request's contents after a read that returned only titles. Every read whose result
|
||||
/// is titles says so, and a read that returns the text does not.
|
||||
/// is titles says so, and a read that returns the text does not. The recorded reads of a simulation say what live says
|
||||
/// (Soul s1, titles-only-gaps), and a rulings list marks only the rows that lack text (mixed-rulings-say-titles-only).
|
||||
#[test]
|
||||
fn a_read_that_returns_only_titles_says_the_contents_were_not_read() {
|
||||
let fixture: ReadFixture = serde_json::from_value(serde_json::json!([
|
||||
{ "kind": "repo", "target": "GameCult/Bifrost#87", "text": "#87 Merge pages and notices\nThe body." }
|
||||
{ "kind": "repo", "target": "GameCult/Bifrost#87", "text": "#87 Merge pages and notices\nThe body." },
|
||||
{ "kind": "repo", "target": "GameCult/Bifrost", "text": "A door.\n\nRecent pull requests, merged and closed:\n- #87 Merge pages and notices (merged, opened by heimdall)" },
|
||||
{ "kind": "repo", "target": "GameCult/Bifrost/README.md", "text": "The readme." },
|
||||
{ "kind": "mind", "target": "passkey cooling-off", "text": "- A ruling title" },
|
||||
{ "kind": "web", "target": "http://example.org/", "text": "A page." }
|
||||
]))
|
||||
.unwrap();
|
||||
let search = fixture.read(&ReadRequest::Repo("GameCult/Bifrost?q=merge pages".into()), Utc::now()).unwrap();
|
||||
let read = |request: ReadRequest| fixture.read(&request, Utc::now()).unwrap();
|
||||
let search = read(ReadRequest::Repo("GameCult/Bifrost?q=merge pages".into()));
|
||||
assert!(search.ends_with(TITLES_ONLY) && TITLES_ONLY.contains("contents were not read"), "{search}");
|
||||
let opened = fixture.read(&ReadRequest::Repo("GameCult/Bifrost#87".into()), Utc::now()).unwrap();
|
||||
assert!(!opened.contains(TITLES_ONLY), "a read of the text is not titles only: {opened}");
|
||||
assert!(read(ReadRequest::Repo("GameCult/Bifrost".into())).ends_with(TITLES_ONLY));
|
||||
assert!(read(ReadRequest::Mind("passkey cooling-off".into())).ends_with(TITLES_ONLY));
|
||||
for whole in [read(ReadRequest::Repo("GameCult/Bifrost#87".into())), read(ReadRequest::Repo("GameCult/Bifrost/README.md".into())), read(ReadRequest::Web("http://example.org/".into()))] {
|
||||
assert!(!whole.contains(TITLES_ONLY), "a read of the text is not titles only: {whole}");
|
||||
}
|
||||
let named = rulings_text([("Ruling one", None), ("Ruling two", Some("The text."))]).unwrap();
|
||||
assert!(named.ends_with(TITLES_ONLY), "{named}");
|
||||
assert!(!rulings_text([("Ruling two", Some("The text."))]).unwrap().contains(TITLES_ONLY));
|
||||
assert_eq!(named, "- Ruling one (title only: the ruling was not read)\n- Ruling two: The text.");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ use crate::projection::harness::tests::{Replaying, Scripted, control};
|
|||
use serde_json::json;
|
||||
use crate::projection::narrate::PROJECTOR_OPENING;
|
||||
use crate::projection::{Answer, Failed, Model, Spent};
|
||||
use crate::projection::read::TITLES_ONLY;
|
||||
|
||||
const TOBIAH: &str = "@eureka:gamecult.org";
|
||||
const LIBBY: &str = "@libby:gamecult.org";
|
||||
|
|
@ -801,8 +800,7 @@ who = "her"
|
|||
let since = DateTime::parse_from_rfc3339("2026-11-19T15:00:00Z").unwrap().with_timezone(&Utc);
|
||||
let reads = CastReads { recorded: &recorded, domain: Some(&domain) };
|
||||
let read = |slug: &str| reads.read(&ReadRequest::Campaign(slug.into()), since);
|
||||
assert_eq!(read("heimdall-body"), Ok(format!("- Account merge ships dark by default: notices and the merge pages stay off until the operator turns them on
|
||||
{TITLES_ONLY}")));
|
||||
assert_eq!(read("heimdall-body"), Ok("- Account merge ships dark by default: notices and the merge pages stay off until the operator turns them on (title only: the ruling was not read)".to_owned()));
|
||||
assert_eq!(read("nowhere"), Err(ReadFailure::NotFound));
|
||||
let mut worded = domain.clone();
|
||||
worded.campaigns[0].rulings[0].ruling = Some("dark until the operator sets AccountMerge__Enabled".into());
|
||||
|
|
|
|||
Loading…
Reference in a new issue