Map: docs/persona-only-heartbeat-map.md (imagination/persona-only-heartbeat,
d861574), cut C2. Rulings: eureka-body:ruling:persona-only-heartbeat (she
reads the Mind and never writes it; no Self runs from the Persona).
Persona organ (persona.rs 3983 -> ~420 lines): deleted the live session
organ whole: TURN_INSTRUCTION, TURN_REMINDER, MESSAGES_HEADER, WORK_QUESTION,
ANSWER_MESSAGES, WAKE_ASK, WORK_TAIL; PersonaReply with intent, remember,
rule, settle, start_self_run, tempo vote and urgency, and reply_schema; the
doctrine and persona-JSON system prompt (read_doctrine, render_instructions,
campaigns); start_session, persona_args, PersonaInbox; act, decode_reply and
every admission (memories, rulings, settles, pulses, follow-ups, run closure);
start_self_run; the responsibilities, recent-runs and wear renderers;
render_input and render_tempo. carry reads the brakes and answers Dead or
NoOrgan; a start writes nothing and records no run. Kept per the map's keep
list for C3: Config (doctrine, image store and fetch fields cut with their
consumers), the brake read, the chat-addressing helpers, the tail renderer
and FileTrace; uncalled ones carry allow(dead_code) naming C3.
Night: sleep.rs is deleted. It was a Mind-writing session built on the
deleted prelude; C4 retargets its contract from history.
attachment.rs is deleted with the reply's save_attachment, its one caller.
chat_image's loader and recall.rs stay for C3 under allow(dead_code).
Heartbeat: no Mind writes. A wake is a plain unit start through the
Launcher (brake, then alive, then start); busy is the unit's own state.
Deleted the Self-run branch (claimable briefs), the self-ended wake, tempo
votes and declared urgency (standing_vote, pending_urgency, last_self_end)
and the run-based last_turn and last_sleep reads; HeartbeatState gains
last_turn_at and last_night_at (default slots, so a state written before
this cut still decodes). The beat is HEARTBEAT_BEAT_S, default 1800 s.
InstanceTrace.vote_beat_s stays as an always-none slot so heartbeat.cc's
older trace records still decode. HeartbeatView loses latest; the
timeline reads FileStore::latest.
tempo.rs: tally, fallback_beat and the PID controller and its sim are
deleted; pick and score stay, without self_permille.
Tests that pinned deleted behaviour are deleted with it; surviving ones are
kept, and two heartbeat tests pin the cut: a Mind with claimable briefs gets
a Persona wake and no Self run, and no poll admits anything to any mind.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
72 lines
3.4 KiB
Rust
72 lines
3.4 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_flag_overrides_the_environment() {
|
|
let dir = tempfile::tempdir().unwrap();
|
|
// The rooms flag replaces the rooms the environment names.
|
|
let flagged = run(dir.path(), &[], &[], &["--instance", "eureka", "--rooms", "#swarm:chat"]);
|
|
assert_eq!(flagged.status.code(), Some(0), "{}", text(&flagged.stderr));
|
|
}
|
|
|
|
#[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}");
|
|
}
|