Skip to content

feat(brain): /wikilint health checker (read-only) (Phase 4)#46

Merged
topcoder1 merged 1 commit into
mainfrom
claude/reverent-blackburn-ac6628
Apr 28, 2026
Merged

feat(brain): /wikilint health checker (read-only) (Phase 4)#46
topcoder1 merged 1 commit into
mainfrom
claude/reverent-blackburn-ac6628

Conversation

@topcoder1
Copy link
Copy Markdown
Owner

Summary

Adds the read-only /wikilint health checker — Phase 4 of the brain wiki layer per .omc/plans/brain-2026-04-27-phases-3-5-detailed.md §4. Builds on Phase 3a/3b (PRs #29 / #32 / #33 / #36).

Surfaces four classes of issue that compound silently as KUs accumulate:

  1. Near-duplicate KUs — cosine ≥ 0.95 in same (entity, topic_key), both un-superseded.
  2. Temporal contradictions — overlapping [valid_from, valid_until] with conflicting text.
  3. Orphan entitiesentities row with <2 linked KUs and >30 days old.
  4. Stale wiki pageslast_synthesis_at older than newest KU valid_from.

v1 does NO autonomous CRUD. Each finding ships with a "merge / mark-superseded / ignore" suggestion; the user runs the action manually. Top anti-pattern from both deep-research passes.

Wiring

  • /wikilint slash command intercept in src/index.ts, placed before /wiki so the shared prefix doesn't route /wikilint to the entity-resolver.
  • Weekly cron piggybacks the existing digest scheduler callback with a 7-day debounce via system_state.last_wikilint — no new setInterval.
  • Class 1 uses qdrant.fetchKuVectors (new) — single Qdrant retrieve round-trip with with_vector: true. Pair budget capped at 500 per run; groups >32 KUs are themselves anomalous and logged + skipped.

Notes for reviewers

  • Group key uses a NUL separator (\0). topic_key is space-joined by extract.ts:normalizeTopic ("current employer"), so a space separator would corrupt multi-word topics on key.split — regression test pinned in wikilint.test.ts.
  • Detector functions are pure: (db, opts?) => Finding[], with findDuplicateKus async only because of the Qdrant fetch. runAll composes them.
  • WikilintCommandOptions.db and WikilintCronOptions.db allow injection for testing without going through getBrainDb() singleton.
  • Independent code-reviewer pass returned 1 HIGH (group-key separator), 1 MED (cron test gap), 1 LOW (comment clarity). HIGH and MED both addressed before push; LOW was a comment polish.

Test plan

  • npx vitest run src/brain → 431/431 passing (+21 new tests across the two new test files)
  • npx vitest run (full repo) → 2468/2468 passing
  • npx tsc --noEmit clean
  • npm run build clean
  • Manual: run /wikilint against a real brain.db from a Telegram main-group chat — verify the report renders + the last_wikilint row appears in system_state
  • Manual: deliberately trigger one issue per class (orphan + dup + stale + temporal) and confirm each section appears in the report
  • Manual: wait until the next digest tick and confirm the wikilint report is delivered alongside the digest

🤖 Generated with Claude Code

Adds a read-only audit command surfacing four classes of issue that
compound silently as the brain accumulates KUs:

  1. Near-duplicate KUs (cosine >= 0.95 in same (entity, topic_key))
  2. Temporal contradictions (overlapping intervals, conflicting text)
  3. Orphan entities (<2 linked KUs, >30 days old)
  4. Stale wiki pages (last_synthesis_at older than newest KU valid_from)

v1 does NO autonomous CRUD. Each finding includes a "merge /
mark-superseded / ignore" suggestion in the report; the user runs the
action manually. Top anti-pattern from both deep-research passes.

Wired into src/index.ts as /wikilint slash command (intercept order
matters — /wikilint check is placed BEFORE /wiki since they share the
prefix). Cron piggybacks the existing digest scheduler with a 7-day
debounce via system_state.last_wikilint, so no new setInterval.

Class 1 uses a new fetchKuVectors helper in qdrant.ts (Qdrant retrieve
with with_vector: true). Pair budget capped at 500 per run; groups
larger than 32 KUs are themselves anomalous and logged + skipped.
Group key uses a NUL separator since topic_key is space-joined by
extract.ts:normalizeTopic ("current employer") — regression-tested.

Tests: 21 new (15 in wikilint.test.ts, 6 in wikilint-command.test.ts).
Brain suite 431/431 green; full repo 2468/2468; typecheck + build clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@topcoder1 topcoder1 merged commit 04caff9 into main Apr 28, 2026
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