Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(channels): let integration tests build DispatchHarnessOptions again, without widening a production type\n\n`f0e898a45` added `workspace_dir` and `system_prompt` to `DispatchHarnessOptions`\nas `pub(crate)`. Every other field on that `pub struct` is `pub`, and the\nintegration tests under `tests/` are a **separate crate** — a struct-update\nexpression (`..DispatchHarnessOptions::default()`) requires every field to be\nvisible, including the ones the caller never names. So\n`tests/raw_coverage/channels_web_startup_raw_coverage_e2e.rs` stopped compiling\nwith E0451 and `main`'s `Rust Core Coverage` has been red since.\n\n`workspace_dir` is simply `pub`: `Option<PathBuf>` is a public type.\n\n`system_prompt` could not be, and that is the interesting half. Making it `pub`\nputs `pub(crate) enum ChannelSystemPrompt` in a public interface, which\n`private_interfaces` reports and `-D warnings` turns into a clippy error — the\nfirst version of this PR did exactly that and went red on `Rust Quality`.\nWidening the enum instead would cascade: its `Refreshing` variant wraps\n`pub(crate) struct RefreshingInner`, whose constructor takes `pub(crate) struct\nChannelPromptInputs`. That is three production types with real invariants\n(`RefreshingInner` holds a `Mutex`-backed render cache) widened to satisfy a\ntest harness.\n\nSo the prompt is wrapped in `pub struct HarnessSystemPrompt(Option<ChannelSystemPrompt>)`\n— a public newtype with a **private** field. The field on the options struct is\nvisible, the type inside it is not, and `private_interfaces` has nothing to\nreport. An out-of-crate caller can only obtain the default (no prompt), which is\nall those tests want; in-crate tests set one with `HarnessSystemPrompt::new`\n(three call sites in `channels/tests/personality.rs`).\n\nVerified against both lanes, because they see different halves of this and\nneither alone is sufficient:\n\n cargo clippy -p openhuman --features "$(bash scripts/ci/product-features.sh)" \\n --no-default-features -- -D warnings # the lane the first attempt broke\n cargo check -p openhuman --tests --features "$(bash scripts/ci/product-features.sh)"\n # the lane clippy cannot see\n

M3gA-Mind8e6ebe149245
diff --git a/src/openhuman/channels/runtime/test_support.rs b/src/openhuman/channels/runtime/test_support.rs
index e157748ed3..7a49fad283 100644
--- a/src/openhuman/channels/runtime/test_support.rs
+++ b/src/openhuman/channels/runtime/test_support.rs
@@ -44,11 +44,60 @@ pub struct DispatchHarnessOptions {
pub seed_history_len: usize,
pub memory_entries: Vec<TestMemoryEntry>,
/// Workspace the runtime context reports; `None` falls back to the OS temp dir.
- pub(crate) workspace_dir: Option<PathBuf>,
- /// The prompt every dispatch is seeded with; `None` pins a fixed literal.
+ ///
+ /// `pub`, like every other field here, and it has to be: integration tests
+ /// under `tests/` are a separate crate, and a struct-update expression
+ /// (`..DispatchHarnessOptions::default()`) requires **every** field to be
+ /// visible — including the ones the caller never names. Added as
+ /// `pub(crate)` in `a45b1c1af`, which broke three of them with E0451.
+ pub workspace_dir: Option<PathBuf>,
+ /// The prompt every dispatch is seeded with; the default pins a fixed literal.
/// Pass one `ChannelSystemPrompt::refreshing` clone to several dispatches
/// to observe a re-render across them.
- pub(crate) system_prompt: Option<ChannelSystemPrompt>,
+ ///
+ /// Wrapped in [`HarnessSystemPrompt`] rather than exposing
+ /// `Option<ChannelSystemPrompt>` — see that type for why.
+ pub system_prompt: HarnessSystemPrompt,
+}
+
+/// Opaque carrier for the harness's system prompt.
+///
+/// [`DispatchHarnessOptions`] is `pub` and integration tests build it with
+/// `..DispatchHarnessOptions::default()`, so every field must be visible from
+/// another crate. The prompt itself must **not** become visible with it:
+/// `ChannelSystemPrompt` is `pub(crate)`, its `Refreshing` variant wraps a
+/// `Mutex`-backed render cache (`RefreshingInner`), and widening it would
+/// cascade to `RefreshingInner` and `ChannelPromptInputs` — production types
+/// with real invariants — purely to satisfy a test harness. A `pub` field of a
+/// `pub(crate)` type is also exactly what the `private_interfaces` lint exists
+/// to catch, and `-D warnings` makes that a hard error.
+///
+/// A `pub` newtype with a **private** field settles both: the field is visible,
+/// the type inside it is not. An out-of-crate caller can therefore only ever
+/// get the default (no prompt), which is all those tests want; in-crate tests
+/// set one with [`HarnessSystemPrompt::new`].
+#[derive(Clone, Default)]
+pub struct HarnessSystemPrompt(Option<ChannelSystemPrompt>);
+
+impl HarnessSystemPrompt {
+ /// Seed the harness with `prompt`. Crate-internal, because the prompt is.
+ pub(crate) fn new(prompt: ChannelSystemPrompt) -> Self {
+ Self(Some(prompt))
+ }
+
+ /// The prompt, if one was set.
+ pub(crate) fn into_inner(self) -> Option<ChannelSystemPrompt> {
+ self.0
+ }
+}
+
+impl std::fmt::Debug for HarnessSystemPrompt {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ match &self.0 {
+ Some(prompt) => f.debug_tuple("HarnessSystemPrompt").field(prompt).finish(),
+ None => f.write_str("HarnessSystemPrompt(default)"),
+ }
+ }
}
impl Default for DispatchHarnessOptions {
@@ -67,7 +116,7 @@ impl Default for DispatchHarnessOptions {
seed_history_len: 0,
memory_entries: Vec::new(),
workspace_dir: None,
- system_prompt: None,
+ system_prompt: HarnessSystemPrompt::default(),
}
}
}
@@ -499,6 +548,7 @@ pub async fn run_dispatch_harness(options: DispatchHarnessOptions) -> DispatchHa
let harness_system_prompt = options
.system_prompt
.clone()
+ .into_inner()
.unwrap_or_else(|| ChannelSystemPrompt::fixed("system prompt"));
let harness_workspace_dir = options
.workspace_dir
diff --git a/src/openhuman/channels/tests/personality.rs b/src/openhuman/channels/tests/personality.rs
index 637be65d81..c9a3505182 100644
--- a/src/openhuman/channels/tests/personality.rs
+++ b/src/openhuman/channels/tests/personality.rs
@@ -8,7 +8,9 @@
//! twice through `run_dispatch_harness` with one shared prompt and edits
//! `SOUL.md` in between — the reproduction in the issue, as a test.
-use super::super::runtime::test_support::{run_dispatch_harness, DispatchHarnessOptions};
+use super::super::runtime::test_support::{
+ run_dispatch_harness, DispatchHarnessOptions, HarnessSystemPrompt,
+};
use super::common::make_workspace;
use crate::openhuman::agent::profiles::home::profile_home;
use crate::openhuman::agent::profiles::store::built_in_default_profile;
@@ -80,7 +82,7 @@ async fn channel_reply_follows_soul_edit_without_restart() {
let first = run_dispatch_harness(DispatchHarnessOptions {
workspace_dir: Some(ws.path().to_path_buf()),
- system_prompt: Some(prompt.clone()),
+ system_prompt: HarnessSystemPrompt::new(prompt.clone()),
content: "hi".to_string(),
..Default::default()
})
@@ -94,7 +96,7 @@ async fn channel_reply_follows_soul_edit_without_restart() {
let second = run_dispatch_harness(DispatchHarnessOptions {
workspace_dir: Some(ws.path().to_path_buf()),
- system_prompt: Some(prompt.clone()),
+ system_prompt: HarnessSystemPrompt::new(prompt.clone()),
content: "hi again".to_string(),
..Default::default()
})
@@ -116,7 +118,7 @@ async fn fixed_prompt_seeds_every_turn_unchanged() {
let ws = make_workspace();
let observed = run_dispatch_harness(DispatchHarnessOptions {
workspace_dir: Some(ws.path().to_path_buf()),
- system_prompt: Some(ChannelSystemPrompt::fixed("pinned prompt")),
+ system_prompt: HarnessSystemPrompt::new(ChannelSystemPrompt::fixed("pinned prompt")),
..Default::default()
})
.await;