K23 the domain digest: what merged and what was ruled in her domain, a section of every packet by code
Select renders "In {her} domain lately:" under its own guard (domain_bytes 900, at most 6 lines, the rest
counted). The lines come from `projection::domain`: her in-force stewardships and the campaigns held in her
own mind through her read door (a query only), and her stewarded repos' pull requests from the forge's
anonymous API. Merged and ruled titles are shown; open pull requests and follow-ups are counts. "Who" is a
pull request's opener and an admission's provenance; no commit is read. A campaign's repos list is never
read (map 16.22.8). Archived, missing and moved repos are skipped and reported; any other failed read
leaves the section out and the report says why. The Interpreter sees the lines by id (d1...); the
Projector's frame says once that the heading is news, never a task.
Room fixtures take `[domain]` and simulation cast entries `[cast.domain]`, so re-tests read no forge.
`mind-persona project` reads it live with MIND_PERSONA_FORGE_URL and an endpoint.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
978de248a8
commit
c61e4102e5
16 changed files with 1030 additions and 51 deletions
|
|
@ -49,6 +49,9 @@ toml = { version = "0.9", default-features = false, features = ["std", "serde",
|
|||
unicode-general-category = "1"
|
||||
# Clips on grapheme boundaries (`projection::select::clip`), so no ZWJ sequence is split; already in the graph through Ghostlight.
|
||||
unicode-segmentation = "1"
|
||||
# The domain digest's forge reads (`projection::domain`, map 16.22.2): plain HTTP to the forge's loopback API, the same
|
||||
# crate and features the daemon's forge read uses, so the graph gains no crate.
|
||||
ureq = { version = "~3.3", default-features = false }
|
||||
uuid = { version = "1", default-features = false, features = ["v5"] }
|
||||
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
|
|
|
|||
|
|
@ -35,6 +35,11 @@
|
|||
//! and writes one Markdown report: a batch of states by scenarios by samples (`harness::batch`), or the swarm's cast taking
|
||||
//! turns in one simulated room (`harness::simulate`). Each case is one `project`.
|
||||
//!
|
||||
//! Her domain (what moved lately in her stewarded repos and her campaigns, map 16.22.2) is read when `MIND_PERSONA_FORGE_URL`
|
||||
//! names the forge's API root (on Yggdrasil the loopback `http://127.0.0.1:3310`) and a daemon endpoint is given: her
|
||||
//! mind through that endpoint, which a Persona reaches at her read door, and the forge anonymously. Without either the
|
||||
//! packet has no domain section and the report says so. A room fixture's `[domain]` replaces both.
|
||||
//!
|
||||
//! The tuning is `MIND_PERSONA_TUNING`, else `/etc/gamecult/minds/<instance>/persona-tuning.toml`; renders and plans need
|
||||
//! `MIND_PERSONA_CONNECTOR_ENDPOINT` (`<loopback ip>:<port>`) and the `connector-key` credential in
|
||||
//! `CREDENTIALS_DIRECTORY`. Without `--select-only` or `--renders` it renders once.
|
||||
|
|
@ -51,7 +56,7 @@ use mind_body::control::{CONTROL_ROOT, FileSource, control_path, swarm_path};
|
|||
use mind_body::persona::{Config, carry};
|
||||
use mind_body::heartbeat::{FileStore, HeartbeatView};
|
||||
use mind_body::projection::harness::{Fixture, Harness, batch, fixture_request, simulate, state_file};
|
||||
use mind_body::projection::{HuginnPersonaSource, KitModel, Model, MouthReader, Organs as ProjectOrgans, PersonaSource, Request as ProjectRequest, TUNING_FILE, TUNING_ROOT, Through, TurnKind, connector_key, project};
|
||||
use mind_body::projection::{DomainSource, HttpForge, HuginnPersonaSource, KitModel, MindDomain, Model, MouthReader, Organs as ProjectOrgans, PersonaSource, Request as ProjectRequest, TUNING_FILE, TUNING_ROOT, Through, TurnKind, connector_key, project};
|
||||
|
||||
const USAGE: &str = "usage: mind-persona --instance <slug> [--endpoint rudp://<ip>:<port>] [--rooms a,b] [--operator id[,id]] [--minds id[,id]] [--self-sender id]";
|
||||
const PROJECT_USAGE: &str = "usage: mind-persona project --instance <slug> [--endpoint rudp://<ip>:<port>] [--kind chat|beat|reflection] [--in <room>] [--room <fixture.toml>] [--seed N] [--state <file>] [--last-outcome <record.json>] [--select-only | --renders K [--through projector|persona|interpreter] [--judge <state-file>]] | (--batch <plan> | --simulate <plan>) --out <report.md>";
|
||||
|
|
@ -176,7 +181,7 @@ fn run_project(args: &[String]) -> Result<String> {
|
|||
let seed_now = u64::try_from(chrono::Utc::now().timestamp_millis()).unwrap_or_default();
|
||||
if let Some(fixture) = &fixture {
|
||||
// The fixture is the room, the clock and who is who: no mouth, no heartbeat table, no persona.env.
|
||||
let organs = ProjectOrgans { persona: harness.persona, chat: Some(fixture), addressing: fixture.addressee(), model: harness.model };
|
||||
let organs = ProjectOrgans { persona: harness.persona, chat: Some(fixture), addressing: fixture.addressee(), model: harness.model, domain: fixture.domain() };
|
||||
let request = ProjectRequest { judge_against: judge, last_outcome, ..fixture_request(&harness, fixture, state, seed.unwrap_or(seed_now), renders, through) };
|
||||
return Ok(serde_json::to_string_pretty(&project(&organs, &request, fixture.now)?)?);
|
||||
}
|
||||
|
|
@ -188,11 +193,17 @@ fn run_project(args: &[String]) -> Result<String> {
|
|||
_ => None,
|
||||
};
|
||||
let heartbeat = setting("MIND_HEARTBEAT_STATE").map(FileStore::new);
|
||||
// Her domain: her mind through the endpoint given (her read door, for a Persona) and the forge, both read-only.
|
||||
let domain = match (address, setting("MIND_PERSONA_FORGE_URL")) {
|
||||
(Some(address), Some(forge)) => Some(MindDomain::new(HuginnClient::new(address, instance.clone(), TIMEOUT), HttpForge::new(&forge))),
|
||||
_ => None,
|
||||
};
|
||||
let organs = ProjectOrgans {
|
||||
persona: harness.persona,
|
||||
chat: chat.as_ref().map(|chat| chat as &dyn MouthReader),
|
||||
addressing: heartbeat.as_ref().map(|store| store as &dyn HeartbeatView),
|
||||
model: harness.model,
|
||||
domain: domain.as_ref().map(|domain| domain as &dyn DomainSource),
|
||||
};
|
||||
let request = ProjectRequest {
|
||||
instance: instance.0.clone(),
|
||||
|
|
@ -211,6 +222,7 @@ fn run_project(args: &[String]) -> Result<String> {
|
|||
recent: vec![],
|
||||
own_rooms: vec![],
|
||||
last_outcome,
|
||||
last_wake: None,
|
||||
};
|
||||
let report = project(&organs, &request, chrono::Utc::now())?;
|
||||
let addressing = &report["addressing"];
|
||||
|
|
|
|||
|
|
@ -6,19 +6,22 @@
|
|||
//! map section 16.3; the Persona stage's membrane stays Ghostlight's). Every knob of both is `persona-tuning.toml` (`tuning`), read at each
|
||||
//! wake, its hash carried with the packet.
|
||||
//!
|
||||
//! The Projector shows her self and her room: her persona state and what the mouth showed. It does not read her Mind;
|
||||
//! that is the Interpreter's read tools' (C3b), when wondering leads to reading.
|
||||
//! The Projector shows her self and her room: her persona state and what the mouth showed. It reads her Mind for one thing
|
||||
//! only, what moved in her domain lately (`domain`, map 16.22.2): her stewardships and campaigns through her read door, her
|
||||
//! repos' pull requests on the forge, rendered by code as news, never as a task. Anything else she reads is the
|
||||
//! Interpreter's read tools' (C3b), when wondering leads to reading.
|
||||
//!
|
||||
//! `project` is the experiment tool over both (`mind-persona project`): what Select would build from her real or a
|
||||
//! hypothetical state, what the Projector would narrate, and with `Through::Persona` what she would answer in her own
|
||||
//! prose and which of her drafts would be said (the Persona stage, C3b's first piece). `harness` runs `project`
|
||||
//! over fixtures: one turn from a mocked room (`--room`), a plan of states by scenarios (`--batch`), and the cast of the
|
||||
//! swarm taking turns in one simulated room (`--simulate`). It adds no second turn: every case is one `project`. Its organs are read-only by type: `PersonaSource` gets,
|
||||
//! `MouthReader` reads pending chat, `Model` asks. None of them can put, admit, send, ack or open a conversation, so
|
||||
//! `MouthReader` reads pending chat, `DomainSource` reads her domain, `Model` asks. None of them can put, admit, send, ack or open a conversation, so
|
||||
//! `project` cannot write and runs under a held brake.
|
||||
|
||||
pub mod harness;
|
||||
mod commit;
|
||||
mod domain;
|
||||
mod interpret;
|
||||
mod narrate;
|
||||
mod outcome;
|
||||
|
|
@ -38,6 +41,7 @@ use crate::address::{Addressee, is_for, localpart};
|
|||
use crate::chat_client::{Chat, ChatPending, Form, ReplyLink};
|
||||
use crate::heartbeat::HeartbeatView;
|
||||
|
||||
pub use domain::{DomainFacts, DomainSource, HttpForge, MindDomain};
|
||||
pub use narrate::{Answer, Failed, KitModel, Model, Spent, connector_key};
|
||||
pub use select::TurnKind;
|
||||
pub use tuning::{TUNING_FILE, TUNING_ROOT};
|
||||
|
|
@ -112,6 +116,9 @@ pub struct Organs<'a> {
|
|||
pub addressing: Option<&'a dyn HeartbeatView>,
|
||||
/// The Projector and the judge; required for renders.
|
||||
pub model: Option<&'a dyn Model>,
|
||||
/// Her domain: her mind through her read door and the forge, live; a fixture's facts in a harness run. None, and the
|
||||
/// packet has no domain section, and the report says so.
|
||||
pub domain: Option<&'a dyn DomainSource>,
|
||||
}
|
||||
|
||||
/// One thing she can do this turn, typed by what it does (map 16.6, 16.18). Derived by `affordances` from what the turn
|
||||
|
|
@ -204,6 +211,9 @@ pub struct Request {
|
|||
/// simulation carries each turn's to her next; a harness run takes a fixture's (`--last-outcome`). None live until
|
||||
/// the commit's trace (C3c) carries it.
|
||||
pub last_outcome: Option<Value>,
|
||||
/// When she last woke: her domain's window opens there, held to at least a day and at most a week (map 16.22.2). A
|
||||
/// simulation carries each Mind's; none, as live until the commit's trace (C3c) carries it, is a week.
|
||||
pub last_wake: Option<DateTime<Utc>>,
|
||||
}
|
||||
|
||||
/// Her addressee: the heartbeat's row for her when its table holds one, else her own names (handle and public name).
|
||||
|
|
@ -231,6 +241,24 @@ fn own_addressee(addressing: Option<&dyn HeartbeatView>, own_sender: &str, publi
|
|||
(Addressee::new(own_sender, [localpart(own_sender), public_name]), report("own names only", &why))
|
||||
}
|
||||
|
||||
/// 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<DateTime<Utc>>, now: DateTime<Utc>) -> (Vec<String>, 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 report = json!({ "read": true, "since": since.to_rfc3339(), "lines": lines.len(), "skipped": facts.skipped });
|
||||
(lines, report)
|
||||
}
|
||||
Err(fault) => (Vec::new(), json!({ "read": false, "since": since.to_rfc3339(), "why": format!("{fault:#}") })),
|
||||
}
|
||||
}
|
||||
|
||||
/// The room through the mouth's pending read, which acks nothing: new messages and the tail, own lines kept for the
|
||||
/// Select stage to drop. A refusal is reported, never hidden.
|
||||
fn read_room(chat: &dyn MouthReader, request: &Request, own: &Addressee) -> (Room, Value) {
|
||||
|
|
@ -292,7 +320,7 @@ fn packet_json(packet: &Packet) -> Value {
|
|||
"present": packet.present,
|
||||
"selected": packet.selected,
|
||||
// Each section's bytes under its own guard, and the sum the Projector is shown of her (map 16.19.4).
|
||||
"bytes": { "identity": packet.identity().len(), "outcome": packet.sections.outcome, "promises": packet.sections.promises, "here": packet.sections.here, "body": packet.sections.body, "people": packet.sections.people, "notes": packet.sections.notes, "total": packet.identity().len() + packet.context.len(), "stimulus": packet.stimulus.len(), "arrival": packet.arrival.len(), "heard": packet.heard.len() },
|
||||
"bytes": { "identity": packet.identity().len(), "outcome": packet.sections.outcome, "promises": packet.sections.promises, "here": packet.sections.here, "body": packet.sections.body, "people": packet.sections.people, "domain": packet.sections.domain, "notes": packet.sections.notes, "total": packet.identity().len() + packet.context.len(), "stimulus": packet.stimulus.len(), "arrival": packet.arrival.len(), "heard": packet.heard.len() },
|
||||
"bound": packet.sections.bound,
|
||||
"overflow": packet.overflow,
|
||||
"clipped": packet.clipped,
|
||||
|
|
@ -302,6 +330,7 @@ fn packet_json(packet: &Packet) -> Value {
|
|||
"amendable": packet.amendable,
|
||||
"quotable": packet.quotable,
|
||||
"promises": packet.promises,
|
||||
"domain": packet.domain,
|
||||
"context": packet.context,
|
||||
"stimulus": packet.stimulus,
|
||||
"arrival": packet.arrival,
|
||||
|
|
@ -404,7 +433,8 @@ pub fn project(organs: &Organs, request: &Request, now: DateTime<Utc>) -> 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 inputs = Inputs { kind: request.kind, state: &state, room: &room, history: &history, observation: None, people, now, seed: request.seed, affordances: &[] };
|
||||
let (domain_lines, domain_report) = read_domain(organs.domain, request.last_wake, now);
|
||||
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 };
|
||||
|
||||
|
|
@ -415,6 +445,7 @@ pub fn project(organs: &Organs, request: &Request, now: DateTime<Utc>) -> Result
|
|||
"tuning": { "path": request.tuning.display().to_string(), "source": loaded.source, "sha256": loaded.sha256 },
|
||||
"room": room_report,
|
||||
"addressing": addressing,
|
||||
"domain": domain_report,
|
||||
"history": if request.recent.is_empty() { json!("none: freshness and her own recent words come from trace v2, which the commit writes (C3c)") } else { json!({ "recent_projections": request.recent.len() }) },
|
||||
// What she is told of her last turn, whole, and what of its record she is not told, and why.
|
||||
"last_outcome": history.last.as_ref().map_or_else(|| json!("none"), |last| json!({ "told": last.lines(select::forms(&state)), "omitted": last.omitted })),
|
||||
|
|
|
|||
453
crates/mind-body/src/projection/domain.rs
Normal file
453
crates/mind-body/src/projection/domain.rs
Normal file
|
|
@ -0,0 +1,453 @@
|
|||
//! Her domain (map 16.22.2, as 16.22.8 amends it): what moved in her part of the coop since her last wake, read by code
|
||||
//! each wake with no model call, and the lines Select renders under `In {her} domain lately:`.
|
||||
//!
|
||||
//! Sources:
|
||||
//! - Her repos are her in-force stewardship records, read through her own read door. A campaign's `repos` list is never
|
||||
//! read: it does not own what she stewards, and K23a found it disagreeing with the records that do.
|
||||
//! - Campaigns enter only through their own documents held in her own mind: rulings admitted, follow-ups opened and
|
||||
//! closed, cut reports and verdicts. A campaign in another Mind's mind is not in hers, whatever repo it names.
|
||||
//! - 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.
|
||||
//!
|
||||
//! 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
|
||||
//! report says why. It never renders "nothing moved", which would be false.
|
||||
|
||||
use std::collections::BTreeSet;
|
||||
use std::time::Duration;
|
||||
|
||||
use anyhow::{Context, Result, anyhow, bail, ensure};
|
||||
use chrono::{DateTime, Utc};
|
||||
use cultnet_rs::Selection;
|
||||
use eureka_pipeline::PipelineKind;
|
||||
use eureka_state::HuginnClient;
|
||||
use eureka_state::hold::Ask;
|
||||
use huginn_mind::{Faculty, HuginnMindRequest, HuginnMindResponse, PipelineDocumentSummary, PipelineFacts, PipelinePageItems, PipelineProvenance, PipelineSelectionPage};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::Value;
|
||||
|
||||
use super::select::{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).
|
||||
pub(crate) const DOMAIN_LINES: usize = 6;
|
||||
/// A merged or ruled title is clipped to this, with a mark where it was cut.
|
||||
const TITLE_BYTES: usize = 120;
|
||||
/// The most titles one line quotes; the rest of its titles are counted.
|
||||
const TITLES_PER_LINE: usize = 2;
|
||||
/// The window: since her last wake, at least a day and at most a week.
|
||||
const WINDOW_MIN_HOURS: i64 = 24;
|
||||
const WINDOW_MAX_DAYS: i64 = 7;
|
||||
/// One page of the forge's pull requests, and how many pages of one repo a read takes: 200 moved in a week is past
|
||||
/// anything the coop has seen, and a repo past it fails the read rather than show part of it.
|
||||
const PULLS_PAGE: usize = 50;
|
||||
const PULLS_PAGES: usize = 4;
|
||||
/// The page the mind's event read asks for.
|
||||
const EVENTS_PAGE: u32 = 200;
|
||||
/// The whole of one forge call.
|
||||
const FORGE_TIMEOUT: Duration = Duration::from_secs(10);
|
||||
|
||||
/// Where the window opens: her last wake, held to at least a day and at most a week before `now`; a week when she has
|
||||
/// not woken before.
|
||||
pub(crate) fn since(last_wake: Option<DateTime<Utc>>, now: DateTime<Utc>) -> DateTime<Utc> {
|
||||
let earliest = now - chrono::Duration::days(WINDOW_MAX_DAYS);
|
||||
let latest = now - chrono::Duration::hours(WINDOW_MIN_HOURS);
|
||||
last_wake.map_or(earliest, |at| at.clamp(earliest, latest))
|
||||
}
|
||||
|
||||
/// What moved in her domain, as read: the facts the section is rendered from. A harness fixture carries the same
|
||||
/// (`[domain]` in a room fixture, `[cast.domain]` in a simulation plan), so a re-test reads no forge and no mind.
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct DomainFacts {
|
||||
#[serde(default)]
|
||||
pub(crate) repos: Vec<RepoFacts>,
|
||||
#[serde(default)]
|
||||
pub(crate) campaigns: Vec<CampaignFacts>,
|
||||
/// Stewarded repos the read skipped, and why: reported, never shown to her.
|
||||
#[serde(default)]
|
||||
pub(crate) skipped: Vec<Skipped>,
|
||||
}
|
||||
|
||||
/// One stewarded repo and its pull requests that moved in the window.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub(crate) struct RepoFacts {
|
||||
/// `Org/Repo`.
|
||||
pub(crate) repo: String,
|
||||
#[serde(default)]
|
||||
pub(crate) pulls: Vec<Pull>,
|
||||
}
|
||||
|
||||
/// A pull request as the forge lists it: its title, the account that opened it, when, and when it merged.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub(crate) struct Pull {
|
||||
pub(crate) title: String,
|
||||
pub(crate) opener: String,
|
||||
pub(crate) opened_at: DateTime<Utc>,
|
||||
#[serde(default)]
|
||||
pub(crate) merged_at: Option<DateTime<Utc>>,
|
||||
/// Still open on the forge.
|
||||
#[serde(default)]
|
||||
pub(crate) open: bool,
|
||||
}
|
||||
|
||||
/// A campaign held in her mind and what was admitted under it in the window.
|
||||
#[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<Admitted>,
|
||||
}
|
||||
|
||||
/// One admission under a campaign: what it was, when, a ruling's title, and who admitted it, in words.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub(crate) struct Admitted {
|
||||
pub(crate) what: Moved,
|
||||
pub(crate) at: DateTime<Utc>,
|
||||
/// A ruling's title; nothing else carries one here, so no open item's words can reach her.
|
||||
#[serde(default)]
|
||||
pub(crate) title: Option<String>,
|
||||
pub(crate) who: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub(crate) enum Moved {
|
||||
Ruled,
|
||||
FollowUpOpened,
|
||||
FollowUpClosed,
|
||||
CutReported,
|
||||
Verdict,
|
||||
}
|
||||
|
||||
/// A stewarded repo the read skipped.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub(crate) struct Skipped {
|
||||
pub(crate) repo: String,
|
||||
pub(crate) why: Skip,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub(crate) enum Skip {
|
||||
Archived,
|
||||
NotFound,
|
||||
Moved,
|
||||
}
|
||||
|
||||
/// What `project` reads her domain through: read-only by type. The live one is `MindDomain`; a fixture's facts are their
|
||||
/// own source.
|
||||
pub trait DomainSource {
|
||||
/// What moved in her domain from `since` to `now`.
|
||||
fn read(&self, since: DateTime<Utc>, now: DateTime<Utc>) -> Result<DomainFacts>;
|
||||
}
|
||||
|
||||
impl DomainSource for DomainFacts {
|
||||
fn read(&self, _since: DateTime<Utc>, _now: DateTime<Utc>) -> Result<DomainFacts> {
|
||||
Ok(self.clone())
|
||||
}
|
||||
}
|
||||
|
||||
/// Her domain, live: her mind through her own read door (a query and nothing else is ever sent), and the forge.
|
||||
pub struct MindDomain {
|
||||
client: HuginnClient,
|
||||
forge: HttpForge,
|
||||
}
|
||||
|
||||
impl MindDomain {
|
||||
pub fn new(client: HuginnClient, forge: HttpForge) -> Self {
|
||||
Self { client, forge }
|
||||
}
|
||||
}
|
||||
|
||||
impl DomainSource for MindDomain {
|
||||
fn read(&self, since: DateTime<Utc>, now: DateTime<Utc>) -> Result<DomainFacts> {
|
||||
let ask = |selection: &Selection| -> Result<PipelineSelectionPage> {
|
||||
let request = HuginnMindRequest::Query { instance: self.client.instance().clone(), selection: selection.clone(), semantic: None };
|
||||
match self.client.call(request).map_err(|_| anyhow!("her mind could not be asked"))? {
|
||||
HuginnMindResponse::Query(page) => Ok(page),
|
||||
HuginnMindResponse::Refused(_) => bail!("her mind refused the read"),
|
||||
_ => bail!("her mind answered a read with something else"),
|
||||
}
|
||||
};
|
||||
read(&ask, &self.client.instance().0, &self.forge, since, now)
|
||||
}
|
||||
}
|
||||
|
||||
/// One GET on the forge: the status and the body.
|
||||
pub(crate) trait ForgeGet {
|
||||
fn get(&self, path: &str) -> Result<(u16, String)>;
|
||||
}
|
||||
|
||||
/// The forge's public API over HTTP, anonymous: what anyone may read. No redirect is followed: a redirect names a moved
|
||||
/// repo, which is skipped.
|
||||
pub struct HttpForge {
|
||||
agent: ureq::Agent,
|
||||
base: String,
|
||||
}
|
||||
|
||||
impl HttpForge {
|
||||
/// `base_url` is the forge's root, the one `/api/v1` hangs from.
|
||||
pub fn new(base_url: &str) -> Self {
|
||||
let agent: ureq::Agent = ureq::Agent::config_builder().timeout_global(Some(FORGE_TIMEOUT)).http_status_as_error(false).max_redirects(0).max_redirects_will_error(false).build().into();
|
||||
Self { agent, base: base_url.trim_end_matches('/').to_owned() }
|
||||
}
|
||||
}
|
||||
|
||||
impl ForgeGet for HttpForge {
|
||||
fn get(&self, path: &str) -> Result<(u16, String)> {
|
||||
// An error names no address: the forge's answer is the report's to know about, its address is not.
|
||||
let mut response = self.agent.get(format!("{}{path}", self.base)).call().map_err(|_| anyhow!("the forge did not answer"))?;
|
||||
let status = response.status().as_u16();
|
||||
let body = response.body_mut().read_to_string().map_err(|_| anyhow!("the forge's answer was cut off"))?;
|
||||
Ok((status, body))
|
||||
}
|
||||
}
|
||||
|
||||
/// Every header of a selection, newest admission first, down to the first admitted before `since`.
|
||||
fn newest(ask: &Ask, selection: &Selection, since: DateTime<Utc>) -> Result<Vec<PipelineDocumentSummary>> {
|
||||
let mut asking = Selection { descending: true, limit: Some(EVENTS_PAGE), ..selection.clone() };
|
||||
let mut found = Vec::new();
|
||||
loop {
|
||||
let page = ask(&asking)?;
|
||||
let PipelinePageItems::Headers(items) = page.items else { bail!("her mind answered documents to a header read") };
|
||||
for item in items {
|
||||
if admitted_at(&item)? < since {
|
||||
return Ok(found);
|
||||
}
|
||||
found.push(item);
|
||||
}
|
||||
match page.next {
|
||||
Some(cursor) => asking.cursor = Some(cursor),
|
||||
None => return Ok(found),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Every header of a selection, in the mind's order.
|
||||
fn all(ask: &Ask, selection: &Selection) -> Result<Vec<PipelineDocumentSummary>> {
|
||||
eureka_state::hold::headers(ask, selection)
|
||||
}
|
||||
|
||||
fn admitted_at(item: &PipelineDocumentSummary) -> Result<DateTime<Utc>> {
|
||||
DateTime::parse_from_rfc3339(&item.admission.admitted_at).map(|at| at.with_timezone(&Utc)).map_err(|_| anyhow!("an admission time in her mind does not read"))
|
||||
}
|
||||
|
||||
/// A key's root segment: the campaign a document belongs to, or the instance of a stewardship.
|
||||
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(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Her domain from `since`: her in-force stewardships and her campaigns through `ask` (her door), each stewarded repo's
|
||||
/// pull requests through `forge`. Any failure fails the whole read, except a repo that is archived, missing or moved,
|
||||
/// which is skipped and named.
|
||||
pub(crate) fn read(ask: &Ask, her: &str, forge: &dyn ForgeGet, since: DateTime<Utc>, now: DateTime<Utc>) -> Result<DomainFacts> {
|
||||
let mut repos: Vec<String> = Vec::new();
|
||||
for item in all(ask, &in_force(of_kind(PipelineKind::Stewardship)))? {
|
||||
if let PipelineFacts::Stewardship { instance, repo, .. } = &item.facts
|
||||
&& instance.0 == her
|
||||
&& !repos.iter().any(|held| held.eq_ignore_ascii_case(&repo.0))
|
||||
{
|
||||
repos.push(repo.0.clone());
|
||||
}
|
||||
}
|
||||
let slugs: Vec<String> = all(ask, &in_force(of_kind(PipelineKind::Campaign)))?.iter().map(|item| root(item).to_owned()).collect::<BTreeSet<_>>().into_iter().collect();
|
||||
let mut campaigns: Vec<CampaignFacts> = slugs.iter().map(|slug| CampaignFacts { slug: slug.clone(), events: Vec::new() }).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 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::Resolution { subject, .. } if subject.kind == PipelineKind::FollowUp => Moved::FollowUpClosed,
|
||||
_ => continue,
|
||||
};
|
||||
let title = match &item.facts {
|
||||
PipelineFacts::Ruling { title, .. } => Some(title.0.clone()),
|
||||
_ => None,
|
||||
};
|
||||
let at = admitted_at(&item)?;
|
||||
if let Some(campaign) = campaigns.iter_mut().find(|campaign| campaign.slug == root(&item)) {
|
||||
campaign.events.push(Admitted { what, at, title, who: who(&item.admission.provenance) });
|
||||
}
|
||||
}
|
||||
}
|
||||
let mut facts = DomainFacts { repos: Vec::new(), campaigns, skipped: Vec::new() };
|
||||
for repo in repos {
|
||||
match repo_state(forge, &repo)? {
|
||||
Some(why) => facts.skipped.push(Skipped { repo, why }),
|
||||
None => {
|
||||
let pulls = pulls(forge, &repo, since, now)?;
|
||||
facts.repos.push(RepoFacts { repo, pulls });
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(facts)
|
||||
}
|
||||
|
||||
/// Why a repo is skipped, or none when it is live: archived, not found (404), or moved (a redirect). Any other answer
|
||||
/// fails the read.
|
||||
fn repo_state(forge: &dyn ForgeGet, repo: &str) -> Result<Option<Skip>> {
|
||||
let (status, body) = forge.get(&format!("/api/v1/repos/{repo}"))?;
|
||||
match status {
|
||||
404 => Ok(Some(Skip::NotFound)),
|
||||
300..400 => Ok(Some(Skip::Moved)),
|
||||
200 => {
|
||||
let value: Value = serde_json::from_str(&body).map_err(|_| anyhow!("the forge's answer for {repo} is not JSON"))?;
|
||||
let archived = value["archived"].as_bool().with_context(|| format!("the forge did not say whether {repo} is archived"))?;
|
||||
Ok(archived.then_some(Skip::Archived))
|
||||
}
|
||||
status => bail!("the forge answered {status} for {repo}"),
|
||||
}
|
||||
}
|
||||
|
||||
fn instant(value: &Value) -> Option<DateTime<Utc>> {
|
||||
value.as_str().and_then(|text| DateTime::parse_from_rfc3339(text).ok()).map(|at| at.with_timezone(&Utc))
|
||||
}
|
||||
|
||||
/// The pull requests of `repo` updated since `since`, newest update first, as the forge lists them. A repo with more
|
||||
/// than `PULLS_PAGES` pages of them in the window fails the read, never a silent part.
|
||||
fn pulls(forge: &dyn ForgeGet, repo: &str, since: DateTime<Utc>, now: DateTime<Utc>) -> Result<Vec<Pull>> {
|
||||
let mut found = Vec::new();
|
||||
for page in 1..=PULLS_PAGES {
|
||||
let (status, body) = forge.get(&format!("/api/v1/repos/{repo}/pulls?state=all&sort=recentupdate&limit={PULLS_PAGE}&page={page}"))?;
|
||||
ensure!(status == 200, "the forge answered {status} to the pull requests of {repo}");
|
||||
let value: Value = serde_json::from_str(&body).map_err(|_| anyhow!("the forge's pull requests of {repo} are not JSON"))?;
|
||||
let listed = value.as_array().with_context(|| format!("the forge's pull requests of {repo} are not a list"))?;
|
||||
for pull in listed {
|
||||
let updated = instant(&pull["updated_at"]).with_context(|| format!("a pull request of {repo} has no update time"))?;
|
||||
if updated < since {
|
||||
return Ok(found);
|
||||
}
|
||||
let title = pull["title"].as_str().with_context(|| format!("a pull request of {repo} has no title"))?;
|
||||
let opener = pull["user"]["login"].as_str().with_context(|| format!("a pull request of {repo} has no opener"))?;
|
||||
let opened_at = instant(&pull["created_at"]).with_context(|| format!("a pull request of {repo} has no opening time"))?;
|
||||
let merged_at = if pull["merged"].as_bool() == Some(true) { instant(&pull["merged_at"]) } else { None };
|
||||
found.push(Pull { title: title.to_owned(), opener: opener.to_owned(), opened_at, merged_at: merged_at.filter(|at| *at <= now), open: pull["state"].as_str() == Some("open") });
|
||||
}
|
||||
if listed.len() < PULLS_PAGE {
|
||||
return Ok(found);
|
||||
}
|
||||
}
|
||||
bail!("more than {} pull requests of {repo} moved in the window", PULLS_PAGE * PULLS_PAGES)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// The lines.
|
||||
|
||||
/// "since Tuesday": the window's opening in words, from where `now` stands.
|
||||
fn since_words(since: DateTime<Utc>, now: DateTime<Utc>) -> String {
|
||||
let days = (now.date_naive() - since.date_naive()).num_days();
|
||||
match days {
|
||||
..=1 => "since yesterday".to_owned(),
|
||||
2..=6 => format!("since {}", since.format("%A")),
|
||||
_ => format!("since last {}", since.format("%A")),
|
||||
}
|
||||
}
|
||||
|
||||
fn plural(n: usize, one: &str, many: &str) -> String {
|
||||
format!("{n} {}", if n == 1 { one } else { many })
|
||||
}
|
||||
|
||||
/// Names joined as a sentence says them: "a", "a and b", "a, b and c".
|
||||
fn joined(names: &[String]) -> String {
|
||||
match names {
|
||||
[] => String::new(),
|
||||
[one] => one.clone(),
|
||||
[rest @ .., last] => format!("{} and {last}", rest.join(", ")),
|
||||
}
|
||||
}
|
||||
|
||||
/// At most `TITLES_PER_LINE` titles, each clipped and quoted, and the rest counted.
|
||||
fn titles(all: &[&str]) -> String {
|
||||
let mut shown: Vec<String> = all.iter().take(TITLES_PER_LINE).map(|title| spoken(&clip(title, TITLE_BYTES))).collect();
|
||||
if all.len() > TITLES_PER_LINE {
|
||||
shown.push(format!("{} more", all.len() - TITLES_PER_LINE));
|
||||
}
|
||||
joined(&shown)
|
||||
}
|
||||
|
||||
fn within(at: DateTime<Utc>, since: DateTime<Utc>, now: DateTime<Utc>) -> bool {
|
||||
since <= at && at <= now
|
||||
}
|
||||
|
||||
/// 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<Utc>, now: DateTime<Utc>) -> Vec<String> {
|
||||
let when = since_words(since, now);
|
||||
let mut dated: Vec<(DateTime<Utc>, String)> = Vec::new();
|
||||
for repo in &facts.repos {
|
||||
let merged: Vec<&Pull> = repo.pulls.iter().filter(|pull| pull.merged_at.is_some_and(|at| within(at, since, now))).collect();
|
||||
let opened = repo.pulls.iter().filter(|pull| pull.open && within(pull.opened_at, since, now)).count();
|
||||
let latest = merged.iter().filter_map(|pull| pull.merged_at).chain(repo.pulls.iter().filter(|pull| pull.open && within(pull.opened_at, since, now)).map(|pull| pull.opened_at)).max();
|
||||
let Some(latest) = latest else { continue };
|
||||
let mut parts = Vec::new();
|
||||
if !merged.is_empty() {
|
||||
let openers: Vec<String> = merged.iter().map(|pull| pull.opener.clone()).collect::<BTreeSet<_>>().into_iter().collect();
|
||||
let named: Vec<&str> = merged.iter().map(|pull| pull.title.as_str()).collect();
|
||||
parts.push(format!("{} merged {when} ({}), opened by {}", plural(merged.len(), "pull request", "pull requests"), titles(&named), joined(&openers)));
|
||||
}
|
||||
if opened > 0 {
|
||||
parts.push(format!("{} opened {when} and not merged yet", plural(opened, "pull request", "pull requests")));
|
||||
}
|
||||
dated.push((latest, format!("- {}: {}.", repo.repo, parts.join("; "))));
|
||||
}
|
||||
for campaign in &facts.campaigns {
|
||||
let events: Vec<&Admitted> = 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<String> = events.iter().map(|event| event.who.clone()).collect::<BTreeSet<_>>().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 (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<String> = [(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));
|
||||
}
|
||||
dated.push((latest, format!("- {}: {}.", campaign.slug, parts.join("; "))));
|
||||
}
|
||||
// Newest activity first; a tie keeps the order read.
|
||||
dated.sort_by_key(|(at, _)| std::cmp::Reverse(*at));
|
||||
dated.into_iter().map(|(_, line)| line).collect()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
280
crates/mind-body/src/projection/domain/tests.rs
Normal file
280
crates/mind-body/src/projection/domain/tests.rs
Normal file
|
|
@ -0,0 +1,280 @@
|
|||
//! The domain digest's reads (map 16.22.2, 16.22.8): her stewardships and campaigns through a real mind over a temporary
|
||||
//! directory, the forge through a scripted one that records every path it is asked. What the packet makes of the lines
|
||||
//! is tested with the packet (`projection/tests.rs`, `k23_*`).
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use chrono::{DateTime, Duration, Utc};
|
||||
use eureka_pipeline::{Date, PipelineCampaign, PipelineDocument, PipelineKind, PipelineStewardship, Slug};
|
||||
use huginn_mind::Faculty;
|
||||
use serde_json::json;
|
||||
|
||||
use super::*;
|
||||
use crate::queue::MindPort;
|
||||
use crate::testkit::{INSTANCE, TestMind, at, close, follow_up, id, recorded, reference, ruling, spec, spec_ref};
|
||||
|
||||
/// A forge that answers from a script and records what it was asked. A repo it holds no script for is a 404.
|
||||
#[derive(Default)]
|
||||
struct Forge {
|
||||
repos: BTreeMap<String, (u16, Value)>,
|
||||
pulls: BTreeMap<String, Value>,
|
||||
asked: RefCell<Vec<String>>,
|
||||
}
|
||||
|
||||
impl Forge {
|
||||
fn live(mut self, repo: &str, pulls: Value) -> Self {
|
||||
self.repos.insert(repo.to_owned(), (200, json!({ "full_name": repo, "archived": false })));
|
||||
self.pulls.insert(repo.to_owned(), pulls);
|
||||
self
|
||||
}
|
||||
|
||||
fn answering(mut self, repo: &str, status: u16, body: Value) -> Self {
|
||||
self.repos.insert(repo.to_owned(), (status, body));
|
||||
self
|
||||
}
|
||||
|
||||
fn asked_about(&self, repo: &str) -> bool {
|
||||
self.asked.borrow().iter().any(|path| path.contains(repo))
|
||||
}
|
||||
}
|
||||
|
||||
impl ForgeGet for Forge {
|
||||
fn get(&self, path: &str) -> Result<(u16, String)> {
|
||||
self.asked.borrow_mut().push(path.to_owned());
|
||||
let route = path.split('?').next().unwrap_or_default().trim_start_matches("/api/v1/repos/");
|
||||
if let Some(repo) = route.strip_suffix("/pulls") {
|
||||
return Ok(self.pulls.get(repo).map_or((404, "{}".to_owned()), |pulls| (200, pulls.to_string())));
|
||||
}
|
||||
Ok(self.repos.get(route).map_or((404, "{}".to_owned()), |(status, body)| (*status, body.to_string())))
|
||||
}
|
||||
}
|
||||
|
||||
/// A forge that answers nothing.
|
||||
struct Down;
|
||||
|
||||
impl ForgeGet for Down {
|
||||
fn get(&self, _path: &str) -> Result<(u16, String)> {
|
||||
bail!("the forge did not answer")
|
||||
}
|
||||
}
|
||||
|
||||
const HUGINN: &str = "GameCult/Huginn";
|
||||
|
||||
fn now() -> DateTime<Utc> {
|
||||
at(0) + Duration::hours(1)
|
||||
}
|
||||
|
||||
/// Three days before `now`: a Tuesday.
|
||||
fn since() -> DateTime<Utc> {
|
||||
now() - Duration::days(3)
|
||||
}
|
||||
|
||||
fn stamp(at: DateTime<Utc>) -> String {
|
||||
at.to_rfc3339()
|
||||
}
|
||||
|
||||
/// A pull request as the forge lists it.
|
||||
fn pull(title: &str, opener: &str, opened: DateTime<Utc>, merged: Option<DateTime<Utc>>) -> Value {
|
||||
json!({
|
||||
"title": title,
|
||||
"user": { "login": opener },
|
||||
"created_at": stamp(opened),
|
||||
"updated_at": stamp(merged.unwrap_or(opened)),
|
||||
"merged": merged.is_some(),
|
||||
"merged_at": merged.map(stamp),
|
||||
"state": if merged.is_some() { "closed" } else { "open" },
|
||||
})
|
||||
}
|
||||
|
||||
fn read_through(mind: &TestMind, forge: &dyn ForgeGet) -> Result<DomainFacts> {
|
||||
read(&|selection: &Selection| mind.query(selection), &mind.instance().0, forge, since(), now())
|
||||
}
|
||||
|
||||
fn stewardship_of(instance: &str, repo: &str) -> PipelineDocument {
|
||||
PipelineDocument::Stewardship(PipelineStewardship { instance: Slug(instance.into()), repo: repo.into(), sequence: 1, assigned_on: Date("2026-10-09".into()), note: "assigned".into(), names: vec![] })
|
||||
}
|
||||
|
||||
fn campaign_listing(slug: &str, repos: &[&str]) -> PipelineDocument {
|
||||
let PipelineDocument::Campaign(campaign) = crate::testkit::campaign_named(slug, "Another campaign") else { unreachable!() };
|
||||
PipelineDocument::Campaign(PipelineCampaign { repos: repos.iter().map(|repo| (*repo).into()).collect(), ..campaign })
|
||||
}
|
||||
|
||||
fn ruled(label: &str, title: &str) -> PipelineDocument {
|
||||
let PipelineDocument::Ruling(mut document) = ruling(label, None) else { unreachable!() };
|
||||
document.title = title.into();
|
||||
PipelineDocument::Ruling(document)
|
||||
}
|
||||
|
||||
/// A mind where Hands opened two follow-ups and closed one, and Soul ruled once, all inside the window.
|
||||
fn worked_on() -> TestMind {
|
||||
let mind = TestMind::seeded();
|
||||
mind.committed(vec![spec("x")]);
|
||||
let PipelineDocument::FollowUp(mut sealed) = follow_up("f1", &spec_ref("x")) else { unreachable!() };
|
||||
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 { .. }));
|
||||
mind
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_window_opens_at_her_last_wake_within_a_day_and_a_week() {
|
||||
let now = now();
|
||||
assert_eq!(super::since(None, now), now - Duration::days(7), "never woken: a week");
|
||||
assert_eq!(super::since(Some(now - Duration::days(30)), now), now - Duration::days(7));
|
||||
assert_eq!(super::since(Some(now - Duration::minutes(10)), now), now - Duration::hours(24));
|
||||
assert_eq!(super::since(Some(now - Duration::days(2)), now), now - Duration::days(2));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn k23_her_door_and_the_forge_render_merged_and_ruled_titles_and_counts_of_what_is_open() {
|
||||
let mind = worked_on();
|
||||
let forge = Forge::default().live(HUGINN, json!([
|
||||
pull("Persona: the domain digest", "kiko", now() - Duration::days(2), Some(now() - Duration::minutes(30))),
|
||||
pull("OPEN-PR-TITLE-SENTINEL", "nibu", now() - Duration::hours(3), None),
|
||||
]));
|
||||
let facts = read_through(&mind, &forge).unwrap();
|
||||
let lines = lines(&facts, since(), now());
|
||||
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(),
|
||||
]);
|
||||
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}");
|
||||
// "Who" is the pull request's opener; no commit is ever read, so a commit's author can say nothing.
|
||||
assert!(forge.asked.borrow().iter().all(|path| !path.contains("/commits") && !path.contains("/git/")), "{:?}", forge.asked.borrow());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn k23_only_her_in_force_stewardships_name_her_repos_never_a_campaign_list() {
|
||||
let mind = TestMind::seeded();
|
||||
// A campaign of hers that lists a repo she does not steward, and a stewarded repo no campaign lists.
|
||||
mind.committed(vec![campaign_listing("other-camp", &["GameCult/NotHers"]), stewardship_of(INSTANCE, "GameCult/Lonely")]);
|
||||
let forge = Forge::default()
|
||||
.live(HUGINN, json!([]))
|
||||
.live("GameCult/Lonely", json!([pull("Lonely: first light", "aqua", now() - Duration::days(1), Some(now() - Duration::hours(5)))]))
|
||||
.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");
|
||||
assert!(all.contains("- GameCult/Lonely: 1 pull request merged since Tuesday (\"Lonely: first light\"), opened by aqua.") && !all.contains("NOT-HERS"), "{all}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn k23_a_stewardship_of_another_instance_held_in_her_mind_names_no_repo_of_hers() {
|
||||
let mind = TestMind::seeded();
|
||||
let outcome = mind.put(vec![stewardship_of("kiko", "GameCult/Ratatoskr")]);
|
||||
let forge = Forge::default().live(HUGINN, json!([])).live("GameCult/Ratatoskr", json!([]));
|
||||
read_through(&mind, &forge).unwrap();
|
||||
assert!(!forge.asked_about("Ratatoskr"), "only her own stewardships ({outcome:?}): {:?}", forge.asked.borrow());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn k23_a_campaign_held_in_another_minds_mind_never_appears_in_hers() {
|
||||
let hers = TestMind::without_campaigns();
|
||||
let theirs = TestMind::seeded_as("kiko");
|
||||
theirs.committed(vec![ruled("r1", "THEIR-RULING-SENTINEL")]);
|
||||
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"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn k23_an_archived_or_missing_or_moved_repo_renders_nothing_and_is_reported() {
|
||||
let mind = TestMind::without_campaigns();
|
||||
mind.committed(vec![stewardship_of(INSTANCE, "GameCult/Gone"), stewardship_of(INSTANCE, "GameCult/Renamed")]);
|
||||
let forge = Forge::default().answering(HUGINN, 200, json!({ "archived": true })).answering("GameCult/Renamed", 301, json!({}));
|
||||
let facts = read_through(&mind, &forge).unwrap();
|
||||
assert_eq!(
|
||||
facts.skipped,
|
||||
vec![
|
||||
Skipped { repo: HUGINN.into(), why: Skip::Archived },
|
||||
Skipped { repo: "GameCult/Gone".into(), why: Skip::NotFound },
|
||||
Skipped { repo: "GameCult/Renamed".into(), why: Skip::Moved },
|
||||
]
|
||||
);
|
||||
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());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn k23_a_failed_read_fails_whole_and_project_leaves_the_section_out_and_reports_why() {
|
||||
let mind = worked_on();
|
||||
assert!(read_through(&mind, &Down).is_err(), "a forge that does not answer fails the read");
|
||||
let refusing = Forge::default().answering(HUGINN, 500, json!({}));
|
||||
assert!(read_through(&mind, &refusing).is_err(), "a 500 is not a missing repo");
|
||||
|
||||
struct Live<'a>(&'a TestMind);
|
||||
impl DomainSource for Live<'_> {
|
||||
fn read(&self, since: DateTime<Utc>, now: DateTime<Utc>) -> Result<DomainFacts> {
|
||||
read(&|selection: &Selection| self.0.query(selection), &self.0.instance().0, &Down, since, now)
|
||||
}
|
||||
}
|
||||
let (lines, report) = crate::projection::read_domain(Some(&Live(&mind)), None, now());
|
||||
assert!(lines.is_empty(), "{lines:?}");
|
||||
assert_eq!((report["read"].clone(), report["why"].as_str().is_some_and(|why| why.contains("forge"))), (json!(false), true), "{report}");
|
||||
let (lines, report) = crate::projection::read_domain(None, None, now());
|
||||
assert!(lines.is_empty() && report["read"] == json!(false), "{report}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
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() }] }],
|
||||
skipped: vec![],
|
||||
};
|
||||
assert!(lines(&facts, since(), now()).is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn k23_lines_run_newest_first_and_clip_long_titles_and_count_past_two() {
|
||||
let long = "x".repeat(300);
|
||||
let merged = |hours: i64, title: &str| Pull { title: title.into(), opener: "kiko".into(), opened_at: now() - Duration::days(2), merged_at: Some(now() - Duration::hours(hours)), open: false };
|
||||
let facts = DomainFacts {
|
||||
repos: vec![
|
||||
RepoFacts { repo: "GameCult/Older".into(), pulls: vec![merged(30, "a")] },
|
||||
RepoFacts { repo: "GameCult/Newer".into(), pulls: vec![merged(1, &long), merged(2, "b"), merged(3, "c"), merged(4, "d")] },
|
||||
],
|
||||
..DomainFacts::default()
|
||||
};
|
||||
let lines = lines(&facts, since(), now());
|
||||
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]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_fixture_reads_as_the_live_facts_do() {
|
||||
let facts: DomainFacts = toml::from_str(
|
||||
r#"
|
||||
[[repos]]
|
||||
repo = "GameCult/Aetheria"
|
||||
[[repos.pulls]]
|
||||
title = "Docs: passages made true"
|
||||
opener = "nibu"
|
||||
opened_at = "2026-10-08T10:00:00Z"
|
||||
merged_at = "2026-10-09T09:00:00Z"
|
||||
[[campaigns]]
|
||||
slug = "aetheria-release"
|
||||
[[campaigns.events]]
|
||||
what = "ruled"
|
||||
at = "2026-10-09T08:00:00Z"
|
||||
title = "Ship v0.2.0"
|
||||
who = "a Self session"
|
||||
[[skipped]]
|
||||
repo = "GameCult/Aetheria-legacy"
|
||||
why = "archived"
|
||||
"#,
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(DomainSource::read(&facts, since(), now()).unwrap(), facts);
|
||||
assert_eq!(lines(&facts, since(), now()), 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(),
|
||||
]);
|
||||
assert!(toml::from_str::<DomainFacts>("[[repos]]\nrepo = \"x\"\nwho = \"y\"\n").is_err(), "an unknown key refuses the fixture");
|
||||
}
|
||||
|
|
@ -33,7 +33,7 @@ Kiko, in #swarm:gamecult.org: "She saw it. She hated it."
|
|||
--- projector prompt
|
||||
You are a private Projector. Write one person's present moment from inside it, in the first person and the present tense: the lived stream she will go on to continue in her own thought. Her interior is the point: what she feels, wants, fears and remembers, and how the people here sit with her, rendered as lived, not listed.
|
||||
|
||||
Render only what is established below: who she is and her present under its headings. Anything absent from these is unavailable: render suspicion or speculation as uncertainty, never as remembered or perceived fact. Furnish no place, object or event these do not give: no act or event of her own (nothing she did, drafted, sent or decided) and no line anyone said that is not below. Each heading says what its lines are. What came of her last turn is what came of what she last meant to do, which she is only now finding out: whenever something she meant did not happen, the stream begins from it, as she notices it, never as a list; when all of it happened, it may pass in a clause or not at all. Her open promises are what she gave her word to do and has not done or taken back: facts about her that hold until they close, there in her awareness as a kept word is, never a list. Here and now is the hour, how her mood leans when it does, and the room as it stands. Her body is how the moment reaches her and how she can answer it: it is not news to her, and a lack in it is felt only when the moment reaches for something it cannot do. The people here are as she holds them, not as those people are. The notes about her were set down at another time, by others and by her own past self: all of it is material for the stream and never its wording. How her words run is the stream's idiom, never its material: it shows in how the stream moves, and nothing in the stream remarks on it.
|
||||
Render only what is established below: who she is and her present under its headings. Anything absent from these is unavailable: render suspicion or speculation as uncertainty, never as remembered or perceived fact. Furnish no place, object or event these do not give: no act or event of her own (nothing she did, drafted, sent or decided) and no line anyone said that is not below. Each heading says what its lines are. What came of her last turn is what came of what she last meant to do, which she is only now finding out: whenever something she meant did not happen, the stream begins from it, as she notices it, never as a list; when all of it happened, it may pass in a clause or not at all. Her open promises are what she gave her word to do and has not done or taken back: facts about her that hold until they close, there in her awareness as a kept word is, never a list. Here and now is the hour, how her mood leans when it does, and the room as it stands. Her body is how the moment reaches her and how she can answer it: it is not news to her, and a lack in it is felt only when the moment reaches for something it cannot do. The people here are as she holds them, not as those people are. What is in her domain lately is news of her part of the coop, what was merged and ruled there and by whom: never a task, and none of it work she owes. The notes about her were set down at another time, by others and by her own past self: all of it is material for the stream and never its wording. How her words run is the stream's idiom, never its material: it shows in how the stream moves, and nothing in the stream remarks on it.
|
||||
|
||||
Render the two or three notes this moment touches and leave the rest. Do not recap the notes. Do not weigh options, list what she might say or do, or steer toward a decision: end where the moment is, not on a resolution. Do not choose actions, emit schemas, expose field names or ids, or claim world effects.
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,9 @@
|
|||
//! - A **room fixture** (`mind-persona project --room <file>`) is a TOML file standing in for the mouth and the room tail:
|
||||
//! her Matrix id, the rooms, the messages with who said them, when and where, and which were new to her, plus a mocked
|
||||
//! clock and a mocked "last heard from" table. The fixture is a `MouthReader`, so `project` reads it exactly as it reads
|
||||
//! the mouth, and whether a message is for her is still `address::is_for`, over the fixture's names.
|
||||
//! the mouth, and whether a message is for her is still `address::is_for`, over the fixture's names. Its optional
|
||||
//! `[domain]` is what a read of her domain returned (`domain::DomainFacts`: repos and their pull requests, campaigns and
|
||||
//! what was admitted under them, repos skipped), so a re-test renders her domain without the forge or her mind.
|
||||
//! - A **batch** (`--batch <plan>`) runs `project` once per state, scenario and sample and writes one Markdown report.
|
||||
//! - A **simulation** (`--simulate <plan>`, `simulate.rs`) runs the cast of the swarm in turn in one simulated room.
|
||||
//!
|
||||
|
|
@ -22,7 +24,7 @@ use serde::Deserialize;
|
|||
use serde_json::{Value, json};
|
||||
|
||||
use super::narrate::{Model, distinct_2};
|
||||
use super::{MouthReader, Organs, PersonaSource, Request, Through, TurnKind, project};
|
||||
use super::{DomainFacts, DomainSource, MouthReader, Organs, PersonaSource, Request, Through, TurnKind, project};
|
||||
use crate::address::{Addressee, localpart};
|
||||
use crate::chat_client::{Basis, ChatDelivery, ChatPending, Form, REPLY_EXCERPT_CHARS, ReplyLink, ReplyTo, TailLine};
|
||||
use crate::heartbeat::{Addressing, HeartbeatView};
|
||||
|
|
@ -242,6 +244,8 @@ struct FixtureFile {
|
|||
last_heard: BTreeMap<String, String>,
|
||||
#[serde(default, rename = "message")]
|
||||
messages: Vec<Message>,
|
||||
#[serde(default)]
|
||||
domain: Option<DomainFacts>,
|
||||
}
|
||||
|
||||
/// A mocked room: it stands in for the mouth and the room tail, the clock, and who is who.
|
||||
|
|
@ -258,6 +262,7 @@ pub struct Fixture {
|
|||
pub minds: Vec<String>,
|
||||
pub last_heard: Vec<(String, u64)>,
|
||||
lines: Vec<Line>,
|
||||
domain: Option<DomainFacts>,
|
||||
}
|
||||
|
||||
impl Fixture {
|
||||
|
|
@ -291,7 +296,7 @@ impl Fixture {
|
|||
lines.push(Line::of(message, at, Some(&file.her), index)?);
|
||||
}
|
||||
let last_heard = file.last_heard.iter().map(|(id, when)| Ok((id.clone(), unix_ms(file.now - ago(when)?)))).collect::<Result<_>>()?;
|
||||
Ok(Self { her: file.her, names: file.names, kind: file.kind, now: file.now, here: file.here, operators: file.operators, minds: file.minds, last_heard, lines })
|
||||
Ok(Self { her: file.her, names: file.names, kind: file.kind, now: file.now, here: file.here, operators: file.operators, minds: file.minds, last_heard, lines, domain: file.domain })
|
||||
}
|
||||
|
||||
/// Her addressee, as the heartbeat's table would carry it, when the fixture names her: her handle and its names.
|
||||
|
|
@ -299,6 +304,11 @@ impl Fixture {
|
|||
pub fn addressee(&self) -> Option<&dyn HeartbeatView> {
|
||||
(!self.names.is_empty()).then_some(self as &dyn HeartbeatView)
|
||||
}
|
||||
|
||||
/// What a read of her domain returned, when the fixture says (`[domain]`); none leaves the packet without the section.
|
||||
pub fn domain(&self) -> Option<&dyn DomainSource> {
|
||||
self.domain.as_ref().map(|facts| facts as &dyn DomainSource)
|
||||
}
|
||||
}
|
||||
|
||||
impl MouthReader for Fixture {
|
||||
|
|
@ -345,6 +355,7 @@ pub fn fixture_request(harness: &Harness, fixture: &Fixture, state: Option<Value
|
|||
recent: vec![],
|
||||
own_rooms: vec![],
|
||||
last_outcome: None,
|
||||
last_wake: None,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -407,7 +418,7 @@ pub fn batch(harness: &Harness, plan_path: &Path) -> Result<String> {
|
|||
for (scenario_name, fixture) in &scenarios {
|
||||
for sample in 0..plan.samples {
|
||||
let seed = plan.seed.wrapping_add(sample as u64);
|
||||
let organs = Organs { persona: harness.persona, chat: Some(fixture), addressing: fixture.addressee(), model: harness.model };
|
||||
let organs = Organs { persona: harness.persona, chat: Some(fixture), addressing: fixture.addressee(), model: harness.model, domain: fixture.domain() };
|
||||
let request = fixture_request(harness, fixture, state.clone(), seed, Some(1), plan.through);
|
||||
let report = project(&organs, &request, fixture.now).unwrap_or_else(|fault| json!({ "error": format!("{fault:#}") }));
|
||||
cases.push(json!({ "state": state_name, "scenario": scenario_name, "sample": sample + 1, "seed": seed, "report": report }));
|
||||
|
|
|
|||
|
|
@ -203,7 +203,7 @@ fn through_the_interpreter_her_prose_continues_the_narration_and_the_interpreter
|
|||
let model = Scripted::new(|_| "He smiles at the screen, then types. <typed>Missed you too, friend.</typed> He does not mention the kettle.".into());
|
||||
let fixture = room("operator-warm.toml");
|
||||
let harness = harness(dir.path(), Some(&NeverAsked), Some(&model));
|
||||
let organs = Organs { persona: harness.persona, chat: Some(&fixture), addressing: fixture.addressee(), model: harness.model };
|
||||
let organs = Organs { persona: harness.persona, chat: Some(&fixture), addressing: fixture.addressee(), model: harness.model, domain: None };
|
||||
let report = project(&organs, &fixture_request(&harness, &fixture, Some(control()), 3, Some(1), Through::Interpreter), fixture.now).unwrap();
|
||||
let render = &report["renders"][0];
|
||||
assert_eq!(render["interpreter"]["said"][0]["text"], "Missed you too, friend.", "{render}");
|
||||
|
|
@ -230,7 +230,7 @@ fn prose_over_budget_is_cut_and_silence_says_nothing() {
|
|||
let model = Scripted::new(move |_| long.clone());
|
||||
let fixture = room("deru-passing.toml");
|
||||
let harness = harness(dir.path(), None, Some(&model));
|
||||
let organs = Organs { persona: None, chat: Some(&fixture), addressing: None, model: harness.model };
|
||||
let organs = Organs { persona: None, chat: Some(&fixture), addressing: None, model: harness.model, domain: None };
|
||||
let report = project(&organs, &fixture_request(&harness, &fixture, Some(control()), 1, Some(1), Through::Interpreter), fixture.now).unwrap();
|
||||
let persona = &report["renders"][0]["persona"];
|
||||
assert_eq!((persona["words"].as_u64(), persona["cut_at_budget"].as_bool()), (Some(180), Some(true)));
|
||||
|
|
@ -283,7 +283,7 @@ fn a_batch_state_without_a_file_is_her_stored_state() {
|
|||
fn group_line_of(dir: &Path, name: &str) -> Option<String> {
|
||||
let fixture = room(name);
|
||||
let harness = harness(dir, None, None);
|
||||
let organs = Organs { persona: None, chat: Some(&fixture), addressing: fixture.addressee(), model: None };
|
||||
let organs = Organs { persona: None, chat: Some(&fixture), addressing: fixture.addressee(), model: None, domain: None };
|
||||
let report = project(&organs, &fixture_request(&harness, &fixture, Some(control()), 1, None, Through::Projector), fixture.now).unwrap();
|
||||
let room = report["packet"]["context"].as_str().unwrap().lines().find(|line| line.starts_with("- the conversation")).map(str::to_owned);
|
||||
let speaking = report["packet"]["speaking"].as_str().filter(|speaking| !speaking.is_empty()).map(str::to_owned);
|
||||
|
|
@ -335,7 +335,7 @@ fn the_third_to_eighth_responder_sees_a_covered_question_and_no_duty() {
|
|||
let mut rendered = String::new();
|
||||
for answered in 2..=7 {
|
||||
let fixture = chorus(answered);
|
||||
let organs = Organs { persona: None, chat: Some(&fixture), addressing: None, model: None };
|
||||
let organs = Organs { persona: None, chat: Some(&fixture), addressing: None, model: None, domain: None };
|
||||
let report = project(&organs, &fixture_request(&harness, &fixture, Some(control()), 1, None, Through::Projector), fixture.now).unwrap();
|
||||
let context = report["packet"]["context"].as_str().unwrap().to_owned();
|
||||
let line = report["packet"]["speaking"].as_str().unwrap_or_default().to_owned();
|
||||
|
|
@ -361,7 +361,7 @@ fn soul_k9_each_outcome_fixture_opens_the_packet_with_his_words_verbatim() {
|
|||
("missing-affordance.json", "it will not happen by itself. In his thought: \"I want to show her the render, not describe it.\"."),
|
||||
] {
|
||||
let record: Value = serde_json::from_str(&std::fs::read_to_string(fixtures().join("outcomes").join(file)).unwrap()).unwrap();
|
||||
let organs = Organs { persona: None, chat: Some(&fixture), addressing: fixture.addressee(), model: None };
|
||||
let organs = Organs { persona: None, chat: Some(&fixture), addressing: fixture.addressee(), model: None, domain: None };
|
||||
let request = Request { last_outcome: Some(record), ..fixture_request(&harness(dir.path(), None, None), &fixture, Some(control()), 1, None, Through::Projector) };
|
||||
let report = project(&organs, &request, fixture.now).unwrap();
|
||||
let context = report["packet"]["context"].as_str().unwrap();
|
||||
|
|
@ -370,3 +370,26 @@ fn soul_k9_each_outcome_fixture_opens_the_packet_with_his_words_verbatim() {
|
|||
assert_eq!(report["last_outcome"]["omitted"], json!([]), "{file}");
|
||||
}
|
||||
}
|
||||
|
||||
/// A room fixture's `[domain]` is what a read of her domain returned: `project` renders it with no forge and no mind, and
|
||||
/// reports what it skipped. Without one, no section, and the report says why.
|
||||
#[test]
|
||||
fn k23_a_room_fixtures_domain_renders_without_the_forge() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let text = format!(
|
||||
"{}\n[[domain.repos]]\nrepo = \"GameCult/Lodur\"\n[[domain.repos.pulls]]\ntitle = \"Reflex: the knee bends first\"\nopener = \"nibu\"\nopened_at = \"2026-11-18T10:00:00Z\"\nmerged_at = \"2026-11-19T12:00:00Z\"\n[[domain.skipped]]\nrepo = \"GameCult/Aetheria-legacy\"\nwhy = \"archived\"\n",
|
||||
std::fs::read_to_string(fixtures().join("rooms/quiet-beat.toml")).unwrap()
|
||||
);
|
||||
let fixture = Fixture::parse(&text).unwrap();
|
||||
let organs = Organs { persona: None, chat: Some(&fixture), addressing: fixture.addressee(), model: None, domain: fixture.domain() };
|
||||
let report = project(&organs, &fixture_request(&harness(dir.path(), None, None), &fixture, Some(control()), 1, None, Through::Projector), fixture.now).unwrap();
|
||||
let context = report["packet"]["context"].as_str().unwrap();
|
||||
assert!(context.contains("domain lately:\n- GameCult/Lodur: 1 pull request merged since last Friday (\"Reflex: the knee bends first\"), opened by nibu."), "{context}");
|
||||
assert_eq!((report["domain"]["read"].clone(), report["domain"]["skipped"][0]["why"].clone()), (json!(true), json!("archived")), "{}", report["domain"]);
|
||||
assert!(!context.contains("Aetheria-legacy"), "a skipped repo is reported, never shown to her");
|
||||
|
||||
let plain = room("quiet-beat.toml");
|
||||
let organs = Organs { persona: None, chat: Some(&plain), addressing: plain.addressee(), model: None, domain: plain.domain() };
|
||||
let report = project(&organs, &fixture_request(&harness(dir.path(), None, None), &plain, Some(control()), 1, None, Through::Projector), plain.now).unwrap();
|
||||
assert!(!report["packet"]["context"].as_str().unwrap().contains("domain lately") && report["domain"]["read"] == json!(false), "{}", report["domain"]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -415,6 +415,14 @@ pub(crate) fn speech_prompt(packet: &Packet, narration: &str, prose: &str, tunin
|
|||
if promises.is_empty() {
|
||||
promises.push_str("- none\n");
|
||||
}
|
||||
// What moved in her domain, by id, so a later read can name a line (map 16.22.2, 16.22.3); listed only when the packet
|
||||
// showed her some, since an empty list would read as nothing having moved.
|
||||
let domain: String = if packet.domain.is_empty() {
|
||||
String::new()
|
||||
} else {
|
||||
let lines: String = packet.domain.iter().map(|moved| format!("- {} \u{2014} {}\n", moved.id, moved.line.trim_start_matches("- "))).collect();
|
||||
format!("What moved in {} domain lately, as id \u{2014} line (news of {} part of the coop, none of it work {} owe{}):\n{lines}\n", her.poss, her.poss, her.subj, her.s)
|
||||
};
|
||||
let found = drafts(prose);
|
||||
let mut numbered: String = found.drafts.iter().map(|draft| format!("{}. {}\n", draft.n, draft.text)).collect();
|
||||
if numbered.is_empty() {
|
||||
|
|
@ -429,7 +437,7 @@ pub(crate) fn speech_prompt(packet: &Packet, narration: &str, prose: &str, tunin
|
|||
let guidance = voiced(tuning.interpreter.guidance.trim(), her);
|
||||
let guidance = if guidance.is_empty() { String::new() } else { format!("{guidance}\n\n") };
|
||||
format!(
|
||||
"{}\n\n{guidance}{}\n\nWho {} {}:\n{}\n\nWhat {} can do here:\n{}.\n\nThe room: {} ({}).\n{conversation}Who is in it, as label \u{2014} Matrix id:\n{people}\nWhat {} know{} privately, none of it to be said here:\n{private}\nLines in this room {} may reply to, as id \u{2014} who: line:\n{quotable}\n{poss} own lines in this room that {} may add to, as id \u{2014} line:\n{amendable}\n{poss} open promises, as id \u{2014} to whom: words:\n{promises}\nWhat reached {}:\n{}\n\n{poss} lived moment:\n{}\n\n{poss} prose:\n{prose}\n\n{poss} drafts, by number:\n{numbered}",
|
||||
"{}\n\n{guidance}{}\n\nWho {} {}:\n{}\n\nWhat {} can do here:\n{}.\n\nThe room: {} ({}).\n{conversation}Who is in it, as label \u{2014} Matrix id:\n{people}\nWhat {} know{} privately, none of it to be said here:\n{private}\nLines in this room {} may reply to, as id \u{2014} who: line:\n{quotable}\n{poss} own lines in this room that {} may add to, as id \u{2014} line:\n{amendable}\n{poss} open promises, as id \u{2014} to whom: words:\n{promises}\n{domain}What reached {}:\n{}\n\n{poss} lived moment:\n{}\n\n{poss} prose:\n{prose}\n\n{poss} drafts, by number:\n{numbered}",
|
||||
speech_frame_head(her),
|
||||
speech_frame_tail(her),
|
||||
her.subj,
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ fn packet_in(kind: TurnKind, state: &Value, room: &Room, seed: u64) -> Packet {
|
|||
let minds = vec![HER.to_owned(), NIBU.to_owned(), VOID.to_owned(), LIBBY.to_owned(), KIKO.to_owned()];
|
||||
let operators = vec!["@meta:gamecult.org".to_owned()];
|
||||
let history = History::default();
|
||||
select(&Inputs { kind, state, room, history: &history, observation: None, people: People { operators: &operators, minds: &minds, own_sender: HER }, now: now(), seed, affordances: &[Affordance::Perceive, Affordance::Speak] }, &Tuning::default())
|
||||
select(&Inputs { kind, state, room, history: &history, observation: None, people: People { operators: &operators, minds: &minds, own_sender: HER }, now: now(), seed, affordances: &[Affordance::Perceive, Affordance::Speak], domain: &[] }, &Tuning::default())
|
||||
}
|
||||
|
||||
/// Heimdall: the control state, he/him.
|
||||
|
|
|
|||
|
|
@ -149,7 +149,8 @@ pub(crate) fn word_budget(kind: TurnKind, tuning: &Tuning) -> usize {
|
|||
/// sentence keeps the absence unfilled. Nothing in it tells her what she has not yet read (map 16.20.1). Dropped: its ban on temperament, mood and inner voice, "no metaphor, no atmosphere",
|
||||
/// "say only what changes the decision" and "a thin moment gets a thin stream". Added: the first person and the present
|
||||
/// tense; what the packet's headings mean (map 16.5, I16.4); that what came of her last turn is news she is only now
|
||||
/// finding out, rendered as noticed and never as a list (map 16.16); that the notes are material,
|
||||
/// finding out, rendered as noticed and never as a list (map 16.16); that her domain lately is news of her part of the coop,
|
||||
/// never a task (map 16.22.2); that the notes are material,
|
||||
/// never wording, and how her words run (under its own heading, map 16.19.3) is idiom, never material; that her body is how the
|
||||
/// moment is perceived, not news, and a lack in it is felt only when the moment reaches for it (map 16.6); no invented act, event or
|
||||
/// line of hers or anyone's; focus on two or three notes (map 16.8: the frame owns focus, the byte caps are guards); and
|
||||
|
|
@ -161,7 +162,7 @@ pub(crate) fn projector_frame(her: Forms) -> String {
|
|||
format!(
|
||||
"{PROJECTOR_OPENING} Write one person's present moment from inside it, in the first person and the present tense: the lived stream {subj} will go on to continue in {poss} own thought. {cap_poss} interior is the point: what {subj} feel{s}, want{s}, fear{s} and remember{s}, and how the people here sit with {obj}, rendered as lived, not listed.
|
||||
|
||||
Render only what is established below: who {subj} {be} and {poss} present under its headings. Anything absent from these is unavailable: render suspicion or speculation as uncertainty, never as remembered or perceived fact. Furnish no place, object or event these do not give: no act or event of {poss} own (nothing {subj} did, drafted, sent or decided) and no line anyone said that is not below. Each heading says what its lines are. What came of {poss} last turn is what came of what {subj} last meant to do, which {subj} {be} only now finding out: whenever something {subj} meant did not happen, the stream begins from it, as {subj} notice{s} it, never as a list; when all of it happened, it may pass in a clause or not at all. {cap_poss} open promises are what {subj} gave {poss} word to do and {has} not done or taken back: facts about {obj} that hold until they close, there in {poss} awareness as a kept word is, never a list. Here and now is the hour, how {poss} mood leans when it does, and the room as it stands. {cap_poss} body is how the moment reaches {obj} and how {subj} can answer it: it is not news to {obj}, and a lack in it is felt only when the moment reaches for something it cannot do. The people here are as {subj} hold{s} them, not as those people are. The notes about {obj} were set down at another time, by others and by {poss} own past self: all of it is material for the stream and never its wording. How {poss} words run is the stream's idiom, never its material: it shows in how the stream moves, and nothing in the stream remarks on it.
|
||||
Render only what is established below: who {subj} {be} and {poss} present under its headings. Anything absent from these is unavailable: render suspicion or speculation as uncertainty, never as remembered or perceived fact. Furnish no place, object or event these do not give: no act or event of {poss} own (nothing {subj} did, drafted, sent or decided) and no line anyone said that is not below. Each heading says what its lines are. What came of {poss} last turn is what came of what {subj} last meant to do, which {subj} {be} only now finding out: whenever something {subj} meant did not happen, the stream begins from it, as {subj} notice{s} it, never as a list; when all of it happened, it may pass in a clause or not at all. {cap_poss} open promises are what {subj} gave {poss} word to do and {has} not done or taken back: facts about {obj} that hold until they close, there in {poss} awareness as a kept word is, never a list. Here and now is the hour, how {poss} mood leans when it does, and the room as it stands. {cap_poss} body is how the moment reaches {obj} and how {subj} can answer it: it is not news to {obj}, and a lack in it is felt only when the moment reaches for something it cannot do. The people here are as {subj} hold{s} them, not as those people are. What is in {poss} domain lately is news of {poss} part of the coop, what was merged and ruled there and by whom: never a task, and none of it work {subj} owe{s}. The notes about {obj} were set down at another time, by others and by {poss} own past self: all of it is material for the stream and never its wording. How {poss} words run is the stream's idiom, never its material: it shows in how the stream moves, and nothing in the stream remarks on it.
|
||||
|
||||
Render the two or three notes this moment touches and leave the rest. Do not recap the notes. Do not weigh options, list what {subj} might say or do, or steer toward a decision: end where the moment is, not on a resolution. Do not choose actions, emit schemas, expose field names or ids, or claim world effects."
|
||||
)
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ use serde_json::Value;
|
|||
use unicode_segmentation::UnicodeSegmentation;
|
||||
|
||||
use super::Affordance;
|
||||
use super::domain::DOMAIN_LINES;
|
||||
use super::outcome::{self, Outcome};
|
||||
use super::tuning::{LensWeights, Tuning};
|
||||
use crate::address::localpart;
|
||||
|
|
@ -222,6 +223,9 @@ pub(crate) struct Inputs<'a> {
|
|||
pub seed: u64,
|
||||
/// What this turn can do (`super::affordances`).
|
||||
pub affordances: &'a [Affordance],
|
||||
/// What moved in her domain lately, one line each, newest first (`domain::lines`, map 16.22.2): empty when nothing
|
||||
/// moved, and when the read failed, which the report says.
|
||||
pub domain: &'a [String],
|
||||
}
|
||||
|
||||
/// Where a turn begins.
|
||||
|
|
@ -333,6 +337,8 @@ pub(crate) struct Packet {
|
|||
pub quotable: Vec<Quotable>,
|
||||
/// Her open promises the packet shows her, for the Interpreter's list (map 16.22.1).
|
||||
pub promises: Vec<Promised>,
|
||||
/// The lines of her domain the packet shows her, for the Interpreter's view by id (map 16.22.2).
|
||||
pub domain: Vec<DomainLine>,
|
||||
/// What came of her last turn that the outcome's guard left out, whole: counted in the packet's last outcome line and
|
||||
/// reported here (map 16.20.5, I16.11), never shown to a model.
|
||||
pub unshown: Vec<String>,
|
||||
|
|
@ -380,6 +386,14 @@ pub(crate) struct Promised {
|
|||
pub words: String,
|
||||
}
|
||||
|
||||
/// A line of her domain as this packet shows it (map 16.22.2): by `id` (`d1`, `d2`) in the Interpreter's view only, so a
|
||||
/// read can name it (16.22.3).
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize)]
|
||||
pub(crate) struct DomainLine {
|
||||
pub id: String,
|
||||
pub line: String,
|
||||
}
|
||||
|
||||
/// What the messages to her cost past the caps: bytes over the stimulus and heard caps, the older messages to her the
|
||||
/// `addressed_bytes` ceiling left out, and the bytes clipped from a single message larger than the ceiling.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize)]
|
||||
|
|
@ -1704,6 +1718,8 @@ enum Section {
|
|||
Body,
|
||||
/// The bonds of the people present.
|
||||
People,
|
||||
/// What moved in her domain lately (map 16.22.2): news of her part of the coop, never a task.
|
||||
Domain,
|
||||
/// Her state's notes about her: anchored thoughts, values, what she said.
|
||||
Notes,
|
||||
}
|
||||
|
|
@ -1716,6 +1732,7 @@ impl Section {
|
|||
Self::Here => "Here and now:".into(),
|
||||
Self::Body => format!("{} body:", capitalized(her.poss)),
|
||||
Self::People => format!("People here, as {} hold{} them:", her.subj, her.s),
|
||||
Self::Domain => format!("In {} domain lately:", her.poss),
|
||||
Self::Notes => format!("Notes about {}, set down at another time:", her.obj),
|
||||
}
|
||||
}
|
||||
|
|
@ -1733,7 +1750,7 @@ const TURNED_BYTES: usize = NAME_BYTES + 40;
|
|||
/// No section's guard is another's, so no section's content can displace another's.
|
||||
fn guards(tuning: &Tuning, her: Forms) -> [usize; SECTIONS] {
|
||||
let select = &tuning.select;
|
||||
[select.outcome_bytes, select.promises_bytes, select.here_bytes, select.body_bytes, people_guard(tuning, her), select.notes_bytes]
|
||||
[select.outcome_bytes, select.promises_bytes, select.here_bytes, select.body_bytes, people_guard(tuning, her), select.domain_bytes, select.notes_bytes]
|
||||
}
|
||||
|
||||
/// How long ago a promise was made, in words.
|
||||
|
|
@ -1802,6 +1819,29 @@ fn open_promises(inputs: &Inputs, her: Forms, bodies: &[String], context: &mut C
|
|||
listed
|
||||
}
|
||||
|
||||
/// What moved in her domain lately (map 16.22.2): the lines `domain::lines` rendered, newest first, under the section's
|
||||
/// own guard (`domain_bytes`, I16.8) and at most `DOMAIN_LINES` lines. Past either the newest that fit are shown and the
|
||||
/// rest counted, never dropped silently (I16.11). The lines shown are the Interpreter's, by id.
|
||||
fn domain_lines(inputs: &Inputs, her: Forms, context: &mut Context) -> Vec<DomainLine> {
|
||||
let lines = inputs.domain;
|
||||
let count = |more: usize| format!("- {more} more {} of {} domain moved, not shown here.", if more == 1 { "part" } else { "parts" }, her.poss);
|
||||
let room = context.room(Section::Domain).saturating_sub(Section::Domain.heading(her).len() + 1);
|
||||
let cost = |shown: usize| lines[..shown].iter().map(|line| line.len() + 1).sum::<usize>() + if shown < lines.len() { count(lines.len() - shown).len() + 1 } else { 0 };
|
||||
let fits = |shown: usize| cost(shown) <= room && shown + usize::from(shown < lines.len()) <= DOMAIN_LINES;
|
||||
let shown = (0..=lines.len()).rev().find(|&shown| fits(shown)).unwrap_or(0);
|
||||
let mut listed = Vec::new();
|
||||
for line in &lines[..shown] {
|
||||
if context.push(Section::Domain, line.clone()) {
|
||||
listed.push(DomainLine { id: format!("d{}", listed.len() + 1), line: line.clone() });
|
||||
}
|
||||
}
|
||||
if shown < lines.len() {
|
||||
context.bound[Section::Domain as usize] = true;
|
||||
context.push(Section::Domain, count(lines.len() - shown));
|
||||
}
|
||||
listed
|
||||
}
|
||||
|
||||
/// The people's guard: its heading and the bonds a packet shows in full, each a summary, its head, the act of turning to
|
||||
/// her, and its newline.
|
||||
pub(crate) fn people_guard(tuning: &Tuning, her: Forms) -> usize {
|
||||
|
|
@ -1810,7 +1850,7 @@ pub(crate) fn people_guard(tuning: &Tuning, her: Forms) -> usize {
|
|||
Section::People.heading(her).len().saturating_add(select.people_full.saturating_mul(bond))
|
||||
}
|
||||
|
||||
const SECTIONS: usize = 6;
|
||||
const SECTIONS: usize = 7;
|
||||
|
||||
/// The bytes each section of the context took as rendered, its heading included, and the sections whose guard refused a
|
||||
/// line: what `--select-only` reports.
|
||||
|
|
@ -1821,6 +1861,7 @@ pub(crate) struct Sections {
|
|||
pub here: usize,
|
||||
pub body: usize,
|
||||
pub people: usize,
|
||||
pub domain: usize,
|
||||
pub notes: usize,
|
||||
pub bound: Vec<&'static str>,
|
||||
}
|
||||
|
|
@ -1838,7 +1879,7 @@ struct Context {
|
|||
|
||||
impl Context {
|
||||
fn new(guards: [usize; SECTIONS], her: Forms) -> Self {
|
||||
Self { sections: [Section::Outcome, Section::Promises, Section::Here, Section::Body, Section::People, Section::Notes].map(|section| (section.heading(her), Vec::new())), guards, used: [0; SECTIONS], bound: [false; SECTIONS] }
|
||||
Self { sections: [Section::Outcome, Section::Promises, Section::Here, Section::Body, Section::People, Section::Domain, Section::Notes].map(|section| (section.heading(her), Vec::new())), guards, used: [0; SECTIONS], bound: [false; SECTIONS] }
|
||||
}
|
||||
|
||||
fn cost(&self, section: Section, line: &str) -> usize {
|
||||
|
|
@ -1880,8 +1921,8 @@ impl Context {
|
|||
|
||||
fn sizes(&self) -> Sections {
|
||||
let bytes = |section: Section| self.used[section as usize].saturating_sub(1);
|
||||
let names = ["outcome", "promises", "here", "body", "people", "notes"];
|
||||
Sections { outcome: bytes(Section::Outcome), promises: bytes(Section::Promises), here: bytes(Section::Here), body: bytes(Section::Body), people: bytes(Section::People), notes: bytes(Section::Notes), bound: names.into_iter().zip(self.bound).filter_map(|(name, bound)| bound.then_some(name)).collect() }
|
||||
let names = ["outcome", "promises", "here", "body", "people", "domain", "notes"];
|
||||
Sections { outcome: bytes(Section::Outcome), promises: bytes(Section::Promises), here: bytes(Section::Here), body: bytes(Section::Body), people: bytes(Section::People), domain: bytes(Section::Domain), notes: bytes(Section::Notes), bound: names.into_iter().zip(self.bound).filter_map(|(name, bound)| bound.then_some(name)).collect() }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2015,6 +2056,7 @@ pub(crate) fn select(inputs: &Inputs, tuning: &Tuning) -> Packet {
|
|||
_ => named.push((also, turned.is_some())),
|
||||
}
|
||||
}
|
||||
let domain = domain_lines(inputs, her, &mut context);
|
||||
// Here's room lines take its room by priority (map 16.21): the conversation, which opens with whoever turned to her
|
||||
// here; the arrivals on the also-here line (its least line, reserved); the pronouns, clipped to what is left; the
|
||||
// other names present. They are rendered in reading order: the pronouns, the conversation, the also-here line.
|
||||
|
|
@ -2094,5 +2136,5 @@ pub(crate) fn select(inputs: &Inputs, tuning: &Tuning) -> Packet {
|
|||
.map(|(at, (event, room, text))| Amendable { id: format!("a{}", at + 1), event: event.clone(), room: room.clone(), text: text.clone() })
|
||||
.collect();
|
||||
let selected = taken.into_iter().map(|candidate| Pick { id: candidate.id, pool: candidate.pool, log_score: candidate.log_score }).collect();
|
||||
Packet { kind: inputs.kind, seed: inputs.seed, lens, name, voice, context: context.render(), sections: context.sizes(), stimulus, heard, bridged, overflow, present: present_names, ids, selected, forms: her, people: people_in_view(inputs, tuning), 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)), bodies, private, clipped, amendable, quotable, promises, arrival, speaking: conversation.speaking.unwrap_or_default(), unshown }
|
||||
Packet { kind: inputs.kind, seed: inputs.seed, lens, name, voice, context: context.render(), sections: context.sizes(), stimulus, heard, bridged, overflow, present: present_names, ids, selected, forms: her, people: people_in_view(inputs, tuning), 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)), bodies, private, clipped, amendable, quotable, promises, domain, arrival, speaking: conversation.speaking.unwrap_or_default(), unshown }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ use super::commit;
|
|||
use super::harness::{Harness, Line, Message, OVERLAP_FLAG, cosine, pending_for, state_file, turn_markdown, usage_markdown, usage_total};
|
||||
use super::select::Draw;
|
||||
use super::tuning;
|
||||
use super::{MouthReader, Organs, Request, Through, TurnKind, project};
|
||||
use super::{DomainFacts, DomainSource, MouthReader, Organs, Request, Through, TurnKind, project};
|
||||
use crate::address::{Addressee, is_for, localpart};
|
||||
use crate::chat_client::ChatPending;
|
||||
use crate::heartbeat::{Addressing, DEFAULT_BEAT_S, FileStore, HeartbeatView, LineFacts, Speaker, WakeCause, WakePolicy, addressed_by_member, wakes};
|
||||
|
|
@ -118,6 +118,10 @@ struct CastEntry {
|
|||
/// `persona.env` records which rooms a Mind owns, so the plan says; a direct message is always hers.
|
||||
#[serde(default)]
|
||||
own_rooms: Vec<String>,
|
||||
/// What a read of her domain returns on every turn of hers (`[cast.domain]`, `domain::DomainFacts`), windowed from her
|
||||
/// last turn in the run; none leaves her packets without the section. No forge and no mind is read.
|
||||
#[serde(default)]
|
||||
domain: Option<DomainFacts>,
|
||||
}
|
||||
|
||||
struct Member {
|
||||
|
|
@ -411,10 +415,11 @@ fn run(harness: &Harness, plan: &SimFile, members: &mut [Member], repeat: usize)
|
|||
recent: recent[at].clone(),
|
||||
own_rooms: member.entry.own_rooms.clone(),
|
||||
last_outcome: last[at].take(),
|
||||
last_wake: last_turn[at],
|
||||
};
|
||||
let view = View { lines: &lines, viewer: &id, rooms: &member.rooms, seen: &seen[at] };
|
||||
let names = Names(&member.addressee);
|
||||
let organs = Organs { persona: None, chat: Some(&view), addressing: Some(&names), model: harness.model };
|
||||
let organs = Organs { persona: None, chat: Some(&view), addressing: Some(&names), model: harness.model, domain: member.entry.domain.as_ref().map(|facts| facts as &dyn DomainSource) };
|
||||
let report = project(&organs, &request, now).unwrap_or_else(|fault| json!({ "error": format!("{fault:#}") }));
|
||||
// Only the room she read is seen.
|
||||
seen[at].insert(here.clone(), lines.len());
|
||||
|
|
|
|||
|
|
@ -293,7 +293,7 @@ fn a_direct_message_in_one_of_the_plans_rooms_is_refused() {
|
|||
|
||||
#[test]
|
||||
fn the_mind_run_is_counted_across_her_rooms_and_an_uncounted_run_is_at_the_cap() {
|
||||
let her = Member { names_from: "test", addressee: Addressee::new("@kiko:x", ["kiko"]), entry: CastEntry { id: "@kiko:x".into(), name: "Kiko".into(), state: PathBuf::new(), rooms: vec![], own_rooms: vec![] }, state: Value::Null, rooms: vec!["#a:x".into(), "#b:x".into()] };
|
||||
let her = Member { names_from: "test", addressee: Addressee::new("@kiko:x", ["kiko"]), entry: CastEntry { id: "@kiko:x".into(), name: "Kiko".into(), state: PathBuf::new(), rooms: vec![], own_rooms: vec![], domain: None }, state: Value::Null, rooms: vec!["#a:x".into(), "#b:x".into()] };
|
||||
let cast = vec![TOBIAH.to_owned(), LIBBY.to_owned(), "@kiko:x".to_owned(), "@other:x".to_owned()];
|
||||
let line = |from: &str, room: &str| Line { from: from.into(), name: String::new(), room: room.into(), at_ms: 0, says: "hi".into(), mentions: vec![], dm_to: None, follow_up: false, reply_to: None, new: false };
|
||||
let lines = [line("@meta:x", "#a:x"), line(TOBIAH, "#a:x"), line("@other:x", "#b:x"), line(TOBIAH, "#b:x"), line("@meta:x", "#c:x")];
|
||||
|
|
@ -640,3 +640,51 @@ fn k22_a_promise_persists_across_silent_turns_until_the_person_releases_it() {
|
|||
let tobiah = members.iter().find(|member| member.entry.id == TOBIAH).unwrap();
|
||||
assert_eq!(tobiah.state["commitments"][0]["status"], "released", "his in-run state holds it, closed, until it is removed");
|
||||
}
|
||||
|
||||
/// A cast entry's `[cast.domain]` reaches her packets and no one else's, windowed from her last turn in the run.
|
||||
#[test]
|
||||
fn k23_a_cast_members_domain_reaches_her_packets_alone() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
cast(dir.path());
|
||||
let path = dir.path().join("plan.toml");
|
||||
std::fs::write(
|
||||
&path,
|
||||
format!(
|
||||
r##"rounds = 1
|
||||
seed = 11
|
||||
wake = "ruled"
|
||||
beat_s = 0
|
||||
start = "2026-11-20T15:00:00Z"
|
||||
rooms = ["#minds:gamecult.org"]
|
||||
operators = ["@meta:gamecult.org"]
|
||||
[[cast]]
|
||||
id = "{TOBIAH}"
|
||||
name = "Tobiah"
|
||||
state = "tobiah.json"
|
||||
[[cast.domain.repos]]
|
||||
repo = "GameCult/Lodur"
|
||||
[[cast.domain.repos.pulls]]
|
||||
title = "Reflex: the knee bends first"
|
||||
opener = "nibu"
|
||||
opened_at = "2026-11-18T10:00:00Z"
|
||||
merged_at = "2026-11-19T12:00:00Z"
|
||||
[[cast]]
|
||||
id = "{LIBBY}"
|
||||
name = "Libby"
|
||||
state = "libby.json"
|
||||
[[message]]
|
||||
from = "@meta:gamecult.org"
|
||||
name = "Meta"
|
||||
room = "#minds:gamecult.org"
|
||||
says = "good afternoon, everyone"
|
||||
"##
|
||||
),
|
||||
)
|
||||
.unwrap();
|
||||
let model = silent();
|
||||
run_plan(&path, &model);
|
||||
let projector: Vec<String> = model.calls.borrow().iter().filter(|(_, prompt)| prompt.starts_with(PROJECTOR_OPENING)).map(|(_, prompt)| prompt.clone()).collect();
|
||||
let with: Vec<&String> = projector.iter().filter(|prompt| prompt.contains("GameCult/Lodur: 1 pull request merged")).collect();
|
||||
assert!(!with.is_empty() && with.len() < projector.len(), "{} of {}", with.len(), projector.len());
|
||||
assert!(with.iter().all(|prompt| !prompt.contains("Libby Test")), "only his packets carry his domain");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ fn packet_of(kind: TurnKind, state: &Value, room: &Room, history: &History, seed
|
|||
fn packet_tuned(kind: TurnKind, state: &Value, room: &Room, history: &History, seed: u64, tuning: &Tuning) -> Packet {
|
||||
let operators = operators();
|
||||
let minds = minds();
|
||||
let inputs = Inputs { kind, state, room, history, observation: None, people: People { operators: &operators, minds: &minds, own_sender: OWN }, now: now(), seed, affordances: CAN };
|
||||
let inputs = Inputs { kind, state, room, history, observation: None, people: People { operators: &operators, minds: &minds, own_sender: OWN }, now: now(), seed, affordances: CAN, domain: &[] };
|
||||
select(&inputs, tuning)
|
||||
}
|
||||
|
||||
|
|
@ -119,10 +119,10 @@ 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());
|
||||
for (name, bytes, guard) in [("outcome", sections.outcome, select.outcome_bytes), ("promises", sections.promises, select.promises_bytes), ("here", sections.here, select.here_bytes), ("body", sections.body, select.body_bytes), ("people", sections.people, select::people_guard(tuning, packet.forms)), ("notes", sections.notes, select.notes_bytes)] {
|
||||
for (name, bytes, guard) in [("outcome", sections.outcome, select.outcome_bytes), ("promises", sections.promises, select.promises_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);
|
||||
}
|
||||
let shown: Vec<usize> = [sections.outcome, sections.here, sections.body, sections.people, sections.notes].into_iter().filter(|bytes| *bytes > 0).collect();
|
||||
let shown: Vec<usize> = [sections.outcome, sections.promises, sections.here, sections.body, sections.people, sections.domain, sections.notes].into_iter().filter(|bytes| *bytes > 0).collect();
|
||||
assert_eq!(shown.iter().sum::<usize>() + shown.len().saturating_sub(1), packet.context.len(), "the reported bytes are the rendered ones");
|
||||
}
|
||||
|
||||
|
|
@ -317,7 +317,7 @@ impl MouthReader for Deaf {
|
|||
#[test]
|
||||
fn what_the_turn_can_do_comes_from_what_it_holds() {
|
||||
let chat = mouth();
|
||||
let with = Organs { persona: None, chat: Some(&chat), addressing: None, model: None };
|
||||
let with = Organs { persona: None, chat: Some(&chat), addressing: None, model: None, domain: None };
|
||||
let without = Organs { chat: None, ..with };
|
||||
let room = Some("#swarm:gamecult.org");
|
||||
assert_eq!(affordances(&with, true, room, Through::Interpreter), [Affordance::Perceive, Affordance::Speak, Affordance::Suggest]);
|
||||
|
|
@ -575,7 +575,7 @@ fn reflection_and_follow_up_stimuli() {
|
|||
let operators = operators();
|
||||
let room = Room::default();
|
||||
let history = History::default();
|
||||
let inputs = Inputs { kind: TurnKind::FollowUp, state: &state(), room: &room, history: &history, observation: Some("Libby's change deleted 40 lines."), people: People { operators: &operators, minds: &[], own_sender: OWN }, now: now(), seed: 1, affordances: CAN };
|
||||
let inputs = Inputs { kind: TurnKind::FollowUp, state: &state(), room: &room, history: &history, observation: Some("Libby's change deleted 40 lines."), people: People { operators: &operators, minds: &[], own_sender: OWN }, now: now(), seed: 1, affordances: CAN, domain: &[] };
|
||||
let state_value = state();
|
||||
let follow = select(&Inputs { state: &state_value, ..inputs }, &Tuning::default());
|
||||
assert_eq!(follow.stimulus, "She just found: Libby's change deleted 40 lines.");
|
||||
|
|
@ -942,7 +942,7 @@ impl PersonaSource for Stored {
|
|||
}
|
||||
|
||||
fn request(dir: &std::path::Path, renders: Option<usize>, judge_against: Option<Value>) -> Request {
|
||||
Request { instance: INSTANCE.into(), kind: TurnKind::Chat, state: None, room: Some("#swarm:gamecult.org".into()), seed: 5, renders, judge_against, operators: operators(), minds: minds(), own_sender: OWN.into(), tuning: dir.join(TUNING_FILE), through: Through::Projector, last_heard: vec![], recent: vec![], own_rooms: vec![], last_outcome: None }
|
||||
Request { instance: INSTANCE.into(), kind: TurnKind::Chat, state: None, room: Some("#swarm:gamecult.org".into()), seed: 5, renders, judge_against, operators: operators(), minds: minds(), own_sender: OWN.into(), tuning: dir.join(TUNING_FILE), through: Through::Projector, last_heard: vec![], recent: vec![], own_rooms: vec![], last_outcome: None, last_wake: None }
|
||||
}
|
||||
|
||||
/// A human's line in her own room is to her (the humans_pace ruling: it always wakes her), with no name and no tag: the arrival
|
||||
|
|
@ -955,7 +955,7 @@ fn a_humans_line_in_her_own_room_is_to_her() {
|
|||
let nibu = "#nibu:gamecult.org";
|
||||
let mouth = |sender: &str, display: &str| ReadOnlyMouth { pending: ChatPending { persona: "eureka".into(), deliveries: vec![delivery(1, nibu, sender, display, "anyone around this evening?", &[])], tail: Some(vec![]), tail_gaps: vec![] }, reads: Cell::new(0) };
|
||||
let packet = |chat: &ReadOnlyMouth, own_rooms: Vec<String>| {
|
||||
let organs = Organs { persona: Some(&stored), chat: Some(chat), addressing: None, model: None };
|
||||
let organs = Organs { persona: Some(&stored), chat: Some(chat), addressing: None, model: None, domain: None };
|
||||
project(&organs, &Request { room: Some(nibu.into()), own_rooms, ..request(dir.path(), None, None) }, now()).unwrap()["packet"].clone()
|
||||
};
|
||||
let meta = mouth(OPERATOR, "Meta");
|
||||
|
|
@ -976,7 +976,7 @@ fn project_in_every_mode_writes_nothing() {
|
|||
let stored = Stored(state());
|
||||
let chat = mouth();
|
||||
let model = Recorded::discriminating();
|
||||
let organs = Organs { persona: Some(&stored), chat: Some(&chat), addressing: None, model: Some(&model) };
|
||||
let organs = Organs { persona: Some(&stored), chat: Some(&chat), addressing: None, model: Some(&model), domain: None };
|
||||
let mut other = state();
|
||||
other["affect"]["socialBonds"][1]["tension"] = json!(0.0);
|
||||
for (renders, judge) in [(None, None), (Some(3), None), (Some(2), Some(other))] {
|
||||
|
|
@ -993,7 +993,7 @@ fn project_select_only_reads_the_room_and_the_state_and_nothing_else() {
|
|||
let dir = tempfile::tempdir().unwrap();
|
||||
let stored = Stored(state());
|
||||
let chat = mouth();
|
||||
let organs = Organs { persona: Some(&stored), chat: Some(&chat), addressing: None, model: None };
|
||||
let organs = Organs { persona: Some(&stored), chat: Some(&chat), addressing: None, model: None, domain: None };
|
||||
let report = project(&organs, &request(dir.path(), None, None), now()).unwrap();
|
||||
assert_eq!(report["tuning"]["source"], "defaults");
|
||||
assert_eq!((report["room"]["read"].as_bool(), report["room"]["messages"].as_u64()), (Some(true), Some(1)), "only the room asked for");
|
||||
|
|
@ -1009,7 +1009,7 @@ fn renders_are_successive_turns_under_freshness_and_carry_the_guard() {
|
|||
let dir = tempfile::tempdir().unwrap();
|
||||
let stored = Stored(state());
|
||||
let model = Recorded::new(|_| "She waits. socialBonds hum.".into(), |_| "A".into());
|
||||
let organs = Organs { persona: Some(&stored), chat: None, addressing: None, model: Some(&model) };
|
||||
let organs = Organs { persona: Some(&stored), chat: None, addressing: None, model: Some(&model), domain: None };
|
||||
let report = project(&organs, &Request { kind: TurnKind::Beat, ..request(dir.path(), Some(4), None) }, now()).unwrap();
|
||||
let renders = report["renders"].as_array().unwrap();
|
||||
assert_eq!(renders.len(), 4);
|
||||
|
|
@ -1034,7 +1034,7 @@ fn the_judge_scores_a_discriminating_projector_and_fails_a_blind_one() {
|
|||
eased["affect"]["socialBonds"][0]["tension"] = json!(0.9);
|
||||
let chat = mouth();
|
||||
let model = Recorded::discriminating();
|
||||
let organs = Organs { persona: Some(&stored), chat: Some(&chat), addressing: None, model: Some(&model) };
|
||||
let organs = Organs { persona: Some(&stored), chat: Some(&chat), addressing: None, model: Some(&model), domain: None };
|
||||
let report = project(&organs, &request(dir.path(), Some(5), Some(eased.clone())), now()).unwrap();
|
||||
assert_eq!((report["judge"]["accuracy"].as_f64(), report["judge"]["passed"].as_bool()), (Some(1.0), Some(true)), "{}", report["judge"]);
|
||||
assert_eq!(report["judge"]["verdicts"].as_array().unwrap().len(), 10);
|
||||
|
|
@ -1049,14 +1049,14 @@ fn the_judge_scores_a_discriminating_projector_and_fails_a_blind_one() {
|
|||
fn renders_without_a_connector_are_refused() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let stored = Stored(state());
|
||||
let organs = Organs { persona: Some(&stored), chat: None, addressing: None, model: None };
|
||||
let organs = Organs { persona: Some(&stored), chat: None, addressing: None, model: None, domain: None };
|
||||
assert!(format!("{:#}", project(&organs, &request(dir.path(), Some(1), None), now()).unwrap_err()).contains("connector"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_given_state_is_projected_without_reading_the_stored_one() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let organs = Organs { persona: None, chat: None, addressing: None, model: None };
|
||||
let organs = Organs { persona: None, chat: None, addressing: None, model: None, domain: None };
|
||||
let mut given = state();
|
||||
given["publicName"] = json!("Hypothetical");
|
||||
let report = project(&organs, &Request { state: Some(given), ..request(dir.path(), None, None) }, now()).unwrap();
|
||||
|
|
@ -1176,7 +1176,7 @@ fn project_over(deliveries: Vec<ChatDelivery>, tail: Vec<TailLine>, request: imp
|
|||
let dir = tempfile::tempdir().unwrap();
|
||||
let mouth = ReadOnlyMouth { pending: ChatPending { persona: "eureka".into(), deliveries, tail: Some(tail), tail_gaps: vec![] }, reads: Cell::new(0) };
|
||||
let stored = Stored(state());
|
||||
let organs = Organs { persona: Some(&stored), chat: Some(&mouth), addressing: None, model: None };
|
||||
let organs = Organs { persona: Some(&stored), chat: Some(&mouth), addressing: None, model: None, domain: None };
|
||||
project(&organs, &request(Request { room: None, ..request_defaults(dir.path()) }), now()).unwrap()
|
||||
}
|
||||
|
||||
|
|
@ -1216,7 +1216,7 @@ fn the_heartbeats_addressing_names_her_projects_too() {
|
|||
let dir = tempfile::tempdir().unwrap();
|
||||
let mouth = ReadOnlyMouth { pending: ChatPending { persona: "eureka".into(), deliveries: vec![delivery(1, "#swarm:gamecult.org", "@kiko:gamecult.org", "Kiko", "Huginn is slow today", &[])], tail: Some(vec![]), tail_gaps: vec![] }, reads: Cell::new(0) };
|
||||
let stored = Stored(state());
|
||||
let with = Organs { persona: Some(&stored), chat: Some(&mouth), addressing: Some(&table), model: None };
|
||||
let with = Organs { persona: Some(&stored), chat: Some(&mouth), addressing: Some(&table), model: None, domain: None };
|
||||
let report = project(&with, &Request { room: None, ..request_defaults(dir.path()) }, now()).unwrap();
|
||||
assert_eq!(report["addressing"]["source"], "heartbeat");
|
||||
assert!(stimulus_of(&report).starts_with("Said to her:"), "a stewarded project's name is for her, as the heartbeat reads it");
|
||||
|
|
@ -1289,7 +1289,7 @@ fn a_stranger_never_borrows_a_bonded_name() {
|
|||
fn project_refuses_to_run_without_her_own_id() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let stored = Stored(state());
|
||||
let organs = Organs { persona: Some(&stored), chat: None, addressing: None, model: None };
|
||||
let organs = Organs { persona: Some(&stored), chat: None, addressing: None, model: None, domain: None };
|
||||
for own in ["", "eureka"] {
|
||||
let fault = format!("{:#}", project(&organs, &Request { own_sender: own.into(), ..request_defaults(dir.path()) }, now()).unwrap_err());
|
||||
assert!(fault.contains("MIND_PERSONA_SELF_SENDER"), "{fault}");
|
||||
|
|
@ -1398,7 +1398,7 @@ fn select_only_reports_each_sections_bytes_the_total_and_what_bound() {
|
|||
let dir = tempfile::tempdir().unwrap();
|
||||
let stored = Stored(state());
|
||||
let chat = mouth();
|
||||
let report = project(&Organs { persona: Some(&stored), chat: Some(&chat), addressing: None, model: None }, &request(dir.path(), None, None), now()).unwrap();
|
||||
let report = project(&Organs { persona: Some(&stored), chat: Some(&chat), addressing: None, model: None, domain: None }, &request(dir.path(), None, None), now()).unwrap();
|
||||
let bytes = &report["packet"]["bytes"];
|
||||
let context = report["packet"]["context"].as_str().unwrap();
|
||||
for section in ["identity", "outcome", "here", "body", "people", "notes", "total", "stimulus", "heard"] {
|
||||
|
|
@ -1493,7 +1493,7 @@ fn every_render_and_every_judge_call_carries_its_usage() {
|
|||
tense["affect"]["socialBonds"][0]["tension"] = json!(0.9);
|
||||
let chat = mouth();
|
||||
let model = Recorded::discriminating();
|
||||
let organs = Organs { persona: Some(&stored), chat: Some(&chat), addressing: None, model: Some(&model) };
|
||||
let organs = Organs { persona: Some(&stored), chat: Some(&chat), addressing: None, model: Some(&model), domain: None };
|
||||
let report = project(&organs, &request(dir.path(), Some(2), Some(tense)), now()).unwrap();
|
||||
for render in report["renders"].as_array().unwrap().iter().chain(report["against"]["renders"].as_array().unwrap()) {
|
||||
let usage = &render["usage"];
|
||||
|
|
@ -1551,7 +1551,7 @@ fn a_failed_call_keeps_the_report_and_its_usage() {
|
|||
let dir = tempfile::tempdir().unwrap();
|
||||
let stored = Stored(state());
|
||||
let model = Flaky(Cell::new(0));
|
||||
let organs = Organs { persona: Some(&stored), chat: None, addressing: None, model: Some(&model) };
|
||||
let organs = Organs { persona: Some(&stored), chat: None, addressing: None, model: Some(&model), domain: None };
|
||||
let report = project(&organs, &Request { kind: TurnKind::Beat, ..request(dir.path(), Some(4), None) }, now()).unwrap();
|
||||
let renders = report["renders"].as_array().unwrap();
|
||||
assert_eq!(renders.len(), 4);
|
||||
|
|
@ -1632,7 +1632,7 @@ fn the_report_says_how_old_the_addressing_table_is_and_why_it_was_not_used() {
|
|||
}
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let stored = Stored(state());
|
||||
let run = |view: &Stale| project(&Organs { persona: Some(&stored), chat: None, addressing: Some(view), model: None }, &request_defaults(dir.path()), now()).unwrap()["addressing"].clone();
|
||||
let run = |view: &Stale| project(&Organs { persona: Some(&stored), chat: None, addressing: Some(view), model: None, domain: None }, &request_defaults(dir.path()), now()).unwrap()["addressing"].clone();
|
||||
let hers = crate::address::Addressee::new(OWN, ["eureka"]);
|
||||
let other = crate::address::Addressee::new("@libby:gamecult.org", ["libby"]);
|
||||
let written = now() - chrono::Duration::minutes(90);
|
||||
|
|
@ -1855,7 +1855,7 @@ fn a_room_is_named_by_the_key_the_tail_carries_and_a_public_rooms_id_is_reported
|
|||
let dir = tempfile::tempdir().unwrap();
|
||||
let stored = Stored(state());
|
||||
let chat = mouth();
|
||||
let organs = Organs { persona: Some(&stored), chat: Some(&chat), addressing: None, model: None };
|
||||
let organs = Organs { persona: Some(&stored), chat: Some(&chat), addressing: None, model: None, domain: None };
|
||||
// The mouth's first delivery is in #swarm, room id !1:gamecult.org; the tail names #swarm by its alias.
|
||||
let by_alias = project(&organs, &Request { room: Some("#swarm:gamecult.org".into()), ..request(dir.path(), None, None) }, now()).unwrap();
|
||||
assert_eq!((by_alias["room"]["messages"].as_u64(), by_alias["room"]["tail"].as_u64()), (Some(1), Some(1)), "{}", by_alias["room"]);
|
||||
|
|
@ -2576,3 +2576,56 @@ fn k22_a_closed_promise_is_told_once_in_the_next_outcome() {
|
|||
let withdrawn = json!({ "interpreter": { "said": [], "heard": [] }, "posted": [], "committed": { "closed": [{ "entry": entry("withdrawn"), "how": "withdrawn", "to_name": "Meta", "by": null }], "refused": [] } });
|
||||
assert_eq!(outcome::outcome_of(&withdrawn).unwrap().lines(select::forms(&state())), ["- Her promise to Meta, \"I'll send the render tonight.\", is closed: she withdrew it in #swarm:gamecult.org."]);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// K23: her domain (map 16.22.2).
|
||||
|
||||
fn packet_with_domain(lines: &[String], tuning: &Tuning) -> Packet {
|
||||
let (operators, minds, history, room) = (operators(), minds(), History::default(), chat_room());
|
||||
let inputs = Inputs { kind: TurnKind::Chat, state: &state(), room: &room, history: &history, observation: None, people: People { operators: &operators, minds: &minds, own_sender: OWN }, now: now(), seed: 1, affordances: CAN, domain: lines };
|
||||
select(&inputs, tuning)
|
||||
}
|
||||
|
||||
/// The lines of the domain section as rendered, heading excluded.
|
||||
fn domain_section(packet: &Packet) -> Vec<String> {
|
||||
packet.context.lines().skip_while(|line| *line != "In her domain lately:").skip(1).take_while(|line| line.starts_with("- ")).map(str::to_owned).collect()
|
||||
}
|
||||
|
||||
/// What moved in her domain is its own section under its own guard, the Projector's as news and the Interpreter's by id;
|
||||
/// past six lines or past the guard the newest are shown and the rest counted; nothing moved, and there is no heading.
|
||||
#[test]
|
||||
fn k23_her_domain_is_a_section_under_its_own_guard_with_ids_for_the_interpreter_alone() {
|
||||
let lines: Vec<String> = (1..=9).map(|n| format!("- GameCult/Repo{n}: 1 pull request merged since Tuesday (\"Change {n}\"), opened by kiko.")).collect();
|
||||
let tuning = Tuning::default();
|
||||
let packet = packet_with_domain(&lines[..2], &tuning);
|
||||
assert_eq!(domain_section(&packet), lines[..2].to_vec(), "{}", packet.context);
|
||||
assert_eq!(packet.domain.iter().map(|line| line.id.as_str()).collect::<Vec<_>>(), ["d1", "d2"]);
|
||||
within_guards(&packet, &tuning);
|
||||
let speech = interpret::speech_prompt(&packet, "The room is warm.", "y", &tuning);
|
||||
assert!(speech.contains("What moved in her domain lately, as id \u{2014} line (news of her part of the coop, none of it work she owes):\n- d1 \u{2014} GameCult/Repo1: 1 pull request merged since Tuesday (\"Change 1\"), opened by kiko.\n- d2 \u{2014} GameCult/Repo2"), "{speech}");
|
||||
let projector = narrate::projector_prompt(&packet, &tuning);
|
||||
assert!(projector.contains("In her domain lately:\n- GameCult/Repo1") && !projector.contains("d1 \u{2014}"), "ids are the Interpreter's alone");
|
||||
assert!(projector.contains("What is in her domain lately is news of her part of the coop, what was merged and ruled there and by whom: never a task, and none of it work she owes."), "the frame says what the heading is");
|
||||
|
||||
// Past six lines: five and a count, never a silent drop.
|
||||
let crowded = packet_with_domain(&lines, &tuning);
|
||||
let shown = domain_section(&crowded);
|
||||
assert_eq!(shown.len(), 6, "{shown:?}");
|
||||
assert_eq!(shown[..5], lines[..5]);
|
||||
assert_eq!(shown[5], "- 4 more parts of her domain moved, not shown here.");
|
||||
assert_eq!(crowded.domain.len(), 5);
|
||||
|
||||
// Past the guard: the newest that fit and a count, within the guard.
|
||||
let mut tight = Tuning::default();
|
||||
tight.select.domain_bytes = 200;
|
||||
let bound = packet_with_domain(&lines[..4], &tight);
|
||||
within_guards(&bound, &tight);
|
||||
let shown = domain_section(&bound);
|
||||
let counted: usize = shown.last().and_then(|line| line.strip_prefix("- ")).and_then(|rest| rest.split(" more parts").next()).and_then(|n| n.parse().ok()).expect("a counted line");
|
||||
assert_eq!(counted + bound.domain.len(), 4, "{shown:?}");
|
||||
assert!(bound.sections.bound.contains(&"domain"), "{:?}", bound.sections.bound);
|
||||
|
||||
// Nothing moved (or the read failed, which `project` reports): no heading at all, and no "nothing moved".
|
||||
let quiet = packet_with_domain(&[], &tuning);
|
||||
assert!(!quiet.context.contains("domain lately") && !interpret::speech_prompt(&quiet, "x", "y", &tuning).contains("domain lately"), "{}", quiet.context);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@ pub(crate) const OUTCOME_ROOM_MIN: usize = 256;
|
|||
/// The least `promises_bytes` may be: the heading and the line counting the promises not shown always fit, so none is
|
||||
/// dropped silently (I16.11).
|
||||
pub(crate) const PROMISES_ROOM_MIN: usize = 128;
|
||||
/// The least `domain_bytes` may be: the heading and the line counting the lines of her domain not shown always fit (I16.11).
|
||||
pub(crate) const DOMAIN_ROOM_MIN: usize = 128;
|
||||
/// The least `body_bytes` may be: the body heading, the longest turn line (`select::turn_words`) and one entry at the
|
||||
/// standard's upper target always fit.
|
||||
pub(crate) const BODY_ROOM_MIN: usize = 768;
|
||||
|
|
@ -135,6 +137,8 @@ pub struct SelectTuning {
|
|||
pub outcome_bytes: usize,
|
||||
/// Her open promises, in bytes, heading included: under their own guard (map 16.22.1, I16.8).
|
||||
pub promises_bytes: usize,
|
||||
/// What moved in her domain lately, in bytes, heading included: under its own guard (map 16.22.2, I16.8).
|
||||
pub domain_bytes: usize,
|
||||
pub stimulus_bytes: usize,
|
||||
/// What was said to her, verbatim, for the Persona stage: on a chat turn, the room's earlier lines too, before the new
|
||||
/// ones (map 16.20.3).
|
||||
|
|
@ -234,6 +238,7 @@ impl Default for SelectTuning {
|
|||
here_bytes: 768,
|
||||
outcome_bytes: 1200,
|
||||
promises_bytes: 600,
|
||||
domain_bytes: 900,
|
||||
stimulus_bytes: 1500,
|
||||
heard_bytes: 2500,
|
||||
addressed_bytes: 8 * 1024,
|
||||
|
|
@ -317,6 +322,7 @@ impl Tuning {
|
|||
("select.here_bytes", select.here_bytes),
|
||||
("select.outcome_bytes", select.outcome_bytes),
|
||||
("select.promises_bytes", select.promises_bytes),
|
||||
("select.domain_bytes", select.domain_bytes),
|
||||
("select.stimulus_bytes", select.stimulus_bytes),
|
||||
("select.heard_bytes", select.heard_bytes),
|
||||
("select.identity_bytes", select.identity_bytes),
|
||||
|
|
@ -353,6 +359,9 @@ impl Tuning {
|
|||
if select.promises_bytes < PROMISES_ROOM_MIN {
|
||||
bail!("select.promises_bytes must be at least {PROMISES_ROOM_MIN}, not {}: the line counting the promises not shown always fits", select.promises_bytes);
|
||||
}
|
||||
if select.domain_bytes < DOMAIN_ROOM_MIN {
|
||||
bail!("select.domain_bytes must be at least {DOMAIN_ROOM_MIN}, not {}: the line counting what of her domain is not shown always fits", select.domain_bytes);
|
||||
}
|
||||
let lens = &self.lens;
|
||||
let weights = [lens.body_and_hour, lens.person_present, lens.unresolved_want, lens.memory_surfacing, lens.wondering];
|
||||
if weights.iter().any(|weight| !weight.is_finite() || *weight < 0.0) || lens.body_and_hour <= 0.0 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue