From 9c1e99264b336156d1fd6d00719c350fd5bd36c6 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Tue, 3 Nov 2026 02:10:56 +0100 Subject: [PATCH] Wear: a read that stopped short says so, the organ filters nothing the forge read already decided, and a missing read does not blame the forge wear_facts drops its second copy of the 3-day window and her-own-login filter; a first read with more=true adds one Beyond line; a later read with more and no events still tells; the missing line says only that the read did not answer (the installed units pass no --forge-url, so 'the forge could not be read' was untrue). Co-Authored-By: Claude Opus 5.5 --- crates/mind-body/src/persona.rs | 20 ++++++++++-------- crates/mind-body/src/persona/tests.rs | 29 ++++++++++++++++++++++++++- 2 files changed, 40 insertions(+), 9 deletions(-) diff --git a/crates/mind-body/src/persona.rs b/crates/mind-body/src/persona.rs index 0f9076c..02a5ebf 100644 --- a/crates/mind-body/src/persona.rs +++ b/crates/mind-body/src/persona.rs @@ -2111,7 +2111,7 @@ fn pr_action_word(action: PrAction) -> &'static str { /// logins only, its text quoted and cut at an entry. Nothing a person wrote on the forge is in the read, so none of it can be here. /// `None` when the read found nothing to say. fn repo_notice_line(activity: &RepoActivity, at_unix_ms: u64) -> Option { - if activity.events.is_empty() { + if activity.events.is_empty() && !activity.more { return None; } let entries = repo_entries(&activity.events); @@ -2134,7 +2134,7 @@ fn repo_notice_line(activity: &RepoActivity, at_unix_ms: u64) -> Option text.push_str(&format!(" and {left} more")); } if activity.more { - text.push_str(" and changes beyond what was read"); + text.push_str(if entries.is_empty() { "more than the read reached" } else { " and changes beyond what was read" }); } text.push('.'); Some(format!("notice role=organ at={} text={}\n", at_text(at_unix_ms), quoted(&text))) @@ -2142,14 +2142,14 @@ fn repo_notice_line(activity: &RepoActivity, at_unix_ms: u64) -> Option /// The most the wear section may take of a first line. const WEAR_MAX_BYTES: usize = 1536; -/// How far back others' changes still count as wear. -const WEAR_CHANGED_DAYS: u64 = 3; /// A fact about her machine from the forge. #[derive(Clone, Debug, PartialEq, Eq)] enum WearFact { /// The forge read failed: the other repo facts are absent, not zero. Missing, + /// The read stopped short of the window: others' changes older than what it reached are not shown. + Beyond, Awaiting { repo: String, number: u32, author: String, at: u64 }, Unseen { repo: String }, Changed { repo: String, words: String, at: u64 }, @@ -2160,7 +2160,7 @@ impl WearFact { /// The priority order a full section drops from the end of. fn rank(&self) -> u8 { match self { - Self::Missing => 0, + Self::Missing | Self::Beyond => 0, Self::Awaiting { .. } => 1, Self::Unseen { .. } => 2, Self::Changed { .. } => 3, @@ -2189,17 +2189,20 @@ fn wear_facts(activity: &RepoActivity, repos: &[OrgRepo], instance: &Slug, now_m } } facts.extend(activity.unseen.iter().map(|repo| WearFact::Unseen { repo: plain(&repo.0) })); - let since = now_ms.saturating_sub(WEAR_CHANGED_DAYS * 24 * 3600 * 1000); + // The read's events are others' changes of the last three days: the daemon's forge read is the one place that window and her own + // login are decided (`RepoActivity`), so nothing is filtered again here. let recent: Vec = activity .events .iter() - .filter(|event| event.at >= since && !hers(&event.actor.0)) .map(|event| RepoEvent { repo: OrgRepo(plain(&event.repo.0)), actor: Short(plain(&event.actor.0)), ..event.clone() }) .collect(); for (repo, actor, words) in repo_entries(&recent) { let at = recent.iter().filter(|event| event.repo.0 == repo && event.actor.0 == actor).map(|event| event.at).max().unwrap_or(0); facts.push(WearFact::Changed { repo, words, at }); } + if activity.more { + facts.push(WearFact::Beyond); + } facts } @@ -2221,7 +2224,8 @@ fn render_wear(now_ms: u64, facts: &[WearFact]) -> String { let lines: Vec = ordered .iter() .map(|fact| match fact { - WearFact::Missing => "- repo facts are missing: the forge could not be read.\n".to_owned(), + WearFact::Missing => "- repo facts are missing: the read did not answer.\n".to_owned(), + WearFact::Beyond => "- more changes by others lie further back than the read went and are not shown.\n".to_owned(), WearFact::Awaiting { repo, number, author, at } => format!("- PR awaiting you: {repo}#{number} by {author} {}\n", age_text(now_ms, *at)), WearFact::Unseen { repo } => format!("- a repo the forge read cannot see: {repo}\n"), WearFact::Changed { repo, words, at } => format!("- changed by others: {repo}: {words} {}\n", age_text(now_ms, *at)), diff --git a/crates/mind-body/src/persona/tests.rs b/crates/mind-body/src/persona/tests.rs index a6a82d0..a058121 100644 --- a/crates/mind-body/src/persona/tests.rs +++ b/crates/mind-body/src/persona/tests.rs @@ -4693,7 +4693,7 @@ fn a_failed_first_read_does_not_fail_the_session() { let passed = vec![event(60, "GameCult/Huginn", "nibu", RepoChange::Pushed { commits: 4 })]; let forged = Forged::over(&rig.mind, vec![None, activity(70, passed), activity(80, vec![event(80, "GameCult/Huginn", "void", RepoChange::Pushed { commits: 1 })])]); let lines = live_session(&rig, &forged, PAST_THE_REPO_READ_MS, true, 4); - assert!(lines[0].contains("Where your machine shows wear") && lines[0].contains("- repo facts are missing"), "{}", lines[0]); + assert!(lines[0].contains("Where your machine shows wear") && lines[0].contains("- repo facts are missing: the read did not answer."), "no claim about the forge: {}", lines[0]); assert_eq!(forged.asked.borrow()[..3], [None, None, Some(70)]); let notices = all_notices(&lines); assert_eq!(notices.len(), 1, "the read that took the cursor told nothing: {lines:?}"); @@ -4726,6 +4726,33 @@ fn a_first_line_shows_wear_after_her_responsibilities() { assert!(input.find("What you are responsible for").unwrap() < input.find("Where your machine shows wear").unwrap()); } +/// A read that stopped short is never silent: the first line says changes lie further back than it went, and still shows what it did +/// reach (the organ takes the daemon's events as given, the window and her own login being the forge read's to decide); a later read +/// that stopped short says so even when it found nothing of anyone's. +#[test] +fn a_read_that_stopped_short_says_so_on_the_first_line_and_in_a_notice() { + let rig = stewarding_rig(2); + let now = unix_ms(at(0)); + let read = RepoActivity { + head: 100, + events: vec![RepoEvent { at: now - 5 * 24 * 3_600_000, ..event(100, "GameCult/Huginn", "nibu", RepoChange::Pushed { commits: 2 }) }], + more: true, + open_prs: vec![], + unseen: vec![], + }; + let forged = Forged::over(&rig.mind, vec![Some(read)]); + live_session(&rig, &forged, 1000, false, 1); + let input = input_of(&rig, 0); + let wear = input.split_once("Where your machine shows wear, with ages (facts, not orders):\n").expect("the section").1.split("\n\n").next().unwrap(); + assert!(wear.contains("changed by others: GameCult/Huginn: 2 commits pushed by nibu (5 d)"), "{wear}"); + assert!(wear.contains("further back than the read went"), "{wear}"); + + let nothing_seen = RepoActivity { head: 9, events: vec![], more: true, open_prs: vec![], unseen: vec![] }; + let notice = repo_notice_line(¬hing_seen, 1_700_000_000_000).expect("a truncated read is told"); + assert!(text_of(¬ice).contains("more than the read reached"), "{notice}"); + assert!(repo_notice_line(&RepoActivity { more: false, ..nothing_seen }, 1_700_000_000_000).is_none()); +} + /// The repos the forge is asked about are her stewardships in force and nothing else: a Mind with none asks about none (and so /// prints no section). #[test]