Repository navigation
Implement nodespace CLI binary (closes #1116) - #1141
Conversation
#1116) Adds the `nodespace` CLI — a thin gRPC client that connects to nodespaced on localhost:50051 and exposes knowledge graph operations as shell commands. - New packages/cli crate, added to workspace - clap-based subcommands: node get/create/update/delete/children, search - Global --json flag and --endpoint override (env: NODESPACE_ENDPOINT) - Friendly remediation when daemon is unreachable - Human-readable and JSON output formatters - Integration test against in-process daemon covers round trip, not-found mapping, search-unavailable surface, and connect-refused 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Code Review — PR #1141: Implement nodespace CLI binaryReview Type: Initial pragmatic code review (no prior reviews on PR) Requirements Check — Issue #1116 Acceptance Criteria
All 12 acceptance criteria met. Bonus capabilities delivered beyond the AC list:
Code Review FindingsArchitectural Design & Integrity🟡 The CLI imports generated proto types and the gRPC client via This is a real coupling issue but proportionate to a pre-release codebase. The cleaner shape per ISP/SRP is a small Suggested follow-up issue: extract 🟢 Otherwise the architecture is clean: Functionality & Correctness🟡 pub async fn connect(endpoint: &str) -> Result<NodeServiceClient<Channel>> {
NodeServiceClient::connect(endpoint.to_string())
.await
.with_context(|| format!("Could not connect to nodespaced at {endpoint}...."))
}
Why it's acceptable today: The underlying Future improvement: Inspect the error before deciding on the message: .map_err(|e| {
let is_refused = e.source()
.and_then(|s| s.source())
.map(|s| s.to_string().contains("Connection refused"))
.unwrap_or(false);
if is_refused {
anyhow::anyhow!("Could not connect to nodespaced at {endpoint}.\n\
Is the daemon running? Start it with `nodespaced`.")
} else {
anyhow::Error::from(e).context(format!("Failed to dial {endpoint}"))
}
})Not a blocker — the current behavior is pragmatic. Worth filing a follow-up issue when other transport failure modes start appearing (e.g. once TLS is added). 🟡 version: None, // auto-fetch current version on the serverAuto-fetch matches the daemon's ops-layer behavior and is correct for an interactive CLI. But there is no CLI surface to pass an explicit version, which means:
Recommendation: Add 🟢 let properties = serde_json::from_str::<serde_json::Value>(&node.properties)
.unwrap_or_else(|_| serde_json::Value::String(node.properties.clone()));The comment says "falling back to the raw string when malformed so we never silently swallow daemon-side issues" — but In practice this fallback should be unreachable because the daemon emits Suggested options:
Not blocking — the branch is defensive code for an invariant the daemon already preserves. Security🟢 No findings. The CLI is local-only loopback by default. 🟢 The endpoint env var ( Testing🟢 Solid coverage for 268 lines of test code:
🟢 The decision to test against the library surface rather than the compiled binary is correct: failures point at code paths under test rather than fork/exec plumbing. 🟡 Gaps worth filing as follow-ups (not blockers):
Maintainability & Readability🟢 Naming is consistent ( 🟢 No 🟢 No 🟢 Nit: 🟢 Nit: Performance🟢 N/A — short-lived CLI, no hot paths, no allocation concerns. The integration test uses Documentation🟢 Each module has a meaningful header doc-comment. Final Recommendation: APPROVEThis is a clean, well-tested, focused implementation that satisfies every acceptance criterion plus useful extras (endpoint override, env var, integration test harness). The findings above are improvements and follow-ups, not blockers:
Net effect on code health: clearly positive. Merge when CI is green. |
malibio
left a comment
There was a problem hiding this comment.
Pragmatic code review complete — recommendation is APPROVE (cannot self-approve via API). Every acceptance criterion met, tests pass (4/4 integration tests green), clippy clean, fmt clean. Detailed findings posted as a comment on this PR. All findings are improvements/follow-ups, not blockers.
- search.rs: validate --limit as non-negative i32 at clap-parse time so negative values are rejected with a clear "not in 0..=2147483647" message instead of silently overflowing on the wire. - output.rs: rewrite the misleading comment on node_to_json's properties fallback (it previously claimed we don't swallow errors, when in fact we do convert malformed JSON to a raw string). Now states honestly that the branch is unreachable in practice and we degrade rather than panic if the daemon's serialization contract ever breaks. Bumped visibility to pub(crate) so tests can exercise it. - output.rs: add unit tests locking in the JSON output shape (properties inlined as a nested object, not a re-encoded string) and the malformed-properties fallback. Without these, a regression in node_to_json would not be caught by the integration suite. - cli_integration.rs: tighten the children-listing step to assert count, content, and parent linkage after the CLI's create-child call. Previously the call was issued but its effects were not verified. Skipped, with reasoning: - Extracting a nodespace-proto shared crate: reviewer flagged as follow-up; out of scope for this review cycle. - Tightening connect() error message for non-refused transport errors: premature until TLS arrives (reviewer agreed). - Adding --version flag for explicit optimistic concurrency: meaningful feature, file as a follow-up issue. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Review feedback addressed✅ Addressed (4)
⏭️ Skipped, with reasoning (3)
Verification
Re-Review DecisionDecision: NO RE-REVIEW NEEDED Rationale: All changes are scoped corrections — a one-line clap-parser fix, a comment rewrite + visibility bump, two targeted unit tests, and additional asserts in an existing integration test. No new functionality, no architectural changes, no production-path behavior changes. Skipped recommendations are deferred to follow-up issues (with reasoning) rather than silently dropped. PR ready for merge. 🤖 Generated with Claude Code |
Re-Review — PR #1141 (commit
|
* Implement nodespace CLI binary with node and search subcommands (closes #1116) Adds the `nodespace` CLI — a thin gRPC client that connects to nodespaced on localhost:50051 and exposes knowledge graph operations as shell commands. - New packages/cli crate, added to workspace - clap-based subcommands: node get/create/update/delete/children, search - Global --json flag and --endpoint override (env: NODESPACE_ENDPOINT) - Friendly remediation when daemon is unreachable - Human-readable and JSON output formatters - Integration test against in-process daemon covers round trip, not-found mapping, search-unavailable surface, and connect-refused 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * Address review feedback on PR #1141 - search.rs: validate --limit as non-negative i32 at clap-parse time so negative values are rejected with a clear "not in 0..=2147483647" message instead of silently overflowing on the wire. - output.rs: rewrite the misleading comment on node_to_json's properties fallback (it previously claimed we don't swallow errors, when in fact we do convert malformed JSON to a raw string). Now states honestly that the branch is unreachable in practice and we degrade rather than panic if the daemon's serialization contract ever breaks. Bumped visibility to pub(crate) so tests can exercise it. - output.rs: add unit tests locking in the JSON output shape (properties inlined as a nested object, not a re-encoded string) and the malformed-properties fallback. Without these, a regression in node_to_json would not be caught by the integration suite. - cli_integration.rs: tighten the children-listing step to assert count, content, and parent linkage after the CLI's create-child call. Previously the call was issued but its effects were not verified. Skipped, with reasoning: - Extracting a nodespace-proto shared crate: reviewer flagged as follow-up; out of scope for this review cycle. - Tightening connect() error message for non-refused transport errors: premature until TLS arrives (reviewer agreed). - Adding --version flag for explicit optimistic concurrency: meaningful feature, file as a follow-up issue. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Michael Libio <[email protected]> Co-authored-by: Claude <[email protected]>
Summary
Implements the
nodespaceCLI from issue #1116 — a thin gRPC client that connects tonodespacedonlocalhost:50051and exposes the knowledge graph as shell commands (Ollama-style).packages/clicrate added to the workspace, ships thenodespacebinaryclap-derived subcommands:node get|create|update|delete|children,search <query> [--limit]--jsonflag and--endpointoverride (also honored viaNODESPACE_ENDPOINT)src/output.rstests/cli_integration.rs) drives the handlers against an in-process daemon: full create/get/update/children/delete round trip, not-found mapping, search-unavailable surface, and connect-refused friendly errorAcceptance criteria
nodespacebinary builds and is installable alongsidenodespaced(cargo build --bin nodespace)nodespace node get <id>retrieves and prints a nodenodespace node create --type <type> --content <content> [--parent <id>]nodespace node update <id> --content <content>nodespace node delete <id>nodespace node children <id>nodespace search <query> [--limit <n>]--jsonflag on all commands outputs raw JSONnodespacedis not running (connection refused → friendly remediation)nodespace --helpandnodespace <subcommand> --helpprint useful usage textcargo build --bin nodespacesucceedsbun run quality:fixTest plan
cargo test -p nodespace-cli— 4 integration tests passcargo test -p nodespace-daemon— 7 tests still pass (no regression)nodespace --help/nodespace node --help/nodespace search --helpreviewed manuallynodespace --endpoint http://127.0.0.1:1 node get xprints the friendly remediation🤖 Generated with Claude Code