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

Function find_missing_okf_fields

openkb/lint.py:531–566  ·  view source on GitHub ↗

Return knowledge pages missing a non-empty ``type`` or ``description``. OKF v0.1 requires every non-reserved knowledge page to carry a non-empty ``type``; ``description`` is OpenKB's required one-liner. Only summaries/, concepts/, entities/ are checked — index.md, log.md and sources/ ar

(
    wiki: Path,
    pages: dict[Path, str] | None = None,
)

Source from the content-addressed store, hash-verified

529
530
531def find_missing_okf_fields(
532 wiki: Path,
533 pages: dict[Path, str] | None = None,
534) -> list[str]:
535 """Return knowledge pages missing a non-empty ``type`` or ``description``.
536
537 OKF v0.1 requires every non-reserved knowledge page to carry a non-empty
538 ``type``; ``description`` is OpenKB's required one-liner. Only summaries/,
539 concepts/, entities/ are checked — index.md, log.md and sources/ are exempt.
540
541 Args:
542 wiki: Path to the wiki root directory.
543 pages: Optional pre-loaded ``{path: text}`` mapping from
544 :func:`_load_wiki_pages`. When ``None`` (the default), the
545 mapping is built internally so existing callers that pass only
546 ``wiki`` keep working unchanged.
547 """
548 issues: list[str] = []
549 if not wiki.exists():
550 return issues
551 if pages is None:
552 pages = _load_wiki_pages(wiki)
553 for path, text in sorted(pages.items()):
554 # find_missing_okf_fields covers only PAGE_CONTENT_DIRS subsets.
555 rel_parts = path.relative_to(wiki).parts
556 if not rel_parts or rel_parts[0] not in PAGE_CONTENT_DIRS:
557 continue
558 fm = frontmatter.parse(text)
559 rel = path.relative_to(wiki)
560 type_val = fm.get("type")
561 if not (isinstance(type_val, str) and type_val.strip()):
562 issues.append(f"{rel}: missing non-empty 'type'")
563 desc_val = fm.get("description")
564 if not (isinstance(desc_val, str) and desc_val.strip()):
565 issues.append(f"{rel}: missing non-empty 'description'")
566 return issues
567
568
569def run_structural_lint(kb_dir: Path) -> str:

Calls 2

_load_wiki_pagesFunction · 0.85
getMethod · 0.45