fix(knowledge): sync backing mental_model name on page rename (#3307) - #3407
Merged
Merged
Conversation
rename_knowledge_node updated knowledge_pages.name only, leaving the backing mental_models.name stale. A page's searchable document is its mental model's name + content, so after a rename search kept indexing the old name (and the two names were not updated atomically). Update mental_models.name in the same transaction as the node rename (re-tokenizing search_vector for vchord; native regenerates, other backends index base columns), so a knowledge_pages name-uniqueness violation rolls both names back together. Folders (mental_model_id NULL) are untouched. Scopes #3307 down to this last remaining gap; roots 1-3, 5, 6 were already fixed by #3318 and #3335.
Pre-existing drift from #3240: the agent-plugin docs source and integrations.json entry were committed, but the generated docs-skill mirror was never regenerated, so verify-generated-files was red on main. Regenerated; only this one file is produced.
nicoloboschi
force-pushed
the
fix/rename-knowledge-page-syncs-mm-name-3307
branch
from
August 12, 2026 05:33
8f2951b to
a6fec9b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
rename_knowledge_nodeupdatedknowledge_pages.nameonly. For a page node the visible name lives onknowledge_pages, but the page's searchable document is its backing mental model'sname + content— so after a rename, search kept indexing the old name, and the two names were never updated atomically.This is root cause 4 of #3307. Roots 1–3, 5, 6 were already resolved by #3318 (
native_inline=Falsesearch_vectorwrites on create/update/clear) and #3335 (PGroonga + sharedmental_models_text_document()), both merged the same day the issue was filed — see the triage comment.Fix
Update
mental_models.namein the same transaction as the node rename:search_vectorfor vchord (native regenerates its generated column automatically;pg_textsearch/pgroonga/pg_searchindex base columns), reusing the samepg_search_vector_expr(..., native_inline=False)helper ascreate/update/clear_mental_model.knowledge_pagesname-uniqueness violation rolls the mental-model name back with it.mental_model_id IS NULL) are untouched.No API/client schema change.
Test
test_rename_page_syncs_backing_model_and_searchrenames a page and asserts (a) the backing mental model's name is updated and (b) the page is retrievable by its new name via knowledge-base search. Deterministic (no LLM). Passes alongside the existing rename/search suite.Closes #3307