Skip to content

Embedding write-wrappers for cloud pull apply (core, sync #97 PR3) - #1417

Merged
mstomar125 merged 1 commit into
NodeSpaceAI:mainfrom
mstomar125:issue-97-core-embedding-write-api
Jun 15, 2026
Merged

mstomar125 merged 1 commit into
NodeSpaceAI:mainfrom
mstomar125:issue-97-core-embedding-write-api

Conversation

@mstomar125

Copy link
Copy Markdown
Contributor

What

Core half of the pull slice of NodeSpaceAI/nodespace-sync#97. The push half (sync #178, merged) used the read API from #1416; the pull half needs to apply vectors synced from another device into the local store, but upsert_embeddings / delete_embeddings were store-only.

Changes

  • NodeService::upsert_embeddings(node_id, Vec<NewEmbedding>) — replace a node's vectors wholesale (mirrors the local generation path; the symmetric write to Read-embeddings API for cloud push (core half of sync #97) #1416's get_embeddings).
  • NodeService::delete_embeddings(node_id) — clear a node's vectors (for a remote embeddings delete).

Both are deliberately not gated behind nlp, same rationale as the read wrappers: applying a received vector doesn't need the generation engine, so a daemon built without llama-cpp (sync #10) can still receive embeddings. Generation stays #[cfg(feature = "nlp")].

Verification

  • New unit test: upsert a synthetic 768-dim vector via the wrapper → read it back via get_embeddings (round-trip) → delete → assert empty.
  • cargo test (new test green) + cargo clippy --lib clean. Additive only.

Part of NodeSpaceAI/nodespace-sync#97 (PR 3a; PR 3b = the daemon pull: realtime/replay embeddings → these wrappers, + the full two-daemon round-trip harness).

The Pro daemon's upcoming embedding PULL needs to apply vectors synced
from another device into the local store, but `upsert_embeddings` /
`delete_embeddings` were store-only (the read API from #1416 added reads;
this adds the symmetric writes). Surface both as `NodeService` wrappers:

- `NodeService::upsert_embeddings(node_id, Vec<NewEmbedding>)` — replace a
  node's vectors wholesale (mirrors the local generation path).
- `NodeService::delete_embeddings(node_id)` — clear a node's vectors.

Like the read wrappers, both are deliberately NOT behind the `nlp`
feature: applying a received vector doesn't need the generation engine,
so a daemon built without llama-cpp can still receive embeddings.

Test: upsert a synthetic 768-dim vector via the wrapper, read it back via
get_embeddings (round-trip), then delete and assert empty.

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

Copy link
Copy Markdown
Contributor Author

APPROVE ⏳

Initial review, top commit on issue-97-core-embedding-write-api (against main). no checks reported; new test + clippy --lib green per the body. Additive only, 2 files.

The symmetric write half of #1416, and just as clean. I checked the things that could bite a thin wrapper:

✅ Both delegate to real, ungated store methods. store.upsert_embeddings (sqlite_store.rs:2376) and store.delete_embeddings (:2663) both exist and neither is #[cfg(feature = "nlp")] — so the "applies received vectors without the generation engine" claim holds, same as the read wrappers. Error mapping to query_failed matches the #1416 wrappers.

✅ The "empty is a no-op" doc is actually true. I went to confirm it, expecting the usual unconditional DELETE ... WHERE node_id to make an empty upsert silently clear the node — but store.upsert_embeddings early-returns Ok(()) on embeddings.is_empty() before touching anything, so the comment is correct and the clear-vs-no-op footgun isn't there. delete_embeddings is the explicit clear path, and it tears down the vec_embeddings vec0 mirror before the embedding rows (right order, transactional).

✅ Round-trip test exercises the real path — upsert a 768-dim vector via the wrapper, read it back through #1416's get_embeddings (axis-3 round-trips), then delete_embeddings → empty. That's the apply→read→clear cycle the pull side will drive.

Good to merge. This lines up the core surface for PR 3b (the daemon pull: realtime/replay embeddings → these wrappers + the two-daemon round-trip harness), which is where #97 finally gets its end-to-end proof.

@mstomar125
mstomar125 merged commit efb69b3 into NodeSpaceAI:main Jun 15, 2026
malibio pushed a commit that referenced this pull request Jun 22, 2026
#1417)

The Pro daemon's upcoming embedding PULL needs to apply vectors synced
from another device into the local store, but `upsert_embeddings` /
`delete_embeddings` were store-only (the read API from #1416 added reads;
this adds the symmetric writes). Surface both as `NodeService` wrappers:

- `NodeService::upsert_embeddings(node_id, Vec<NewEmbedding>)` — replace a
  node's vectors wholesale (mirrors the local generation path).
- `NodeService::delete_embeddings(node_id)` — clear a node's vectors.

Like the read wrappers, both are deliberately NOT behind the `nlp`
feature: applying a received vector doesn't need the generation engine,
so a daemon built without llama-cpp can still receive embeddings.

Test: upsert a synthetic 768-dim vector via the wrapper, read it back via
get_embeddings (round-trip), then delete and assert empty.

Co-authored-by: Mayank  Tomar <[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.

1 participant