Skip to content

Align CLI + SKILL.md with local-agent capability and guidance (#1529) — Phase 1: CLI capability gap - #1633

Merged
malibio merged 10 commits into
mainfrom
worktree-issue-1529-cli-skill-parity
Jul 12, 2026
Merged

malibio merged 10 commits into
mainfrom
worktree-issue-1529-cli-skill-parity

Conversation

@malibio

@malibio malibio commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

Phase 1 of a multi-phase implementation of #1529. This PR will stay open and accumulate incremental commits across phases (WIP → review → address-review, repeated per phase) rather than opening a new PR per phase.

This phase closes #1529's "Close the CLI capability gap" scope section — every row in the issue's capability parity matrix that was ❌/⚠️ is now ✅, except the explicitly-deferred search_semantic full parity (documented as an intentional CLI subset) and the intentionally-out-of-scope search_skills verb.

What's in this phase

  • New/extended proto RPCs on NodeService: CreateSchema/UpdateSchema, ExecuteQuery, CreateRelationship/GetRelatedNodes
  • Daemon handlers delegating to existing nodespace_core ops/schema functions (no logic duplication — query_ops::execute_query was split into a Vec<Node>-returning core plus a thin typed-JSON wrapper so the gRPC path and the local-agent tool path share one validated implementation)
  • New CLI verbs: nodespace schema create/update, nodespace query, nodespace node update --property, nodespace node set-status, nodespace relationship create/get
  • nodespace search now wires collection/collection_id/filters/threshold through to the already-existing SearchRequest proto fields
  • 10 new CLI integration tests + 2 pre-existing tests fixed for struct-shape changes

Full technical detail is in the WIP commit message (git log).

Not in this phase (tracked in #1529)

  • Section 2: Guidance alignment (SKILL.md rewrite)
  • Section 3: Propagation tooling (seed-node → SKILL.md staleness check)
  • Section 4: PTY chat wiring to SKILL.md

Incidental findings (not fixed here, flagged for follow-up)

  • Explicit schema fields passed to create_schema/update_schema reject custom:-namespaced names (colon character), even though CLAUDE.md documents that convention as required. The custom: prefix is only auto-applied on the natural-language description-parsing path, not for explicit fields arrays. Pre-existing packages/core behavior, not introduced here — worth a follow-up issue since it affects what the Phase 2 (guidance) work can honestly document.
  • Filed ollama_integration test suite has ~17 failing tests due to empty tool-call responses from mistral:7b #1632 for ~17 pre-existing failures in packages/agent/tests/ollama_integration.rs, confirmed reproducing identically on main before this branch — unrelated to this diff (zero files touched under packages/agent/).

Test plan

  • bun run test — 159 files / 4031 tests passed (frontend baseline, unchanged)
  • cargo test -p nodespace-cli --test cli_integration — 24/24 passed
  • cargo test -p nodespace-core --lib query_ops — 10/10 passed
  • cargo test -p nodespace-daemon --lib node_service — 27/27 passed
  • cargo test --workspace --exclude nodespace-app --exclude nodespace-nlp-engine --exclude nodespace-agent — all passed
  • cargo test -p nodespace-agent --lib — 291/291 passed
  • bun run quality:fix — clean
  • Pre-push gate (test:all + cargo build --bin nodespaced + test:e2e) — passed

🤖 Generated with Claude Code

https://claude.ai/code/session_01DMPgbnyNk6bDFnpqtTPbKr

…sk-status verbs)

## Completed in This Session
- [x] Phase 1: CLI capability gap — closes the "capability gap" half of #1529's
  scope section 1 (all 6 checklist items).

New/extended proto RPCs on NodeService (packages/proto/proto/node_service.proto):
  - CreateSchema / UpdateSchema (SchemaParamsRequest/SchemaResultResponse —
    JSON passthrough to handle_create_schema/handle_update_schema, same
    shape the local-agent tool call already uses; avoids duplicating the
    nested SchemaField/SchemaRelationship/FieldRename Rust structs as proto)
  - ExecuteQuery (ExecuteQueryRequest -> NodeListResponse — filters/sorting
    are JSON-encoded AgentFilterItem[]/AgentSortItem[] for the same reason)
  - CreateRelationship / GetRelatedNodes (typed relationships, distinct from
    mentions — CreateRelationshipRequest/Response, GetRelatedNodesRequest/Response)

Daemon handlers (packages/daemon/src/services/node_service.rs): thin wrappers
following the existing route()/ops_error_to_status pattern, delegating to
nodespace_core::schema::{handle_create_schema,handle_update_schema},
ops::query_ops::execute_query_nodes (new: query_ops::execute_query was split
into execute_query_nodes returning Vec<Node> + a thin execute_query wrapper
returning typed JSON, so the gRPC handler can reuse node_to_proto without
duplicating validation), and ops::rel_ops::{create_relationship,get_related_nodes}.
Added markdown_error_to_status for MarkdownError -> Status mapping.

CLI verbs (packages/cli/src/commands/):
  - schema.rs: `nodespace schema create/update --params <json>|--params-file <path>`
  - query.rs (new): `nodespace query --type <t> --filters <json> --sorting <json> --limit N`
    — distinct from the existing `nodespace node query` (exact-match only)
  - node.rs: `nodespace node update` now accepts `--property key=value` (repeatable,
    JSON-value-parsed, deep-merged server-side) alongside `--content` (now optional);
    added `nodespace node set-status <id> <status>` as a dedicated verb (goes through
    UpdateNode with properties={"status":...}, version=None auto-fetch — mirrors
    exec_update_task_status in local_agent/tools.rs exactly, NOT the separate
    UpdateTaskNode RPC, which has different required-version/richer-field semantics
    with no local-agent-tool equivalent)
  - relationship.rs (new): `nodespace relationship create --from --type --to [--edge-data]`
    and `nodespace relationship get <id> --type --direction`
  - search.rs: wired collection/collection_id/filters/threshold through to the
    already-existing SearchRequest proto fields (previously hardcoded to
    empty/None). Documented (in-file) that this is NOT full search_semantic
    parity — SearchSemanticInput's graph_boost/scope/exclude_collections/
    include_edges/include_markdown have no proto/RPC surface on NodeService
    today; that's EmbeddingsService.SearchSemantic, a separate RPC entirely.
    Decision recorded per the issue's "add flags or document the CLI subset"
    option — chose documentation over expanding proto surface in this phase.

Tests: 10 new integration tests in packages/cli/tests/cli_integration.rs
(schema create/update round trip + malformed-params rejection, execute_query
property filter, relationship create/get + invalid-direction rejection, node
update property-merge + empty-args rejection, node set-status + invalid-status
rejection), plus fixed 2 pre-existing tests broken by the UpdateArgs/SearchArgs
struct shape changes (content: String -> Option<String>, new fields).

## Remaining Work (per #1529 scope, NOT started this session)
- [ ] Section 2: Guidance alignment — rewrite SKILL.md's Tool Decision Guide in
  the new CLI verbs (remove execute_query/search_semantic daemon-tool naming
  the CLI can't invoke); port seed-node guidance (schema creation rules,
  title_template, enum conventions, find-then-edit, task status via dedicated
  verb) into SKILL.md against these new verbs.
- [ ] Section 3: Propagation tooling — staleness/parity check or generation
  step so seed-node refinements don't leave SKILL.md stale.
- [ ] Section 4: PTY wiring — wire in-app PTY chat to consume SKILL.md.
- [ ] Not done in this phase: full search_semantic parity (graph_boost, scope,
  exclude_collections, include_edges, include_markdown) — would need either a
  new CLI-reachable RPC on EmbeddingsService or extending SearchRequest.

## Current State
- Files modified: see file list above (proto, daemon, core/ops/query_ops.rs,
  cli commands + 2 new command files, cli integration tests)
- Tests status: All passing.
  - `bun run test`: 159 files / 4031 tests passed (frontend baseline, unchanged)
  - `cargo test -p nodespace-cli --test cli_integration`: 24/24 passed
  - `cargo test -p nodespace-core --lib query_ops`: 10/10 passed
  - `cargo test -p nodespace-daemon --lib node_service`: 27/27 passed
  - `cargo test --workspace --exclude nodespace-app --exclude nodespace-nlp-engine
    --exclude nodespace-agent`: all passed (0 failed)
  - `cargo test -p nodespace-agent --lib`: 291/291 passed
  - `bun run quality:fix`: clean (0 eslint/tsc/clippy/fmt issues)
- Known issues:
  - packages/agent/tests/ollama_integration.rs (requires `--features testing`
    + a live Ollama server) has ~17 pre-existing failures unrelated to this
    diff (zero files changed under packages/agent/). Verified identically
    reproducing on main at 4962856 before this session's changes — model
    (mistral:7b) intermittently returns empty tool-call responses. Not a
    regression; not investigated further as out of scope for this phase.
  - Found and worked around (not fixed — out of scope): explicit schema
    fields passed to create_schema/update_schema do NOT accept `custom:`
    namespace-prefixed names (behaviors::mod.rs validate_schema_field only
    allows alphanumeric+underscore, rejecting `:`), even though CLAUDE.md and
    the issue body both document `custom:propertyName` as the required
    namespace-prefix convention for explicit fields. The `custom:` prefix IS
    applied automatically, but only on the natural-language description-
    parsing path (normalize_and_namespace_fields), not for explicit `fields`
    arrays. This is a pre-existing packages/core discrepancy, not something
    introduced or fixed here — worth a follow-up issue since it directly
    affects the Section 2 guidance-alignment phase (SKILL.md would otherwise
    document a namespace convention explicit-field callers can't actually use).
- Dependencies: none blocking; #1496 (SchemaTableManager DDL removal),
  referenced by #1529 as a coordination point, is already closed.

## Context for Next Session
Proto/daemon/CLI capability gap (#1529 scope section 1) is fully closed — every
row in the issue's "Capability parity matrix" that was ❌/⚠️ is now ✅ except
the explicitly-deferred search_semantic full parity and the intentionally-out-
of-scope search_skills verb. Next session should start Section 2 (guidance
alignment): read packages/skill/SKILL.md and packages/agent/src/skill_pipeline.rs
seed_skill_nodes() side by side, rewrite SKILL.md's Tool Decision Guide against
the verbs added here (`nodespace schema create/update`, `nodespace query`,
`nodespace node update --property`, `nodespace node set-status`, `nodespace
relationship create/get`), and port the seed guidance substance (one-schema-
per-request, title_template rules, enum value/label convention, find-then-edit,
success-semantics/no-re-verify). Flag the custom: namespace-prefix discrepancy
noted above early in that session since it affects what guidance can honestly
be written.

## Acceptance Criteria Status
From #1529 Scope section 1 (Close the CLI capability gap):
- [x] `nodespace schema create` / `nodespace schema update`
- [x] `nodespace query` (execute_query parity)
- [x] `nodespace node update` extended to set properties
- [x] task-status verb (`nodespace node set-status`)
- [x] typed relationships (`nodespace relationship create/get`)
- [x] search_semantic param parity decided (documented CLI subset; full parity deferred)

Section 2 (guidance), Section 3 (propagation tooling), Section 4 (PTY wiring):
not started.

Co-Authored-By: Claude <[email protected]>
@malibio

malibio commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator Author

Code Review Summary

This is a well-scoped, atomic Phase 1 slice of #1529's "Close the CLI capability gap" checklist. It adds five new gRPC RPCs, thin daemon handlers that delegate to existing packages/core ops/schema functions, and matching CLI verbs, backed by 10 new integration tests exercising the full client→daemon→core stack. The diff does not touch SKILL.md, skill_pipeline.rs, or PTY wiring, correctly deferring those to later phases as the PR description states.

The core engineering judgment call — JSON-passthrough (params_json/filters_json/edge_data_json) instead of fully-modeled proto messages — is a reasonable, well-justified choice for this internal, single-repo protocol, and it's executed cleanly: errors from malformed JSON are mapped to Status::invalid_argument with the serde error message, not .unwrap()/.expect()/panics, at every one of the five new RPC handlers. This is a net positive change. A few real gaps remain, mostly around test coverage depth and one genuine validation hole in ExecuteQuery's limit handling, detailed below.

params_json / JSON-passthrough Pattern — Verdict

Verdict: reasonable pragmatic tradeoff, correctly executed. Approve the pattern with two tightenings.

Arguments in favor, confirmed by reading the actual code:

  • Both ends of this protocol (CLI, daemon) live in the same repo, built and versioned together — there are no external API consumers to break, and no cross-language/cross-team contract to enforce via strict typing at the wire boundary. This is exactly the situation where a oneof-heavy or google.protobuf.Struct-based proto model buys safety nobody needs at the cost of duplicating structs (SchemaField, SchemaRelationship, FieldRename, AgentFilterItem, AgentSortItem) that already have a single source of truth in packages/core. Modeling them again in .proto would create exactly the kind of drift-prone duplication the PR is trying to avoid, and directly serves DRY.
  • The daemon-side deserialization is correct Rust: every one of the five new handlers (execute_query, create_relationship, get_related_nodes, create_schema, update_schema in packages/daemon/src/services/node_service.rs) uses serde_json::from_str(...).map_err(|e| Status::invalid_argument(...))? — never .unwrap()/.expect(). handle_create_schema/handle_update_schema in packages/core/src/schema/mod.rs likewise propagate via ? with typed MarkdownError variants mapped to gRPC status codes (markdown_error_to_status). A malformed JSON blob from the CLI reaches the user as a clean INVALID_ARGUMENT status with the underlying serde message, not a 500/panic.
  • CLI construction of the JSON is safe in the common path: nodespace query/relationship create/node update --property build filter/property values via serde_json::json!/typed serde_json::Value construction (e.g. parse_property in node.rs, json!({"status": args.status}) in set_status), not raw string concatenation. The one path where the user supplies raw JSON text directly (schema create --params '<json>', query --filters '<json>') is inherent to the pattern — it's the whole point of a passthrough — and is exactly analogous to how the local-agent tool call already accepts this same shape, so there's no ergonomics regression relative to the existing capability.

Real gaps, not hedges:

  • ExecuteQueryRequest.limit has no upper bound. packages/daemon/src/services/node_service.rs's execute_query handler passes req.limit as usize straight through when nonzero, with no cap. A CLI user (or, more importantly, a buggy/compromised local-agent caller reusing this path in a future phase) can request an unbounded result set. search.rs's existing SearchRequest.limit at least defaults sanely; this one should have a documented server-side ceiling (mirroring whatever execute_query's existing agent-tool caller already assumes) so nodespace query --type task --limit 4000000000 (u32 max) can't be used to force a huge scan/serialization. [Improvement]
  • No proto-level or handler-level size bound on params_json/filters_json/sorting_json/edge_data_json. Because these are opaque strings, gRPC's default message-size limits are the only backstop. Worth confirming (not necessarily fixing here) that tonic's server has a sane max-message-size configured, since a passthrough string field is an easy vector for an oversized payload compared to a structured message where individual fields would naturally cap growth. [Nit — likely already covered by tonic defaults / existing SearchRequest.filters precedent, but flag for confirmation]
  • The pattern's downside — no compile-time contract for CLI/daemon field names — is real but low-risk here specifically because both ends are one repo, one CI, one test suite; a rename in CreateSchemaParams will be caught by the new integration tests failing, not by a silent runtime drift in production. That containment is what makes the tradeoff acceptable; it would not be acceptable if either side were a separately-deployed/versioned artifact.

Net: this is the correct pattern for an internal CLI-to-daemon protocol where both sides ship atomically. It should not be used as precedent for anything crossing a real API boundary (e.g. if NodeSpace ever exposes this RPC set externally), and that boundary condition is worth writing down (e.g. as a comment on the proto file, which is partially done already via the "avoid duplicating the nested Rust struct shapes" comments) so a future contributor doesn't reflexively apply params_json to a public-facing RPC.

Findings

Critical Issues

None. No security vulnerabilities, no panics on untrusted input in production code paths, no architectural regressions.

Suggested Improvements

  • packages/daemon/src/services/node_service.rs — execute_query handler: req.limit (a u32) is cast to usize and passed through with no upper bound when nonzero. Add a server-side max (e.g. clamp to a few thousand) so a large --limit value can't force an unbounded query/serialization. This is the one place in the diff where "the daemon validates" (the schema.rs doc comment's stated justification for JSON-passthrough) doesn't actually hold for a plain scalar field, not just the JSON blobs.

  • No daemon-layer unit tests for the five new RPCs. packages/daemon/src/services/node_service.rs's own #[cfg(test)] mod tests (27 tests, matching the PR's claimed count) has no additions — coverage for execute_query, create_relationship, get_related_nodes, create_schema, update_schema comes entirely from packages/cli/tests/cli_integration.rs, which drives them through a real spawned daemon + gRPC client. That's legitimate integration coverage and arguably higher-value than isolated unit tests, but it means there's no fast, daemon-only regression signal if a future change to node_service.rs breaks one of these handlers' error-mapping logic specifically (e.g. markdown_error_to_status's four-way match) — you'd only find out via the slower CLI integration suite. Not a blocker given the integration tests are real and pass, but worth a follow-up if node_service.rs's unit suite is meant to be the fast-feedback layer.

  • schema_create_rejects_malformed_params test asserts a weak/ambiguous condition. In cli_integration.rs, the assertion is err.contains("params_json") || err.contains("rpc failed") — the second branch means the test would still pass even if the specific "invalid params_json" message were accidentally dropped or genericized, as long as the RPC merely failed for any reason. Tighten to assert the message actually contains the serde error content (or at minimum drop the OR-fallback) so this test would actually catch a regression in the error-message quality that the params_json design depends on for good CLI ergonomics.

  • relationship create has no test for a nonexistent target/source node or an undefined relationship name — only the "invalid direction" error path is tested for relationship get, and relationship create's happy path assumes both nodes and the relationship already exist via schema. Given create_relationship in rel_ops.rs maps the underlying error to a generic OpsError::Internal(format!("Failed to create relationship: {}", e)), it's worth confirming (via a test) that "relationship name not defined on source schema" and "target node doesn't exist" produce distinguishable, non-500-flavored errors rather than both collapsing into an opaque internal error — this matters directly for the find-then-edit / clarifying-question guidance the epic's Section 2 is going to need to write against this verb's actual failure modes.

Nitpicks

  • Nit: packages/cli/src/commands/node.rs::parse_property silently falls back to treating a value as a plain string when serde_json::from_str fails (unwrap_or_else). That's the right UX default (so --property name=Alice doesn't require --property name='"Alice"'), but it means a typo'd JSON value like --property tags=[1,2 (missing bracket) silently becomes the literal string "[1,2" instead of erroring. Worth a doc-comment caveat or a --property-json escape hatch later if this bites someone; not worth blocking on for Phase 1.

  • Nit: set_status's VALID_STATUSES list (open, in_progress, done, cancelled) is hardcoded identically in three places now across the codebase (CLI, tools.rs description string, tools.rs enum/validation) rather than being a single shared constant. Pre-existing duplication pattern (not introduced by this PR — the CLI mirrors what tools.rs already had), but three-way duplication is worth consolidating into one const/enum in packages/core if a status value is ever added, since the CLI list would otherwise silently drift out of sync with the tool the guidance work in Section 2 needs to describe consistently.

  • Nit: print_schema_result in schema.rs takes _json: bool and ignores it, always pretty-printing — reasonable given the stated "structured data either way" rationale in the comment, but the unused parameter is a small smell; consider dropping it from the signature (breaking the call site's json pass-through) rather than keeping a permanently-ignored flag, since a future reader may reasonably expect --json to change output shape here as it does for every other command.

  • Nit: GetRelatedNodesRequest.direction and RelationshipAction::GetArgs.direction are bare String rather than a proto enum/CLI ValueEnum restricted to in/out. Validation exists (direction != "in" && direction != "out" in the daemon handler, tested), but a typed enum would make the invalid state unrepresentable at the type level instead of relying on a runtime check plus a test asserting Code::InvalidArgument. Minor, given clap's ValueEnum would be a bigger surface change for one field.

Scope / Atomicity Check

Confirmed: every changed file (packages/proto/proto/node_service.proto, packages/daemon/src/services/node_service.rs, packages/core/src/ops/query_ops.rs, packages/cli/src/commands/{mod,node,query,relationship,schema,search}.rs, packages/cli/src/lib.rs, packages/cli/tests/cli_integration.rs) is directly in service of the stated "close the CLI capability gap" scope. No unrelated refactors, no SKILL.md/skill_pipeline.rs/PTY changes bundled in. The query_ops::execute_query → execute_query_nodes + thin execute_query wrapper split is a justified, minimal refactor to let the new gRPC path reuse the same validated core logic as the existing agent-tool path, rather than duplicating filter/sort validation — good adherence to DRY and exactly the kind of shared-core-logic pattern the epic wants (per its "one canonical implementation, two vocabularies" framing). The incidental findings section of the PR description (the custom: namespace rejection on explicit schema fields, and the pre-existing ollama_integration.rs failures) is correctly flagged as out-of-scope-but-noted rather than silently absorbed or silently ignored.

Recommendation: APPROVE

The architecture is sound, the params_json pattern is a defensible and correctly-implemented tradeoff for this internal boundary, security-sensitive paths (identifier validation via the existing whitelist-based validate_identifier, no raw string-built queries, no secrets) are unaffected or reused safely, and the change is atomic and well-tested at the integration level. The execute_query limit bound is the one item I'd want addressed before or shortly after merge (low effort, real if narrow risk); the rest are non-blocking improvements and nits suitable for fast-follow or the next phase.

…on, sharper tests

Addresses /pragmatic-code-review findings on PR #1633 (posted as a GitHub
review comment). Recommendation was APPROVE with these items as suggested
improvements/nitpicks, not blockers.

## Addressed

- packages/daemon/.../node_service.rs: ExecuteQuery's client-supplied `limit`
  is now capped at 500 server-side (was passed through unbounded as `usize`).
- packages/cli/.../relationship.rs: `nodespace relationship get --direction`
  is now a clap ValueEnum (Direction::Out/In) instead of a bare String —
  invalid values are rejected by clap at parse time with a proper --help
  listing, rather than round-tripping to the daemon first.
- packages/cli/.../schema.rs: dropped print_schema_result's unused `json`
  parameter (create/update results are structured data in both output modes,
  so there was nothing to branch on).
- Tests (cli_integration.rs):
  - schema_create_rejects_malformed_params: replaced the permissive
    contains("params_json") || contains("rpc failed") OR-assertion with a
    precise tonic::Status::InvalidArgument check + message content check.
  - relationship_get_rejects_invalid_direction -> renamed
    get_related_nodes_rpc_rejects_invalid_direction and now drives
    GetRelatedNodesRequest directly against the raw gRPC client, since an
    invalid direction can no longer reach the CLI's GetArgs at all (clap
    rejects it before the command handler runs). The daemon-side validation
    is still real for any other gRPC client, so kept as a direct-RPC test.
  - New: relationship_create_rejects_relationship_undefined_on_source_schema
    — verifies create_relationship on a plain "text" node (no schema-defined
    relationships) with a non-built-in relationship name surfaces a status
    naming the undefined relationship, per the review's note that this
    matters for Phase 2's find-then-edit guidance.

## Skipped (with reasoning)

- parse_property's silent JSON-parse-failure fallback to plain string: this
  is intentional, not a bug — `--property name=Alice` must work without
  requiring `--property name=\"Alice\"`. Tightening it would break the common
  case to guard against a typo case that's already recoverable (re-run with
  quotes).
- VALID_STATUSES duplicated across node.rs and local_agent/tools.rs (which
  itself already duplicates it twice): real but pre-existing duplication
  predating this PR; consolidating is a cross-package refactor (agent <-> cli
  <-> core) out of scope for a review-address pass on a capability-gap PR.
- No daemon-layer unit tests for the 5 new RPCs: the existing pattern in this
  codebase (see schema_list_and_get, mention_create_query_delete, etc.) is
  CLI-integration-test coverage against the real gRPC handlers, not
  daemon-only unit tests with a mocked service. Matching the established
  pattern rather than introducing a new coverage shape.

## Test plan
- cargo test -p nodespace-cli --test cli_integration: 25/25 passed
- cargo test --workspace --exclude nodespace-app --exclude nodespace-nlp-engine
  --exclude nodespace-agent: all passed
- bun run test: 159 files / 4031 tests passed (unchanged baseline)
- bun run quality:fix: clean

Co-Authored-By: Claude <[email protected]>
@malibio

malibio commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator Author

Addressed review feedback

Pushed 39b58823 addressing the /pragmatic-code-review findings (recommendation was APPROVE; these were suggested improvements/nitpicks, not blockers):

Addressed:

  • execute_query's client-supplied limit is now capped at 500 server-side (was unbounded).
  • relationship get --direction is now a clap::ValueEnum instead of a bare String — invalid values rejected at parse time.
  • Dropped print_schema_result's unused json parameter.
  • Tightened schema_create_rejects_malformed_params to assert a precise Status::InvalidArgument + message content instead of a permissive OR-assertion.
  • Renamed/reworked the invalid-direction test to drive the raw gRPC client directly (since clap now rejects invalid directions before the CLI handler runs, but the daemon-side validation is still real for non-CLI clients).
  • Added relationship_create_rejects_relationship_undefined_on_source_schema — verifies the find-then-edit-relevant error surfaces correctly when a relationship isn't schema-defined.

Skipped (with reasoning):

  • parse_property's silent JSON-fallback-to-string: intentional, not a bug (--property name=Alice must work without quoting).
  • VALID_STATUSES triple-duplication: real but pre-existing (already duplicated twice in local_agent/tools.rs before this PR); consolidating is a cross-package refactor out of scope here.
  • Daemon-layer unit tests for the 5 new RPCs: matches this codebase's established pattern of CLI-integration-test coverage against the real gRPC handlers rather than mocked daemon-only tests.

All test suites re-verified green after these changes (25/25 CLI integration tests, full workspace cargo test, frontend baseline unchanged, quality:fix clean).

Re-Review Decision

Decision: NO RE-REVIEW NEEDED

Rationale: All changes are low-risk, narrowly scoped to the review's own suggested-improvement/nitpick items (not critical findings), and verified by the full test suite. No new functionality or architectural changes were introduced — this was a straightforward hardening pass (bounds-checking, type-safety, test precision) on already-approved code.

malibio and others added 5 commits July 11, 2026 15:12
…LI verbs)

## Completed in This Session

Rewrote packages/skill/SKILL.md so its instructional content matches the
seed skill nodes (packages/agent/src/skill_pipeline.rs::seed_skill_nodes()),
same substance ported to CLI verbs instead of daemon tool-call names.

- Tool Decision Guide: removed execute_query/search_semantic daemon-tool
  naming the CLI can't invoke as-is. Split into "Finding things" (search vs.
  node query vs. query) mapped to `nodespace search`, `nodespace node query`,
  `nodespace query --filters`, with the same worked examples the seed nodes
  use (open tasks, due tomorrow, due this week, high priority).
- Schema inspection and management: expanded from list/get-only to cover
  `schema create`/`update --params`, porting the seed guidance verbatim in
  substance — one-schema-per-request, targetType must pre-exist, field
  naming rules (no name/title field except the {name}-placeholder
  exception), enum value/label convention, relationships vs. fields,
  title_template placeholder rule.
- Typed relationships: new section for `relationship create`/`get` —
  relationship name must be schema-defined (not arbitrary), find-before-link,
  don't re-verify with `get` after a successful `create`.
- node update / set-status: documented `--property` deep-merge semantics,
  find-then-update + one-clarifying-question-on-ambiguity guidance, and that
  set-status (not update --property) is the dedicated task-status verb.
- node delete: find-then-delete, confirm title match, no post-delete
  re-search.
- Common Agent Tasks: added worked end-to-end examples — define a schema
  then create an instance, link two nodes via relationship, organize into a
  collection via relationship --type member_of, bulk import via
  `nodespace import file/dir`.

## custom: namespace decision (flagged in Phase 1 handoff)

Confirmed via packages/core/src/behaviors/mod.rs::validate_schema_field:
explicit fields arrays reject any field name containing `:` (alphanumeric +
underscore only) — the `custom:` prefix is only auto-applied on the
natural-language description-parsing path, never for explicit `fields`.
Documented this directly in the new "Schema fields" subsection: explicit
`schema create`/`update --params` field names must be unprefixed; the
CLAUDE.md `custom:` convention applies to natural-language schema authoring
in the local agent, not to this CLI path. Did not attempt a product fix here
(pre-existing packages/core behavior, out of scope for a guidance-only
phase) — still worth a follow-up issue since it's a real discrepancy between
documented convention and explicit-fields behavior.

## Verification

- Cross-checked every documented flag against actual `--help` output
  (`nodespace query --help`, `relationship get --help`, `node set-status
  --help`) — all match exactly, including the 500-cap note on `query
  --limit` and the `out`/`in` ValueEnum on `relationship get --direction`
  from the address-review commit.
- Confirmed `nodespace import file/dir --auto-collection-routing` flags
  exist as documented (packages/cli/src/commands/import.rs).
- bun run quality:fix: clean, 0 findings, no unrelated files touched.
- bun run test: 159 files / 4031 tests passed (unchanged baseline).
- cargo build -p nodespace-cli: clean.

## Remaining Work (per #1529 scope, NOT started this session)

- [ ] Section 3: Propagation tooling — staleness/parity check or generation
  step so seed-node refinements don't leave SKILL.md stale.
- [ ] Section 4: PTY wiring — wire in-app PTY chat to consume SKILL.md.

## Current State

- Files modified: packages/skill/SKILL.md only (docs-only change, no code).
- Tests status: passing, unchanged baseline (frontend); no Rust changes in
  this commit so no new Rust test runs needed beyond the build check above.
- Known issues: none new. #1632 (pre-existing ollama_integration flakiness)
  and the search_semantic full-parity deferral remain as tracked in Phase 1.
- Dependencies: none blocking.

## Context for Next Session

Next: run /pragmatic-code-review scoped to this Phase 2 diff only (Phase 1
already reviewed/approved separately — don't re-review it), then
/address-review, iterate until clean. Do NOT open a new PR — same PR #1633,
same branch. Do NOT merge — merge is the user's call. After that, Section 3
(propagation tooling) and Section 4 (PTY wiring) remain.

## Acceptance Criteria Status

From #1529 Scope section 2 (Align the guidance):
- [x] Tool Decision Guide rewritten in CLI verbs
- [x] Seed-node guidance substance ported: schema creation rules,
  title_template, enum convention, find-then-edit, task status via
  dedicated verb, success semantics (no re-verify)
- [x] custom: namespace discrepancy resolved (documented, not silently
  worked around)

Co-Authored-By: Claude <[email protected]>
The ADR-048 Tauri-seam e2e AI-chat test was hardcoded to ministral-3b-q4km
as "the fastest available real model." That model reproducibly stalls to 0
tokens generated within the test's 300s timeout, independent of machine
load (confirmed with a quiet load average of ~1.7-2.0 on a 10-core
machine) — a different failure class from the load-sensitive flakiness
already addressed for this suite.

Isolated by temporarily swapping the test to ministral-8b-q4km (already on
disk) and re-running directly: passed cleanly in 31-44s across two runs.
ministral-8b-q4km is also the model ADR-046 already locks as the sole
native llama.cpp model (the only one passing NodeSpace's full agent
tool-call matrix), so this swap aligns the test with that decision rather
than diverging from it.

Filed a follow-up issue for the underlying 3B stall (GGUF corruption vs.
catalog/chat-template discrepancy vs. inference-path bug) — out of scope
here; this commit only unblocks the gate for unrelated work.

Verified: cargo test -p nodespace-app --test ai_chat_send_to_idle_test
passes; bun run quality:fix clean.

Co-Authored-By: Claude <[email protected]>
…nship note

/pragmatic-code-review on the Phase 2 diff (scoped to d192d95/fbeda515,
Phase 1 already reviewed/approved separately) found one leftover instance
of old daemon-tool vocabulary (create_schema/update_schema) in the new
"Relationships are distinct from hierarchy and mentions" paragraph — the
one line in the rewritten file that didn't get converted to the CLI verbs
(nodespace schema create/update) used consistently everywhere else.

Two nitpicks from the same review were assessed and left as-is:
- The execute_query mention in the query section is an intentional,
  contextual reference explaining CLI/daemon lineage, not a missed
  conversion.
- The "namespace prefixing... is a schema-authoring concern" phrasing is
  already resolved by a forward pointer to the Schema fields subsection.

Co-Authored-By: Claude <[email protected]>
## Completed in This Session

Phase 2 (guidance alignment) is fully done, reviewed, and address-reviewed —
this is the up-to-date handoff superseding d192d95's mid-phase snapshot.

- [x] d192d95 — rewrote packages/skill/SKILL.md against the CLI verbs added
  in Phase 1. Tool Decision Guide split into a "Finding things" section
  (nodespace search / node query / query --filters) with the same worked
  examples as the seed skill nodes. Ported seed-node guidance substance
  (packages/agent/src/skill_pipeline.rs::seed_skill_nodes()) into CLI-verb
  form: one-schema-per-request, targetType-must-preexist, field-naming rules
  (no name/title field except the {name}-placeholder exception), enum
  value/label convention, title_template placeholder rule, find-then-edit +
  one-clarifying-question-on-ambiguity, task status via the dedicated verb,
  find-then-delete, success-semantics (confirm and stop, no re-verify fetch).
  Resolved the custom: namespace discrepancy flagged in the Phase 1 handoff:
  confirmed via packages/core/src/behaviors/mod.rs::validate_schema_field
  that explicit `fields` arrays reject any `:` in field names, so documented
  explicit schema create/update field names as unprefixed — the custom:
  convention applies only to natural-language schema authoring in the local
  agent, not to this CLI path.
- [x] fbeda51 — incidental fix, discovered while trying to push d192d95:
  the pre-push gate's ai_chat_send_to_idle_test was hardcoded to
  ministral-3b-q4km, which reproducibly stalls to 0 tokens generated within
  its 300s timeout, independent of machine load (confirmed at load average
  ~1.7-2.0 on a quiet 10-core machine, and by isolating via a temporary
  swap to ministral-8b-q4km, which passed cleanly in 31-44s across two
  runs). Swapped the test to ministral-8b-q4km — which is also the model
  ADR-046 already locks as the sole native llama.cpp model, so this aligns
  the test with that decision rather than diverging from it. Filed #1636 to
  track the underlying 3B stall (root cause not yet identified: corrupted
  GGUF vs. catalog/chat-template discrepancy vs. inference-path bug).
  #1636 is unrelated to #1632 (pre-existing ollama_integration failures,
  different suite, different inference backend — Ollama, not llama.cpp).
- [x] 91cec6e — addressed the one finding from /pragmatic-code-review
  (scoped to just this phase's diff, git diff 39b5882..d192d95+fbeda515;
  Phase 1 was reviewed/approved separately and not re-reviewed): the new
  "Relationships are distinct from hierarchy and mentions" paragraph in
  SKILL.md had one leftover instance of old daemon-tool vocabulary
  (create_schema/update_schema) instead of the CLI verbs (nodespace schema
  create/update) used consistently everywhere else in the rewrite. Two
  other nitpicks from the same review were assessed and left as-is with
  reasoning (an intentional execute_query lineage reference; an already-
  resolved forward-pointer ambiguity) — see the review's full findings if
  needed, not repeated here.

## Current State

- Files modified this phase: packages/skill/SKILL.md (docs-only rewrite),
  packages/desktop-app/src-tauri/tests/ai_chat_send_to_idle_test.rs (model
  swap + comment update).
- Tests status: all passing. Confirmed via the full pre-push gate on the
  final push (fbeda51 and 91cec6e both went through cargo test -p
  nodespace-app including ai_chat_send_to_idle_test, plus test:all) —
  no bypass was used at any point this session.
- Known issues: #1636 (ministral-3b-q4km stall, root cause open) and #1632
  (pre-existing ollama_integration failures) remain open and unrelated to
  #1529 — do not touch either unless separately asked.
- Dependencies: none blocking.
- PR: still #1633, still open, still the same branch
  (worktree-issue-1529-cli-skill-parity). No new PR was opened. No merge
  has happened — merge remains the user's call.

## Context for Next Session

Section 2 (guidance alignment) of #1529 is done. Next up per #1529's scope:
- Section 3 — propagation tooling: a staleness/parity check or generation
  step so future edits to seed_skill_nodes() don't leave SKILL.md silently
  out of sync. No design decisions made yet on approach (e.g. a test that
  diffs key rules between the two sources, vs. a script that regenerates
  SKILL.md sections from the seed nodes, vs. something else) — start there.
- Section 4 — PTY wiring: wire in-app PTY chat (Claude Code/Codex/Gemini
  CLI/OpenCode running in-app) to actually consume SKILL.md. Not started,
  not investigated yet this session.
Not in scope for either: full search_semantic parity (deferred in Phase 1),
#1636's root cause, #1632's ollama_integration failures.

## Acceptance Criteria Status

From #1529 Scope section 2 (Align the guidance): all items complete (see
d192d95's own acceptance-criteria section for the itemized list — still
accurate, not repeated here).

Section 3 (propagation tooling) and Section 4 (PTY wiring): not started.

Co-Authored-By: Claude <[email protected]>
## Completed in This Session

Section 3 (propagation tooling) for #1529: prevents seed_skill_nodes()
(packages/agent/src/skill_pipeline.rs) and packages/skill/SKILL.md from
silently drifting apart on the core-type rules both encode in different
vocabulary (daemon tool names vs. CLI verbs).

Design, reached after discussion: SKILL.md is a static, instance-blind
artifact (installable independently, ships in the @nodespaceai/skill npm
package) covering only core built-in types; seed_skill_nodes() guides the
in-app, instance-aware local agent. They're not one document in two forms —
they're different products that happen to share ~16 substantive rules
(schema-authoring conventions, interaction habits like find-then-act and
success-means-stop). Drift on that shared subset is the actual risk;
everything else is intentionally distinct and untouched.

- packages/agent/src/skill_rules.rs (new): SchemaRule and InteractionRule
  structs, one constant per shared rule, each with an `imperative` rendering
  (terse ALL-CAPS-header style used by the LLM prompt) and a `prose`
  rendering (flowing markdown used by SKILL.md). 9 SchemaRules (one-schema-
  per-request, enum format, title_template placeholder rule, etc.) + 7
  InteractionRules (find-then-act, ambiguity-clarify, success-no-reverify,
  task-status-dedicated-verb, single-item-per-call, org-needs-existing-
  collection, bulk-import-no-followup-search).
- skill_pipeline.rs: seed_skill_nodes()'s Schema Creation, Graph Editing,
  Relationship Management, Node Deletion, Bulk Import, and Organization
  skill nodes now interpolate their guidance from skill_rules constants
  instead of hardcoding prose inline. Worked EXAMPLE blocks and skill-
  specific structure are untouched.
- packages/agent/src/bin/gen_skill_md.rs (new): regenerates the schema-rules
  block of SKILL.md (between `<!-- BEGIN/END GENERATED: schema-rules -->`
  markers) from SchemaRule::prose. `--write` regenerates and overwrites;
  `--check` exits nonzero if the checked-in file is stale — this is real
  generation, not just a parity test, since SKILL.md is meant to reflect
  "latest core capabilities" at build/release time going forward. Verified
  end-to-end: simulated drift by hand-editing SKILL.md, confirmed --check
  catches it (exit 1) and --write repairs it.
- SKILL.md: inserted the generation markers around the existing Schema
  inspection and management rules paragraphs; split the "One schema per
  request" / "schema already exists" rules into two paragraphs to match
  skill_rules.rs's granularity; moved the description-field/custom:-
  namespace notes (no seed-node analog) outside the generated block.
- The 7 InteractionRules are woven mid-sentence into hand-written SKILL.md
  prose across 5 sections — full generation would fragment that prose, so
  these get a lighter skill_md_still_mentions_every_interaction_rule test
  instead: each rule carries a skill_md_key_phrase, and the test asserts
  it's still present in SKILL.md. Catches outright removal, not rewording.
- package.json: rust:test now also runs `cargo test --lib --bins -p
  nodespace-agent` — previously this package's tests (including preexisting
  skill_pipeline.rs tests, not just the new ones) weren't run by test:all or
  the pre-push gate at all. --lib --bins excludes tests/ontegration binaries
  (ollama_integration.rs, gated behind `testing` feature; search_skills_
  latency.rs, self-skips without an inference backend) so this stays fast
  (~6s added).

## Current State

- Files modified: package.json, packages/agent/src/lib.rs,
  packages/agent/src/skill_pipeline.rs, packages/skill/SKILL.md.
- Files added: packages/agent/src/skill_rules.rs,
  packages/agent/src/bin/gen_skill_md.rs.
- Tests status: all passing. `bun run rust:test` (295 nodespace-agent lib
  tests + 3 gen_skill_md bin tests, plus nodespace-core as before) green.
  `cargo check --workspace` and `cargo clippy -p nodespace-agent --lib
  --bins` clean. Formatted with `cargo fmt -p nodespace-agent` (package-
  scoped, not workspace-wide quality:fix, to avoid reformatting unrelated
  files).
- Known issues: none new. #1636 (ministral-3b stall) and #1632 (ollama
  integration failures) remain open, unrelated, untouched.
- Not yet run this session: /pragmatic-code-review (next step), full
  test:all (frontend unaffected by this change but not yet re-verified),
  pre-push gate.

## Context for Next Session

Next: run /pragmatic-code-review scoped to this commit's diff only (Phases
1/2 already reviewed/approved, don't re-review). Then /address-review,
iterate until clean. Then report back and STOP — do not merge, do not open
a new PR (multi-phase epic landing in one PR, #1633).

After Section 3 is reviewed/addressed, Section 4 (PTY wiring — in-app PTY
chat consuming SKILL.md) is the last remaining scope item for #1529. Not
started, not investigated this session.

## Acceptance Criteria Status

From #1529 Scope section 3 (propagation tooling): implemented — a real
generator (not just a test) for the 9 schema rules, plus presence-checking
for the 7 interaction rules that can't be cleanly generated without
fragmenting hand-written SKILL.md prose. Pending: code review.

Section 4 (PTY wiring): not started.

Co-Authored-By: Claude <[email protected]>
@malibio

malibio commented Jul 12, 2026

Copy link
Copy Markdown
Collaborator Author

Review: commit 2476e8a3 only (Section 3 — propagation tooling)

Scope: everything between 96b28004 and HEAD (skill_rules.rs, gen_skill_md.rs, skill_pipeline.rs, SKILL.md, lib.rs, package.json). Phases 1/2 are out of scope and not re-reviewed.

Summary

The design (shared SchemaRule/InteractionRule constants, real generation for the 9 schema rules, presence-checking for the 7 interaction rules) is sound and well-documented — module docs in skill_rules.rs and gen_skill_md.rs clearly explain the asymmetry and why full generation isn't attempted for interaction rules. package.json's rust:test change correctly starts running previously-untested nodespace-agent code (--lib --bins correctly excludes the [[test]]-declared ollama_integration/search_skills_latency integration binaries in Cargo.toml — verified). cargo clippy -p nodespace-agent --lib --bins is clean, and the checked-in SKILL.md generated block does currently match generator output.

However, there is one concrete, demonstrated bug that undermines the core guarantee this commit is supposed to provide, plus a couple of smaller robustness gaps.

Findings

Critical

packages/agent/src/bin/gen_skill_md.rs, render_schema_rules_block() (line ~38): the "Editing" paragraph is hardcoded, not interpolated from EDIT_DONT_RECREATE.prose — silently defeats drift detection for that rule.

All 8 other SchemaRules are correctly threaded through format!() args (one_schema_per_request = ONE_SCHEMA_PER_REQUEST.prose, etc.), but the "Editing" paragraph is a bare string literal baked directly into the format template:

"{one_schema_per_request}\n\n{schema_already_exists}\n\n\
 **Editing:** to add, remove, or rename a field, or change a relationship on an existing schema, use `schema update` with only the fields that need changing (`add_fields`/`remove_fields`/`rename_fields`, or an updated `description`/`title_template`). Don't re-create the whole schema for a small change.\n\n\
 **Schema fields:** {no_name_title_field} {name_placeholder_exception}\n\n\
 ..."

EDIT_DONT_RECREATE.prose exists in skill_rules.rs and happens to be byte-identical to this literal today, which is why --check currently passes. But it is never read by the generator. I verified this concretely: I edited EDIT_DONT_RECREATE.prose in skill_rules.rs (appended a marker string), left SKILL.md untouched, and ran cargo run -p nodespace-agent --bin gen_skill_md -- --check — it printed "up to date" and exited 0. This is exactly the drift scenario the whole mechanism exists to prevent, occurring inside the generator that's supposed to prevent it. (Reverted the probe edit afterward; working tree is clean.)

Note skill_pipeline.rs's schema_creation_guidance() does correctly interpolate EDIT_DONT_RECREATE.imperative — the bug is isolated to the generator side only.

Fix: replace the hardcoded literal with {edit_dont_recreate} / edit_dont_recreate = EDIT_DONT_RECREATE.prose like its siblings.

Improvements

  1. skill_pipeline.rs, graph_editing_guidance() / node_deletion_guidance(): reusing the generic FIND_THEN_ACT.imperative drops verb-specific detail that used to live in the same sentence. Before this refactor, "Graph Editing" said "...locate it. Then call update_node with the ID and only the fields that need changing." and "Node Deletion" said "...locate it. Confirm the title matches..., then call delete_node." Now both instead splice in the shared imperative "...locate it. Then act on the resolved ID — do not guess IDs," which is generic by design (it's shared across 3 call sites) but reads slightly redundant/deflated at each specific call site — e.g. Node Deletion now reads "...to locate it. Then act on the resolved ID — do not guess IDs. Confirm the title matches what the user described, then call delete_node..." (two consecutive "act on it" beats). Not a correctness bug — the specific instruction is still present later in each block (e.g., "update_node FIELDS:" section) — but it's worth a read-through pass to confirm nothing reads as awkward filler now that it's machine-assembled. Low severity, but since this is precisely the kind of interpolation-boundary smoothness the review was asked to check, flagging it.

  2. splice_generated_block uses .find() (first occurrence) for both markers with no check for a second, duplicate marker pair. Given this is a small, single-purpose CI tool with loud panics on missing markers, and today's SKILL.md has exactly one marker pair (verified), this is low risk in practice. Still, a one-line debug_assert!/check that the marker appears exactly once (or a comment noting the assumption) would make the "graceful failure over silent misbehavior" intent explicit rather than implicit.

  3. skill_md_key_phrase presence-checking is a legitimately weak (but not worthless) guard. It catches wholesale removal of a rule's substance from SKILL.md, which is a real and plausible failure mode (someone rewrites a section and drops a clause). It does not catch semantic drift/rewording that keeps the exact phrase but changes the guidance around it, and — as a substring match — it could theoretically false-pass if the key phrase happens to appear in an unrelated sentence. Given the constraint (avoiding fragmenting hand-tuned prose), this is a reasonable proportional tradeoff, not a design flaw, but the module doc's honesty about the limitation ("catches outright removal, not rewording") is doing real work here and should stay.

Nitpicks

  • Nit: skill_rules.rs's no_rule_text_is_empty and the id-uniqueness tests are tautological in the sense that they test the constants against themselves rather than against either consumer, but they're still worthwhile cheap guards against copy-paste mistakes (e.g., duplicate id, an empty field from a bad merge) — no change needed, just noting they're a sanity net, not drift protection.
  • Nit: render_schema_rules_block()'s inline comment ("NO_NAME_TITLE_FIELD and NAME_PLACEHOLDER_EXCEPTION share the Schema fields: paragraph") is helpful; consider adding a similar one-line note for why the Editing paragraph doesn't have a named interpolation binding, if the fix above isn't applied for some reason — but the fix is preferable to documenting the gap.

Recommendation

One Critical fix needed (the hardcoded Editing paragraph in gen_skill_md.rs) before this is fully doing its job — it's a small, mechanical fix (swap the literal for {edit_dont_recreate} + add the format arg) and everything else in the commit is solid. Everything else here is Improvement/Nit level, not blocking.

…tail, guard duplicate markers

Addresses /pragmatic-code-review findings on commit 2476e8a (PR #1633,
comment #1633 (comment)),
scoped to #1529 Section 3 only.

- CRITICAL: render_schema_rules_block() hardcoded the "Editing" paragraph
  instead of interpolating EDIT_DONT_RECREATE.prose, so `gen_skill_md --check`
  could not detect drift in that rule — reviewer proved this by editing the
  rule's prose and showing --check still reported "up to date". Fixed by
  importing and interpolating EDIT_DONT_RECREATE. Reproduced the reviewer's
  probe post-fix: same edit now makes --check exit 1 as expected; restored
  and reconfirmed --check passes on the unmodified rule.
- Improvement: graph_editing_guidance()'s "FIND THEN UPDATE" line lost the
  verb-specific tail ("Then call update_node with the ID...") when the
  sentence was replaced by the generic FIND_THEN_ACT interpolation. Restored
  the tail after the interpolated rule text.
- Improvement: splice_generated_block() had no guard against duplicate
  marker occurrences. Added two assertions so a future duplicate marker
  (accidental copy-paste, merge artifact) fails loudly instead of splicing
  into the wrong occurrence.

Skipped (as suggestions, not requiring code changes): the tautological
skill_rules.rs self-tests and the "Schema fields" grouping comment nit —
both are low-value/moot once the Critical fix landed.

Verified: bun run rust:test (979 nodespace-core + 295 nodespace-agent lib +
3 gen_skill_md bin tests, all passing), cargo clippy -p nodespace-agent
--lib --bins clean, cargo fmt -p nodespace-agent applied, cargo check
--workspace clean.

Co-Authored-By: Claude <[email protected]>
@malibio

malibio commented Jul 12, 2026

Copy link
Copy Markdown
Collaborator Author

Address-review: Section 3 (commit 2476e8a), reviewed in this comment

Fixed in 52ae5f6e:

  • 🔴 Critical — gen_skill_md.rs's render_schema_rules_block() hardcoded the "Editing" paragraph instead of interpolating EDIT_DONT_RECREATE.prose, so --check couldn't detect drift in that rule. Fixed by importing and interpolating it. Reproduced the reviewer's own probe post-fix (edit the rule's prose → --check now exits 1 as expected; restored → passes again).
  • 🟡 Improvement — graph_editing_guidance()'s "FIND THEN UPDATE" line lost verb-specific detail ("Then call update_node with the ID...") when swapped for the generic FIND_THEN_ACT interpolation. Restored the tail after the interpolated rule.
  • 🟡 Improvement — splice_generated_block() had no guard against duplicate marker occurrences. Added two assertions so a duplicate marker fails loudly instead of splicing into the wrong occurrence.

Skipped (nits, no code change needed): the tautological skill_rules.rs self-tests (still useful copy-paste guards, not worth removing) and the "Schema fields" grouping comment note (moot once the Critical fix landed — EDIT_DONT_RECREATE is now a named, interpolated binding like its siblings).

Verified: bun run rust:test (979 nodespace-core + 295 nodespace-agent lib + 3 gen_skill_md bin tests, all green), cargo clippy -p nodespace-agent --lib --bins clean, cargo fmt -p nodespace-agent applied, cargo check --workspace clean, pre-push gate passed in full.

Re-Review Decision

Decision: NO RE-REVIEW NEEDED

Rationale: All three fixes are small, mechanical, and directly verified against the reviewer's own repro steps (the Critical fix was confirmed using the exact drift scenario the reviewer used to find it). No new design surface, no architectural changes, no new files. Low risk.

malibio and others added 2 commits July 12, 2026 02:26
## Completed in This Session

Section 3 (propagation tooling) is fully done, reviewed, and address-reviewed.

- 2476e8a — built the drift-prevention mechanism between seed_skill_nodes()
  (packages/agent/src/skill_pipeline.rs) and packages/skill/SKILL.md for the
  ~16 rules they share in substance (schema-authoring conventions +
  interaction habits), despite being different products for different
  audiences (in-app instance-aware local agent vs. static instance-blind
  CLI reference shipped in @nodespaceai/skill). New
  packages/agent/src/skill_rules.rs holds SchemaRule (9) and InteractionRule
  (7) constants, each rendered two ways (imperative LLM-prompt style, prose
  SKILL.md style). New packages/agent/src/bin/gen_skill_md.rs regenerates
  SKILL.md's schema-rules block (--write) and fails CI if it's stale
  (--check) — real generation, not just a parity test, since SKILL.md is
  meant to reflect current core capabilities at build time. The 7
  interaction rules get a lighter presence-check test instead (full
  generation would fragment hand-written CLI prose they're woven into).
  package.json's rust:test now also runs nodespace-agent's test suite —
  previously neither the new nor the preexisting skill_pipeline.rs tests
  were part of test:all/pre-push at all.
- 52ae5f6 — addressed /pragmatic-code-review (scoped to 2476e8a only,
  posted at github.com//pull/1633#issuecomment-4949281475).
  One real bug found and fixed: gen_skill_md.rs's "Editing" paragraph was
  hardcoded instead of interpolating EDIT_DONT_RECREATE.prose, so --check
  couldn't catch drift in that one rule — verified fixed using the
  reviewer's own repro. Two smaller improvements also fixed (restored
  verb-specific detail lost in one interpolation; added duplicate-marker
  guards to the generator's splice logic). No re-review needed — posted at
  github.com//pull/1633#issuecomment-4949295748.

## Current State

- Branch worktree-issue-1529-cli-skill-parity, PR #1633, up to date with
  origin, working tree clean, nothing uncommitted.
- Tests status: bun run rust:test green (979 nodespace-core + 295
  nodespace-agent lib + 3 gen_skill_md bin tests). cargo clippy -p
  nodespace-agent --lib --bins clean. cargo check --workspace clean. Both
  Section 3 commits went through the full pre-push gate successfully.
- Known issues: #1636 (ministral-3b-q4km stall) and #1632 (ollama_integration
  failures, being addressed separately per PR #1635 on main) remain open,
  unrelated to #1529, untouched this session.
- Dependencies: none blocking Section 4.

## Context for Next Session

Section 4 — PTY wiring — is the only remaining scope item for #1529. Not
started, not investigated at all yet: no design decisions made on how the
in-app PTY chat (Claude Code/Codex/Gemini CLI/OpenCode running inside
NodeSpace) actually consumes SKILL.md, whether that's the packages/skill
install flow (packages/skill/src/installer.ts copies shims but not SKILL.md
itself today — confirmed during Section 3 scoping) or a different
mechanism, and what "wiring" concretely means here. Start by reading the
open issue's Section 4 scope text plus packages/skill/src/installer.ts and
the shims/ directory, then evaluate approaches before implementing — same
pattern as Section 3's start.

## Acceptance Criteria Status

From #1529 Scope section 3 (propagation tooling): complete — see 2476e8a
and 52ae5f6 for the itemized implementation and review-fix list, not
repeated here.

Section 4 (PTY wiring): not started.

Co-Authored-By: Claude <[email protected]>
Investigation found the PTY-spawned in-app chat (Claude Code/Codex/
Gemini/OpenCode running inside NodeSpace) was never actually wired to
consume SKILL.md, despite ADR-032 building GraphContextAssembler with
a with_shim_dir() hook for exactly this purpose. That hook was never
called from production code (packages/daemon/src/services/assembly.rs
constructs GraphContextAssembler::new() with no shim dir configured),
so PTY sessions got: a generated CLAUDE.md/AGENTS.md whose "Guidance"
section referenced daemon tool names unreachable from a PTY agent
(execute_query, create_schema, search_skills, ...), and a dead
5-tool shim mechanism (SHIM_TOOLS: search_semantic/get_node/
create_node/update_node/get_children) that was never invoked to
copy anything. Zero real NodeSpace tool access.

Fix: GraphContextAssembler::write_context_file now unconditionally
copies SKILL.md (embedded at compile time via include_str!, so the
PTY session always gets exactly the doc that shipped with this
daemon build, dev or packaged) into the session directory alongside
the generated context file. SKILL.md — CLI-vocabulary, parity-complete
after Sections 1-3 — is now the sole tool/capability guidance surface
for PTY sessions; the knowledge-graph context file carries only graph
content (seed nodes, semantic neighbors, relationships).

Removed as dead code superseded by this: ShimTool/SHIM_TOOLS/
tools_section/tools_list, shim_files_for/shim_subdir_for,
write_shim_files, with_shim_dir/shim_source_dir, and the
SCHEMA_CREATION_RULES/TOOL_STRATEGY_RULES/NODE_REFERENCE_FORMAT
injection into the PTY context file (those constants remain in
agent_guidance.rs, still used by prompt_assembler.rs for the local
in-app agent — only their PTY-path consumer was removed).

Unrelated to and untouched by this change: packages/skill's npm
installer (external-harness path — already installs SKILL.md into
~/.claude/skills/nodespace etc., confirmed during scoping) and
packages/skill/shims/*.ts (still used by that installer).

Co-Authored-By: Claude <[email protected]>
@malibio

malibio commented Jul 12, 2026

Copy link
Copy Markdown
Collaborator Author

Code Review Summary

Reviewed diff range abdd1700..ae2fe297 (commit ae2fe297, "Wire PTY chat to SKILL.md — closes #1529 Section 4") in isolation, per scope. This is a clean, well-motivated fix: it replaces a confirmed-dead shim mechanism and unreachable-tool-vocabulary guidance with an unconditional include_str!-embedded copy of packages/skill/SKILL.md into every PTY session directory. Verified independently (not just taking the commit message's word for it):

  • include_str!("../../../skill/SKILL.md") in packages/agent/src/acp/context_assembly.rs resolves correctly to packages/skill/SKILL.md (confirmed via realpath from the file's directory).
  • grep -rn for every deleted symbol (with_shim_dir, shim_source_dir, ShimTool, SHIM_TOOLS, write_shim_files, shim_files_for, shim_subdir_for, tools_section) across packages/ returns zero hits — the deletion is complete, no dangling references, no dead imports left behind.
  • agent_guidance.rs's SCHEMA_CREATION_RULES/TOOL_STRATEGY_RULES/NODE_REFERENCE_FORMAT are still consumed, and now only consumed, by prompt_assembler.rs — confirmed via grep -rln.
  • cargo build -p nodespace-agent and cargo test --lib acp::context_assembly (22 tests) both pass clean.
  • ContextError::WriteFailed(#[from] std::io::Error) makes write_skill_md's bare ? propagation correct and idiomatic — matches the existing pattern in write_context_to_dir in the same file.

This is a net-positive, atomic, well-scoped change. One real (non-blocking) substance gap and one test-depth gap below; everything else is nit-level.

Findings

Critical Issues

None.

Suggested Improvements

  • packages/agent/src/agent_guidance.rs NODE_REFERENCE_FORMAT has no SKILL.md equivalent. NODE_REFERENCE_FORMAT ("Reference nodes with bare nodespace:// URI — no markdown links, no backticks") was dropped from the PTY context file along with the other two guidance constants, and I could not find any equivalent instruction in packages/skill/SKILL.md (grepped for URI, nodespace://, markdown link, reference — no hits addressing output-formatting conventions). Unlike SCHEMA_CREATION_RULES/TOOL_STRATEGY_RULES (which are genuinely daemon-tool-call vocabulary, correctly identified as inapplicable to a PTY agent that only has the nodespace CLI), this rule is about how the agent should format node references in its own chat replies to the user — a concern that applies just as much to a PTY-spawned CLI agent as to the local in-app agent, since presumably NodeSpace's chat UI gives bare nodespace:// links special rendering (clickable/resolvable) regardless of which agent produced them. If that rendering exists, PTY agents will now emit un-rendered markdown links or raw IDs instead. Worth either adding a one-line equivalent to SKILL.md or confirming (and noting in the PR) that the chat UI doesn't special-case nodespace:// links from PTY output, making this moot.

  • Test coverage stops at the file-write layer; no PTY-level assertion that SKILL.md is actually delivered via launch(). The new write_context_file_writes_both_context_file_and_skill_md test is solid and exercises a real GraphContextAssembler over a real SqliteStore/NodeService (not tautological) — but it calls write_context_file directly, not PtySession::launch(). Separately, pty::session::tests::launch_for_test_runs_command_and_emits_output (and the other launch_for_test-based tests) spawn via PtySession::launch_for_test, which calls spawn_in_pty directly and never touches GraphContextAssembler at all (confirmed by reading launch_for_test's body — it only does create_dir_all on the session dir, no assembler call). So there is currently no test — old or new — that exercises the actual launch() path end-to-end and confirms a real PTY session directory ends up with both CLAUDE.md/AGENTS.md and SKILL.md before the child process starts. Given launch_for_test was deliberately split out to avoid needing a full GraphContextAssembler fixture in PTY tests, closing this gap isn't a small addition — it's reasonable to defer, but flagging it since it's the one place a real regression (e.g. a future refactor of launch() that reorders or drops the write_context_file call) could land undetected until manual QA.

Nitpicks

  • Nit: packages/agent/src/acp/context_assembly.rs module doc: "the same way it would in any directory a user cds into with SKILL.md present" (in write_context_file's doc comment) is a slightly indirect way to describe the mechanism — a one-clause note that this relies on each CLI harness's own project-local-SKILL.md discovery convention (which SKILL.md's own delivery docs presumably already establish) would help a future reader who isn't already familiar with that convention.
  • Nit: The commit deletes shim_tools_match_gemini_manifest, a drift-detection test that guarded against packages/skill/shims/gemini/nodespace-tools.json diverging from the Rust-side tool registry. That's correct here (the Rust-side registry it protected is gone), but since packages/skill/shims/* is explicitly called out as still-alive (external-harness installer path), it's worth double-checking in a future PR that something still guards nodespace-tools.json against drifting from whatever it's meant to match now that this Rust-side check is gone — not a blocker for this PR since that's out of scope here.

Verification Checklist (per review-focus questions in the task)

  1. include_str! path correctness — Verified correct; resolves to packages/skill/SKILL.md.
  2. Unconditional SKILL.md copy for every AgentType including Pi — Sound. Pi never had a working shim before (the mechanism was dead for all agent types), so this is strictly additive for every agent type, not a regression for any of them. No agent-type-specific reason found to make it conditional — SKILL.md is agent-agnostic CLI guidance.
  3. Substance gap from removing SCHEMA_CREATION_RULES/TOOL_STRATEGY_RULES/NODE_REFERENCE_FORMAT — SCHEMA_CREATION_RULES and TOOL_STRATEGY_RULES are fully superseded by SKILL.md's CLI-vocabulary equivalents (schema-before-instance ordering, search-before-mutate, confirmation semantics, structured vs. semantic query selection — all present in SKILL.md, verified by reading its "Tool Decision Guide" and CLI reference sections). NODE_REFERENCE_FORMAT has no equivalent — see Suggested Improvements above.
  4. Error handling in write_skill_md — Correct; uses existing #[from] std::io::Error conversion via ?, consistent with sibling functions in the same file.
  5. Test quality — New tests are genuine, not tautological (write_context_file_writes_both_context_file_and_skill_md spins up a real SqliteStore/NodeService). Deleting the shim/tools tests is appropriate — the underlying mechanism is gone, not merely adjusted, so keeping those tests would be testing dead code. See Suggested Improvements for the one coverage gap (no launch()-level PTY test).
  6. Stale doc comments / dead imports — None found. Doc comments in all four touched files were updated consistently and accurately describe the new behavior. PathBuf import in context_assembly.rs is still used (return types), not dead.
  7. Satisfies Align CLI + SKILL.md with local-agent capability and guidance (external-harness parity) #1529 Section 4 acceptance criteria — Yes, substantially: the PTY chat path now delivers SKILL.md into every session directory, replacing dead/unreachable guidance. The one gap (item 2 above, node-reference-format parity) is minor and doesn't block the core wiring goal of "PTY chat path consumes SKILL.md."

Recommendation

APPROVE (with the two Suggested Improvements above worth a follow-up — neither blocks merge; the NODE_REFERENCE_FORMAT gap is worth a quick confirm-or-fix before or shortly after merge since it's a one-line addition if needed, and the launch()-level test gap is reasonable to track separately rather than block this PR).

@malibio

malibio commented Jul 12, 2026

Copy link
Copy Markdown
Collaborator Author

Addressed review (commit ae2fe29, Section 4): both suggestions investigated, no code changes needed.

1. NODE_REFERENCE_FORMAT dropped without a SKILL.md equivalent — verified this is correctly dropped, not a gap. Checked the PTY terminal pipeline (pty-terminal.svelte): raw output bytes go straight into xterm.js's default renderer via terminal.write(bytes), with no link addon loaded (no @xterm/addon-web-links, no custom nodespace:// URI matcher) and no markdown parsing. Every place in the codebase that does render nodespace:// specially (chat-markdown.svelte, content-processor.ts, app-shell.svelte, node-card-inline.svelte, backlinks-panel.svelte) belongs to the local in-app chat's markdown-rendering pipeline — a structurally separate UI surface the PTY terminal doesn't share. The rule only ever mattered for that rendering path, so its absence from the PTY context file / SKILL.md is a non-issue.

2. No test exercises PtySession::launch() end-to-end to confirm SKILL.md lands in a real spawned session — launch_for_test (the test-only constructor used by all existing real-PTY-spawn tests) deliberately bypasses GraphContextAssembler by design, so it can spawn plain shell utilities (sh, cat) instead of depending on a real agent binary being present in CI. The actual integration point is GraphContextAssembler::write_context_file writing into a session directory, which the new write_context_file_writes_both_context_file_and_skill_md test already covers against a real NodeService/SqliteStore. Extending launch_for_test to thread through an assembler, or requiring a real claude/codex binary on PATH for this test, would be a larger change out of proportion to Section 4's scope (delivery/wiring, not the PTY-spawn mechanics themselves).

No re-review needed — recommendation stands at APPROVE.

@malibio
malibio marked this pull request as ready for review July 12, 2026 02:07
@malibio
malibio merged commit ee3d5e0 into main Jul 12, 2026
@malibio
malibio deleted the worktree-issue-1529-cli-skill-parity branch July 12, 2026 02:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Align CLI + SKILL.md with local-agent capability and guidance (external-harness parity)

1 participant