Skip to content

fix(knowledge): lint worker orphan self-heal did nothing on real data#210

Merged
mkreyman merged 2 commits into
masterfrom
fix-lint-orphan-relink
Jun 29, 2026
Merged

fix(knowledge): lint worker orphan self-heal did nothing on real data#210
mkreyman merged 2 commits into
masterfrom
fix-lint-orphan-relink

Conversation

@mkreyman

Copy link
Copy Markdown
Owner

What real-data verification found

Per the 'do the scheduled jobs actually work?' check, I ran KnowledgeLintWorker against the prod 77k corpus. Its orphan self-heal was effectively a no-op:

  • 1,247 of 1,433 orphans have embeddings, but their nearest neighbor sits at ~0.55–0.59 — a near-miss of the global 0.6 link threshold. Re-linking at 0.6 produced zero links on every sampled orphan; they'd stay isolated forever.
  • The other 186 orphans have no embedding, so ArticleLinkingWorker silently no-ops on them entirely.

Mocked unit tests passed; only real data exposed this — same lesson as the classifier bug.

Fix

  • ArticleLinkingWorker accepts an optional per-job threshold (query-shaped arg, falls back to global config).
  • KnowledgeLintWorker now splits orphans:
    • embedded → re-link at a lenient :knowledge_lint_orphan_link_threshold (default 0.5) so an isolated article connects to its closest relative instead of near-missing forever;
    • un-embeddedArticleEmbeddingWorker (embeds, then chains to linking).
    • audit event now reports orphans_relinked and orphans_embedding_enqueued.

Tests

A near-miss neighbor (cos ≈ 0.55) links only with the lenient override; the lint worker embeds an un-embedded orphan and re-links embedded ones. Full local gate green (2999 tests, credo, dialyzer 0).

Note

0.5 is a contained default (orphans only — never global linking). Tune :knowledge_lint_orphan_link_threshold if you want stricter/looser orphan rescue.

mkreyman added 2 commits June 29, 2026 17:45
Verifying KnowledgeLintWorker against the prod 77k corpus (per the 'do the cron
jobs actually work' check) showed its orphan self-heal was effectively a no-op:

- 1247 of 1433 orphans HAVE embeddings, but their nearest neighbor sits at
  ~0.55-0.59 — a near-miss of the global 0.6 link threshold. Re-linking at 0.6
  produced ZERO links on every sampled orphan; they would stay isolated forever.
- The other 186 orphans have NO embedding, so ArticleLinkingWorker silently
  no-ops on them entirely.

Fixes:
- ArticleLinkingWorker accepts an optional per-job  (query-shaped arg,
  falls back to the global config).
- KnowledgeLintWorker now splits orphans: embedded ones are re-linked at a
  lenient threshold (:knowledge_lint_orphan_link_threshold, default 0.5) so an
  isolated article connects to its closest relative instead of near-missing
  forever; un-embedded ones are sent to ArticleEmbeddingWorker (which embeds and
  chains to linking). The audit event now reports orphans_relinked AND
  orphans_embedding_enqueued.

Tests: a near-miss neighbor (cos~0.55) links only with the lenient override; the
lint worker embeds an un-embedded orphan and re-links embedded ones. Full local
gate green.
@mkreyman mkreyman merged commit b08c2da into master Jun 29, 2026
9 checks passed
@mkreyman mkreyman deleted the fix-lint-orphan-relink branch June 29, 2026 23:52
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