Projector (the operator: "Sounds like a Projector issue"):
- The group state is the conversation as it stands, in one room: who is talking with whom, a human's question to the
room that others answered as covered (one nobody answered goes unmentioned), when a human last spoke, Mind lines in a
row, and a human waiting on her by name. Never what she owes. Every count covers the window the line describes (S4);
never several rooms folded together, never a direct message into a public room (S3). Default group_lines 12.
- Absent state is left out: no "mood: none recorded"; a bond, need, memory, stance, wondering or value without content
is not rendered, and a bond without trust or tension says neither.
- Guidance: never retell what she heard (it reaches her verbatim), render what it stirs; never a debt; no options; leave
out what the context does not carry; use pronouns as given. Metrics, not filters: heard_overlap (word trigrams shared
with the heard lines) and offers_options (a narrow lexical flag), per render and per run.
- Pronouns: `[pronouns]` in the tuning by Matrix id, the swarm's people as the default, they/them for anyone else; the
persona schema has no pronoun field for another person. A pronoun line names everyone the packet shows from the room.
The packet speaks of her in her own pronouns throughout ("Said to him:") (S5).
- Bond lines put the kind after a dash and lists use semicolons: a label may hold a comma ("Meta, the operator").
Persona stage: continues her inner stream in the first person; speech only where her thought moves her to it, in double
quotes; others' words she recalls in single quotes; @handle tags someone. The report shows her inner prose apart from
what she would say.
humans_pace (ruling persona-only-humans-pace; the operator's words that Minds' explicit mentions wake too):
`HumansPace(cap)`: a human's line wakes her in her own room or a direct message always, and in a public room when it
addresses her or continues an exchange she is in (an exchange ends at a gap over exchange_gap_minutes, default 20); a
Mind's line wakes her only by a Matrix mention or a reply, in any room, while fewer than `cap` Mind lines in a row came
before it. Own rooms come from the plan: neither the heartbeat's table nor persona.env records ownership. Live is
unchanged. In the simulation a said line's @handle of a cast member stands in for a Matrix mention.
Soul's hold:
- S1: Config::new refuses an operator id that is also a persona's.
- S2: the simulator's beat asks heartbeat::addressed_by_member over the deliveries the mouth would give her.
- S3: --in given as a room id is read by its alias.
- S6: a scripted direct message names its recipient (`to`), is seen by sender and recipient alone, and wakes only her.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
98 lines
5.6 KiB
Rust
98 lines
5.6 KiB
Rust
//! The `mind-persona` binary as the unit runs it: arguments `--instance`, the rest
|
|
//! from `persona.env`. The control root is a constant that does not exist where
|
|
//! this runs, so a start that is configured right ends dead at the gate (exit 0);
|
|
//! a start configured wrong ends 2 and names the setting, never a value.
|
|
|
|
use std::path::Path;
|
|
use std::process::{Command, Output};
|
|
|
|
fn run(dir: &Path, drop: &[&str], extra: &[(&str, &str)], args: &[&str]) -> Output {
|
|
let mut env = vec![
|
|
("HUGINN_ENDPOINT", "rudp://127.0.0.1:9".to_string()),
|
|
("STATE_DIRECTORY", dir.to_string_lossy().into_owned()),
|
|
("MIND_PERSONA_ROOMS", "#swarm:chat,#ops:chat".to_string()),
|
|
("MIND_PERSONA_OPERATOR", "@op:chat".to_string()),
|
|
("MIND_PERSONA_MINDS", "@eureka:chat,@libby:chat".to_string()),
|
|
("MIND_PERSONA_SELF_SENDER", "@eureka:chat".to_string()),
|
|
("MIND_PERSONA_MODEL", "claude-test-model".to_string()),
|
|
];
|
|
env.retain(|(name, _)| !drop.contains(name) && !extra.iter().any(|(set, _)| set == name));
|
|
env.extend(extra.iter().map(|(name, value)| (*name, (*value).to_string())));
|
|
Command::new(env!("CARGO_BIN_EXE_mind-persona")).args(args).env_clear().envs(env).output().unwrap()
|
|
}
|
|
|
|
/// What to drop from the environment, what to set instead, and the setting the error must name.
|
|
type Case<'a> = (&'a [&'a str], &'a [(&'a str, &'a str)], &'a str);
|
|
|
|
fn text(bytes: &[u8]) -> String {
|
|
String::from_utf8_lossy(bytes).into_owned()
|
|
}
|
|
|
|
#[test]
|
|
fn a_unit_configured_from_its_environment_alone_reaches_the_gate_and_ends_dead() {
|
|
let dir = tempfile::tempdir().unwrap();
|
|
let output = run(dir.path(), &[], &[], &["--instance", "eureka"]);
|
|
assert_eq!(output.status.code(), Some(0), "{}", text(&output.stderr));
|
|
assert!(text(&output.stdout).starts_with("dead:"), "{}", text(&output.stdout));
|
|
}
|
|
|
|
#[test]
|
|
fn a_setting_that_is_missing_or_wrong_ends_two_naming_the_setting_and_no_value() {
|
|
let dir = tempfile::tempdir().unwrap();
|
|
let cases: [Case; 4] = [
|
|
(&["MIND_PERSONA_ROOMS"], &[], "usage"),
|
|
(&["MIND_PERSONA_MINDS"], &[], "usage"),
|
|
(&["MIND_PERSONA_MODEL"], &[], "MIND_PERSONA_MODEL"),
|
|
(&[], &[("HUGINN_ENDPOINT", "canary-endpoint")], "endpoint"),
|
|
];
|
|
for (drop, extra, names) in cases {
|
|
let output = run(dir.path(), drop, extra, &["--instance", "eureka"]);
|
|
let stderr = text(&output.stderr);
|
|
assert_eq!(output.status.code(), Some(2), "{drop:?} {extra:?}: {stderr}");
|
|
assert!(stderr.contains(names), "{drop:?} {extra:?}: {stderr}");
|
|
assert!(!stderr.contains("canary-endpoint") && !stderr.contains("#ops:chat"), "no value is echoed: {stderr}");
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn the_retired_max_turns_flag_is_refused_and_its_value_is_not_echoed() {
|
|
let dir = tempfile::tempdir().unwrap();
|
|
let output = run(dir.path(), &[], &[], &["--instance", "eureka", "--max-turns", "canary-turns"]);
|
|
let stderr = text(&output.stderr);
|
|
assert_eq!(output.status.code(), Some(2), "{stderr}");
|
|
assert!(stderr.contains("usage") && !stderr.contains("canary-turns"), "{stderr}");
|
|
}
|
|
|
|
/// The harness's read-only proof at the binary: with a room fixture and a state file, `project` runs with no persona.env,
|
|
/// no mouth and the daemon's endpoint unreachable, and never needs them.
|
|
#[test]
|
|
fn project_over_a_room_fixture_and_a_state_file_needs_no_daemon_and_no_mouth() {
|
|
let fixtures = Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures/harness");
|
|
let room = fixtures.join("rooms/mind-teases.toml");
|
|
let state = fixtures.join("states/control.json");
|
|
let args = ["project", "--instance", "eureka", "--room", room.to_str().unwrap(), "--state", state.to_str().unwrap(), "--select-only"];
|
|
// Nothing listens on the discard port: a read of her stored state would fail the run.
|
|
let output = Command::new(env!("CARGO_BIN_EXE_mind-persona")).args(args).env_clear().env("HUGINN_ENDPOINT", "rudp://127.0.0.1:9").env("MIND_PERSONA_TUNING", "/nonexistent/persona-tuning.toml").output().unwrap();
|
|
assert_eq!(output.status.code(), Some(0), "{}", text(&output.stderr));
|
|
let report: serde_json::Value = serde_json::from_slice(&output.stdout).unwrap();
|
|
assert_eq!((report["state"].as_str(), report["persona_receipt"].is_null()), (Some("given"), true), "{report}");
|
|
assert!(report["packet"]["identity"].as_str().unwrap().starts_with("Tobiah Fenn"), "{report}");
|
|
assert!(report["packet"]["stimulus"].as_str().unwrap().contains("Said to him"), "Kiko's tagged reply is for him, in his own pronouns: {report}");
|
|
// Without any endpoint at all it runs the same.
|
|
let output = Command::new(env!("CARGO_BIN_EXE_mind-persona")).args(args).env_clear().env("MIND_PERSONA_TUNING", "/nonexistent/persona-tuning.toml").output().unwrap();
|
|
assert_eq!(output.status.code(), Some(0), "{}", text(&output.stderr));
|
|
}
|
|
|
|
#[test]
|
|
fn a_state_file_a_put_would_refuse_is_refused() {
|
|
let dir = tempfile::tempdir().unwrap();
|
|
let fixtures = Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures/harness");
|
|
let mut state: serde_json::Value = serde_json::from_str(&std::fs::read_to_string(fixtures.join("states/control.json")).unwrap()).unwrap();
|
|
state["personaId"] = "libby".into();
|
|
let file = dir.path().join("foreign.json");
|
|
std::fs::write(&file, state.to_string()).unwrap();
|
|
let room = fixtures.join("rooms/quiet-beat.toml");
|
|
let output = Command::new(env!("CARGO_BIN_EXE_mind-persona")).args(["project", "--instance", "eureka", "--room", room.to_str().unwrap(), "--state", file.to_str().unwrap(), "--select-only"]).env_clear().output().unwrap();
|
|
assert_eq!(output.status.code(), Some(2));
|
|
assert!(text(&output.stderr).contains("refused by a put"), "{}", text(&output.stderr));
|
|
}
|