Skip to content

fix(search): keep mental-model derived state current - #3313

Open
JiehoonKwak wants to merge 1 commit into
vectorize-io:mainfrom
JiehoonKwak:codex/fix-mental-model-search-lifecycle
Open

fix(search): keep mental-model derived state current#3313
JiehoonKwak wants to merge 1 commit into
vectorize-io:mainfrom
JiehoonKwak:codex/fix-mental-model-search-lifecycle

Conversation

@JiehoonKwak

@JiehoonKwak JiehoonKwak commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • rebuild a mental model's embedding from the canonical stored name + content document on both name-only and content-only updates
  • re-embed the name-only document and refresh the VectorChord lexical projection when content is cleared
  • atomically synchronize a Knowledge Page rename with its backing mental-model name, embedding, and lexical projection

Root cause

After #3318, VectorChord lexical projections are written on normal create/update paths, but partial updates can still derive dense search state from incomplete text. Name-only updates do not re-embed, clear leaves the old dense vector searchable, and a Knowledge Page rename changes only knowledge_pages.name while its searchable backing row retains the old name.

The fix resolves the complete stored document before embedding, keeps provider calls outside pooled database connections, and reuses the shared pg_search_vector_expr() helper added upstream for the only application-maintained lexical column (VectorChord). Native PostgreSQL updates its generated column; the other backends index base columns.

Part of #3307.

Scope

This PR intentionally does not change Knowledge Page query dispatch, runtime backend reconciliation, or perform an in-place text-backend conversion. #3318 owns query dispatch; safe PGroonga physical reconciliation is a separate atomic change.

Verification

  • ./scripts/hooks/lint.sh (Ruff, formatting, ty, ESLint/Prettier): passed
  • related mental-model CRUD, clear, and Knowledge Page move/rename/delete tests: 17 passed
  • new regressions cover name-only and content-only canonical embedding input, clear, and page-rename synchronization

Build embeddings and VectorChord lexical projections from the same canonical name-plus-content document for partial updates and clears. Keep Knowledge Page renames synchronized with their backing mental model so dense and lexical search state cannot silently retain the old page name.\n\nThis narrows the former PR after upstream vectorize-io#3318: backend query dispatch and schema reconciliation are intentionally excluded and will be handled separately.\n\nContext:\n- vectorize-io#3318 now owns backend-neutral Knowledge Page search dispatch.\n- Name-only and content-only writes previously embedded incomplete text.\n- Clear and page rename left dense embeddings stale.\n- Provider calls remain outside pooled database connections.
@JiehoonKwak
JiehoonKwak force-pushed the codex/fix-mental-model-search-lifecycle branch from 0ce205f to 395e410 Compare August 10, 2026 11:36
@JiehoonKwak JiehoonKwak changed the title fix(search): maintain mental-model search state fix(search): keep mental-model derived state current Aug 10, 2026
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.

1 participant