Skip to content

Delete the dead embedding push/pull seam; keep embedding.origin for existing databases #3337

Closed

Description

@mstomar125

Summary

This issue removes the embedding cloud push/pull code that nothing calls any more, while keeping existing databases openable. It implements ADR-083 §3 (proposed; decision 3-A).

  • Delete the embedding push/pull API.
  • Fold the store's origin-tagged upsert into a single local upsert.
  • Drop the push-sweep index from the DDL.
  • Keep the embedding.origin and node.sync_seq columns. They stay unused and are commented as such, so databases created by earlier builds still pass the schema shape check.

Context

  • Nothing outside core calls it, so there is no gate.
    • nodespace-sync stopped syncing embeddings under ADR-045.
    • Its test sync_tables_exclude_embeddings (nodespaced-pro/src/cloud_sync/grpc.rs) pins the synced tables to nodes and relationships.
    • A grep of sync at 17f9557 finds no call to any API below.
  • Inside core, only tests call them. That covers the NodeService wrappers, apply_remote_embeddings and embeddings_modified_since.
  • Columns are shape-checked; indexes are not. create_schema compares the column names of existing tables with the DDL (find_shape_mismatches in packages/core/src/db/schema.rs).
    • Dropping embedding.origin or node.sync_seq would send every existing database to the incompatible-database screen.
    • Removing idx_emb_modified from the DDL is safe. Old databases keep the index, harmlessly.
  • Never put ; in a SCHEMA_SQL comment. execute_schema_sql (schema.rs, ~217) splits SCHEMA_SQL on ;, and a debug assertion fails when a comment splits a statement.
  • Not recommended: keeping a neutral imported-embeddings writer. If ADR-083 nevertheless keeps one, keep SqliteStore::apply_remote_embeddings under a neutral name and doc, and skip its deletion in step 3. It would have no consumer, and core CLAUDE.md bans dead code.

Scope (symbols; lines at af8ddb61 are hints)

  • packages/core/src/services/node_service/embedding.rs:
    • delete NodeService::get_embeddings, embeddings_modified_since, upsert_embeddings, apply_remote_embeddings and delete_embeddings, with their docs (~6-80);
    • keep everything from set_embedding_waker onward;
    • update the test helpers embed_fresh (~386) and is_stale (~398), and the asserts at ~525 and ~548.
  • packages/core/src/services/node_service/mod.rs:
    • update svc.get_embeddings(id) in the rootness-refresh test (~4088);
    • delete test_embedding_write_wrappers_upsert_read_delete (~4969-4993).
  • packages/core/src/db/sqlite_store/embeddings.rs:
    • upsert_embeddings (~5-15) and its doc;
    • apply_remote_embeddings (~17-28);
    • upsert_embeddings_with_origin (~30-164);
    • the get_embeddings doc (~218-220);
    • embeddings_modified_since (~242-281).
  • packages/core/src/db/sqlite_store/mod.rs: test_get_embeddings_roundtrip_and_modified_since (~2052).
  • packages/core/src/db/schema.rs:
    • the node.sync_seq column (~49), comment only;
    • the embedding.origin comment (~124-127);
    • idx_emb_modified and its comment (~136-140).
  • packages/core/tests/it/schema_test.rs:
    • the origin column assertion (~70-73);
    • the expected index list (~101);
    • embedding_modified_index_leads_on_origin (~123-146).

Out of scope

  • Dropping or renaming embedding.origin or node.sync_seq. That waits for the next change that alters a table's column set (ADR-083 §3).
  • The store-level upsert_embeddings, delete_embeddings and get_embeddings signatures. They must compile unchanged, because these callers use them:
    • embedding_service.rs and node_service/crud.rs;
    • tests/it/embedding_service_test.rs and tests/it/search_result_scaling_test.rs;
    • benches/query_crud.rs and examples/seed_search_corpus.rs.
  • Pro wording elsewhere (Remove Pro, Supabase and nodespace-sync wording from core comments, docs and the skill #3372).

Steps

  1. Start up. Follow core CLAUDE.md's startup sequence:
    • pull main;
    • EnterWorktree({name: "issue-<N>-embedding-seam"});
    • bun install, then the bun run test baseline;
    • bun run gh:assign <N> "@me", then bun run gh:status <N> "In Progress".
  2. Wrappers. Delete the five NodeService wrappers in node_service/embedding.rs.
  3. Point the tests at the store.
    • Replace svc.upsert_embeddings(..) with svc.store().upsert_embeddings(..).
    • Replace svc.get_embeddings(id) with svc.store().get_embeddings(id).
    • NodeService::store() is pub. Keep .unwrap(), since the store returns anyhow::Result.
    • Delete test_embedding_write_wrappers_upsert_read_delete.
  4. Store upsert (sqlite_store/embeddings.rs):
    • Delete apply_remote_embeddings and embeddings_modified_since.

    • Merge upsert_embeddings_with_origin into upsert_embeddings. Drop:

      • the origin parameter;
      • its libsql::Value::Text(origin..) param (~88);
      • origin from the INSERT INTO embedding (...) column list (~124).

      New rows then take the column's DEFAULT 'local'.

    • Change the placeholder builder from 14 params per row to 13:

      • base = i * 13;
      • template (?1..?11, 0, 0, NULL, ?12, ?13);
      • fix the // 14 params/row comment.

      EMBEDDING_CHUNK = 60 stays well under SQLite's variable limit.

    • Reword the upsert_embeddings and get_embeddings docs so they describe local behaviour only.

  5. DDL (db/schema.rs; comments only, and no ; in them):
    • Keep origin TEXT NOT NULL DEFAULT 'local', and replace its comment. The new comment says it is a legacy provenance column: every write stores the default, and nothing reads it. It is kept because create_schema's shape check compares column names, so dropping it would refuse every database an earlier build created.
    • Add a one-line comment of the same kind above sync_seq.
    • Delete idx_emb_modified and its comment.
  6. Store test. Rename test_get_embeddings_roundtrip_and_modified_since to test_get_embeddings_roundtrip.
    • Delete the modified-since cursor, remote-provenance and EXPLAIN QUERY PLAN sections.
    • Keep the chunk round-trip and empty-read assertions.
    • Add a raw SELECT origin FROM embedding assertion that an upserted row stores local.
  7. tests/it/schema_test.rs:
    • Keep the assertion that embedding has an origin column. Its message becomes: kept so databases created by earlier builds pass the shape check.
    • Remove idx_emb_modified from the expected index list.
    • Delete embedding_modified_index_leads_on_origin.
    • Add a_database_that_still_has_idx_emb_modified_opens:
      • run create_schema;
      • create idx_emb_modified ON embedding (origin, modified_at, node_id, chunk_index) by hand;
      • assert that a second create_schema on the same connection returns Ok.
  8. Ratchet.
    • Run bun run scripts/check-pro-boundary.ts.
    • Set BASELINES to the printed counts, using its paste block.
    • List the lowered markers in the PR description. Expect cloudSyncHooks, cloudWording and proWording to drop.
  9. Finish.
    • bun run test:changed, then bun run quality:fix, then commit.
    • git push origin HEAD:issue-<N>-embedding-seam.
    • gh pr create --repo NodeSpaceAI/nodespace-core --base main --head issue-<N>-embedding-seam, then bun run gh:status <N> "In Review".
    • After approval, run bun run merge <PR#> in the background.

Acceptance criteria

  • git grep -n -E 'apply_remote_embeddings|embeddings_modified_since|upsert_embeddings_with_origin' -- packages prints nothing.
  • git grep -n idx_emb_modified -- packages prints only the new legacy-index test.
  • NodeService has no embedding read or write wrappers.
  • Embedding generation and semantic search still work, through the unchanged embedding_service and crud paths.
  • A fresh database still has embedding.origin and node.sync_seq, and a new embedding row stores origin = 'local'.
  • A database that still has idx_emb_modified passes create_schema (the new test).
  • The executable statements in SCHEMA_SQL differ from origin/main only by the removed index, and no edited comment contains ;.
  • There is no #[allow(dead_code)], no compatibility shim, and no issue number in any comment.
  • bun run scripts/check-pro-boundary.ts exits 0, and BASELINES equals its printed counts.
  • Core builds, all tests pass, and the free app is unchanged.

Tests and verification

  • bun run test:changed. Run Rust through this, not ad hoc: the dev Mac is shared, and this tier takes the machine slot.
  • For iteration:
    • .tools/bin/cargo-nextest nextest run -p nodespace-core --lib embedding
    • .tools/bin/cargo-nextest nextest run -p nodespace-core --test it schema_test::
    • .tools/bin/cargo-nextest nextest run -p nodespace-core --test it embedding_service_test::
  • Lint and format: cargo clippy -p nodespace-core --all-targets -- -D warnings -D clippy::unused-async, then cargo fmt --all --check.
  • Manual check. Use an isolated NODESPACE_HOME holding a database created by the current release.
    • The dev app opens it without the incompatible-database screen.
    • Edit a node so it is re-embedded. Semantic search still finds it.

Dependencies

Risks and rollback

  • Placeholder arithmetic. A mistake in step 3 breaks every embedding write. The store tests, embedding_service_test and the search tests catch it.
  • Rollback. Revert the PR. The on-disk shape is unchanged. Only databases created while the change was live lack the index.

Plan key: C7.1 (pro-boundary DAG).

🤖 Generated with Claude Code

Activity

  1. self-assigned this
    on Sep 30, 2026
  2. added
    pro-boundary
    on Sep 30, 2026
  3. mstomar125 commented on Sep 30, 2026

    @mstomar125
    ContributorAuthor

    Completed in #3382 (merged). Auto-close did not fire; closing manually.

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

Metadata

Metadata

Assignees

Labels

pro-boundary

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions