Skip to content

Commit fe581ef

Browse files
malibioclaude
andcommitted
Address re-review: drop the unused tool_is_offered and tighten the gate test
- tool_is_offered had no production caller once the agent moved to ToolOrigin; deleted, with its tests pointed at ToolOrigin. - The stored-default assertion now passes the value it read to the gate. - Log lines say what was actually skipped. Skipped: two tools that are not native sharing a name (nothing dispatches one yet; settled with remote bindings), and reading seeds by id instead of through the 256-node page (not reachable with the built-in set). Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 4fea0db commit fe581ef

3 files changed

Lines changed: 33 additions & 31 deletions

File tree

‎packages/agent/src/local_agent/tools.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4374,7 +4374,7 @@ impl AgentToolExecutor for GraphToolExecutor {
43744374
tracing::debug!(
43754375
node_id,
43764376
node_type,
4377-
"available_tools: skipping unenabled tool"
4377+
"available_tools: skipping a node the tool trust gate does not offer"
43784378
);
43794379
continue;
43804380
};
@@ -4416,7 +4416,7 @@ impl AgentToolExecutor for GraphToolExecutor {
44164416
node_id,
44174417
node_type,
44184418
name = %name,
4419-
"available_tools: skipping tool node that is not the built-in tool it names"
4419+
"available_tools: skipping tool node that is not the seed of a built-in tool but is native or takes one's name"
44204420
);
44214421
continue;
44224422
}

‎packages/core/src/behaviors/mod.rs‎

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2039,6 +2039,16 @@ impl ToolOrigin {
20392039
/// The trust gate: whether a tool of this origin may be offered to the
20402040
/// model. A native tool always is. Every other tool is offered only when
20412041
/// `enabled`, the base field every tool carries.
2042+
///
2043+
/// # Examples
2044+
///
2045+
/// ```rust
2046+
/// use nodespace_core::behaviors::ToolOrigin;
2047+
///
2048+
/// assert!(ToolOrigin::Native.is_offered(false));
2049+
/// assert!(!ToolOrigin::External.is_offered(false));
2050+
/// assert!(ToolOrigin::External.is_offered(true));
2051+
/// ```
20422052
pub fn is_offered(self, enabled: bool) -> bool {
20432053
match self {
20442054
Self::Native => true,
@@ -2047,23 +2057,6 @@ impl ToolOrigin {
20472057
}
20482058
}
20492059

2050-
/// The tool trust gate for a type's `chain`: [`ToolOrigin::is_offered`] for a
2051-
/// tool, and never for a type that is not one.
2052-
///
2053-
/// # Examples
2054-
///
2055-
/// ```rust
2056-
/// use nodespace_core::behaviors::tool_is_offered;
2057-
///
2058-
/// assert!(tool_is_offered(&["tool-native", "tool"], false));
2059-
/// assert!(!tool_is_offered(&["tool-remote", "tool"], false));
2060-
/// assert!(tool_is_offered(&["tool-remote", "tool"], true));
2061-
/// assert!(!tool_is_offered(&["text"], true));
2062-
/// ```
2063-
pub fn tool_is_offered<S: AsRef<str>>(chain: &[S], enabled: bool) -> bool {
2064-
ToolOrigin::of(chain).is_some_and(|origin| origin.is_offered(enabled))
2065-
}
2066-
20672060
/// Maximum object-nesting depth allowed in a tool's `parameter_schema`.
20682061
///
20692062
/// Bounded nesting stops a tool registered from outside from storing a schema
@@ -5144,19 +5137,22 @@ mod tests {
51445137
/// always offered, and any other tool subtype only when `enabled`.
51455138
#[test]
51465139
fn the_trust_gate_is_decided_by_the_tool_subtype() {
5140+
let offered = |chain: &[&str], enabled: bool| {
5141+
ToolOrigin::of(chain).is_some_and(|origin| origin.is_offered(enabled))
5142+
};
51475143
for enabled in [true, false] {
5148-
assert!(tool_is_offered(&NATIVE_TOOL_CHAIN, enabled));
5144+
assert!(offered(&NATIVE_TOOL_CHAIN, enabled));
51495145
// A subtype of the native tool is native too.
5150-
assert!(tool_is_offered(
5146+
assert!(offered(
51515147
&["tool-native-plus", "tool-native", "tool"],
51525148
enabled
51535149
));
5154-
assert_eq!(tool_is_offered(&["tool-remote", "tool"], enabled), enabled);
5150+
assert_eq!(offered(&["tool-remote", "tool"], enabled), enabled);
51555151
// The bare base is no more trusted than any other tool that is
51565152
// not native, and a type that is no tool is never offered.
5157-
assert_eq!(tool_is_offered(&["tool"], enabled), enabled);
5158-
assert!(!tool_is_offered(&["text"], enabled));
5159-
assert!(!tool_is_offered(&["invoice"], enabled));
5153+
assert_eq!(offered(&["tool"], enabled), enabled);
5154+
assert!(!offered(&["text"], enabled));
5155+
assert!(!offered(&["invoice"], enabled));
51605156
}
51615157
assert_eq!(ToolOrigin::of(&NATIVE_TOOL_CHAIN), Some(ToolOrigin::Native));
51625158
assert_eq!(

‎packages/core/tests/it/tool_subtypes_test.rs‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//! core subtype NodeSpace's built-in tools are, the base's rules reach every
44
//! subtype, and no tool carries a `source`: its type says where it comes from.
55
6-
use nodespace_core::behaviors::tool_is_offered;
6+
use nodespace_core::behaviors::ToolOrigin;
77
use nodespace_core::db::{SqliteStore, TreeInvariantRule};
88
use nodespace_core::models::{node_to_typed_value, CoreNodeType, Node, NodeUpdate};
99
use nodespace_core::schema::handle_create_schema;
@@ -351,19 +351,25 @@ async fn the_trust_gate_follows_the_stored_chain() {
351351
let native = svc.resolve_type_chain(NATIVE).await.unwrap();
352352
let remote = svc.resolve_type_chain(REMOTE).await.unwrap();
353353
assert_eq!(remote, vec![REMOTE, "tool"]);
354+
assert_eq!(ToolOrigin::of(&native), Some(ToolOrigin::Native));
355+
let remote_origin = ToolOrigin::of(&remote).expect("a type extending tool is a tool");
356+
assert_eq!(remote_origin, ToolOrigin::External);
354357

355-
assert!(tool_is_offered(&native, false));
356-
assert!(!tool_is_offered(&remote, false));
357-
assert!(tool_is_offered(&remote, true));
358+
assert!(ToolOrigin::Native.is_offered(false));
359+
assert!(!remote_origin.is_offered(false));
360+
assert!(remote_origin.is_offered(true));
358361

359362
// A tool that doesn't say is stored as not enabled, so the gate is closed
360363
// until someone opens it.
361364
let unstated = create(&svc, REMOTE, "remote_lookup", json!({}))
362365
.await
363366
.unwrap();
364367
let stored = get(&svc, &unstated).await;
365-
assert_eq!(stored.properties["tool"]["enabled"], false);
366-
assert!(!tool_is_offered(&remote, false));
368+
let enabled = stored.properties["tool"]["enabled"]
369+
.as_bool()
370+
.expect("the default is stored");
371+
assert!(!enabled);
372+
assert!(!remote_origin.is_offered(enabled));
367373
}
368374

369375
/// The parameter-schema guard is the base's, so it holds for a native tool

0 commit comments

Comments
 (0)