Skip to content

feat: Google OKF-conformant wiki frontmatter#102

Merged
KylinMountain merged 12 commits into
mainfrom
feat/okf-frontmatter
Jun 18, 2026
Merged

feat: Google OKF-conformant wiki frontmatter#102
KylinMountain merged 12 commits into
mainfrom
feat/okf-frontmatter

Conversation

@KylinMountain

@KylinMountain KylinMountain commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Every generated wiki knowledge page (summary / concept / entity) now carries a controlled type + a description one-liner in YAML frontmatter, replacing brief. type is code-injected (Concept, Summary, or a capitalized entity subtype like Organization) — the LLM never authors frontmatter.
  • Long-document (PageIndex) summaries get the same fields via tree_renderer; compile_long_doc idempotently backfills existing long-doc summaries on recompile.
  • New openkb lint OKF-conformance check flags knowledge pages missing a non-empty type/description.
  • Net effect: the wiki's knowledge pages become OKF v0.1 conformant as a by-product. Wikilinks, the link whitelist, directory layout, and index.md/log.md are unchanged. Readers keep a brief fallback so un-migrated pages still parse.

Test Plan

  • Full suite green (764 passed)
  • ruff clean on changed files; no new mypy errors (main 54 == branch 54)
  • openkb recompile --all --dry-run smoke OK
  • Run openkb recompile --all then openkb lint on a real KB to confirm backfill + zero OKF-conformance issues

Write entity frontmatter with type capitalized (e.g. "Organization"),
use the key `description` instead of `brief` for the one-liner field.
Readers normalize type to lowercase and prefer `description`, falling
back to legacy `brief` for pre-migration pages.

LLM prompts and JSON extraction updated to use the `description` key.
…ext, backfill order + dirty-check, lint isinstance)
… concept malformed fallback

- Import openkb.frontmatter; replace local _yaml_kv_line / _yaml_list_line /
  _parse_yaml_list_value / _set_fm_line bodies with thin aliases to the shared
  module exports (call sites unchanged).
- Replace all ad-hoc text.find("---", 3) splits with frontmatter.split():
  _write_summary, _write_concept, _write_entity, _read_concept_briefs,
  _read_entity_briefs, compile_long_doc backfill, _gen_update,
  _gen_entity_update, summary-rewrite strip, _prepend_source_to_frontmatter,
  _remove_source_from_frontmatter, scan_affected_pages.
- Add module-level _resolve_description(fm) helper; use it in both reader
  functions to consolidate description/brief fallback logic.
- _read_concept_briefs and _read_entity_briefs now use frontmatter.parse()
  instead of manual yaml.safe_load.
- Replace re.sub(r"^brief:.*\n?", ...) with frontmatter.drop_line() in both
  _write_concept and _write_entity update paths.
- Add malformed-frontmatter fallback to _write_concept update path: when
  frontmatter.split returns None, rebuild valid block (type: Concept,
  sources, description) rather than writing a bare body.
- Remove now-unused direct yaml import.
- Add 3 regression tests: concept round-trip with "---" in brief, entity
  round-trip with "---" in brief, concept update on malformed frontmatter.
Adds _load_wiki_pages() to walk wiki/*.md (excluding reports/, sources/,
and _EXCLUDED_FILES) and return a {path: text} dict.  Both
find_invalid_frontmatter and find_missing_okf_fields accept an optional
pages= kwarg; run_structural_lint builds it once and passes it to both,
reducing 2N file reads to N.  Standalone callers that pass only wiki
continue to work unchanged.  Also switches find_invalid_frontmatter to
use frontmatter.split() for line-anchored delimiter detection.
@KylinMountain KylinMountain changed the title feat: OKF-aligned frontmatter normalization (type + description) feat: Google OKF-conformant wiki frontmatter Jun 18, 2026
@KylinMountain KylinMountain merged commit 1afb2c5 into main Jun 18, 2026
1 check passed
@KylinMountain KylinMountain deleted the feat/okf-frontmatter branch June 22, 2026 09:53
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