The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
test(tools): assert the recovered registry handle is the same handle\n\nCodeRabbit on #5965: `is_some()` proves only that the erased extension held a\n`PackRegistryHandle`, not that it held *the* one. A producer handing back a\nfresh `default()` — or a second instance — satisfies the assertion while\n`toolpacks::ops` reads an unbound registry and skips the pack, which is the\nsame silent outcome as a failed downcast.\n\n`PackRegistryHandle` is `Clone + Default` over a private `Arc<OnceLock<_>>`\nwith no `PartialEq`, so identity cannot be compared directly. It can be\nobserved: two handles share one `OnceLock` only if they are the same handle.\nBind a registry through the recovered handle and read the effect off the tool,\nwhich consults its own.\n\n`render_pack` names the two states differently, which is what makes this\ndiscriminate rather than smoke-test:\n\n unbound -> "The skill registry is not available in this session"\n bound, registry empty -> "Skill `...` has no tools available"\n\nso both are asserted: the first must be absent, the second present. The empty\nregistry is deliberate — the second message proves the binding was observed\nwithout standing up a real packed tool. The skill id comes from\n`PACKS.first()` so a pack rename cannot turn this into an `Unknown skill`\nno-op.\n\nProved non-vacuous: with `recovered.bind(..)` replaced by\n`PackRegistryHandle::default().bind(..)` the test fails on its own assertion,\nrendering the "registry is not available" sentinel.\n\ncargo test --features "voice,inference" --test raw_coverage_all\n -- a_pack_tools_registry_handle -> 1 passed; 0 failed\n
M3gA-Minde2c39dd73a09
diff --git a/tests/raw_coverage/tools_erased_host_extension_raw_coverage_e2e.rs b/tests/raw_coverage/tools_erased_host_extension_raw_coverage_e2e.rsindex 3faa615f3a..b5f43054b3 100644--- a/tests/raw_coverage/tools_erased_host_extension_raw_coverage_e2e.rs+++ b/tests/raw_coverage/tools_erased_host_extension_raw_coverage_e2e.rs@@ -22,6 +22,7 @@//! only tested state were the same value. These tests assert the `Some` side.use std::any::Any;+use std::sync::Arc;use async_trait::async_trait;use serde_json::{json, Value};@@ -30,28 +31,77 @@ use openhuman_core::openhuman::agent::tool_policy::{GeneratedToolRuntimeContext, GeneratedToolRuntimeRisk,};use openhuman_core::openhuman::skills::types::tool_result_from_mcp;+use openhuman_core::openhuman::tools::toolpacks::registry::PACKS;use openhuman_core::openhuman::tools::toolpacks::tools::{LoadSkillTool, PackRegistryHandle};use openhuman_core::openhuman::tools::traits::{generated_runtime_context, pack_registry_handle, PermissionLevel, Tool, ToolResult,};/// A production pack tool's registry handle survives the round trip through-/// `dyn Any`.+/// `dyn Any` **as the same handle**, not merely as some handle.////// `LoadSkillTool` is one of the two real producers in the tree. If its/// `host_extension` ever stored something other than a `PackRegistryHandle`,/// this is the only place that would notice: `toolpacks::ops` reads the handle/// back through the same free function and, on `None`, silently skips the pack/// registry rather than failing.-#[test]-fn a_pack_tools_registry_handle_reads_back_through_the_erased_extension() {+///+/// `is_some()` alone is too weak to catch the interesting half of that. A+/// producer that handed back a *different* `PackRegistryHandle` — a fresh+/// `default()`, or a second instance — satisfies `is_some()` while+/// `toolpacks::ops` reads an unbound registry and skips the pack exactly as if+/// the downcast had failed. `PackRegistryHandle` is `Clone + Default` with a+/// private `Arc<OnceLock<_>>` and no `PartialEq`, so identity is not directly+/// comparable; it is observable, because two handles share one `OnceLock` only+/// if they are the same handle. So bind through the **recovered** handle and+/// observe the effect on the **tool**, which reads its own.+///+/// `render_pack` distinguishes the two states by message, which is what makes+/// this a real discriminator rather than a smoke test:+///+/// * handle unbound ⇒ "The skill registry is not available in this session"+/// * handle bound, registry empty ⇒ "Skill `…` has no tools available"+///+/// An empty registry is deliberate: the second message proves the binding was+/// observed without needing to construct a real packed tool.+#[tokio::test]+async fn a_pack_tools_registry_handle_reads_back_as_the_same_handle() {let tool = LoadSkillTool::new(PackRegistryHandle::default());- assert!(- pack_registry_handle(&tool).is_some(),+ let recovered = pack_registry_handle(&tool).expect("a pack tool must yield its PackRegistryHandle through the erased \host extension; None here is the silent-downcast failure that makes \- toolpacks::ops skip the registry"+ toolpacks::ops skip the registry",+ );++ // Kept alive for the whole test: the handle stores a `Weak`, so dropping+ // this would make the binding unobservable and the assertion vacuous.+ let registry: Arc<Vec<Box<dyn Tool>>> = Arc::new(Vec::new());+ recovered.bind(Arc::downgrade(®istry));++ let skill = PACKS+ .first()+ .expect("the pack registry ships at least one pack")+ .id;+ let rendered = tool+ .execute(json!({ "skill": skill }))+ .await+ .expect("load_skill reports failure in its ToolResult, never as Err")+ .output()+ .to_string();++ assert!(+ !rendered.contains("registry is not available"),+ "binding through the recovered handle did not reach the tool's own \+ handle, so the erased extension yielded a different \+ PackRegistryHandle than the one supplied — the failure `is_some()` \+ cannot see. Rendered: {rendered}"+ );+ assert!(+ rendered.contains("has no tools available"),+ "the tool should have got as far as walking the (empty) bound \+ registry; a different message means this test is no longer \+ discriminating between bound and unbound. Rendered: {rendered}");}