Skip to content

Phase 2: embedded store + context injection - #8

Merged
dkritarth merged 3 commits into
mainfrom
copilot/add-embedded-store-context-injection
Apr 11, 2026
Merged

Phase 2: embedded store + context injection#8
dkritarth merged 3 commits into
mainfrom
copilot/add-embedded-store-context-injection

Conversation

Copilot AI commented Apr 11, 2026

Copy link
Copy Markdown

Implements Module 2 / Phase 2 from the super-ollama plan: a local SQLite-backed data store with semantic vector search, wired into every inference path for automatic context injection.

internal/store (new)

  • SQLite via modernc.org/sqlite (pure Go, no CGO) — auto-migrates a 4-table schema (events, emails, todos, contacts) on Open()
  • Embedder interfacestore.Embedder decouples embedding generation from the store; wired post-open via SetEmbedder()
  • Vector search — embeddings stored as JSON BLOBs; Search() / SearchSummaries() run in-process cosine similarity ranking (no external vector DB)
  • SaveInteraction() — persists every prompt/response pair as a source='interaction' event for future retrieval
  • Full CRUD: InsertEvent, InsertEmail, UpsertTodo, UpsertContact, UpdateEventEmbedding, EventsWithoutEmbedding

internal/engine — context-aware inference

// Generates a float32 embedding via the in-process EmbedHandler
emb, err := eng.Embed(ctx, "nomic-embed-text", text)

// Retrieves top-10 similar events, prepends as context, saves interaction
resp, err := eng.GenerateWithContext(ctx, model, prompt, prompt, nil, store)

ContextSearcher interface keeps engine independent of store (no import cycle).

internal/config — new fields

embedding_model (default: nomic-embed-text) and db_path (default: ~/.super-ollama/data.db) with ResolvedDBPath() expanding ~.

CLI changes

  • learn command (was stub) — iterates EventsWithoutEmbedding, calls Embed(), persists results; respects SIGINT
  • ask / chat — open store on startup, inject semantic context per turn; degrade gracefully if store is unavailable
  • config show — now prints embedding_model and db_path

Tests

12 unit tests in internal/store using in-memory SQLite (:memory:), covering schema migration, all CRUD paths, cosine similarity correctness, SearchSummaries, and SaveInteraction.

Copilot AI linked an issue Apr 11, 2026 that may be closed by this pull request
Copilot AI and others added 2 commits April 11, 2026 14:05
- Add internal/store package: SQLite (modernc.org/sqlite), schema
  migrations, CRUD operations for events/emails/todos/contacts,
  cosine similarity vector search, and Embedder interface.
- Add SearchSummaries() and SaveInteraction() for engine.ContextSearcher.
- Add Embed(), GenerateWithContext(), ChatWithContext() to engine.
- Add ContextSearcher interface to engine (no circular dependency).
- Update internal/config: add EmbeddingModel, DBPath fields.
- Wire store context injection into ask/chat commands.
- Implement learn command (re-index events missing embeddings).
- Unit tests: 12 tests covering all CRUD, vector search, interface methods.

Agent-Logs-Url: https://github.com/Kritarth-Dandapat/super-ollama/sessions/a33144a1-c45f-4fe3-84de-acf2a6756c28

Co-authored-by: Kritarth-Dandapat <141005022+Kritarth-Dandapat@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Kritarth-Dandapat/super-ollama/sessions/a33144a1-c45f-4fe3-84de-acf2a6756c28

Co-authored-by: Kritarth-Dandapat <141005022+Kritarth-Dandapat@users.noreply.github.com>
Copilot AI changed the title [WIP] Add embedded store and context injection for Phase 2 Phase 2: embedded store + context injection Apr 11, 2026
Copilot AI requested a review from dkritarth April 11, 2026 14:09

@dkritarth dkritarth left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Verified locally: go test ./... -count=1 passes on macOS (PR branch). Internal/store + engine + server packages OK.

@dkritarth
dkritarth marked this pull request as ready for review April 11, 2026 14:56
@dkritarth
dkritarth merged commit 30bc260 into main Apr 11, 2026
5 of 8 checks passed
@dkritarth
dkritarth deleted the copilot/add-embedded-store-context-injection branch April 11, 2026 14:56
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.

Phase 2: embedded store + context injection

2 participants