Repository navigation
Reject create_node against a nonexistent node_type (closes #1895) - #1902
Conversation
…y persisting a shell (closes #1895) Agent-matrix scenario 4 traced create_node succeeding against an invented node_type (a display name like "Equipment Item Tracker" instead of the real schema id "equipment_item"). CustomNodeBehavior accepts any type string, so the call succeeded with a bare-shell node and every supplied property silently dropped -- indistinguishable at the tool-call level from #1866's defect, and the model reported the write as successful. create_node_with_parent now rejects a node_type that is neither a registered core behavior nor an existing schema id, surfacing a loud, model-visible error naming the bad type instead of a silent zero-property write. Core types (text, task, date, ...) are unaffected -- they're recognized by behavior registration, not by a schema row. Co-Authored-By: Claude <[email protected]>
Code Review SummaryThis PR closes the second of two mechanisms behind agent-matrix scenario 4's zero-property This is a net positive and narrowly scoped — it does exactly what the issue asked for in its stated preference order, and explicitly does not attempt the second (investigative) acceptance criterion, which I address below as a note rather than a blocker. Requirements CheckIssue #1895 acceptance criteria:
FindingsCritical IssuesNone. Suggested Improvements
Nitpicks
PerformanceThe added check costs one extra Verification performed
Recommendation: APPROVENet positive, correctly scoped to the issue's stated preferred direction, well-tested, and I found no production regression across the call sites I traced. The |
|
Review recommendation: APPROVE (see full review above). Note: could not set a formal GitHub review status via |
…ersion Code review on #1902 caught that create_node's map_err flattened every NodeServiceError -- including the new UnknownNodeType -- to OpsError::Internal instead of going through the From<NodeServiceError> impl. That meant an unknown node_type reached the daemon's gRPC boundary as INTERNAL instead of INVALID_ARGUMENT, misreporting a caller mistake as a server fault. Using `?` routes through the shared conversion so every variant lands on its correct OpsError category, pinned by a new test asserting InvalidParams specifically. Co-Authored-By: Claude <[email protected]>
|
Addressed the review finding: pushed d9cd3db, which routes `create_node`'s `NodeServiceError` through the shared `From for OpsError` conversion (via `?`) instead of a hand-rolled `map_err` that flattened everything to `OpsError::Internal`. `UnknownNodeType` now correctly reaches the daemon's gRPC boundary as `INVALID_ARGUMENT` rather than `INTERNAL`, pinned by a new test (`create_node_unknown_type_surfaces_as_invalid_params_not_internal` in `packages/core/src/ops/node_ops.rs`). Full pre-push gate (test:all + cargo build --bin nodespaced + cargo test -p nodespace-app) passed on the follow-up commit. Re: the two unaddressed acceptance criteria noted in the review (prompt-content investigation, repeated-run scenario-4 verification) — leaving those as follow-up under the issue rather than blocking this PR, per the issue's own stated preference for the loud-failure fix "regardless of what else is done." |
- Renumber create_node_with_parent's step comments (2-8b) now that the node_type validation is a permanent step, not a late "1.5" insertion. - Dedupe the UnknownNodeType message: ops/mod.rs now calls err.to_string() instead of re-deriving the same text in a separate format!, so the Display impl in error.rs stays the single source of truth (matching the PlaybookValidationFailed arm one line below it). Co-Authored-By: Claude <[email protected]>
Review recommendations addressed (round 2)
Skipped
Verification
Re-Review DecisionDecision: NO RE-REVIEW NEEDED Rationale: All changes in this round are the two nitpicks explicitly called out in the original review — a comment renumbering (pure readability, no logic change) and a string-dedup refactor using an already-reviewed |
Summary
create_node_with_parentnow rejects anode_typethat is neither a registered core behavior (text, task, date, ...) nor an existing schema id, returning a loudUnknownNodeTypeerror that names the offending type instead of silently persisting a bare-shell node with zero properties.create_node: the model inventing a display-name-stylenode_type(e.g."Equipment Item Tracker") instead of copying the real schema id ("equipment_item").#1866fixed the sibling defect (values dropped for an undeclared field on a valid type); this closes the invalid type path, which previously fell through toCustomNodeBehaviorand succeeded regardless.Changes
NodeServiceError::UnknownNodeType(new variant) +unknown_node_type()constructor, mirroring the existingNotAContainerpattern.create_node_with_parent(packages/core/src/services/node_service/crud.rs): validatesnode_typeagainstself.behaviors.get(...)(core types) ORstore.get_schema(...)(custom types) before creating the node.OpsErrormapping:UnknownNodeType→InvalidParams, surfacing throughexec_create_nodeas a normalis_error: truetool result the model can act on and retry.test_query_any_node_type) that created a custom-typed node with no schema — now seeds a minimal schema first, matching how a real agent would callcreate_schemabeforecreate_node.Test plan
rejects_node_type_with_no_schema_and_no_core_behavior— invented type is rejected, error names itaccepts_core_node_type_with_no_schema_node—"text"still works with no schema rowcreate_node_rejects_unknown_node_type—exec_create_nodesurfaces the rejection as a named tool errorcargo test -p nodespace-core --lib— 1105 passedcargo test -p nodespace-core --test '*'— 154 passed across 12 filescargo test -p nodespace-agent --lib— 408 passedcargo test -p nodespace-daemon --lib— 114 passedbun run test— 4108 passed (171 files), matches baselinecargo fmt --check/cargo clippy -D warningsclean on touched cratestest:all+cargo build --bin nodespaced+cargo test -p nodespace-app) passedCo-Authored-By: Claude [email protected]
https://claude.ai/code/session_01DkqjrfV1G6kugsEjvyU9wU