feat: embedding providers, code quality fixes, and comprehensive test coverage - #1
Merged
Conversation
Add Section 8 to the OMS specification defining: - EmbeddingProvider trait with embed_texts, embed_query, dimensions, model_id - Three provider types: local (in-process), remote (OpenAI-compatible), noop - Server-side auto-embedding on write (create/update) and search - Client-supplied embeddings always take priority over auto-embedding - Dimension validation rejects mismatched caller-provided vectors Signed-off-by: David Justice <david@justice.dev>
Implement the EmbeddingProvider trait (kd6-core) and three providers: - LocalEmbedder: In-process ONNX via fastembed-rs (all-MiniLM-L6-v2, 384 dimensions). Ideal for local development and testing. - OpenAiCompatibleEmbedder: Calls any /v1/embeddings endpoint (OpenAI, Azure, Ollama, vLLM). Includes error classification (4xx/429/5xx), out-of-order index sorting, and dimension/count validation. - NoopEmbedder: Pass-through that returns errors on embed calls, for deployments where callers manage their own embeddings. Also adds auto_embed_content, auto_embed_query, and auto_embed_update helpers in kd6-core that skip embedding when a provider is noop or when the caller supplies their own vectors. Includes 20 unit tests for kd6-core embedding helpers (FakeEmbedder) and 13 wiremock-based tests for the OpenAI-compatible provider. Signed-off-by: David Justice <david@justice.dev>
Address correctness issues in the SQLite backend: - Upsert scope matching: match all 8 scope columns using COALESCE for NULL-safe comparison, persist scope on UPDATE, return original created_at from database rather than request time - GDPR audit hash integrity: add redacted column to audit_log so hash chain remains verifiable after anonymization (entries are flagged rather than having their hashes broken) - Atomic bubble_up: extract insert_memory_on_conn helper, run both the dedupe check and inserts inside a single BEGIN IMMEDIATE txn - Atomic store provisioning: add get_or_create_store to OmsProvider trait with INSERT OR IGNORE + unique (tenant_id, name) index, eliminating TOCTOU race in resolve_store - Add full-scope upsert index, pagination index, and stores unique constraint via new migration Signed-off-by: David Justice <david@justice.dev>
Wire embedding into both server frontends: HTTP server (kd6-server): - AppState carries Arc<dyn EmbeddingProvider> - Auto-embed on create, update, and search routes - Dimension validation rejects mismatched caller vectors - resolve_store uses atomic get_or_create_store MCP server (kd6-mcp): - Add gdpr_purge tool (10 tools total, spec parity) - Rename graph_traverse → traverse_graph (matches HTTP API) - Normalize response shape (deleted_count → deleted) - CreateMemoryParams accepts serde_json::Value content and scope fields - Expose list_tools() for test introspection Both servers select provider via KD6_EMBEDDING_PROVIDER env var (local | openai-compatible | none). Signed-off-by: David Justice <david@justice.dev>
devigned
force-pushed
the
code-quality-and-embedding
branch
from
June 3, 2026 17:20
a0113e7 to
7c223a3
Compare
Expand test coverage from 77 to 144 tests: kd6-server (47 tests): - Embedding integration: auto-embed on write, search, update - Dimension validation rejects mismatched caller vectors - Caller-supplied embeddings preserved (not overwritten) - Vector search returns scored results - Structured content with arrays embeds correctly - Inheritance create/delete and bubble-up - Shared space lifecycle (create, join, leave, delete) - Noop embedder pass-through behavior kd6-mcp (17 tests): - All 10 tools exercised end-to-end - MCP tool registration and server info smoke tests - GDPR purge with selective agent data removal - Error handling for invalid UUIDs and missing resources All tests use deterministic FakeEmbedder (3-dim, no model downloads) to ensure fast, reproducible CI runs. Also updates copilot-instructions.md with current tool count and adds Squad/LangChain validation scaffold. Signed-off-by: David Justice <david@justice.dev>
devigned
force-pushed
the
code-quality-and-embedding
branch
from
June 3, 2026 17:23
7c223a3 to
d91ec78
Compare
Add Makefile with targets mirroring CI: - make ci: fmt-check → lint → build → test (use before every push) - make fix: auto-format then run lint/build/test - make run-server / make run-mcp: convenience targets Update CI workflow to use 'make ci' so local and CI run identical steps in the same order. Signed-off-by: David Justice <david@justice.dev>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds server-side embedding support, fixes critical correctness issues found through two rounds of code quality analysis, and significantly expands test coverage.
Embedding Providers (OMS Spec Section 8)
/v1/embeddingsendpoint (OpenAI, Azure, Ollama, vLLM)P0 Correctness Fixes
scope_tenant_id)redactedcolumn so hash chain remains verifiable after anonymizationP1 Fixes
graph_traverse→traverse_graph(matches HTTP API)get_or_create_storewith INSERT OR IGNORE eliminates TOCTOU racedeleted_count→deletedTest Coverage
Spec Updates