Skip to content

fix(wiki): preserve graph and tenant integrity#1660

Open
yangcongcong-coding wants to merge 1 commit into
Tencent:mainfrom
yangcongcong-coding:codex/fix-wiki-graph-integrity
Open

fix(wiki): preserve graph and tenant integrity#1660
yangcongcong-coding wants to merge 1 commit into
Tencent:mainfrom
yangcongcong-coding:codex/fix-wiki-graph-integrity

Conversation

@yangcongcong-coding

Copy link
Copy Markdown

Summary

  • count graph links as distinct, live neighbors instead of raw in_links + out_links
  • inherit the knowledge base tenant when a Wiki page is created without an explicit tenant_id
  • add regression tests for both data-integrity issues

Root cause

Reciprocal Wiki links appear in both in_links and out_links. Adding both array lengths double-counts the same neighbor, while missing and self-referential targets are counted even though the graph cannot render them. This can make the sidebar report an unreachable or dead neighbor when every real neighbor is present.

The built-in Wiki fixer creates pages without setting TenantID. CreatePage previously persisted that zero value instead of resolving ownership from the parent knowledge base, leaving tenantless Wiki rows.

Impact

  • graph neighbor totals match the distinct nodes that can actually be displayed
  • reciprocal links no longer create false dead-link warnings
  • Wiki fixer-created pages remain scoped to the knowledge base tenant

Validation

go test ./internal/application/service \
  -run 'Test(InheritWikiPageTenant|ComputeGraphSubset|ParseOutLinks)' \
  -count=1

ok github.com/Tencent/WeKnora/internal/application/service 0.278s

gofmt and git diff --check also pass.

@yangcongcong-coding yangcongcong-coding marked this pull request as ready for review June 25, 2026 06:50
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