Commit 1afb2c5
authored
feat: Google OKF-conformant wiki frontmatter (#102)
* feat(compiler): capitalize entity type, rename brief→description
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.
* feat(compiler): add type: Concept and rename brief→description on concept pages
* feat(compiler): add type+description to short-doc summary frontmatter
* feat(tree_renderer): add type+description to PageIndex summary frontmatter
* feat(compiler): backfill type+description on long-doc summaries during recompile
* feat(lint): flag knowledge pages missing OKF type/description
* docs(schema): document type/description frontmatter in AGENTS_MD
* fix(compiler): strip legacy brief: on entity update (parity with concept pages)
* fix(review): harden frontmatter writes (title-case type, quote full_text, backfill order + dirty-check, lint isinstance)
* refactor(compiler): use shared frontmatter module; fix --- boundary + 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.
* refactor(tree_renderer, lint): use shared frontmatter module
* perf(lint): read wiki pages once and share across frontmatter checks
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.1 parent 26f8b13 commit 1afb2c5
12 files changed
Lines changed: 897 additions & 254 deletions
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
174 | 174 | | |
175 | 175 | | |
176 | 176 | | |
177 | | - | |
| 177 | + | |
178 | 178 | | |
179 | 179 | | |
180 | 180 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
449 | 450 | | |
450 | 451 | | |
451 | 452 | | |
452 | | - | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
453 | 478 | | |
454 | 479 | | |
455 | 480 | | |
456 | 481 | | |
457 | 482 | | |
458 | 483 | | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
459 | 491 | | |
460 | 492 | | |
461 | 493 | | |
462 | 494 | | |
463 | | - | |
464 | | - | |
465 | | - | |
466 | | - | |
467 | | - | |
468 | | - | |
469 | | - | |
470 | | - | |
471 | | - | |
472 | | - | |
473 | | - | |
474 | | - | |
475 | | - | |
476 | | - | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
477 | 500 | | |
478 | | - | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
479 | 511 | | |
480 | | - | |
| 512 | + | |
481 | 513 | | |
482 | 514 | | |
483 | 515 | | |
484 | 516 | | |
485 | 517 | | |
486 | 518 | | |
487 | 519 | | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
488 | 558 | | |
489 | 559 | | |
490 | 560 | | |
| |||
497 | 567 | | |
498 | 568 | | |
499 | 569 | | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
500 | 574 | | |
501 | 575 | | |
502 | 576 | | |
503 | 577 | | |
504 | | - | |
| 578 | + | |
| 579 | + | |
505 | 580 | | |
506 | 581 | | |
507 | 582 | | |
| |||
548 | 623 | | |
549 | 624 | | |
550 | 625 | | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
551 | 635 | | |
552 | 636 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
52 | 58 | | |
53 | 59 | | |
54 | 60 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
27 | | - | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
36 | | - | |
37 | | - | |
| 37 | + | |
| 38 | + | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| 42 | + | |
| 43 | + | |
41 | 44 | | |
42 | | - | |
| 45 | + | |
43 | 46 | | |
44 | 47 | | |
45 | 48 | | |
0 commit comments