Skip to content

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

test(storage): narrow oversized inline blob test to the inline cap

Steven Enamakel64472b3f0993
diff --git a/crates/openhuman-core/src/modules/storage_host_cdylib_tests.rs b/crates/openhuman-core/src/modules/storage_host_cdylib_tests.rs
index 03ed8505a9..cb69912838 100644
--- a/crates/openhuman-core/src/modules/storage_host_cdylib_tests.rs
+++ b/crates/openhuman-core/src/modules/storage_host_cdylib_tests.rs
@@ -68,21 +68,20 @@ fn probe_artifact() -> &'static Path {
}
let root = repo_root();
let target = root.join("target/storage-probe");
- let status = std::process::Command::new(
- std::env::var_os("CARGO").unwrap_or_else(|| "cargo".into()),
- )
- .args(["build", "--quiet", "--manifest-path"])
- .arg(root.join("tests/fixtures/storage_probe_module/Cargo.toml"))
- .arg("--target-dir")
- .arg(&target)
- // The test run's own flags (coverage instrumentation, a linker choice)
- // must not leak into a fixture that is a different build.
- .env_remove("RUSTFLAGS")
- .env_remove("CARGO_ENCODED_RUSTFLAGS")
- .env_remove("RUSTC_WRAPPER")
- .env_remove("CARGO_TARGET_DIR")
- .status()
- .expect("run cargo to build the storage probe module");
+ let status =
+ std::process::Command::new(std::env::var_os("CARGO").unwrap_or_else(|| "cargo".into()))
+ .args(["build", "--quiet", "--manifest-path"])
+ .arg(root.join("tests/fixtures/storage_probe_module/Cargo.toml"))
+ .arg("--target-dir")
+ .arg(&target)
+ // The test run's own flags (coverage instrumentation, a linker choice)
+ // must not leak into a fixture that is a different build.
+ .env_remove("RUSTFLAGS")
+ .env_remove("CARGO_ENCODED_RUSTFLAGS")
+ .env_remove("RUSTC_WRAPPER")
+ .env_remove("CARGO_TARGET_DIR")
+ .status()
+ .expect("run cargo to build the storage probe module");
assert!(status.success(), "building the storage probe module failed");
target.join("debug").join(format!(
"{}storage_probe_module{}",
@@ -296,7 +295,10 @@ async fn a_loaded_module_cannot_reach_another_modules_collections() {
for (selector, request) in [
("Get", get(&theirs, "session")),
- ("Put", put(&theirs, "session", &json!({"marker": "overwritten"}))),
+ (
+ "Put",
+ put(&theirs, "session", &json!({"marker": "overwritten"})),
+ ),
(
"Query",
json!({"collection": theirs, "filter": null, "limit": 10}),
@@ -307,7 +309,10 @@ async fn a_loaded_module_cannot_reach_another_modules_collections() {
),
] {
let answer = rig.call("Documents", selector, request).await;
- assert!(denied(&answer, "target-not-granted"), "{selector}: {answer}");
+ assert!(
+ denied(&answer, "target-not-granted"),
+ "{selector}: {answer}"
+ );
assert!(!answer.to_string().contains("OTHER-MODULES-SECRET"));
}
// Untouched: the refusal came before the backend.
@@ -319,7 +324,12 @@ async fn a_loaded_module_cannot_reach_another_modules_collections() {
.contains("OTHER-MODULES-SECRET"));
// And its own scope never got the collection.
let own = rig.backend.for_scope(&rig.scope("tinymcp")).unwrap();
- assert!(!own.documents().collections("").await.unwrap().contains(&theirs));
+ assert!(!own
+ .documents()
+ .collections("")
+ .await
+ .unwrap()
+ .contains(&theirs));
}
#[tokio::test(flavor = "multi_thread")]
@@ -391,7 +401,10 @@ async fn a_loaded_module_cannot_use_a_collection_it_never_declared() {
_ => json!({"collection": "never_declared"}),
};
let answer = rig.call("Documents", selector, request).await;
- assert!(denied(&answer, "target-not-granted"), "{selector}: {answer}");
+ assert!(
+ denied(&answer, "target-not-granted"),
+ "{selector}: {answer}"
+ );
}
let wrote = rig
.call(
@@ -421,7 +434,10 @@ async fn a_loaded_module_cannot_use_a_collection_it_never_declared() {
assert!(denied(&dropped, "schema-is-host-only"), "{dropped}");
let own = rig.backend.for_scope(&rig.scope("tinymcp")).unwrap();
let listed = own.documents().collections("").await.unwrap();
- assert!(!listed.contains(&"never_declared".to_string()), "{listed:?}");
+ assert!(
+ !listed.contains(&"never_declared".to_string()),
+ "{listed:?}"
+ );
// The module's listing shows its own names only.
let seen = rig.call("Documents", "Collections", json!({})).await;
assert!(!seen.to_string().contains("never_declared"), "{seen}");
@@ -465,9 +481,7 @@ async fn a_peer_that_is_not_a_registry_module_is_refused() {
STORAGE_INTERFACE,
)
.unwrap();
- let refused: tinybus::Result<Value> = proxy
- .call("Get", (get("mcp_servers", "files"),))
- .await;
+ let refused: tinybus::Result<Value> = proxy.call("Get", (get("mcp_servers", "files"),)).await;
match refused {
Err(tinybus::Error::MethodFailed { name, message }) => {
assert_eq!(name, "ai.tinyhumans.tinystorage.Error.Denied");
@@ -478,7 +492,7 @@ async fn a_peer_that_is_not_a_registry_module_is_refused() {
}
#[tokio::test(flavor = "multi_thread")]
-async fn a_blob_over_the_frame_cannot_go_inline() {
+async fn a_blob_over_the_inline_cap_is_refused_and_stores_nothing() {
let _turn = TURN.lock().await;
let rig = rig("tinyjuice").await;
let small: Value = rig
@@ -486,28 +500,41 @@ async fn a_blob_over_the_frame_cannot_go_inline() {
.call("PutBlob", ("tinyjuice_ccr/small", 1024usize))
.await
.unwrap();
- assert!(small.get("ok").is_some(), "a small inline blob works: {small}");
- // Past the contract's inline cap (1 MiB) the server refuses the body, and
- // past the 16 MiB frame (4.5 MB of 0xFF bytes is already 18 MB as JSON)
- // the bus never delivers it. Either way it must fail closed and store
- // nothing; the way for a big body is `PutStream` (#7781).
- for (len, name) in [(2usize * 1024 * 1024, "over-cap"), (4_500_000, "over-frame")] {
- let key = format!("tinyjuice_ccr/{name}");
- eprintln!("[cdylib-test] inline blob {name} ({len} bytes)");
- let started = std::time::Instant::now();
- let big: Value = rig.probe.call("PutBlob", (key.as_str(), len)).await.unwrap();
- eprintln!("[cdylib-test] {name} answered in {:?}: {}", started.elapsed(), big.to_string().chars().take(200).collect::<String>());
- assert!(big.get("err").is_some(), "{name}: an oversized inline blob must fail: {big}");
- let handle = rig.backend.for_scope(&rig.scope("tinyjuice")).unwrap();
- assert!(handle.blobs().head(&key).await.unwrap().is_none(), "{name}");
- }
+ assert!(
+ small.get("ok").is_some(),
+ "a small inline blob works: {small}"
+ );
+ // Past the contract's inline cap (1 MiB) the server refuses the body and
+ // stores nothing; a body that size or bigger goes by `PutStream`, which
+ // waits for the tinybus move (#7781). (The 16 MiB frame itself is the
+ // bus's to enforce and is not exercised here: an inline body big enough to
+ // hit it takes the probe longer to build than a unit test should wait.)
+ let big: Value = rig
+ .probe
+ .call("PutBlob", ("tinyjuice_ccr/over-cap", 2usize * 1024 * 1024))
+ .await
+ .unwrap();
+ assert!(
+ big.get("err").is_some(),
+ "an oversized inline blob must fail: {big}"
+ );
+ let handle = rig.backend.for_scope(&rig.scope("tinyjuice")).unwrap();
+ assert!(handle
+ .blobs()
+ .head("tinyjuice_ccr/over-cap")
+ .await
+ .unwrap()
+ .is_none());
// The refusal does not take the module's connection down with it.
let after: Value = rig
.probe
.call("PutBlob", ("tinyjuice_ccr/after", 2048usize))
.await
.unwrap();
- assert!(after.get("ok").is_some(), "the module keeps working: {after}");
+ assert!(
+ after.get("ok").is_some(),
+ "the module keeps working: {after}"
+ );
// A blob key outside the CCR prefix is not the module's.
let outside = rig
.call("Blobs", "Get", json!({"key": "tinyjuice_other/x"}))
@@ -528,7 +555,11 @@ async fn streams_and_watches_are_refused_until_tinybus_binds_them() {
.await;
assert!(denied(&put_stream, "unsupported-selector"), "{put_stream}");
let get_stream = rig
- .call("Blobs", "GetStream", json!({"key": "tinyjuice_ccr/streamed"}))
+ .call(
+ "Blobs",
+ "GetStream",
+ json!({"key": "tinyjuice_ccr/streamed"}),
+ )
.await;
assert!(denied(&get_stream, "unsupported-selector"), "{get_stream}");
let mcp = crate::modules::storage_grants::declared("tinymcp").unwrap();
@@ -537,7 +568,11 @@ async fn streams_and_watches_are_refused_until_tinybus_binds_them() {
// refused first. The unsupported label is pinned for a documented grant by
// `storage_grants_tests` and below for tinymcp.
let watch = rig
- .call("Documents", "WatchOpen", json!({"collection": "mcp_servers"}))
+ .call(
+ "Documents",
+ "WatchOpen",
+ json!({"collection": "mcp_servers"}),
+ )
.await;
assert!(
denied(&watch, "object-not-granted") || denied(&watch, "unsupported-selector"),
@@ -558,7 +593,11 @@ async fn a_watch_is_unsupported_for_a_module_that_may_use_documents() {
let _turn = TURN.lock().await;
let rig = rig("tinymcp").await;
let watch = rig
- .call("Documents", "WatchOpen", json!({"collection": "mcp_servers"}))
+ .call(
+ "Documents",
+ "WatchOpen",
+ json!({"collection": "mcp_servers"}),
+ )
.await;
assert!(denied(&watch, "unsupported-selector"), "{watch}");
let close = rig
@@ -575,7 +614,11 @@ async fn every_call_is_audited_under_the_module_id_without_a_payload() {
.call(
"Documents",
"Put",
- put("mcp_servers", "audited", &json!({"marker": "PAYLOAD-MARKER"})),
+ put(
+ "mcp_servers",
+ "audited",
+ &json!({"marker": "PAYLOAD-MARKER"}),
+ ),
)
.await;
let _ = rig