6.9 KiB
Semantic Vector Index Integration Plan
Status: Proposed (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-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/search
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 tests and policy guards
Exit:
- interface tests pass
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
- Approve local-only (non-synced embeddings) as Phase A baseline.
- Finalize field-level allowlist/denylist defaults with security review.
- Implement Phase A core scaffolding behind feature flag:
semantic_index_enabled(defaultfalse)
- Add CLI
seedpass semantic status/build/rebuild/searchas first user-facing slice.