Skip to content

Audit & cleanup: finish daemon + SQLite migrations (purge dead HTTP MCP / SurrealDB / RocksDB from code and docs) - #1230

Merged
malibio merged 3 commits into
mainfrom
worktree-issue-1226-migration-cleanup
May 29, 2026
Merged

malibio merged 3 commits into
mainfrom
worktree-issue-1226-migration-cleanup

Conversation

@malibio

@malibio malibio commented May 29, 2026

Copy link
Copy Markdown
Collaborator

Closes #1226

…l/rocksdb naming (#1226)

Reconciles the code with two completed migrations (daemon-client ADR-031/032,
SQLite/libsql #1222/#1224) that left dead code and stale naming behind.

A1 — MCP transport vs. live handler library:
- Extract the transport-agnostic library logic the agent/daemon/benches still
  use out of `core/src/mcp/handlers/` into normal core modules:
    * `core/src/markdown/` (convert/template/links/export + MarkdownError,
      replacing the MCPError dependency)
    * `core/src/schema/` (handle_create_schema / handle_update_schema)
    * `core/src/node_batch.rs` (batch get/update used by perf benches)
    * `core/src/agent_params.rs` (Search*Params used by the local agent)
- Repoint agent (skill_pipeline, prompt_assembler, local_agent/tools),
  daemon (main, import_service), and benches to the new module paths.
- Delete the dead HTTP/JSON-RPC transport entirely: the whole `core/src/mcp/`
  tree, `services/mcp_server_service.rs`, and `dev-tools/src/bin/dev-mcp.rs`
  (its only caller). The dev-tools Rust crate had no other source, so it's
  removed from the workspace (dev-proxy.ts is a standalone Bun script).
- Delete the orphaned handler integration tests (mcp_handlers_integration_test,
  relationships_handler_test, search_handler_test).

A2 — Drop the `SqliteStore as SurrealStore` compatibility alias and rename all
241 `SurrealStore` identifiers to `SqliteStore`.

A3 — Proto consolidation: `packages/proto/proto/` is the single source (the only
protos Rust compiles). Deleted the stale `packages/daemon/proto/` copy (its
node_service.proto was missing the relationship events) and repointed the TS
consumers (dev-proxy.ts, agent-tools/client.ts) to the canonical path.

A4 — Cleanse all surreal/rocksdb naming residue from `.rs`/`.ts` comments,
doc-comments, test fixtures, and string literals; obsolete "eventual
consistency / write visibility" caveats (false under SQLite) reworded or
removed. Deleted the stray nested check-dev-deps.ts that gated dev startup on a
SurrealDB CLI binary. `grep -riE "surreal|rocksdb"` over .rs/.ts is now empty.

Also fixes a latent SQLite-migration bug surfaced by the cleanup: CLI
`diagnostics` sized the database by walking it as a RocksDB directory tree;
SQLite is a single file, so it now sizes the file (plus -wal/-shm sidecars) or
a directory.

Tests: core 966 lib + 223 integration, agent 223 lib, daemon 36, cli 5,
src-tauri 24, agent-tools 17, frontend 3913 — all green. (Live-Ollama
integration tests require a running model and are excluded.)

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@malibio

malibio commented May 29, 2026

Copy link
Copy Markdown
Collaborator Author

Code Review — PR #1230 (Part A of #1226)

Scope reviewed: the new/moved logic (markdown/schema/node_batch/agent_params extraction, MCPError→MarkdownError, diagnostics database_size fix, proto consolidation), not the bulk dead-MCP deletions. Build verified green (cargo build -p nodespace-core -p nodespace-agent -p nodespace-daemon -p nodespace-cli).

Requirements Check (Part A — #1226)

  • ✅ A1 — dead HTTP MCP transport removed after extracting live handler logic. core/src/mcp/ tree, services/mcp_server_service.rs, dev-tools/src/bin/dev-mcp.rs deleted; dev-tools Rust crate removed from Cargo.toml (no .rs source remains, Cargo.toml gone). Live logic relocated to core/src/markdown/, core/src/schema/, core/src/node_batch.rs, core/src/agent_params.rs; agent/daemon/benches repointed. No live references to deleted symbols (grep nodespace_core::mcp, McpServerService, etc. all clean).
  • ✅ A2 — SqliteStore as SurrealStore alias removed; all callers renamed. Zero SurrealStore references remain in .rs/.ts.
  • ✅ A3 — proto duplication resolved. packages/daemon/proto/ deleted; both TS consumers (dev-proxy.ts, agent-tools/client.ts) repointed to canonical packages/proto/proto/node_service.proto (the source tonic-build compiles). Resolved paths verified to exist.
  • ✅ A4 — surreal/rocksdb naming purged. grep -riE "surreal|rocksdb" over .rs/.ts (excl. target/node_modules) returns nothing. Stray nested check-dev-deps.ts removed; canonical desktop-app/scripts/check-dev-deps.ts still present, referenced by package.json, and no longer gates on the SurrealDB CLI.
  • ✅ Latent SQLite bug fix (diagnostics database_size) — correct (see below).
  • ✅ Build green after removal. (Live-Ollama integration tests flaky/unrelated — confirmed out of scope.)
  • ➖ Part B (docs) — explicitly a separate PR; not in this changeset. Correct.

Findings

🔴 Critical

None.

🟡 Improvements

  • packages/core/src/lib.rs:20 — Stale crate-level doc still lists //! - [mcp] - MCP stdio server for AI agent integration, but the mcp module was deleted. This is a broken rustdoc intra-doc link: cargo doc -p nodespace-core emits warning: unresolved link to 'mcp' (reproduced). It also documents a deleted module as current — exactly the residue A4 targets. One-line fix: delete the line (or replace with the new markdown/schema modules). Principle: no stale residue / don't introduce suppressible warnings.

  • Stale "MCP" naming in the relocated modules — these now live in core as plain libraries but still describe themselves as MCP handlers:

    • markdown/mod.rs:1 //! MCP Markdown Import Handler
    • markdown/mod.rs:847 /// Handle create_nodes_from_markdown MCP request
    • markdown/mod.rs:997 // Default: Fire-and-forget async for fast MCP response
    • markdown/mod.rs:1626 // MCP generates IDs server-side
    • schema/mod.rs:1 //! Schema MCP Handlers; :108,334,402,475 /// # MCP Tool: ...
    • markdown/markdown_test.rs:1, schema/schema_test.rs:1 headers

    A4 only enforced surreal/rocksdb, so this isn't a hard criterion miss, but it's the same staleness class the PR set out to remove and is now wrong (the MCP transport these "tools/requests" belonged to is deleted). Suggest a sweep to reword as library docs. Principle: docs as source of truth — confidently-wrong comments mislead future readers/agents. (The historical-context notes in error.rs, node_batch.rs, agent_params.rs saying "previously MCP / deleted transport" are legitimate and should stay.)

🟢 Nits / Observations

  • MCPError → MarkdownError is a faithful, improved replacement. All four used constructors (invalid_params, internal_error, node_not_found, node_creation_failed) preserved; node_not_found keeps the identical "Node not found: {id}" message. The original MCPError had no Display impl; MarkdownError adds one (with "invalid params:"/"not found:"/"node creation failed:" prefixes) plus std::error::Error — strictly additive. No consumer reads .code, confirmed.
  • Behavior note — local_agent/tools.rs:1224 surfaces create_schema errors to the model via format!("{:?}", e). Debug shape changed from MCPError { code: -32602, message: "...", data: None } to InvalidParams("..."). The human-readable message is preserved inside; the new form is cleaner (drops JSON-RPC noise). Acceptable; flag only because it's a model-facing string.
  • node_batch.rs error type MCPError→String is fine — only benches/performance.rs consumes these, and they're correctly wired (build passes). OCC-bypass warning behavior preserved.
  • diagnostics.rs database_size is correct. Uses symlink_metadata (lstat) so a symlinked DB path at top level falls to the Ok(_) => 0 arm (no follow, no loop risk); file case sums main file + -wal/-shm sidecars via with_file_name; directory case delegates to the existing recursive directory_size. The only edge it intentionally doesn't handle — a symlink pointing to a real DB file returns 0 — is a defensible, documented trade-off and unlikely in practice.

Standards

No lint suppression, no #[allow(dead_code)], no console.log in production code, no any, no backward-compat shims introduced. console.log in check-dev-deps.ts is a dev/build script (exempt, pre-existing pattern).

Recommendation: COMMENT (approve-with-nits)

Net-positive, well-executed cleanup that faithfully extracts live logic, deletes dead transport, and fixes a real SQLite sizing bug. No blockers. Please address the broken [mcp] doc link in lib.rs:20 (introduces a cargo doc warning) and ideally sweep the residual "MCP handler/tool/request" comments in the relocated modules before merge — both are quick and align with the PR's own A4 intent.

@malibio malibio left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed (initial). Net-positive cleanup, no blockers. Two non-blocking items: (1) broken [mcp] rustdoc link in core/src/lib.rs:20 introduces a cargo doc warning — delete it; (2) residual 'MCP handler/tool/request' comments in the relocated markdown/schema modules describe the deleted transport as current (A4 intent). Full review posted as a PR comment. Recommendation: COMMENT / approve-with-nits.

…modules (#1226)

Fixes the broken [`mcp`] rustdoc link in lib.rs and the residual 'MCP
handler/tool/request' wording in the relocated markdown/schema modules and
their tests — the MCP transport no longer exists; these are now plain core
library functions. Comment-only; core builds green.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@malibio

malibio commented May 29, 2026

Copy link
Copy Markdown
Collaborator Author

Addressed the two 🟡 nits in commit 7d3d8c9e:

  • Removed the broken [mcp] rustdoc link in lib.rs (replaced with the new markdown/schema modules).
  • Swept residual "MCP handler/tool/request" wording from the relocated markdown/ and schema/ modules and their test headers — these are now plain core library functions, not MCP handlers.

Comment-only; cargo build -p nodespace-core and the 966 core lib tests stay green. Part B (docs reconciliation in nodespace-docs) follows as a separate PR per the issue plan.

…ments (#1226)

Completes the review-nit sweep: the `# MCP Tool:` headings in schema/mod.rs
and the residual 'MCP request/response/tool' comments in markdown/mod.rs are
now phrased as plain library docs. Legitimate historical MCP references in
error.rs/node_batch.rs/agent_params.rs (explaining the relocation) are kept.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@malibio

malibio commented May 29, 2026

Copy link
Copy Markdown
Collaborator Author

Re-Review — PR #1230 (Part A of #1226)

Review Type: Re-Review
Recommendation: APPROVE

Previous Review Summary

The prior review (2026-05-29) returned COMMENT (approve-with-nits) with two 🟡 recommendations:

  1. Broken [mcp] rustdoc intra-doc link in packages/core/src/lib.rs pointing at the deleted mcp module.
  2. Residual "MCP handler / MCP Tool / MCP request" wording in the relocated core/src/markdown/ and core/src/schema/ modules and their test headers, describing the deleted HTTP transport as if it were current.

Outcome: 2/2 addressed. No recommendations outstanding. No new issues introduced.

Verification of Fixes

🟢 Nit 1 resolved — lib.rs:20-21: the [mcp] crate-doc bullet is replaced with [markdown] and [schema] bullets that match the actual relocated modules (pub mod markdown; at L26, pub mod schema; at L31). grep -n "mcp" packages/core/src/lib.rs returns nothing. cargo doc -p nodespace-core --no-deps no longer emits the unresolved-link warning for mcp. (Remaining unresolved-link warnings — a nodespace-docs archived path and get_enum_values/tuple-index example identifiers — are pre-existing and unrelated to this changeset.)

🟢 Nit 2 resolved — grep -rniE "MCP" across markdown/mod.rs, schema/mod.rs, markdown/markdown_test.rs, schema/schema_test.rs returns empty. Stale wording was rewritten accurately:

  • markdown/mod.rs:1 "MCP Markdown Import Handler" → "Markdown import/export and templating." plus a "Consumed as a library by nodespace-agent and nodespace-daemon" note reflecting the new call sites.
  • Doc comments at markdown/mod.rs:848, 998, 1261, 1627 reworded ("MCP request"/"MCP response"/"bulk-import MCP tool"/"MCP generates IDs" → transport-neutral phrasing).
  • schema/mod.rs:1 "Schema MCP Handlers" → "Schema creation and updates.", and the four # MCP Tool: rustdoc section headers → # Tool:.
  • Test header comments at markdown_test.rs:1 and schema_test.rs:1 updated to describe behavior rather than the dead transport.

Regression Check

🟢 The two fix commits (3478e3a, 910787d) are comment-only. git diff 1962f1bb..HEAD touches only //!/////// lines across the 5 files; the sole inline edit (markdown/mod.rs:1627, // MCP generates IDs server-side → // IDs are generated server-side) leaves the underlying id: None, statement unchanged. No logic, signatures, or control flow altered.
🟢 cargo build -p nodespace-core succeeds.

Findings

None new. No blockers.

(Note: flaky live-Ollama integration tests are environmental and unrelated to this PR. Part B docs reconciliation is correctly scoped to a separate PR in the nodespace-docs repo and is not expected here.)

This cleanup PR is a clear net improvement to code health with both prior nits fully resolved. Approving.

@malibio malibio left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review: both prior nits (broken [mcp] doc link in lib.rs; stale MCP wording in relocated markdown/schema modules + test headers) are fully resolved. Fix commits are comment-only, no logic changes; build green. No new findings — approve-equivalent (GitHub blocks self-approval on own PR). See summary comment for full details.

@malibio

malibio commented May 29, 2026

Copy link
Copy Markdown
Collaborator Author

Part B (docs reconciliation) is up as a companion PR: NodeSpaceAI/nodespace-docs#49 — rewrites the DB + MCP/daemon architecture docs and ADR-031 to match this PR's reality (SQLite/libsql + gRPC-only daemon).

@malibio
malibio merged commit fe88968 into main May 29, 2026
@malibio
malibio deleted the worktree-issue-1226-migration-cleanup branch May 29, 2026 21:23
malibio added a commit that referenced this pull request Jun 22, 2026
…CP / SurrealDB / RocksDB from code and docs) (#1230)

* Part A: purge dead HTTP MCP transport, SurrealStore alias, and surreal/rocksdb naming (#1226)

Reconciles the code with two completed migrations (daemon-client ADR-031/032,
SQLite/libsql #1222/#1224) that left dead code and stale naming behind.

A1 — MCP transport vs. live handler library:
- Extract the transport-agnostic library logic the agent/daemon/benches still
  use out of `core/src/mcp/handlers/` into normal core modules:
    * `core/src/markdown/` (convert/template/links/export + MarkdownError,
      replacing the MCPError dependency)
    * `core/src/schema/` (handle_create_schema / handle_update_schema)
    * `core/src/node_batch.rs` (batch get/update used by perf benches)
    * `core/src/agent_params.rs` (Search*Params used by the local agent)
- Repoint agent (skill_pipeline, prompt_assembler, local_agent/tools),
  daemon (main, import_service), and benches to the new module paths.
- Delete the dead HTTP/JSON-RPC transport entirely: the whole `core/src/mcp/`
  tree, `services/mcp_server_service.rs`, and `dev-tools/src/bin/dev-mcp.rs`
  (its only caller). The dev-tools Rust crate had no other source, so it's
  removed from the workspace (dev-proxy.ts is a standalone Bun script).
- Delete the orphaned handler integration tests (mcp_handlers_integration_test,
  relationships_handler_test, search_handler_test).

A2 — Drop the `SqliteStore as SurrealStore` compatibility alias and rename all
241 `SurrealStore` identifiers to `SqliteStore`.

A3 — Proto consolidation: `packages/proto/proto/` is the single source (the only
protos Rust compiles). Deleted the stale `packages/daemon/proto/` copy (its
node_service.proto was missing the relationship events) and repointed the TS
consumers (dev-proxy.ts, agent-tools/client.ts) to the canonical path.

A4 — Cleanse all surreal/rocksdb naming residue from `.rs`/`.ts` comments,
doc-comments, test fixtures, and string literals; obsolete "eventual
consistency / write visibility" caveats (false under SQLite) reworded or
removed. Deleted the stray nested check-dev-deps.ts that gated dev startup on a
SurrealDB CLI binary. `grep -riE "surreal|rocksdb"` over .rs/.ts is now empty.

Also fixes a latent SQLite-migration bug surfaced by the cleanup: CLI
`diagnostics` sized the database by walking it as a RocksDB directory tree;
SQLite is a single file, so it now sizes the file (plus -wal/-shm sidecars) or
a directory.

Tests: core 966 lib + 223 integration, agent 223 lib, daemon 36, cli 5,
src-tauri 24, agent-tools 17, frontend 3913 — all green. (Live-Ollama
integration tests require a running model and are excluded.)

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* Address review: remove stale MCP doc-comment references in relocated modules (#1226)

Fixes the broken [`mcp`] rustdoc link in lib.rs and the residual 'MCP
handler/tool/request' wording in the relocated markdown/schema modules and
their tests — the MCP transport no longer exists; these are now plain core
library functions. Comment-only; core builds green.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* Address review: drop remaining MCP wording in schema/markdown doc-comments (#1226)

Completes the review-nit sweep: the `# MCP Tool:` headings in schema/mod.rs
and the residual 'MCP request/response/tool' comments in markdown/mod.rs are
now phrased as plain library docs. Legitimate historical MCP references in
error.rs/node_batch.rs/agent_params.rs (explaining the relocation) are kept.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

---------

Co-authored-by: Michael Libio <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
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.

Audit & cleanup: finish daemon + SQLite migrations (purge dead HTTP MCP / SurrealDB / RocksDB from code and docs)

1 participant