Repository navigation
Tools as nodes: deterministic-handler bridge with TYPED tools generated from nodes (no universal invoker), plus external-tool trust boundary - #1362
Conversation
…vailable_tools (closes #1353) - Add ToolNodeBehavior (node_type='tool') to nodespace-core behaviors: validates handler key, description, parameter_schema, source/enabled provenance markers, and enforces trust boundary schema depth + no additionalProperties:true. - Register ToolNodeBehavior in NodeBehaviorRegistry (now 16 built-in types). - Add seed_tool_nodes() in skill_pipeline.rs: generates one NodeTemplate per Tool::ALL entry, storing handler key, typed parameter_schema, description, source="internal", and enabled=true as node properties. - Update available_tools() in GraphToolExecutor: queries tool nodes from DB, generates typed ToolDefinition from each enabled node whose handler key is in the deterministic registry, preserves canonical Tool::ALL ordering, and falls back to hardcoded list when DB unavailable or empty. External tools with enabled=false are filtered out (trust boundary enforcement). - Update seed_agent_nodes() in daemon/main.rs to seed tool nodes alongside skill/prompt nodes on first launch. - Fix pre-existing model_manager test (catalog count was 9, now 10 after MISTRAL_SMALL_3_2 + QWEN3_8B entries were added in a prior commit). Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Code Review — Initial ReviewReview Type: Initial Review Requirements CheckTracing each acceptance criterion from issue #1353:
Findings🔴 Critical:
|
malibio
left a comment
There was a problem hiding this comment.
Review recommendation: REQUEST CHANGES. See detailed findings in the review comment above. Critical blocker is the parameter_schema loss during DB round-trip.
…tests, trust boundary - Pre-namespace seed_tool_nodes() properties under "tool" key so normalize_flat_properties_to_namespace detects the existing namespace and returns early, preserving parameter_schema through the DB round-trip. Without this, the normalizer misclassifies the parameter_schema object as a dormant namespace; flatten_properties_for_api then drops it silently. - Add 12 ToolNodeBehavior unit tests covering: valid node, empty handler, missing handler, empty content, invalid source, external source, schema depth exceeded, additionalProperties:true, embeddable content, parent contribution, and can_have_children. - Fix depth check from depth>MAX to depth>=MAX so the limit is strictly 5 levels, not 6. - Replace blocklist trust boundary (external && !enabled) with allowlist (internal || enabled) so future unknown source values default to rejected. - Update seed_tool_nodes tests to read from pre-namespaced "tool" key. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Address-Review SummaryThe critical and important findings from the initial review have been addressed in commit ✅ Addressed🔴 Critical: 🟡 Important: No unit tests for 🟡 Important: Trust boundary as blocklist instead of allowlist Nit: Off-by-one in depth validator ⏭️ Explicitly Deferred❌ AC4: 🟡 Important: Coarse-grained idempotency (no warn log for skipped tools) 🟡 Important: No integration test for the live Nit: Re-Review DecisionDecision: RE-REVIEW NEEDED Rationale: The critical |
Code Review — Re-Review (commit 46244c7)Review Type: Re-Review — addressing findings from the initial REQUEST CHANGES review. Delta SummaryThis pass reviews only the single commit Finding Verification✅ Critical Fixed:
|
| Test | Validates |
|---|---|
tool_node_valid_accepts_well_formed_node |
Happy path |
tool_node_rejects_empty_handler |
Empty handler string |
tool_node_rejects_missing_handler |
Absent handler key |
tool_node_rejects_empty_content |
Empty display name |
tool_node_rejects_invalid_source |
Unknown source value |
tool_node_accepts_external_source |
External + disabled is valid to store |
tool_node_rejects_schema_depth_exceeded |
6-level nesting rejected (depth=5 trips >= MAX) |
tool_node_rejects_unbounded_additional_properties |
additionalProperties: true rejected |
tool_node_embeddable_content_uses_name_and_description |
Embeddable content format |
tool_node_embeddable_content_none_when_empty |
None when empty |
tool_node_does_not_have_children |
can_have_children() == false |
tool_node_parent_contribution_is_none |
No parent contribution |
One gap noted but not a blocker: additionalProperties: true at a nested depth (not the root schema) is not explicitly tested. The validator recurses into all child objects via validate_parameter_schema_depth, so nested additionalProperties: true is caught — but a regression test for this specific case would improve confidence. [Improvement]
✅ Important Fixed: Trust boundary changed to allowlist
The old blocklist (source == "external" && !enabled) has been replaced with:
let is_allowed = source == "internal" || enabled;This correctly handles the three cases: internal tools always pass, external tools require enabled=true, and unknown future source values require enabled=true (fail-secure). The comment accurately describes the intent.
[Improvement] A minor inconsistency remains: unwrap_or("internal") for a missing source field elevates a source-less node to internal trust, bypassing the enabled requirement. The comment directly above says "unknown source values are treated as untrusted and require enablement" — the default contradicts this. Since all seeded internal nodes have source="internal" explicitly, this only affects manually-inserted DB rows and is not a runtime risk, but the comment and the default disagree. unwrap_or("") (which would fall through to the enabled gate) would match the stated policy exactly.
✅ Nit Fixed: Depth check corrected
depth > MAX_SCHEMA_DEPTH → depth >= MAX_SCHEMA_DEPTH. With MAX_SCHEMA_DEPTH = 5 and the initial call at depth=0, valid nesting levels are 0–4 (5 levels). The depth test (tool_node_rejects_schema_depth_exceeded) constructs a 6-level schema that correctly trips the error at depth=5. Verified.
Deferred Items (acknowledged, not blocking)
- AC4 (
tool_whitelistholding node IDs): Explicitly deferred with sound rationale (UUIDs are runtime-generated; stable IDs or a startup resolve pass needed). Issue Tools as nodes: deterministic-handler bridge with TYPED tools generated from nodes (no universal invoker), plus external-tool trust boundary #1353 correctly remains open. - Coarse-grained idempotency warn log: Acceptable deferral per CLAUDE.md greenfield policy.
- Integration test for live
available_toolsDB path: Still missing. The pre-namespace fix makes the round-trip mechanically correct, and the seeding tests verify the structure is right before it reaches the normalizer. The gap is real — a test that seeds + queries + assertsparameter_schemapreserved end-to-end would be the strongest regression guard — but this is not a blocker for merge. available_toolsper-call DB query: No caching. Not blocking.
Verdict
All critical and important findings from the initial review are resolved. The fix is mechanically correct, the tests pass, and the trust boundary logic is a genuine improvement over the original. The two remaining items (nested additionalProperties regression test, unwrap_or source default inconsistency) are improvements, not blockers.
Recommendation: APPROVE
unwrap_or("internal") meant a node with no source property got unconditional
internal trust, contradicting the documented policy that unknown source values
are treated as untrusted. Changed to unwrap_or("") so the allowlist condition
(source == "internal" || enabled) correctly requires enabled=true for any node
without an explicit source.
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…ed from nodes (no universal invoker), plus external-tool trust boundary (#1362) * Tools as nodes: ToolNodeBehavior, seed_tool_nodes, typed-from-nodes available_tools (closes #1353) - Add ToolNodeBehavior (node_type='tool') to nodespace-core behaviors: validates handler key, description, parameter_schema, source/enabled provenance markers, and enforces trust boundary schema depth + no additionalProperties:true. - Register ToolNodeBehavior in NodeBehaviorRegistry (now 16 built-in types). - Add seed_tool_nodes() in skill_pipeline.rs: generates one NodeTemplate per Tool::ALL entry, storing handler key, typed parameter_schema, description, source="internal", and enabled=true as node properties. - Update available_tools() in GraphToolExecutor: queries tool nodes from DB, generates typed ToolDefinition from each enabled node whose handler key is in the deterministic registry, preserves canonical Tool::ALL ordering, and falls back to hardcoded list when DB unavailable or empty. External tools with enabled=false are filtered out (trust boundary enforcement). - Update seed_agent_nodes() in daemon/main.rs to seed tool nodes alongside skill/prompt nodes on first launch. - Fix pre-existing model_manager test (catalog count was 9, now 10 after MISTRAL_SMALL_3_2 + QWEN3_8B entries were added in a prior commit). Co-Authored-By: Claude Sonnet 4.6 <[email protected]> * Fix review findings: pre-namespace tool properties, ToolNodeBehavior tests, trust boundary - Pre-namespace seed_tool_nodes() properties under "tool" key so normalize_flat_properties_to_namespace detects the existing namespace and returns early, preserving parameter_schema through the DB round-trip. Without this, the normalizer misclassifies the parameter_schema object as a dormant namespace; flatten_properties_for_api then drops it silently. - Add 12 ToolNodeBehavior unit tests covering: valid node, empty handler, missing handler, empty content, invalid source, external source, schema depth exceeded, additionalProperties:true, embeddable content, parent contribution, and can_have_children. - Fix depth check from depth>MAX to depth>=MAX so the limit is strictly 5 levels, not 6. - Replace blocklist trust boundary (external && !enabled) with allowlist (internal || enabled) so future unknown source values default to rejected. - Update seed_tool_nodes tests to read from pre-namespaced "tool" key. Co-Authored-By: Claude Sonnet 4.6 <[email protected]> * Fix trust boundary default: sourceless tool nodes require enabled=true unwrap_or("internal") meant a node with no source property got unconditional internal trust, contradicting the documented policy that unknown source values are treated as untrusted. Changed to unwrap_or("") so the allowlist condition (source == "internal" || enabled) correctly requires enabled=true for any node without an explicit source. Co-Authored-By: Claude Sonnet 4.6 <[email protected]> --------- Co-authored-by: Claude Sonnet 4.6 <[email protected]>
Closes #1353