feat(documents): add semantic attachment search - #664
Conversation
roborev: Combined Review (
|
|
@wesm can you take this over and finish it off from here? The current branch is pushed as-is. Remaining work is the main-branch conflict plus the outstanding RoboRev and PostgreSQL CI issues. |
|
Yes, I'm on it |
71bd914 to
0886c23
Compare
roborev: Combined Review (
|
0886c23 to
e0b5eb8
Compare
roborev: Combined Review (
|
roborev: Combined Review (
|
roborev: Combined Review (
|
roborev: Combined Review (
|
|
Hey @salmonumbrella — thanks again for the substantial work on #664. During final review we compared the branch with the document-understanding packages that have now landed in Docbank. We found that this branch necessarily chooses and fingerprints a document embedding recipe and retrieval policy locally. Those are cross-project contracts: if we merge them only in msgvault now, Docbank and msgvault will drift, or we will require a full re-embedding and compatibility transition later. Our intent is therefore to pause merging #664 while we define and evaluate the storage-neutral EmbeddingPlan and shared retrieval rules in Docbank, then update this PR to consume those contracts. This PR remains the working integration vehicle and the basis of the feature; this is not a rejection or restart. Msgvault will continue to own attachment/message occurrence mapping, consent enforcement, provenance and filtering, scheduling, publication authority, and its CLI/API/MCP surfaces. The shared Docbank work will cover deterministic semantic preparation, recipe identity, provider request safety, and common retrieval behavior. This will add some time and reshape parts of the diff. We will link the Docbank work here and coordinate the rebase/refactor instead of asking you to chase implementation-specific review feedback that may shortly be superseded. |
|
@wesm I paused implementation and opened kenn-io/docbank#176 so we can align the ownership boundary before either repository hardens a conflicting contract. It contains the complete provider-neutral design spec and all four implementation plans: evidence/Markdown/catalog, provider runtime and self-hosted Docling, embeddings/retrieval, and operator/consumer surfaces. The main question is explicit there. Our proposed direction makes Docbank the optional durable authority for a file's sanitized Markdown, normalized evidence, embedding sets, corpus index, and document-candidate retrieval. Msgvault would keep attachment/message occurrence mapping, source visibility, mirroring orchestration, and presentation. Your comment here describes Msgvault retaining publication authority with Docbank providing the shared semantic contracts. Could you review #176 and say which side of that boundary you intend? We will hold the Docbank foundation implementation until that is settled, then update #664 against the agreed contract instead of creating another re-embedding transition. |
roborev: Combined Review (
|
649365f to
81af514
Compare
81af514 to
68845d3
Compare
roborev: Combined Review (
|
roborev: Combined Review (
|
roborev: Combined Review (
|
roborev: Combined Review (
|
roborev: Combined Review (
|
roborev: Combined Review (
|
roborev: Combined Review (
|
roborev: Combined Review (
|
roborev: Combined Review (
|
roborev: Combined Review (
|
dbd98ef to
02c7dbe
Compare
roborev: Combined Review (
|
Add optional lexical, semantic, and hybrid search over indexed attachment text, with generation-based activation so incomplete vector builds never replace the active corpus. Use Docbank's released normalized-document and embedding contracts as the shared source of truth. Keep document and query egress consent separate, reject redirects, and page vector candidates until scoped retrieval is complete and accurately bounded. This also: - shares the document-vector CLI consent command and routing - stabilizes generation, endpoint, and provider identity - preserves provenance through bounded hybrid fusion - updates the Go and Nix dependency closures for Docbank's Go 1.27 requirement - makes vector builds converge safely - rejects stale normalized identity and invalid embedding policy - makes malformed provider responses terminal - makes semantic paging exhaustive and stable - decouples retired cleanup from consent - exposes vector status and coherent hybrid evidence - keeps restore and cleanup recoverable - preserves lexical search depth and store-native pagination - refreshes the generated document-search client Generated with Codex Co-authored-by: Wes McKinney <wesmckinn+git@gmail.com> Co-authored-by: Codex <noreply@openai.com>
02c7dbe to
5b7835c
Compare
roborev: Combined Review (
|
Cron and post-sync convergence can run at the same time in one SQLite daemon. The archive ownership lock only excludes other processes, so both passes could mutate the same generation concurrently. Serialize the existing SQLite operation boundary in process. PostgreSQL retains its schema-wide advisory lock. Generated with Codex Co-authored-by: Codex <noreply@openai.com>
roborev: Combined Review (
|
Semantic candidate collection spans provider and backend calls. An activation or reindex during that window can apply new authority to old hits and silently return a partial response. Revalidate the active generation, target, fingerprint, and document revision after collection. Return the existing stale-cursor signal so clients can retry deliberately without automatic duplicate query egress. Generated with Codex Co-authored-by: Codex <noreply@openai.com>
roborev: Combined Review (
|
Attachment documents can now be searched lexically, semantically, or with deterministic hybrid ranking. Vector generations build behind the active corpus and become visible only after exact coverage is complete, so interrupted or replacement builds never expose a partial index.
Build failures are isolated to the affected extraction. A malformed provider result no longer poisons healthy documents later in the batch, and input-preparation failures follow the same bounded retry and terminal-diagnostic lifecycle as provider failures. A generation with terminal failures is reported as blocked instead of appearing to make silent progress; operators can inspect it, retry failed work, or retire it while the prior active generation remains searchable.
Archives upgraded from older extraction storage must run
msgvault documents build --full-rebuild --capabilities <manifest> --yesbefore document-vector consent or build. Their missing normalized identity is not guessed or backfilled, and newly published extractions must carry the current Docbank identity.PostgreSQL holds an archive-scoped advisory lock across ledger and backend mutations, fencing daemon and local command writers from deleting a vector another process just republished. SQLite continues to rely on its archive ownership lock. Because document vectors have not shipped, the final table and constraint shapes live directly in the base schemas; there are no upgrade-only repair paths for unreleased layouts.
The document lane consumes Docbank v0.14.0's normalized-document, embedding-plan, retrieval, and egress-identity contracts rather than maintaining parallel implementations. Msgvault persists enough normalized identity to reconstruct the Docbank raw embedding plan, pages vector backends until the scoped candidate bound is satisfied, and preserves attachment, message, person, source-unit, model, generation, rank, score, excerpt, and highlight provenance through fusion. Because scope metadata remains in Msgvault, pageable candidate collection uses exact distance ordering; this favors complete scoped results over approximate nearest-neighbor speed until scope can move into the backend query.
Hosted processing has two independent consent boundaries:
semanticorhybridsearches.autoremains lexical and causes no query egress.Both paths reject redirects and revalidate the exact endpoint/model policy before each request. SQLite/sqlite-vec and PostgreSQL/pgvector implement the same generation and paging lifecycle; builds without vector support fail closed only when an embedding operation is requested.
With
[vector],[vector.embeddings], and[attachments.documents.index.embeddings]configured, review and record each disclosure separately:msgvault documents vectors consent --purpose documents --yes msgvault documents vectors consent --purpose queries --yes msgvault documents vectors build --limit 100 msgvault documents vectors status msgvault documents search "signed inspection notes" --mode hybrid --candidate-limit 100Rebuilds keep the prior generation searchable until atomic activation. Operators can use
resume,retry,retire, andstatusfor bounded recovery and cleanup.This is the document-semantic foundation consumed by #668. It remains separate from the visual attachment lane in #650 and does not mix document vectors with visual vectors or ordinary message-search ranking.
Closes #617