Skip to content

fix(knowledge): sync backing mental_model name on page rename (#3307) - #3407

Merged
nicoloboschi merged 2 commits into
mainfrom
fix/rename-knowledge-page-syncs-mm-name-3307
Aug 12, 2026
Merged

fix(knowledge): sync backing mental_model name on page rename (#3307)#3407
nicoloboschi merged 2 commits into
mainfrom
fix/rename-knowledge-page-syncs-mm-name-3307

Conversation

@nicoloboschi

Copy link
Copy Markdown
Collaborator

What

rename_knowledge_node updated knowledge_pages.name only. For a page node the visible name lives on knowledge_pages, but the page's searchable document is its backing mental model's name + 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=False search_vector writes on create/update/clear) and #3335 (PGroonga + shared mental_models_text_document()), both merged the same day the issue was filed — see the triage comment.

Fix

Update mental_models.name in the same transaction as the node rename:

  • Re-tokenize search_vector for vchord (native regenerates its generated column automatically; pg_textsearch/pgroonga/pg_search index base columns), reusing the same pg_search_vector_expr(..., native_inline=False) helper as create/update/clear_mental_model.
  • Both writes share one transaction, so a knowledge_pages name-uniqueness violation rolls the mental-model name back with it.
  • Folders (mental_model_id IS NULL) are untouched.

No API/client schema change.

Test

test_rename_page_syncs_backing_model_and_search renames 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

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
nicoloboschi force-pushed the fix/rename-knowledge-page-syncs-mm-name-3307 branch from 8f2951b to a6fec9b Compare August 12, 2026 05:33
@nicoloboschi
nicoloboschi merged commit 4e4b87b into main Aug 12, 2026
319 of 321 checks passed
@nicoloboschi
nicoloboschi deleted the fix/rename-knowledge-page-syncs-mm-name-3307 branch August 12, 2026 06:01
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.

mental_models search state is not maintained and reconciliation still targets reflections

1 participant