Skip to content

Open source Grok Bot alternative, Bring your own agent and subscription: message Claude Code, Codex, Gemini CLI, Cursor, Copilot and 40+ AI agents as bots on your own computer, from iPhone, Mac, Windows, Linux or terminal. Agent-agnostic and free. Also a Muse and Dots alternative. Built in Rust.

test(host): share one Engram copy across the test hosts

leepokai34c844a06b90
diff --git a/docs/features/engram-memory.md b/docs/features/engram-memory.md
index b0ad3acf..8eb6aa5d 100644
--- a/docs/features/engram-memory.md
+++ b/docs/features/engram-memory.md
@@ -89,7 +89,9 @@ and `memoryCall`; agents receive their real ACP session binding, including indep
## Verification
`packaging/engram/test-runtime.py` downloads and checksum-verifies the same pinned binary used by the host.
-Set `CODYNC_TEST_ENGRAM` to its output path, then run:
+The integration tests run it themselves (once; the copy stays in `host/target/engram-test-runtime`), so
+their hosts don't each download Engram; `CODYNC_TEST_ENGRAM` points them at another copy. The last
+command below needs `CODYNC_TEST_ENGRAM` set to the script's output:
```sh
cd host
diff --git a/host/tests/common/mod.rs b/host/tests/common/mod.rs
index 5afd964f..e6ed28f9 100644
--- a/host/tests/common/mod.rs
+++ b/host/tests/common/mod.rs
@@ -1,11 +1,30 @@
//! Shared by the end-to-end tests.
+use std::path::{Path, PathBuf};
use std::process::{Child, Command, Stdio};
+use std::sync::OnceLock;
use std::time::{Duration, Instant};
+/// The checksum-verified Engram release the test hosts share: `CODYNC_TEST_ENGRAM`, else the copy
+/// `packaging/engram/test-runtime.py` fetches once into `target/engram-test-runtime`. Without it
+/// each host downloads its own, slow enough that tests time out. `None` when offline.
+pub fn engram_fixture() -> Option<PathBuf> {
+ static FIXTURE: OnceLock<Option<PathBuf>> = OnceLock::new();
+ FIXTURE
+ .get_or_init(|| {
+ if let Some(binary) = std::env::var_os("CODYNC_TEST_ENGRAM") {
+ return Some(binary.into());
+ }
+ let script = Path::new(env!("CARGO_MANIFEST_DIR")).join("../packaging/engram/test-runtime.py");
+ let output = Command::new(python()).arg(script).output().ok().filter(|o| o.status.success())?;
+ Some(String::from_utf8_lossy(&output.stdout).trim().into())
+ })
+ .clone()
+}
+
/// Use the checksum-verified release fixture so isolated hosts don't each download it.
-pub fn seed_memory_runtime(home: &std::path::Path) {
- let Some(binary) = std::env::var_os("CODYNC_TEST_ENGRAM") else {
+pub fn seed_memory_runtime(home: &Path) {
+ let Some(binary) = engram_fixture() else {
return;
};
let dir = home.join("engram/3.2.1");
@@ -17,7 +36,7 @@ pub fn seed_memory_runtime(home: &std::path::Path) {
/// Runs `codync-host serve` for `home` until it answers: the process and its base URL. A port
/// picked here is only free for a moment; when something else takes it before the host binds, the
/// host exits and this starts it again on another one.
-pub async fn serve(home: &std::path::Path) -> (Child, String) {
+pub async fn serve(home: &Path) -> (Child, String) {
let deadline = Instant::now() + Duration::from_secs(30);
loop {
let port = std::net::TcpListener::bind("127.0.0.1:0").expect("free port").local_addr().expect("port").port();
@@ -63,7 +82,7 @@ pub fn python() -> &'static str {
}
/// The agent command that runs a Python fixture (quoted for `sh -c` / `cmd /c`).
-pub fn python_agent(script: &std::path::Path) -> String {
+pub fn python_agent(script: &Path) -> String {
let path = script.display().to_string();
if cfg!(windows) {
format!("{} -u \"{path}\"", python())
diff --git a/host/tests/memory_e2e.rs b/host/tests/memory_e2e.rs
index f70137bd..e1015208 100644
--- a/host/tests/memory_e2e.rs
+++ b/host/tests/memory_e2e.rs
@@ -30,7 +30,7 @@ impl Drop for Host {
impl Host {
async fn start() -> Self {
- assert!(std::env::var_os("CODYNC_TEST_ENGRAM").is_some(), "set CODYNC_TEST_ENGRAM to the pinned binary");
+ assert!(common::engram_fixture().is_some(), "needs the pinned Engram binary");
let home = std::env::temp_dir().join(format!("codync-memory-e2e-{}", uuid::Uuid::new_v4()));
common::seed_memory_runtime(&home);
let (child, base) = common::serve(&home).await;