Repository navigation
Description
Summary
Two large migrations shipped recently without finishing their cleanup passes:
- Daemon-client migration (ADR-031 / ADR-032) — MCP moved from an in-process HTTP server to TypeScript clients talking to
nodespacedover gRPC. - SQLite/libsql migration (Migrate local DB from SurrealDB embedded to SQLite (libsql) #1222, Integrate sqlite-vec for vector search (closes #1221) #1224) — replaced embedded SurrealDB + RocksDB with SQLite + sqlite-vec.
The result is a codebase where dead code from the old architecture still compiles (sometimes only via compatibility aliases) and architecture docs still describe the superseded design as current. This violates the repo's "no backward compatibility / delete old patterns immediately" principle and actively misleads anyone (human or agent) reading the docs.
This issue is a two-part audit + cleanup: (A) reconcile the code, (B) reconcile the docs. Both halves trace to the same unfinished migrations.
Part A — Dead / stale CODE
A1. Dead MCP transport — but the handler logic is live (corrected 2026-05-29)
Correction. An earlier revision called
packages/core/src/mcp/(server + handlers) entirely dead. That is wrong. The HTTP transport is dead; several handler functions are reused as a library bypackages/agent. Verified below. Split the deletion accordingly.
Dead — the transport/server (delete):
- Nothing in
packages/daemonorpackages/desktop-app/src-tauristartsMcpServerService/run_mcp_server. - The only constructor of
McpServerServiceispackages/dev-tools/src/bin/dev-mcp.rs, whose own header says "This binary should be removed or migrated" (issue Restore dev-proxy HTTP client mode (broken by #927) #955) and documents an embedded-RocksDB + dev-proxy:3001 architecture that no longer exists. dev-proxy.tshas fully migrated to gRPC → daemon and does not import the HTTP MCP server.- Live agent path is now:
Claude Code → @nodespaceai/skill (SKILL.md → CLI)/packages/mcp (TS stdio → CLI)→nodespaceCLI → daemon gRPC. (We are also migrating off MCP toward skills+scripts — see the architectural audit issue and CLI coverage gap: surface remaining knowledge-graph operations so skills+scripts can replace MCP #1227.)
Live — handler logic reused as a library (extract, do NOT delete):
packages/agent/src/skill_pipeline.rs:17,231andprompt_assembler.rs:12,257,409importnodespace_core::mcp::handlers::markdown::{NodeTemplate, prepare_nodes_from_template}.packages/agent/src/local_agent/tools.rs:10importshandle_create_schema;:894,901callshandle_get_markdown_from_node_id;:1215callshandle_create_schema.- So this logic (markdown templating/import/export, schema creation) is on a live path through the local agent — deleting
mcp/handlers/outright would breakpackages/agent.
Action (ordered):
- Extract the reused, transport-agnostic logic out of
packages/core/src/mcp/handlers/into a normal core module (e.g.core/src/markdown/,core/src/schema/) and repointpackages/agentimports there - Audit the remaining handlers vs. daemon gRPC + CLI (CLI coverage gap: surface remaining knowledge-graph operations so skills+scripts can replace MCP #1227) — list any logic that would be lost; port what's still needed
- Then delete the MCP transport:
McpServerService,McpTransport,default_mcp_port,run_mcp_server*, the JSON-RPC server inmcp/server.rs, and the now-orphaned handlers — pluspackages/dev-tools/src/bin/dev-mcp.rs - (Coordinate with the architectural audit's MCP→skills migration — the end state deletes
packages/mcpand the MCP protocol layer entirely)
A2. SqliteStore as SurrealStore compatibility alias
packages/core/src/db/mod.rs:15 re-exports SqliteStore as SurrealStore. This alias is the only reason old call sites and tests (e.g. mcp/server.rs tests, dev-mcp, cli/tests) still compile under the old name. Pure backward-compat shim — should not exist per CLAUDE.md.
- Delete the
as SurrealStorealias; rename all callers toSqliteStore - Audit doc comments referring to "SurrealStore" / "Domain Events emitted by SurrealStore" in
packages/core/src/db/events.rsetc.
A3. Duplicated proto files
packages/proto/proto/*.proto and packages/daemon/proto/*.proto appear to be duplicate copies of the same 5 service protos. dev-proxy.ts and agent-tools load from daemon/proto; the Rust build may use packages/proto. Drift risk.
- Determine the canonical proto location, make the other a reference (or delete), verify all consumers (Rust
tonic-build, TSproto-loader) point at one source
A4. Purge all SurrealDB / RocksDB naming from code
The dependencies are already gone (no Cargo.toml declares surreal or rocksdb — the migration itself completed). What remains is naming residue: 354 references across 55 source files (.rs/.ts, excluding target/node_modules) — comments, type aliases, test names, doc-comments still saying "SurrealStore" / "SurrealDB" / "RocksDB". There should be zero SurrealDB or RocksDB anywhere in the codebase.
Concentrations: core/tests (9 files), core/src/mcp/handlers (7), core/src/db (6), core/src/services (5), core/src/playbook (4), daemon/tests (3), plus scattered in models, desktop-app services, cli, benches.
- Sweep all
.rs/.tssource forsurreal/rocksdb/SurrealStoreand rename to the SQLite/SqliteStorereality (much ofcore/src/mcp/handlersoverlaps A1 and dies with it) - Rename test files/fns and fixtures (e.g.
cli/tests,daemon/tests,core/tests) that bake the old name into identifiers - Confirm
dev-proxy.tsheader (still says→ RocksDB) and anyMCP_PORT/port-3100 plumbing are removed or corrected - Final check:
grep -riE "surreal|rocksdb" packages --include="*.rs" --include="*.ts"(excl. target/node_modules) returns nothing
Part B — Stale DOCS (nodespace-docs repo)
The docs are substantially out of date. 78 docs still reference SurrealDB/RocksDB, and multiple architecture docs still present the in-process HTTP MCP server as the live design. ADR-032 already documents the correct end state — but the cleanup never propagated to the surrounding docs.
B1. MCP architecture docs describe a dead design as current
architecture/mcp-integration.md— has a "superseded by ADR-032" banner, but the body still diagramsMcpServerServiceinside the Tauri process on port 3100. Either fully rewrite or clearly archive.architecture/daemon-cli-protocol.md— diagram showsClaude Code → HTTP/JSON-RPC → MCP Serverinside the daemon. Not true; daemon is gRPC-only, MCP is external TS.architecture/daemon-cli-overview.md— same: includes anMCP HTTP Servernode inside the daemon withAI → HTTP JSON-RPC → MCP.- ADR-031 — lists
McpServerService: "HTTP JSON-RPC for external AI agents"as a daemon component. It is not hosted by the daemon. ADR-031 status is still "Proposed" despite being implemented. - Reconcile 021/031/032 chain: mark 031 as Accepted/Implemented, correct its component list (remove McpServerService from the daemon), ensure 032's "MCP eliminated, use agent-tools via gRPC" is the single source of truth
- Fix or archive
mcp-integration.md,daemon-cli-protocol.md,daemon-cli-overview.mdMCP diagrams to reflect: daemon = gRPC only; MCP = external TS (packages/mcpstdio→CLI,@nodespaceai/agent-toolsdirect gRPC)
B2. Database docs name the wrong database
architecture/data-layer.mdopens with "NodeSpace uses SurrealDB embedded with RocksDB" — now SQLite/libsql + sqlite-vec.architecture/technology-stack.mdlistsSurrealDB | Embedded document database.architecture/surrealdb-v3-gotchas.mddocuments a database that no longer ships.- ~78
.mdfiles mention surreal/rocksdb. - Rewrite
data-layer.mdandtechnology-stack.mdDB sections for SQLite/libsql + sqlite-vec (ref Migrate local DB from SurrealDB embedded to SQLite (libsql) #1222, Integrate sqlite-vec for vector search (closes #1221) #1224) - Archive or delete
surrealdb-v3-gotchas.md - Sweep remaining docs; correct or archive stale SurrealDB/RocksDB references (diagrams in cloud-sync, schema-migration, monitoring, etc.)
- Update "Status: Proposed" banners on docs that have actually shipped (daemon-cli-overview, ADR-031)
Why now / honesty principle
Per CLAUDE.md, NodeSpace has no users and no backward-compat obligations — old patterns should be deleted on replacement, not aliased and left behind. The docs are the project's source of truth for onboarding humans and agents; a doc that says "SurrealDB" or "in-process MCP HTTP server" is worse than no doc because it's confidently wrong. This audit closes the gap left by #1220-era and #1222/#1224 migrations.
Interaction with #1216
#1216 (InsertPosition enum) lists mcp/handlers/nodes.rs as a migration target. Those specific handlers (handle_insert_child_at_index, handle_move_child_to_index) are not in the live-library set (A1) — they're only reachable via the dead HTTP transport — so A1's transport deletion removes them. Sequence A1 before #1216 and #1216 shrinks: it no longer needs to touch mcp/handlers/nodes.rs, only the daemon gRPC + core + proto call sites. Note the dependency on both issues.
Out of scope
- Functional changes to the daemon, CLI, or TS tool packages — this is cleanup + doc reconciliation only.
- The
InsertPositionrefactor itself (API: introduce InsertPosition enum across proto/gRPC + service (replace overloaded insert_after_node_id) #1216).
Acceptance criteria
- Part A: dead HTTP MCP server + dev-mcp removed (after tool-surface audit),
SurrealStorealias gone, proto duplication resolved, surreal/rocksdb code references swept - Part B: MCP + DB architecture docs reflect daemon-gRPC + external-TS-MCP + SQLite reality; superseded docs archived; shipped ADRs marked Accepted
- Zero
surreal/rocksdb/SurrealStorereferences remain in.rs/.tssource (target/node_modules excluded); the only permitted mentions are intentional historical context inside superseded ADR markdown -
bun run test:all+cargo buildgreen after code removal
Activity
malibio commentedon May 29, 2026
Baseline (worktree issue-1226-migration-cleanup): Frontend 129 test files / 3913 tests passed (bun run test). cargo build --workspace baseline capturing. Starting Part A: extract live MCP handler logic to core/markdown+schema, delete dead HTTP transport, drop SurrealStore alias, cleanse surreal/rocksdb naming, consolidate protos.
Address review: remove stale MCP doc-comment references in relocated …
Address review: drop remaining MCP wording in schema/markdown doc-com…
malibio commentedon May 29, 2026
Part B docs PR opened: NodeSpaceAI/nodespace-docs#49 (companion to code PR #1230). Reconciles data-layer/technology-stack/system-overview to SQLite/libsql+sqlite-vec, archives surrealdb-v3-gotchas, removes the in-daemon MCP HTTP server from daemon-cli-overview/protocol + mcp-integration, and flips ADR-031 to Accepted (McpServerService removed, amended by ADR-032). SurrealDB Cloud retained as the live remote sync backend.
Audit & cleanup: finish daemon + SQLite migrations (purge dead HTTP M…
Audit & cleanup: finish daemon + SQLite migrations (purge dead HTTP M…