WeKnora/internal/application
LuckVd ee3623ab76
fix(wiki): reuse cross-type page for same-title items instead of creating twins (#3547)
* fix(wiki): reuse cross-type page for same-title items instead of creating twins

Re-ingesting the same document can flip the model's page-type judgment for
the same real-world thing (first extracted as concept/X, later as entity/X).
The exact-identity fast path only matched same-type pages, and the slug
carries the type prefix, so every reparse materialized another concept/X +
entity/X twin pair that then cross-link to each other (fixes #3526).

- exactIdentityTarget: same-type exact match still wins; with no same-type
  page, a cross-type candidate with the same normalized title is reused so
  the write path updates the existing page instead of creating a twin
- attachExactIdentityPages: cross-type safety-net lookup (batched and
  cached like the same-type pass) covers same-title pages the trigram probe
  missed
- regression tests for the fallback, the same-type preference, and the
  no-leak guarantee for unrelated titles

* docs(wiki): update identity-title comment; assert cross-type binding in tests

Review feedback on #3547:
- normalizeWikiIdentityTitle's comment no longer claims same-type-only
  scope: it now drives cross-type entity/concept reuse as well
- stubNormalizedTitleWiki filters fixtures by pageType and the batching
  test asserts the cross-type safety net binds concept/mencius onto the
  entity item and registers it in candidatePages
- rename TestExactIdentityTargetSameTypeOnly to
  TestExactIdentityTargetPrefersSameType to reflect what it now pins

---------

Co-authored-by: LuckVd <LuckVd@users.noreply.github.com>
2026-09-23 11:58:29 +08:00
..
access feat(artifacts): let users delete generated files (#3447) 2026-09-20 13:01:46 +08:00
repository fix(graph): 给 Neo4j SearchNode 加上种子上限与行数兜底,避免一次查询拉回整个邻域 (#3550) 2026-09-23 11:57:57 +08:00
service fix(wiki): reuse cross-type page for same-title items instead of creating twins (#3547) 2026-09-23 11:58:29 +08:00