diff --git a/crates/mind-body/README.md b/crates/mind-body/README.md index 540da22..2c3ce78 100644 --- a/crates/mind-body/README.md +++ b/crates/mind-body/README.md @@ -29,3 +29,16 @@ Mutation testing of the actuator, with the globs that reach the library and the binary: `cargo mutants -p mind-body -f "**/src/self_run.rs" -f "**/src/bin/mind-self-run.rs"`. The binary's mutants are killed only by the lane above. + +## Before the live switch + +The Persona turn's reads run live only once the heartbeat switch lands. Simulations and harness runs read fixtures +(`[domain]`, `[cast.domain]`) and need none of this. One gamecult-ops change carries all of it, ruled by Self on +2026-11-20: + +- **The forge, for persona uids.** `mind_fence`'s `persona` chain rejects every local TCP port but 4110, 80 and 443, so + a Persona cannot reach the forge's loopback API (`http://127.0.0.1:3310`), and port 80 only redirects to HTTPS. Her + domain digest and her `repo` reads need an accept for tcp 127.0.0.1:3310 from `@persona_uids`. Until then a live read + fails whole and the packet leaves the section out, as designed. mind-body carries no TLS; the forge is read on loopback. +- **Her read door.** Each Persona reaches only her own door (`huginn` set: uid . port). The digest and her reads use it + as `HUGINN_ENDPOINT`; nothing to change. diff --git a/crates/mind-body/src/projection.rs b/crates/mind-body/src/projection.rs index ba6bfac..4955ec1 100644 --- a/crates/mind-body/src/projection.rs +++ b/crates/mind-body/src/projection.rs @@ -244,14 +244,14 @@ fn own_addressee(addressing: Option<&dyn HeartbeatView>, own_sender: &str, publi /// What moved in her domain since her last wake, as lines, and what the read did: from when, how many lines, the repos it /// skipped (archived, not found, moved), or why it failed. A failed read shows her nothing and says so here; it is never /// rendered as nothing having moved (map 16.22.2). -fn read_domain(source: Option<&dyn DomainSource>, last_wake: Option>, now: DateTime) -> (Vec, Value) { +fn read_domain(source: Option<&dyn DomainSource>, last_wake: Option>, now: DateTime, names: &domain::Names) -> (Vec, Value) { let since = domain::since(last_wake, now); let Some(source) = source else { return (Vec::new(), json!({ "read": false, "why": "no domain source is configured" })); }; match source.read(since, now) { Ok(facts) => { - let lines = domain::lines(&facts, since, now); + let lines = domain::lines(&facts, since, now, names); let report = json!({ "read": true, "since": since.to_rfc3339(), "lines": lines.len(), "skipped": facts.skipped }); (lines, report) } @@ -433,7 +433,8 @@ pub fn project(organs: &Organs, request: &Request, now: DateTime) -> Result // until then only what the caller carried from earlier turns of its own. let history = History { recent: request.recent.clone(), last: request.last_outcome.as_ref().and_then(outcome::outcome_of), ..History::default() }; let people = People { operators: &request.operators, minds: &request.minds, own_sender: &request.own_sender }; - let (domain_lines, domain_report) = read_domain(organs.domain, request.last_wake, now); + let names = domain::Names::of(&state, &people, &request.instance); + let (domain_lines, domain_report) = read_domain(organs.domain, request.last_wake, now, &names); let inputs = Inputs { kind: request.kind, state: &state, room: &room, history: &history, observation: None, people, now, seed: request.seed, affordances: &[], domain: &domain_lines }; let can = affordances(organs, room_report["read"] == true, turn_room(&inputs), request.through); let inputs = Inputs { affordances: &can, ..inputs }; diff --git a/crates/mind-body/src/projection/domain.rs b/crates/mind-body/src/projection/domain.rs index 24dd310..6cda6b2 100644 --- a/crates/mind-body/src/projection/domain.rs +++ b/crates/mind-body/src/projection/domain.rs @@ -9,9 +9,11 @@ //! - The forge gives each stewarded repo's pull requests: title, opening account, when opened and when merged. A commit //! is never read: every agent commit is the operator's account, so its author says nothing about who worked. //! -//! Past tense only: merged and ruled titles are shown, because they happened. What is still open (a pull request, a -//! follow-up) is a count, never a title, so the section is never a task queue. "Who" is a pull request's opener and an -//! admission's provenance. +//! Past tense only, and meaning over counts: merged and ruled titles are shown, because they happened, at most two a line +//! and the rest counted. What is still open (a pull request, a follow-up) is a count, never a title, so the section is +//! never a task queue. Cut reports and verdicts are never counted: a digest of the pipeline's machinery is the status +//! talk the Persona-only turn removed. "Who" is people and Minds, never a faculty: a pull request's opener, and for an +//! admission the Mind or person that ran it, read from its provenance (`Who`); when that cannot be told, no one is named. //! //! A stewarded repo that is archived, that the forge does not find, or that it answers with a redirect is skipped and //! reported, never shown to her. Any other failed read fails the whole read: `project` leaves the section out and its @@ -30,7 +32,7 @@ use huginn_mind::{Faculty, HuginnMindRequest, HuginnMindResponse, PipelineDocume use serde::{Deserialize, Serialize}; use serde_json::Value; -use super::select::{clip, spoken}; +use super::select::{People, capitalized, clip, spoken}; use crate::queue::{any_of, in_force, of_kind}; /// The most lines the section shows, a counted line included (map 16.22.2). @@ -97,16 +99,19 @@ pub(crate) struct Pull { pub(crate) open: bool, } -/// A campaign held in her mind and what was admitted under it in the window. +/// A campaign held in her mind, what was admitted under it in the window, and how many of its follow-ups stand open now. #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] #[serde(deny_unknown_fields)] pub(crate) struct CampaignFacts { pub(crate) slug: String, #[serde(default)] pub(crate) events: Vec, + /// Its follow-ups in force now: told as "N things still open", never by name. + #[serde(default)] + pub(crate) open: usize, } -/// One admission under a campaign: what it was, when, a ruling's title, and who admitted it, in words. +/// One admission under a campaign: what it was, when, a ruling's title, and who ran it. #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] #[serde(deny_unknown_fields)] pub(crate) struct Admitted { @@ -115,17 +120,54 @@ pub(crate) struct Admitted { /// A ruling's title; nothing else carries one here, so no open item's words can reach her. #[serde(default)] pub(crate) title: Option, - pub(crate) who: String, + #[serde(default)] + pub(crate) who: Who, } +/// What an admission was. `Worked` is a cut report or a verdict: it says who worked on the campaign and is never counted. #[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "snake_case")] pub(crate) enum Moved { Ruled, FollowUpOpened, FollowUpClosed, - CutReported, - Verdict, + Worked, +} + +/// Who ran an admission, as people and Minds: her own organs (her Persona turn, her Self runs and what they dispatch), +/// the operator driving a session on her behalf, or the operator; never a faculty. `Unknown` names no one. +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] +#[serde(rename_all = "snake_case")] +pub(crate) enum Who { + #[default] + Unknown, + Her, + OperatorWithHer, + Operator, +} + +/// The names a line calls people by: hers, and the operator's as her state holds the operator. +#[derive(Clone, Debug, PartialEq, Eq)] +pub(crate) struct Names { + pub(crate) her: String, + pub(crate) operator: String, +} + +impl Names { + /// Her public name (her instance, capitalized, when the state has none), and the operator by the label of her live + /// bond with the operator ("the operator" when she holds none). + pub(crate) fn of(state: &Value, people: &People, instance: &str) -> Self { + let her = state["publicName"].as_str().map(str::trim).filter(|name| !name.is_empty()).map_or_else(|| capitalized(instance), str::to_owned); + let operator = state["affect"]["socialBonds"] + .as_array() + .into_iter() + .flatten() + .filter(|bond| !matches!(bond["status"].as_str(), Some("retired" | "cooled" | "resolved"))) + .find(|bond| bond["object"]["id"].as_str().is_some_and(|id| people.person_of(id) == "operator")) + .and_then(|bond| bond["object"]["label"].as_str().map(str::trim).filter(|label| !label.is_empty()).map(str::to_owned)) + .unwrap_or_else(|| "the operator".to_owned()); + Self { her, operator } + } } /// A stewarded repo the read skipped. @@ -247,18 +289,23 @@ fn root(item: &PipelineDocumentSummary) -> &str { item.id.id.0.split(':').next().unwrap_or_default() } -/// Who admitted it, in words: the faculty, a Self session, the operator, or a member or steward by name. Never a git -/// author. -fn who(provenance: &PipelineProvenance) -> String { - match provenance.faculty { - Faculty::SelfFaculty => "a Self session".to_owned(), - Faculty::Imagination => "Imagination".to_owned(), - Faculty::Hands => "Hands".to_owned(), - Faculty::Soul => "Soul".to_owned(), - Faculty::Life => "Life".to_owned(), - Faculty::Eyes => "Eyes".to_owned(), - Faculty::Operator => "the operator".to_owned(), - Faculty::Member | Faculty::Steward => provenance.agent.0.clone(), +/// Who ran an admission in her mind, from its provenance, never its faculty: the operator's own admission; an agent of her +/// own organs (`mind-persona`, `mind-self-run` and the runs it dispatches: every `mind-` agent), which is her; an agent or +/// a session named for her (`nibu-hands`, `nibu-self-2026-11-17`: the per-Mind sessions the operator runs for her), which +/// is the operator with her. A replayed admission, and any other agent, names no one. Never a git author. +fn who(provenance: &PipelineProvenance, her: &str) -> Who { + let (agent, session) = (provenance.agent.0.as_str(), provenance.session.0.as_str()); + let named = |text: &str| text.strip_prefix(her).is_some_and(|rest| rest.starts_with('-')); + if provenance.imported_from.is_some() { + Who::Unknown + } else if provenance.faculty == Faculty::Operator { + Who::Operator + } else if agent.starts_with("mind-") { + Who::Her + } else if named(agent) || named(session) { + Who::OperatorWithHer + } else { + Who::Unknown } } @@ -276,17 +323,21 @@ pub(crate) fn read(ask: &Ask, her: &str, forge: &dyn ForgeGet, since: DateTime = all(ask, &in_force(of_kind(PipelineKind::Campaign)))?.iter().map(|item| root(item).to_owned()).collect::>().into_iter().collect(); - let mut campaigns: Vec = slugs.iter().map(|slug| CampaignFacts { slug: slug.clone(), events: Vec::new() }).collect(); + let mut campaigns: Vec = slugs.iter().map(|slug| CampaignFacts { slug: slug.clone(), events: Vec::new(), open: 0 }).collect(); if !slugs.is_empty() { let kinds = [PipelineKind::Ruling, PipelineKind::FollowUp, PipelineKind::CutReport, PipelineKind::Verdict, PipelineKind::Resolution]; let selection = Selection { schemas: Some(kinds.iter().map(|kind| kind.type_id().to_owned()).collect()), ..Selection::default() }; let roots: Vec<&str> = slugs.iter().map(String::as_str).collect(); + for item in all(ask, &any_of(in_force(of_kind(PipelineKind::FollowUp)), "root", &roots))? { + if let Some(campaign) = campaigns.iter_mut().find(|campaign| campaign.slug == root(&item)) { + campaign.open += 1; + } + } for item in newest(ask, &any_of(selection, "root", &roots), since)? { let what = match &item.facts { PipelineFacts::Ruling { .. } => Moved::Ruled, PipelineFacts::FollowUp { .. } => Moved::FollowUpOpened, - PipelineFacts::CutReport { .. } => Moved::CutReported, - PipelineFacts::Verdict { .. } => Moved::Verdict, + PipelineFacts::CutReport { .. } | PipelineFacts::Verdict { .. } => Moved::Worked, PipelineFacts::Resolution { subject, .. } if subject.kind == PipelineKind::FollowUp => Moved::FollowUpClosed, _ => continue, }; @@ -296,7 +347,7 @@ pub(crate) fn read(ask: &Ask, her: &str, forge: &dyn ForgeGet, since: DateTime, since: DateTime, now: DateTime) -> bool { since <= at && at <= now } +/// Who worked on a campaign, in words, from who ran what moved: "Meta and Nibu" where the operator drove, "Nibu's own +/// sessions" where only hers ran, "Meta" alone; none when no one can be told. +fn workers(events: &[&Admitted], names: &Names) -> Option { + let has = |who: Who| events.iter().any(|event| event.who == who); + let operator = has(Who::Operator) || has(Who::OperatorWithHer); + let her = has(Who::Her) || has(Who::OperatorWithHer); + match (operator, her) { + (true, true) => Some(format!("{} and {}", names.operator, names.her)), + (true, false) => Some(names.operator.clone()), + (false, true) => Some(format!("{}'s own sessions", names.her)), + (false, false) => None, + } +} + /// One line per stewarded repo and per campaign that moved from `since` to `now`, newest activity first, each in code's -/// words: merged and ruled titles, open things as counts. A repo or campaign where nothing moved has no line. -pub(crate) fn lines(facts: &DomainFacts, since: DateTime, now: DateTime) -> Vec { +/// words: merged and ruled titles, at most two and the rest counted, and what still stands open as a count. A repo or +/// campaign where nothing moved, or where nothing moved that can be told (no title and no one to name), has no line. +pub(crate) fn lines(facts: &DomainFacts, since: DateTime, now: DateTime, names: &Names) -> Vec { let when = since_words(since, now); let mut dated: Vec<(DateTime, String)> = Vec::new(); for repo in &facts.repos { @@ -423,24 +489,16 @@ pub(crate) fn lines(facts: &DomainFacts, since: DateTime, now: DateTime = campaign.events.iter().filter(|event| within(event.at, since, now)).collect(); let Some(latest) = events.iter().map(|event| event.at).max() else { continue }; - let count = |what: Moved| events.iter().filter(|event| event.what == what).count(); - let workers: Vec = events.iter().map(|event| event.who.clone()).collect::>().into_iter().collect(); - let mut parts = vec![format!("{} worked on it {when}", joined(&workers))]; let ruled: Vec<&str> = events.iter().filter(|event| event.what == Moved::Ruled).filter_map(|event| event.title.as_deref()).collect(); - if !ruled.is_empty() { - parts.push(format!("ruled {}", titles(&ruled))); + let mut parts = Vec::new(); + match (workers(&events, names), ruled.is_empty()) { + (Some(who), true) => parts.push(format!("{who} worked on it {when}")), + (Some(who), false) => parts.push(format!("{who} worked on it {when}; ruled {}", titles(&ruled))), + (None, false) => parts.push(format!("ruled {when} {}", titles(&ruled))), + (None, true) => continue, } - let (opened, closed) = (count(Moved::FollowUpOpened), count(Moved::FollowUpClosed)); - match (opened, closed) { - (0, 0) => {} - (opened, 0) => parts.push(format!("{} opened", plural(opened, "follow-up", "follow-ups"))), - (0, closed) => parts.push(format!("{} closed", plural(closed, "follow-up", "follow-ups"))), - (opened, closed) => parts.push(format!("{} opened, {closed} closed", plural(opened, "follow-up", "follow-ups"))), - } - let (reports, verdicts) = (count(Moved::CutReported), count(Moved::Verdict)); - let checked: Vec = [(reports, "cut report", "cut reports"), (verdicts, "verdict", "verdicts")].into_iter().filter(|(n, ..)| *n > 0).map(|(n, one, many)| plural(n, one, many)).collect(); - if !checked.is_empty() { - parts.push(joined(&checked)); + if campaign.open > 0 { + parts.push(plural(campaign.open, "thing still open", "things still open")); } dated.push((latest, format!("- {}: {}.", campaign.slug, parts.join("; ")))); } diff --git a/crates/mind-body/src/projection/domain/tests.rs b/crates/mind-body/src/projection/domain/tests.rs index 43a1f23..13402f3 100644 --- a/crates/mind-body/src/projection/domain/tests.rs +++ b/crates/mind-body/src/projection/domain/tests.rs @@ -87,6 +87,10 @@ fn pull(title: &str, opener: &str, opened: DateTime, merged: Option Names { + Names { her: "Eureka".into(), operator: "Meta".into() } +} + fn read_through(mind: &TestMind, forge: &dyn ForgeGet) -> Result { read(&|selection: &Selection| mind.query(selection), &mind.instance().0, forge, since(), now()) } @@ -106,7 +110,8 @@ fn ruled(label: &str, title: &str) -> PipelineDocument { PipelineDocument::Ruling(document) } -/// A mind where Hands opened two follow-ups and closed one, and Soul ruled once, all inside the window. +/// A mind where an unnamed agent opened two follow-ups and closed one, and her own Self run's Soul ruled once, all inside +/// the window. fn worked_on() -> TestMind { let mind = TestMind::seeded(); mind.committed(vec![spec("x")]); @@ -114,7 +119,7 @@ fn worked_on() -> TestMind { sealed.item = "SEALED-FOLLOW-UP-ITEM, still to do".into(); mind.committed(vec![PipelineDocument::FollowUp(sealed), follow_up("f2", &spec_ref("x"))]); mind.committed(vec![close(reference(PipelineKind::FollowUp, &id("follow_up", "f2")), recorded())]); - assert!(matches!(mind.put_as(Faculty::Soul, vec![ruled("r1", "The digest shows what merged")]), huginn_mind::PipelineAdmissionOutcome::Committed { .. })); + assert!(matches!(mind.put_by(Faculty::Soul, "mind-self-run", "run-1", vec![ruled("r1", "The digest shows what merged")]), huginn_mind::PipelineAdmissionOutcome::Committed { .. })); mind } @@ -135,10 +140,10 @@ fn k23_her_door_and_the_forge_render_merged_and_ruled_titles_and_counts_of_what_ pull("OPEN-PR-TITLE-SENTINEL", "nibu", now() - Duration::hours(3), None), ])); let facts = read_through(&mind, &forge).unwrap(); - let lines = lines(&facts, since(), now()); + let lines = lines(&facts, since(), now(), &names()); assert_eq!(lines, vec![ "- GameCult/Huginn: 1 pull request merged since Tuesday (\"Persona: the domain digest\"), opened by kiko; 1 pull request opened since Tuesday and not merged yet.".to_owned(), - "- eureka-body: Hands and Soul worked on it since Tuesday; ruled \"The digest shows what merged\"; 2 follow-ups opened, 1 closed.".to_owned(), + "- eureka-body: Eureka's own sessions worked on it since Tuesday; ruled \"The digest shows what merged\"; 1 thing still open.".to_owned(), ]); let all = lines.join("\n"); assert!(!all.contains("SEALED-FOLLOW-UP-ITEM") && !all.contains("OPEN-PR-TITLE-SENTINEL"), "nothing open is shown by name: {all}"); @@ -157,7 +162,7 @@ fn k23_only_her_in_force_stewardships_name_her_repos_never_a_campaign_list() { .live("GameCult/NotHers", json!([pull("NOT-HERS-SENTINEL", "void", now() - Duration::days(1), Some(now() - Duration::hours(5)))])); let facts = read_through(&mind, &forge).unwrap(); assert!(!forge.asked_about("NotHers"), "a campaign's repo list is never read: {:?}", forge.asked.borrow()); - let all = lines(&facts, since(), now()).join("\n"); + let all = lines(&facts, since(), now(), &names()).join("\n"); assert!(all.contains("- GameCult/Lonely: 1 pull request merged since Tuesday (\"Lonely: first light\"), opened by aqua.") && !all.contains("NOT-HERS"), "{all}"); } @@ -178,7 +183,7 @@ fn k23_a_campaign_held_in_another_minds_mind_never_appears_in_hers() { let forge = Forge::default().live(HUGINN, json!([])); let facts = read_through(&hers, &forge).unwrap(); assert!(facts.campaigns.is_empty(), "{facts:?}"); - assert!(!lines(&facts, since(), now()).join("\n").contains("THEIR-RULING-SENTINEL")); + assert!(!lines(&facts, since(), now(), &names()).join("\n").contains("THEIR-RULING-SENTINEL")); } #[test] @@ -197,7 +202,7 @@ fn k23_an_archived_or_missing_or_moved_repo_renders_nothing_and_is_reported() { ); assert!(facts.repos.is_empty(), "a skipped repo's pull requests are not read: {facts:?}"); assert!(!forge.asked.borrow().iter().any(|path| path.contains("/pulls")), "{:?}", forge.asked.borrow()); - assert!(lines(&facts, since(), now()).is_empty()); + assert!(lines(&facts, since(), now(), &names()).is_empty()); } #[test] @@ -224,10 +229,10 @@ fn k23_a_failed_read_fails_whole_and_project_leaves_the_section_out_and_reports_ fn k23_what_moved_before_the_window_is_not_shown() { let facts = DomainFacts { repos: vec![RepoFacts { repo: HUGINN.into(), pulls: vec![Pull { title: "Old".into(), opener: "kiko".into(), opened_at: since() - Duration::days(3), merged_at: Some(since() - Duration::hours(1)), open: false }] }], - campaigns: vec![CampaignFacts { slug: "eureka-body".into(), events: vec![Admitted { what: Moved::Ruled, at: since() - Duration::hours(1), title: Some("Old".into()), who: "Hands".into() }] }], + campaigns: vec![CampaignFacts { slug: "eureka-body".into(), events: vec![Admitted { what: Moved::Ruled, at: since() - Duration::hours(1), title: Some("Old".into()), who: Who::Her }], open: 0 }], skipped: vec![], }; - assert!(lines(&facts, since(), now()).is_empty()); + assert!(lines(&facts, since(), now(), &names()).is_empty()); } #[test] @@ -241,7 +246,7 @@ fn k23_lines_run_newest_first_and_clip_long_titles_and_count_past_two() { ], ..DomainFacts::default() }; - let lines = lines(&facts, since(), now()); + let lines = lines(&facts, since(), now(), &names()); assert!(lines[0].starts_with("- GameCult/Newer: 4 pull requests merged since Tuesday (") && lines[1].starts_with("- GameCult/Older"), "{lines:?}"); let clipped = format!("{}…", "x".repeat(TITLE_BYTES - '…'.len_utf8())); assert!(lines[0].contains(&format!("\"{clipped}\", \"b\" and 2 more), opened by kiko.")), "{}", lines[0]); @@ -264,7 +269,7 @@ fn a_fixture_reads_as_the_live_facts_do() { what = "ruled" at = "2026-10-09T08:00:00Z" title = "Ship v0.2.0" - who = "a Self session" + who = "operator_with_her" [[skipped]] repo = "GameCult/Aetheria-legacy" why = "archived" @@ -272,9 +277,45 @@ fn a_fixture_reads_as_the_live_facts_do() { ) .unwrap(); assert_eq!(DomainSource::read(&facts, since(), now()).unwrap(), facts); - assert_eq!(lines(&facts, since(), now()), vec![ + assert_eq!(lines(&facts, since(), now(), &names()), vec![ "- GameCult/Aetheria: 1 pull request merged since Tuesday (\"Docs: passages made true\"), opened by nibu.".to_owned(), - "- aetheria-release: a Self session worked on it since Tuesday; ruled \"Ship v0.2.0\".".to_owned(), + "- aetheria-release: Meta and Eureka worked on it since Tuesday; ruled \"Ship v0.2.0\".".to_owned(), ]); assert!(toml::from_str::("[[repos]]\nrepo = \"x\"\nwho = \"y\"\n").is_err(), "an unknown key refuses the fixture"); } + +/// Who is people and Minds, from provenance, never a faculty: her own organs are her, a session named for her is the +/// operator with her, the operator's own admission is the operator, and anything else names no one. +#[test] +fn who_is_the_mind_or_person_that_ran_it_never_a_faculty() { + let provenance = |faculty: Faculty, agent: &str, session: &str| PipelineProvenance { faculty, agent: agent.into(), session: session.into(), tool: "t".into(), imported_from: None }; + assert_eq!(super::who(&provenance(Faculty::SelfFaculty, "mind-persona", "mind-20261112T154923445Z"), "aqua"), Who::Her); + assert_eq!(super::who(&provenance(Faculty::Hands, "mind-self-run-hands-a", "x"), "aqua"), Who::Her); + assert_eq!(super::who(&provenance(Faculty::Imagination, "nibu-imagination", "nibu-self-2026-11-17"), "nibu"), Who::OperatorWithHer); + assert_eq!(super::who(&provenance(Faculty::SelfFaculty, "self", "nibu-self-2026-11-17"), "nibu"), Who::OperatorWithHer); + assert_eq!(super::who(&provenance(Faculty::Operator, "meta", "desk"), "nibu"), Who::Operator); + for (agent, session) in [("eureka-self", "swarm-shakedown-2026-10-31"), ("hands", "x"), ("aqua", "x"), ("nibuish-hands", "x")] { + assert_eq!(super::who(&provenance(Faculty::Hands, agent, session), "nibu"), Who::Unknown, "{agent}"); + } +} + +/// The coordinator's rule for the digest's words: no faculty name and no count of the pipeline's machinery in any line, +/// whoever ran what moved; ruling titles and "N things still open" are what it says. +#[test] +fn no_rendered_digest_names_a_faculty_or_counts_cut_reports_or_verdicts() { + let at = |hours: i64| now() - Duration::hours(hours); + let mut campaigns = Vec::new(); + for (index, who) in [Who::Unknown, Who::Her, Who::OperatorWithHer, Who::Operator].into_iter().enumerate() { + let events = [Moved::Ruled, Moved::FollowUpOpened, Moved::FollowUpClosed, Moved::Worked].into_iter().map(|what| Admitted { what, at: at(index as i64 + 1), title: (what == Moved::Ruled).then(|| format!("Hated standing is kill on sight, part {index}")), who }).collect(); + campaigns.push(CampaignFacts { slug: format!("camp-{index}"), events, open: 3 }); + } + campaigns.push(CampaignFacts { slug: "quiet-machinery".into(), events: vec![Admitted { what: Moved::Worked, at: at(1), title: None, who: Who::Unknown }], open: 9 }); + let facts = DomainFacts { campaigns, ..DomainFacts::default() }; + let all = lines(&facts, since(), now(), &names()).join("\n"); + for banned in ["Hands", "Soul", "Imagination", "Self session", "Eyes", "Life", "cut report", "verdict", "follow-up"] { + assert!(!all.contains(banned), "{banned}: {all}"); + } + assert!(all.contains("- camp-1: Eureka's own sessions worked on it since Tuesday; ruled \"Hated standing is kill on sight, part 1\"; 3 things still open."), "{all}"); + assert!(all.contains("- camp-2: Meta and Eureka worked on it") && all.contains("- camp-3: Meta worked on it") && all.contains("- camp-0: ruled since Tuesday \"Hated standing"), "{all}"); + assert!(!all.contains("quiet-machinery"), "machinery alone with no one to name and no title is no line: {all}"); +} diff --git a/crates/mind-body/src/testkit.rs b/crates/mind-body/src/testkit.rs index 4502c8f..11cb3b8 100644 --- a/crates/mind-body/src/testkit.rs +++ b/crates/mind-body/src/testkit.rs @@ -124,10 +124,15 @@ impl TestMind { /// Admits as `faculty`, one second after the last admission. pub(crate) fn put_as(&self, faculty: Faculty, documents: Vec) -> PipelineAdmissionOutcome { + self.put_by(faculty, "test", "test", documents) + } + + /// Admits as `faculty`, by `agent` in `session`, one second after the last admission. + pub(crate) fn put_by(&self, faculty: Faculty, agent: &str, session: &str, documents: Vec) -> PipelineAdmissionOutcome { self.now.set(self.now.get() + Duration::seconds(1)); let batch = PipelineAdmissionBatch { instance: self.instance.clone(), - provenance: PipelineProvenance { faculty, agent: "test".into(), session: "test".into(), tool: "test".into(), imported_from: None }, + provenance: PipelineProvenance { faculty, agent: agent.into(), session: session.into(), tool: "test".into(), imported_from: None }, documents, }; self.mind.borrow_mut().admit(batch, self.now.get())