Skip to content

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

Merged
mstomar125 merged 2 commits into
mainfrom
issue-3337-embedding-seam
Sep 30, 2026
Merged

mstomar125 merged 2 commits into
mainfrom
issue-3337-embedding-seam

Conversation

@mstomar125

Copy link
Copy Markdown
Contributor

Closes #3337

Deletes the embedding push/pull API that nothing calls any more, while keeping every existing database openable. Implements ADR-083 section 3 (proposed).

What changed

  • NodeService: deleted the five embedding wrappers get_embeddings, embeddings_modified_since, upsert_embeddings, apply_remote_embeddings and delete_embeddings. Core's own tests now go through svc.store(). Deleted test_embedding_write_wrappers_upsert_read_delete, which only exercised the wrappers.
  • SqliteStore: deleted apply_remote_embeddings and embeddings_modified_since, and folded upsert_embeddings_with_origin into upsert_embeddings. The insert no longer names origin, so a new row takes the column default 'local'. The placeholder builder goes from 14 to 13 params per row (base = i * 13). The store upsert_embeddings, delete_embeddings and get_embeddings signatures are unchanged, so embedding_service, crud, the benches and the example compile as before.
  • DDL (db/schema.rs, comments only apart from the index): removed idx_emb_modified. embedding.origin and node.sync_seq stay, now commented as unused legacy columns. create_schema compares column names of existing tables with the DDL, so dropping either column would send every database an earlier build created to the incompatible-database screen. Old databases keep the index, harmlessly.

Dead-code confirmation

Before deleting, grepped every caller repo-wide (not just packages/core):

  • git grep -E 'apply_remote_embeddings|embeddings_modified_since|upsert_embeddings_with_origin' found only the definitions, the wrappers and core tests. Nothing in daemon, cli, agent, desktop-app or the TypeScript side.
  • The remaining get_embeddings / upsert_embeddings / delete_embeddings callers outside the deleted wrappers all use the store (embedding_service.rs, node_service/crud.rs, tests/it/embedding_service_test.rs, tests/it/search_result_scaling_test.rs, benches/query_crud.rs, examples/seed_search_corpus.rs).
  • nodespace-sync at 17f9557 has no call to any of them. This PR breaks nothing there.
  • The GetEmbeddingStatus gRPC endpoint is an unrelated queue-status call and is untouched.

Deviations from the issue text

  • Ratchet baselines not edited. scripts/check-pro-boundary.ts is not on origin/main yet (it is still in review). I ran the unmerged script from the ratchet branch against origin/main and against this branch; it exits 0 on both. Once it lands, its one-way check only prints a notice for the drop below, so the ceilings can be tightened in any later change.
  • Extra assertion. fresh_database_gets_the_complete_current_schema now also asserts node.sync_seq exists, since the acceptance criteria call for both columns to survive.
  • Manual app check not run. I did not launch the dev app against a database built by the current release. The equivalent evidence: the executable SQL in SCHEMA_SQL differs from origin/main only by the removed CREATE INDEX (checked by diffing the statements with comments stripped), no edited comment contains ;, and a_database_that_still_has_idx_emb_modified_opens runs create_schema over a database holding the old index. The embedding generation and semantic search paths are covered by embedding_service_test (all passing).

Ratchet delta (script from the ratchet branch, origin/main vs this branch)

marker before after
cloudSyncHooks 15 4
cloudWording 82 74
proWording 300 294

Every other marker is unchanged. The 4 remaining cloudSyncHooks hits are get_multi_membership_edges, not this seam.

Tests

  • db::sqlite_store::tests::test_get_embeddings_roundtrip (renamed from ..._and_modified_since): keeps the chunk round-trip and empty-read assertions and adds a raw SELECT origin FROM embedding assertion that upserted rows store local.
  • schema_test::a_database_that_still_has_idx_emb_modified_opens (new): runs create_schema, creates idx_emb_modified by hand, runs create_schema again and asserts Ok and that the index is left in place.
  • schema_test::fresh_database_gets_the_complete_current_schema: keeps the origin assertion with its new message, adds node.sync_seq, and drops idx_emb_modified from the expected index list. Deleted embedding_modified_index_leads_on_origin.

Mutation checks (each applied, run, then reverted)

mutation result
origin column default changed to 'remote' test_get_embeddings_roundtrip fails
node.sync_seq removed from the DDL fresh_database_gets_the_complete_current_schema fails
placeholder stride changed back to i * 14 test_get_embeddings_roundtrip and test_upsert_embeddings_batches_across_chunk_boundary fail (Failed to insert embeddings batch)
create_schema drops the legacy index a_database_that_still_has_idx_emb_modified_opens fails on the "left in place" assertion
create_schema refuses a database holding the legacy index a_database_that_still_has_idx_emb_modified_opens fails on the create_schema call

Verification run

  • cargo clippy -p nodespace-core --all-targets -- -D warnings -D clippy::unused-async: clean.
  • cargo fmt -p nodespace-core --check: clean.
  • bun run test:changed (Rust workspace nextest plus scripts tier): passed.
  • 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.

🤖 Generated with Claude Code

@mstomar125

Copy link
Copy Markdown
Contributor Author

Review Type: Initial Review

Code Review Summary

Clean, well-scoped deletion. I verified the risky parts independently rather than relying on the PR description: the 13-param insert lines up exactly, the executable SCHEMA_SQL is unchanged apart from the removed index, no edited comment contains ;, and nothing in core, the rest of the repo, or nodespace-sync (17f9557) calls the deleted API. Net positive. No blockers; one small test-coverage suggestion and a few doc nits.

Requirements Check (issue #3337)

  • ✅ git grep -n -E 'apply_remote_embeddings|embeddings_modified_since|upsert_embeddings_with_origin' (whole repo, not just packages) prints nothing.
  • ✅ git grep -n idx_emb_modified prints only the new legacy-index test (packages/core/tests/it/schema_test.rs:134-156).
  • ✅ NodeService has no embedding read/write wrappers. Remaining embedding fns in node_service/embedding.rs are set_embedding_waker, get_embedding_root_id, and the queue_* fns; none read or write the embedding table.
  • ✅ Embedding generation and search paths unchanged. Store signatures (upsert_embeddings, get_embeddings, delete_embeddings) are unchanged, and the remaining callers all use the store: embedding_service.rs:403,452,1072, crud.rs:3031, tests/it/embedding_service_test.rs, tests/it/search_result_scaling_test.rs, benches/query_crud.rs, examples/seed_search_corpus.rs. git grep -w for the three names finds no caller of a NodeService method anywhere (daemon, cli, agent, desktop-app, scripts, skill, proto).
  • ✅ Fresh DB keeps embedding.origin and node.sync_seq, and a new row stores origin = 'local' (sqlite_store/mod.rs:2081-2098, schema_test.rs:69-83).
  • ✅ A DB that still has idx_emb_modified passes create_schema and keeps the index (schema_test.rs:137-158).
  • ✅ SCHEMA_SQL executable statements differ from origin/main only by the removed CREATE INDEX. I extracted the DDL from both revisions with comments stripped and diffed them: exactly one line differs, the idx_emb_modified statement. The two new comments (schema.rs:49-50, schema.rs:127-129) contain no ;. expected_shape/find_shape_mismatches derive from the DDL's columns only, and the node and embedding column sets are unchanged, so the shape check is unaffected.
  • ✅ No #[allow(...)], no #[deprecated], no compat shim, no issue numbers in added comments (grepped the added diff lines).
  • ⚠️ Ratchet: scripts/check-pro-boundary.ts is not on origin/main (confirmed: git ls-tree origin/main scripts/check-pro-boundary.ts is empty), so BASELINES could not be edited. Reasonable and disclosed; the ratchet only prints a notice for a drop, so the ceilings can be tightened in the next change that touches it.
  • ✅ Core builds and tests: I did not run them (shared machine), but the author reports clippy, fmt, nextest and test:changed green.
  • 📝 Manual app check against a release-built DB was not run (disclosed). The equivalent evidence above is sound: the shape check is column-based and the columns are untouched.

Placeholder arithmetic (sqlite_store/embeddings.rs:76-105), counted by hand:

  • Params vector: id, node_id, vector, dimension, model_name, chunk_index, chunk_start, chunk_end, total_chunks, content_hash, token_count, created_at, modified_at = 13.
  • Template: 11 ?{} + literals 0, 0, NULL + 2 ?{} = 13 bound placeholders, fed by base+1 .. base+13 (13 args). Stride i * 13.
  • Column list = 16 columns (11 bound + stale, error_count, last_error literals + created_at, modified_at), and the 16 value slots map 1:1 in order. Correct.

Findings

Critical Issues

None.

Suggested Improvements

  • 🟡 packages/core/src/db/sqlite_store/mod.rs:2052-2108 (test_get_embeddings_roundtrip): the round-trip asserts node, chunk_index, vector, stale and origin, but never dimension, model_name, chunk_start, chunk_end, total_chunks, token_count. Those are exactly the columns whose positional binding this PR just rewrote (the params vector and the column list are two hand-aligned lists), and no other test in packages/core asserts them after a store round trip (content_hash is pinned only indirectly by the rootness-refresh test in node_service/mod.rs:4013-4018). The existing mutation checks cover the stride but not a column/params order slip. The test already sets total_chunks = 2 and unit_embedding sets model_name = "test-model", chunk_end = 100, token_count = 10, so a few extra assert_eq! lines on got[0]/got[1] would pin the whole 13-param contract cheaply. Not blocking (pre-existing gap, and the current code is correct by my count).

Nitpicks

  • Nit: packages/core/src/db/sqlite_store/embeddings.rs:194-196: the get_embeddings doc says it "works whether or not embedding generation is compiled in". That was the justification for the deleted NodeService wrapper's nlp-feature framing. On a store method it says nothing useful, so it could be dropped.
  • Nit: packages/core/src/db/sqlite_store/embeddings.rs:144: "Column order must match the SELECTs below" is now a single SELECT (get_embeddings is the only row_to_embedding caller). Reads better as "the SELECT below".
  • Nit: packages/core/tests/it/schema_test.rs:44: the fresh_database_gets_the_complete_current_schema doc still presents embedding.origin as something "a naive collapse would silently drop". It is now a deliberately unused legacy column kept only for the shape check, so the sentence is slightly misleading. Optional reword.

Coverage lost (assessed, acceptable)

The removed tests covered only behaviour that no longer exists (push cursor, origin = 'remote' exclusion, idx_emb_modified query plan, the deleted NodeService wrappers). The live behaviour they incidentally exercised (chunk round-trip, empty read, delete, batch across the 60-row boundary) is still covered by test_get_embeddings_roundtrip, test_upsert_embeddings_batches_across_chunk_boundary (130 rows, spans three insert batches so it exercises base = i * 13 past the first row) and the store-level delete tests. The new a_database_that_still_has_idx_emb_modified_opens pins both failure modes that matter: create_schema rejecting a DB that has the legacy index, and create_schema dropping it.

nodespace-sync

grep -rnw in /Users/mayanktomar/nodespace/sync (17f9557) for apply_remote_embeddings|embeddings_modified_since|get_embeddings|upsert_embeddings|delete_embeddings|idx_emb_modified finds no caller, and no raw SQL touching the local embedding.origin or node.sync_seq columns (the sync_seq hits there are the server-side cursor). No breakage.

Recommendation

APPROVE — no blockers. The test-assert addition is worth a quick follow-up in this PR since it is a few lines, but it should not hold the merge.

@mstomar125 mstomar125 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Automated pragmatic-code-review: APPROVE (posted as a comment, GitHub blocks self-approval). Full findings in the review comment above.

@mstomar125
mstomar125 force-pushed the issue-3337-embedding-seam branch from 14e023e to 8cd7f3b Compare September 30, 2026 10:33
@mstomar125

Copy link
Copy Markdown
Contributor Author

Address-review summary

The review verdict was APPROVE with no blockers. One improvement and three nits came back. All four were addressed in Pin every bound embedding column in the store roundtrip test.

Addressed (4 of 4)

  • Improvement, test_get_embeddings_roundtrip (sqlite_store/mod.rs): now asserts dimension, model_name, chunk_start, chunk_end, total_chunks, content_hash and token_count on both chunks. Chunk 1 now uses chunk_start = 100 and chunk_end = 200, so each bound column has a distinct value and a transposed pair cannot pass. This pins the positional contract between the insert's column list and its params vector, which this PR rewrote.
  • Nit, get_embeddings doc: dropped the "works whether or not embedding generation is compiled in" sentence, which only made sense for the deleted NodeService wrapper.
  • Nit, row_to_embedding doc: "the SELECTs below" is now "the SELECT below", since get_embeddings is the only caller.
  • Nit, schema_test.rs doc: reworded so embedding.origin and node.sync_seq read as unused legacy columns kept for the shape check, not as tables a naive collapse would drop.

Mutation check of the new assertions (each applied, run, reverted; the restored tree passes):

mutation result
swap the chunk_start and chunk_end params test_get_embeddings_roundtrip fails (chunk_start 100, expected 0)
swap the total_chunks and token_count params fails (total_chunks 10, expected 2)
swap the model_name and content_hash params fails (model_name "hash-0", expected "test-model")
swap the dimension and chunk_index params fails

Skipped: none.

Verification after the change: cargo clippy -p nodespace-core --all-targets -- -D warnings -D clippy::unused-async clean, cargo fmt -p nodespace-core --check clean, bun run test:changed passed (Rust workspace nextest plus scripts tier). The branch was then rebased onto current main (the desktop crate split), with no conflicts and no seam symbols in the relocated code.

Re-Review Decision

Decision: NO RE-REVIEW NEEDED

Rationale: the follow-up commit adds test assertions and edits three comments. It changes no production logic, so nothing new needs a second reviewer pass. The production diff is identical to the one that was reviewed.

mstomar125 and others added 2 commits September 30, 2026 12:39
Nothing calls the cloud embedding sync API any more: the NodeService
get/upsert/delete/apply_remote/modified_since wrappers were used only by
core's own tests, and nodespace-sync stopped syncing embeddings.

- Delete the five NodeService embedding wrappers. Tests read and write
  through NodeService::store() instead.
- Delete SqliteStore::apply_remote_embeddings and embeddings_modified_since,
  and fold upsert_embeddings_with_origin into upsert_embeddings. The insert
  no longer names `origin`, so new rows take the column default 'local'.
  The row placeholder builder goes from 14 params to 13.
- Drop idx_emb_modified from the DDL. Existing databases keep the index,
  and a new test pins that create_schema still opens one that has it.
- Keep embedding.origin and node.sync_seq. create_schema's shape check
  compares column names, so dropping either would refuse every database an
  earlier build created. Both are now commented as unused legacy columns.
- Rename the store roundtrip test, drop its cursor, provenance and query
  plan sections, and assert a new row stores origin 'local'.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
The upsert's column list and params vector are two hand-aligned lists. The
roundtrip test now asserts dimension, model_name, chunk_start, chunk_end,
total_chunks, content_hash and token_count, with distinct values per column
so a transposed pair fails. Also tighten three comments that still read as
if the removed NodeService wrappers and a second SELECT existed.

Co-Authored-By: Claude Sonnet 5 <[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.

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

1 participant