Skip to content

fix(memory-wiki): standardize page schema + repair pipeline#3

Merged
LightDriverCS merged 1 commit into
mainfrom
fix/memory-wiki-standardization
Apr 19, 2026
Merged

fix(memory-wiki): standardize page schema + repair pipeline#3
LightDriverCS merged 1 commit into
mainfrom
fix/memory-wiki-standardization

Conversation

@LightDriverCS

Copy link
Copy Markdown

Summary

Harden the memory-wiki vault so it's deterministic and trustworthy for daily use. Kills three pipeline bugs responsible for most of the current 42 lint errors + 682 warnings, codifies the canonical page standard in code + docs, and adds a deterministic repair command for legacy content.

Pipeline bugs fixed

  1. Code-fence link leakextractWikiLinks now strips fenced code blocks and inline code before scanning. [[reply_to_current]] tokens inside transcript fences no longer count as wikilinks (~288 false-positive broken-link warnings).
  2. Native-mode link validatorcollectBrokenLinkIssues normalizes .md suffix and path prefix on both sides so [Title](sources/foo.md) in dashboard reports resolves. Previously every native-mode markdown link was lint-broken.
  3. Orphan-shell creationrefreshPageRelatedBlocks now skips pages with no frontmatter and no body, so compile no longer papers over empty source files by adding ## Related blocks to them.

Canonical standard + repair

  • New structure-repair.ts module with ensurePageStructure, repairMemoryWikiVault, and findOrphanSourceShells.
  • Compile auto-runs the structure sweep so generated artifacts always carry id, pageType, title, updatedAt. Human-authored body text and existing frontmatter are never rewritten.
  • New openclaw wiki repair [--dry-run] [--remove-orphans] CLI for explicit legacy backfill and orphan cleanup.
  • Lint report includes updatedAt on first creation.
  • README documents the canonical standard table, provenance discipline, orphan-shell semantics, and the daily operator workflow.

Operator workflow

Daily loop is unchanged:

openclaw wiki bridge import
openclaw wiki compile
openclaw wiki lint

One-time legacy cleanup:

openclaw wiki repair --dry-run
openclaw wiki repair --remove-orphans
openclaw wiki compile
openclaw wiki lint

Test plan

  • Full memory-wiki test suite: 97/97 green (16 new tests).
  • pnpm oxlint --type-aware extensions/memory-wiki/src clean.
  • pnpm tsgo --noEmit -p extensions/memory-wiki/tsconfig.json clean.
  • Integration test seeds the exact failure patterns observed in the live vault (orphan shell, legacy concept without frontmatter, transcript with [[reply_to_current]] inside a code fence, native-mode dashboard link) and verifies the full repair -> compile -> lint loop drops errors and broken-link warnings to zero.
  • After merge + reinstall: run openclaw wiki repair --dry-run against the live vault to confirm orphan count matches, then openclaw wiki repair --remove-orphans && openclaw wiki compile && openclaw wiki lint and inspect the reduction.

🤖 Generated with Claude Code

Kill the three pipeline bugs that accounted for the majority of vault
lint noise (42 errors + 682 warnings):

1. `extractWikiLinks` now strips fenced code blocks and inline code
   before scanning — `[[reply_to_current]]` tokens inside transcript
   fences no longer look like wikilinks (~288 false positives gone).
2. `collectBrokenLinkIssues` normalizes `.md` suffix and path prefix
   on both sides — native-mode dashboard links like
   `[Title](sources/foo.md)` now resolve instead of lint-broken.
3. `refreshPageRelatedBlocks` skips pages with no frontmatter and no
   body, so compile no longer synthesizes empty "orphan shell" files
   by adding `## Related` blocks to nothing.

Also codify the canonical standard so drift is repairable, not
chronic:

- New `structure-repair.ts` module with `ensurePageStructure`,
  `repairMemoryWikiVault`, and `findOrphanSourceShells`.
- Compile auto-runs the structure sweep, so any generated artifact
  ends up with `id`, `pageType`, `title`, and `updatedAt` — never
  rewriting human-authored body text or existing frontmatter.
- New `openclaw wiki repair [--dry-run] [--remove-orphans]` CLI for
  legacy backfill and explicit orphan cleanup.
- Lint report page includes `updatedAt` on first creation.
- README gains the canonical standard table, provenance discipline
  notes, orphan-shell explanation, and daily operator workflow.

16 new unit + integration tests cover the link extractor code-fence
handling, the `.md` link validator, structure backfill, orphan
detection, compile's self-heal, and the full repair -> compile ->
lint loop. Full suite: 97/97 green.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
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