feat: Google OKF-conformant wiki frontmatter#102
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
type+ adescriptionone-liner in YAML frontmatter, replacingbrief.typeis code-injected (Concept,Summary, or a capitalized entity subtype likeOrganization) — the LLM never authors frontmatter.tree_renderer;compile_long_docidempotently backfills existing long-doc summaries onrecompile.openkb lintOKF-conformance check flags knowledge pages missing a non-emptytype/description.index.md/log.mdare unchanged. Readers keep abrieffallback so un-migrated pages still parse.Test Plan
ruffclean on changed files; no newmypyerrors (main 54 == branch 54)openkb recompile --all --dry-runsmoke OKopenkb recompile --allthenopenkb linton a real KB to confirm backfill + zero OKF-conformance issues