MCPcopy Create free account
hub / github.com/VectifyAI/OpenKB / run_structural_lint

Function run_structural_lint

openkb/lint.py:569–647  ·  view source on GitHub ↗

Run all structural lint checks and return a formatted Markdown report. Args: kb_dir: Root of the knowledge base (contains wiki/ and raw/). Returns: Formatted Markdown string with lint results.

(kb_dir: Path)

Source from the content-addressed store, hash-verified

567
568
569def run_structural_lint(kb_dir: Path) -> str:
570 """Run all structural lint checks and return a formatted Markdown report.
571
572 Args:
573 kb_dir: Root of the knowledge base (contains wiki/ and raw/).
574
575 Returns:
576 Formatted Markdown string with lint results.
577 """
578 wiki = kb_dir / "wiki"
579 raw = kb_dir / "raw"
580
581 # Load all wiki pages once and share across both frontmatter checks
582 # (avoids 2N disk reads when the wiki is large).
583 wiki_pages = _load_wiki_pages(wiki) if wiki.exists() else {}
584
585 broken = find_broken_links(wiki)
586 orphans = find_orphans(wiki)
587 missing = find_missing_entries(raw, wiki, kb_dir=kb_dir)
588 sync_issues = check_index_sync(wiki)
589 bad_frontmatter = find_invalid_frontmatter(wiki, pages=wiki_pages)
590 missing_okf = find_missing_okf_fields(wiki, pages=wiki_pages)
591
592 lines = ["## Structural Lint Report\n"]
593
594 # Broken links
595 lines.append(f"### Broken Links ({len(broken)})")
596 if broken:
597 for issue in broken:
598 lines.append(f"- {issue}")
599 else:
600 lines.append("No broken links found.")
601 lines.append("")
602
603 # Orphans
604 lines.append(f"### Orphaned Pages ({len(orphans)})")
605 if orphans:
606 for page in orphans:
607 lines.append(f"- {page}")
608 else:
609 lines.append("No orphaned pages found.")
610 lines.append("")
611
612 # Missing entries
613 lines.append(f"### Raw Files Without Wiki Entry ({len(missing)})")
614 if missing:
615 for name in missing:
616 lines.append(f"- {name}")
617 else:
618 lines.append("All raw files have wiki entries.")
619 lines.append("")
620
621 # Index sync
622 lines.append(f"### Index Sync Issues ({len(sync_issues)})")
623 if sync_issues:
624 for issue in sync_issues:
625 lines.append(f"- {issue}")
626 else:

Calls 7

_load_wiki_pagesFunction · 0.85
find_broken_linksFunction · 0.85
find_orphansFunction · 0.85
find_missing_entriesFunction · 0.85
check_index_syncFunction · 0.85
find_invalid_frontmatterFunction · 0.85
find_missing_okf_fieldsFunction · 0.85