diff --git a/crates/mind-body/src/bin/mind-persona.rs b/crates/mind-body/src/bin/mind-persona.rs index f475fb4..1faca96 100644 --- a/crates/mind-body/src/bin/mind-persona.rs +++ b/crates/mind-body/src/bin/mind-persona.rs @@ -18,7 +18,8 @@ //! process's fresh configuration; `CLAUDE_LEASE_SOCKET` is the connector's lease socket (the token itself //! is never in this process's environment, only the descriptor a lease grants); `RUNTIME_DIRECTORY` (the //! unit's `RuntimeDirectory=`) holds each process's configuration and instructions; `BIFROST_CHAT_ENDPOINT` -//! (`rudp://:`, the mouth) and `BIFROST_CHAT_KEY_FILE`. Without +//! (`rudp://:`, the mouth) and `BIFROST_CHAT_KEY_FILE`; `BIFROST_CHAT_PENDING_V4` set to exactly `1` asks the mouth for the +//! reply link (`chat_pending.v4`), anything else or unset does not. Without //! `--endpoint` the daemon is `HUGINN_ENDPOINT`; the trace is `persona-trace.cc` //! under `STATE_DIRECTORY`, and her sandbox is `STATE_DIRECTORY/sandbox`. The key file is read here and its //! text goes to the transport, which holds it; nothing is printed. @@ -76,7 +77,8 @@ fn run() -> Result { .strip_prefix("rudp://") .and_then(|address| address.parse().ok()) .ok_or_else(|| anyhow!("BIFROST_CHAT_ENDPOINT is not rudp://:"))?; - let chat = RudpChat::new(chat_endpoint, connection_id(&credential("BIFROST_CHAT_KEY_FILE")?), instance.0.clone(), CHAT_TIMEOUT); + let reply_link = setting("BIFROST_CHAT_PENDING_V4").as_deref() == Some("1"); + let chat = RudpChat::new(chat_endpoint, connection_id(&credential("BIFROST_CHAT_KEY_FILE")?), instance.0.clone(), CHAT_TIMEOUT).with_reply_link(reply_link); let run_cap_s: u64 = setting(ENV_RUN_CAP).and_then(|seconds| seconds.parse().ok()).filter(|seconds| *seconds > 0).ok_or_else(|| anyhow!("{ENV_RUN_CAP} is not set to the unit's RuntimeMaxSec in seconds"))?; let scratch = PathBuf::from(required(SCRATCH_VARIABLE)?); let sandbox = Path::new(&state).join(SANDBOX_DIR); diff --git a/crates/mind-body/tests/persona_bin.rs b/crates/mind-body/tests/persona_bin.rs index 463f8e5..e27c256 100644 --- a/crates/mind-body/tests/persona_bin.rs +++ b/crates/mind-body/tests/persona_bin.rs @@ -83,3 +83,15 @@ fn the_retired_max_turns_flag_is_refused_and_its_value_is_not_echoed() { assert_eq!(output.status.code(), Some(2), "{stderr}"); assert!(stderr.contains("usage") && !stderr.contains("canary-turns"), "{stderr}"); } + +/// The reply-link setting is the mouth's own rule: exactly `1` is on, anything else is off, and none of it ends the unit or reaches a message. +#[test] +fn a_v4_setting_other_than_exactly_1_is_off() { + let dir = tempfile::tempdir().unwrap(); + for value in ["", "0", "true", "yes", " 1", "canary-v4"] { + let output = run(dir.path(), &[], &[("BIFROST_CHAT_PENDING_V4", value)], &["--instance", "eureka"]); + assert_eq!(output.status.code(), Some(0), "{value:?}: {}", text(&output.stderr)); + assert!(!text(&output.stderr).contains("canary-v4") && !text(&output.stdout).contains("canary-v4")); + } + assert_eq!(run(dir.path(), &[], &[("BIFROST_CHAT_PENDING_V4", "1")], &["--instance", "eureka"]).status.code(), Some(0)); +}