Skip to content

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

Closed

Description

@malibio

Summary

Two large migrations shipped recently without finishing their cleanup passes:

  1. Daemon-client migration (ADR-031 / ADR-032) — MCP moved from an in-process HTTP server to TypeScript clients talking to nodespaced over gRPC.
  2. 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 by packages/agent. Verified below. Split the deletion accordingly.

Dead — the transport/server (delete):

  • Nothing in packages/daemon or packages/desktop-app/src-tauri starts McpServerService / run_mcp_server.
  • The only constructor of McpServerService is packages/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.ts has 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) → nodespace CLI → 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,231 and prompt_assembler.rs:12,257,409 import nodespace_core::mcp::handlers::markdown::{NodeTemplate, prepare_nodes_from_template}.
  • packages/agent/src/local_agent/tools.rs:10 imports handle_create_schema; :894,901 calls handle_get_markdown_from_node_id; :1215 calls handle_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 break packages/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 repoint packages/agent imports 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 in mcp/server.rs, and the now-orphaned handlers — plus packages/dev-tools/src/bin/dev-mcp.rs
  • (Coordinate with the architectural audit's MCP→skills migration — the end state deletes packages/mcp and 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 SurrealStore alias; rename all callers to SqliteStore
  • Audit doc comments referring to "SurrealStore" / "Domain Events emitted by SurrealStore" in packages/core/src/db/events.rs etc.

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, TS proto-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/.ts source for surreal/rocksdb/SurrealStore and rename to the SQLite/SqliteStore reality (much of core/src/mcp/handlers overlaps 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.ts header (still says → RocksDB) and any MCP_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 diagrams McpServerService inside the Tauri process on port 3100. Either fully rewrite or clearly archive.
  • architecture/daemon-cli-protocol.md — diagram shows Claude Code → HTTP/JSON-RPC → MCP Server inside the daemon. Not true; daemon is gRPC-only, MCP is external TS.
  • architecture/daemon-cli-overview.md — same: includes an MCP HTTP Server node inside the daemon with AI → 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.md MCP diagrams to reflect: daemon = gRPC only; MCP = external TS (packages/mcp stdio→CLI, @nodespaceai/agent-tools direct gRPC)

B2. Database docs name the wrong database

  • architecture/data-layer.md opens with "NodeSpace uses SurrealDB embedded with RocksDB" — now SQLite/libsql + sqlite-vec.
  • architecture/technology-stack.md lists SurrealDB | Embedded document database.
  • architecture/surrealdb-v3-gotchas.md documents a database that no longer ships.
  • ~78 .md files mention surreal/rocksdb.
  • Rewrite data-layer.md and technology-stack.md DB 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

Acceptance criteria

  • Part A: dead HTTP MCP server + dev-mcp removed (after tool-surface audit), SurrealStore alias 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/SurrealStore references remain in .rs/.ts source (target/node_modules excluded); the only permitted mentions are intentional historical context inside superseded ADR markdown
  • bun run test:all + cargo build green after code removal

Activity

  1. added
    documentation
    on May 29, 2026
  2. self-assigned this
    on May 29, 2026
  3. malibio commented on May 29, 2026

    @malibio
    CollaboratorAuthor

    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.

  4. malibio commented on May 29, 2026

    @malibio
    CollaboratorAuthor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

backenddocumentationfoundation

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions