8.5 KiB
Semantic Vector Index Integration Plan
Status: In Progress (updated 2026-03-02)
Branch target: beta
Scope: Legacy TUI + Textual TUI v2 + CLI + API
1) Goal
Add semantic retrieval for knowledge-base content (documents, notes, titles, tags, graph context) without changing SeedPass canonical sync semantics or deterministic secret generation behavior.
2) Key Decision
Use a local derived vector index per profile/device.
Do not sync embeddings in Phase 1.
Canonical vault/index data remains the only synced source of truth. Vectors are a rebuildable cache derived from synced data.
3) Why Local-Only First
- Privacy: embeddings can leak semantic content.
- Portability: embedding model/version drift across devices is common.
- Stability: avoids index incompatibility in cross-device sync.
- Simplicity: no changes required to existing sync payload schema.
4) Data Eligibility Policy
Default include (non-secret KB-centric):
label/ titlenotesdocumentcontent- tags
- graph link metadata (relation + note + neighbor label where available)
Default exclude:
- generated secrets and private key material
- seed phrases
- TOTP secrets/codes
- high-risk private fields
Policy controls:
- per-kind index enable/disable
- optional per-field allowlist/denylist
- respect lock/session constraints for retrieval paths
5) Architecture
5.1 New Core Components
seedpass.core.semantic_index:
- chunking/normalization
- embedding adapter interface
- local vector store adapter
- metadata schema/versioning
SemanticIndexService(thread-safe wrapper):
- rebuild profile index
- incremental upsert/remove
- semantic search API
- health/status/report
5.2 Storage
Per-profile local path (example):
~/.seedpass/<fingerprint>/semantic_index/
Artifacts:
- vector store files
- index manifest (
model_id, dimensions, schema version, timestamps) - source hash map for incremental updates
5.3 Event Hooks
Index updates on:
- entry add/modify/archive/restore/delete
- tag/field/link operations that change indexable content
- profile switch/load/import sync completion
6) Sync and Lifecycle Model
On new device/profile bootstrap:
- run existing sync/import
- mark semantic index stale/unbuilt
- trigger background build
- expose build progress/status
On incremental change:
- compute affected entry IDs
- re-embed changed chunks only
- upsert vectors + metadata
On model/schema change:
- invalidate manifest
- rebuild full local index
7) Interface Integration
7.1 Legacy TUI
Add settings + search affordances:
Semantic Search: on/offRebuild semantic indexSemantic index status- search mode toggle: keyword vs hybrid (keyword + semantic)
7.2 Textual TUI v2
Palette commands:
semantic-statussemantic-enable/semantic-disablesemantic-buildsemantic-rebuildsemantic-search <query>search-mode <keyword|hybrid|semantic>
UI surfaces:
- top ribbon indicator (
SEM: ready/building/stale/off) - results annotation showing semantic score + matched context
7.3 CLI
Proposed command group:
seedpass semantic ...
Commands:
seedpass semantic statusseedpass semantic buildseedpass semantic rebuildseedpass semantic search "<query>" --k N --kind document --jsonseedpass semantic config --enabled true --mode hybrid
7.4 API
Proposed endpoints:
GET /api/v1/semantic/statusPOST /api/v1/semantic/buildPOST /api/v1/semantic/rebuildPOST /api/v1/semantic/searchPOST /api/v1/semantic/config
Request examples:
- query text
- filters (
kinds, tags, archive scope) - mode (
semantic,hybrid)
Response includes:
- entry ID and summary
- semantic score
- matched chunk excerpt
- optional graph-neighbor IDs
8) Search Strategy
Default: hybrid retrieval.
Pipeline:
- lexical pre-filter (existing search/tags/kind/archive)
- semantic top-k retrieval
- lightweight rerank combining lexical + semantic + graph proximity
- return ranked candidates
9) Security and Privacy Controls
- Explicit opt-in toggle per profile.
- High-risk kinds excluded by default.
- Index files encrypted at rest if feasible through existing vault keying; if not in first cut, keep local-only and document risk explicitly.
- No embeddings in sync payload by default.
- Honor lock state: semantic retrieval disabled or restricted while locked.
- Audit log events for semantic build/rebuild/search in agent/API contexts.
10) Determinism and Invariants
SeedPass deterministic artifact rules remain unchanged for secrets/keys/totp derivations.
Semantic index is a derived retrieval cache and:
- must never influence cryptographic derivation outputs
- must never alter canonical vault records as source-of-truth
- must be safe to delete/rebuild at any time
11) Testing Plan
Unit tests:
- chunking and field-selection policy
- incremental update diffing
- model/schema invalidation and rebuild triggers
Integration tests:
- new profile bootstrap -> build triggered
- synced import -> index rebuild path
- CRUD updates -> incremental upsert/remove
- lock mode behavior
Interface tests:
- legacy TUI semantic status/build/search controls
- TUI v2 palette semantic commands
- CLI semantic command suite
- API semantic endpoints and auth guards
Scale tests:
- semantic retrieval latency and memory usage over KB stress datasets
- hybrid ranking quality smoke checks
12) Rollout Phases
Phase A: Core scaffolding (no UI)
- add service interfaces + local store abstraction
- add index manifest + per-profile storage layout
- add offline build/rebuild/status operations
Exit:
- CLI-only smoke works (
semantic status/build/search)
Phase B: CLI + API
- expose semantic commands in CLI
- expose semantic endpoints in API
- add initial tests for core + CLI + API
- add lock/policy guard refinements for high-risk partitions and audit logging
Exit:
- interface tests pass for current endpoints/commands
- audit and lock-policy behavior validated end-to-end
Phase C: TUI integration
- wire legacy TUI settings/search hooks
- wire TUI v2 palette commands + ribbon/status indicators
- add hybrid search mode toggles
Exit:
- both TUIs can build/check/search semantic index reliably
Phase D: Hardening and optional sync research
- evaluate encrypted local vector store mode
- evaluate optional embedding sync (off by default) with strict policy controls
- add production metrics and runbooks
Exit:
- readiness checklist sign-off
13) Open Decisions
- Embedding model/runtime choice and offline availability constraints.
- On-disk vector backend selection.
- Whether encrypted-at-rest vector files are mandatory in Phase A or phased into hardening.
- Whether semantic search is enabled-by-default for new profiles or opt-in.
14) Recommended Immediate Next Steps
- Complete Phase C integration in both TUIs (
semantic-status/build/rebuild/search+ status indicator). - Add incremental update hooks on entry/link/tag mutations (avoid full rebuild for small edits).
- Expand hybrid ranking quality and retrieval relevance validation on KB stress datasets.
- Add audit logging and lock-policy tests for semantic operations in agent/API contexts.
- Run KB scale benchmark with semantic index enabled and record latency/memory evidence.
15) Progress Snapshot (2026-03-02)
Implemented:
seedpass.core.semantic_indexlocal derived index with profile-local manifest/records.semantic_index_enabledprofile config flag and config service wrappers.SemanticIndexServicein core API layer.- CLI commands:
seedpass semantic status|enable|disable|build|rebuild|searchseedpass semantic config --enabled <true|false> --mode <keyword|hybrid|semantic>
- API endpoints:
GET /api/v1/semantic/statusPOST /api/v1/semantic/buildPOST /api/v1/semantic/rebuildPOST /api/v1/semantic/searchPOST /api/v1/semantic/config
- Initial tests for core service/index, CLI commands, and API endpoints.
- Semantic search mode support:
- profile config key
semantic_search_mode(keyword|hybrid|semantic) - API
semantic/searchmode override - API
semantic/configmode updates - TUI v2
search-modecommand + ribbon mode indicator - legacy TUI semantic submenu mode setter
Not yet implemented:
- True embedding backend and vector DB adapter (current implementation is token-overlap baseline).
- Incremental mutation hooks (entry/tag/link CRUD triggers).
- Audit/logging policy hardening and lock-state behavior validation.