Commit bfb4e3c
authored
* fix(compiler): YAML-safe brief in concept frontmatter (closes #67)
LLM-authored brief values often contain colons, quotes, or hashes; the
existing f-string interpolation in _write_concept produced invalid
frontmatter (e.g. "brief: Why X: Y" → mapping value not allowed).
OpenKB's own reader uses string slicing so it never noticed, but
external YAML-aware tools (VS Code preview, Obsidian, doc generators)
reject the page.
- New _yaml_kv_line helper routes the value through yaml.safe_dump so
PyYAML auto-quotes when needed.
- Both write sites in _write_concept (re.sub update path + create
path) use the helper. re.sub now takes a lambda replacement to
bypass backref interpretation when brief contains literal \1 / \g<…>.
- New find_invalid_frontmatter check in lint.py runs yaml.safe_load
on every wiki page's frontmatter and is wired into the
run_structural_lint report; future regressions surface immediately
instead of silently writing bad YAML.
Repro and root-cause analysis by @invu557 (issue #67).
* fix(compiler): close 4 review findings on YAML-safe frontmatter
- _yaml_kv_line: switch from yaml.safe_dump+split to json.dumps. The
old form silently truncated briefs with embedded newlines (PyYAML
promoted them to multi-line single-quoted scalars; taking the first
line dropped the rest AND left an unterminated quote). json.dumps
always produces single-line, correctly-escaped output that round-
trips through any YAML loader.
- _read_concept_briefs: parse frontmatter via yaml.safe_load instead
of string-slicing the brief line. Without this, every brief that
PyYAML auto-quoted (any colon-bearing value) leaked its surrounding
quotes back into the LLM planning prompt and the index.md display.
- New _yaml_list_line / _parse_yaml_list_value helpers harden the
sources field the same way; _write_concept, _prepend_source_to_
frontmatter, and _remove_source_from_frontmatter all route through
them. Without this, the PR's own new lint flagged compiler-emitted
pages as invalid whenever a source filename contained a comma,
bracket, or other YAML-significant character.
- find_invalid_frontmatter now skips wiki/sources/ and wiki/reports/,
matching the convention in find_broken_links / find_orphans —
otherwise user-uploaded source markdown with malformed YAML
produced non-actionable lint noise.
Tests: 520 pass. Updated 9 assertion strings to match the new quoted
output format; one assertion (TestAddRelatedLink) kept the old
unquoted form because that test exercises an existing-file path
where the brief line is preserved verbatim.
1 parent 7289cfe commit bfb4e3c
3 files changed
Lines changed: 115 additions & 30 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| |||
405 | 406 | | |
406 | 407 | | |
407 | 408 | | |
408 | | - | |
| 409 | + | |
409 | 410 | | |
410 | | - | |
411 | | - | |
412 | | - | |
413 | | - | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
414 | 417 | | |
415 | 418 | | |
416 | 419 | | |
| |||
564 | 567 | | |
565 | 568 | | |
566 | 569 | | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
567 | 603 | | |
568 | 604 | | |
569 | 605 | | |
| |||
598 | 634 | | |
599 | 635 | | |
600 | 636 | | |
| 637 | + | |
601 | 638 | | |
602 | | - | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
603 | 642 | | |
604 | | - | |
| 643 | + | |
605 | 644 | | |
606 | 645 | | |
607 | 646 | | |
608 | 647 | | |
609 | 648 | | |
610 | 649 | | |
611 | 650 | | |
612 | | - | |
| 651 | + | |
613 | 652 | | |
614 | | - | |
| 653 | + | |
615 | 654 | | |
616 | 655 | | |
617 | 656 | | |
| |||
624 | 663 | | |
625 | 664 | | |
626 | 665 | | |
627 | | - | |
| 666 | + | |
628 | 667 | | |
629 | 668 | | |
630 | 669 | | |
| |||
637 | 676 | | |
638 | 677 | | |
639 | 678 | | |
640 | | - | |
641 | | - | |
642 | | - | |
| 679 | + | |
| 680 | + | |
643 | 681 | | |
644 | | - | |
645 | 682 | | |
646 | 683 | | |
647 | 684 | | |
648 | | - | |
| 685 | + | |
649 | 686 | | |
650 | 687 | | |
651 | | - | |
| 688 | + | |
652 | 689 | | |
653 | 690 | | |
654 | 691 | | |
| |||
676 | 713 | | |
677 | 714 | | |
678 | 715 | | |
679 | | - | |
680 | | - | |
681 | | - | |
| 716 | + | |
| 717 | + | |
682 | 718 | | |
683 | | - | |
684 | 719 | | |
685 | 720 | | |
686 | 721 | | |
687 | | - | |
| 722 | + | |
688 | 723 | | |
689 | 724 | | |
690 | 725 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| 16 | + | |
| 17 | + | |
15 | 18 | | |
16 | 19 | | |
17 | 20 | | |
| |||
402 | 405 | | |
403 | 406 | | |
404 | 407 | | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
405 | 444 | | |
406 | 445 | | |
407 | 446 | | |
| |||
418 | 457 | | |
419 | 458 | | |
420 | 459 | | |
| 460 | + | |
421 | 461 | | |
422 | 462 | | |
423 | 463 | | |
| |||
455 | 495 | | |
456 | 496 | | |
457 | 497 | | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
458 | 507 | | |
459 | 508 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
140 | | - | |
141 | | - | |
| 140 | + | |
| 141 | + | |
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| |||
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
151 | | - | |
| 151 | + | |
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
| |||
163 | 163 | | |
164 | 164 | | |
165 | 165 | | |
166 | | - | |
| 166 | + | |
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
| |||
633 | 633 | | |
634 | 634 | | |
635 | 635 | | |
636 | | - | |
| 636 | + | |
| 637 | + | |
637 | 638 | | |
638 | 639 | | |
639 | 640 | | |
| |||
732 | 733 | | |
733 | 734 | | |
734 | 735 | | |
735 | | - | |
| 736 | + | |
736 | 737 | | |
737 | 738 | | |
738 | 739 | | |
| |||
1205 | 1206 | | |
1206 | 1207 | | |
1207 | 1208 | | |
1208 | | - | |
| 1209 | + | |
1209 | 1210 | | |
1210 | 1211 | | |
1211 | 1212 | | |
| |||
1287 | 1288 | | |
1288 | 1289 | | |
1289 | 1290 | | |
1290 | | - | |
| 1291 | + | |
1291 | 1292 | | |
1292 | 1293 | | |
1293 | 1294 | | |
| |||
1338 | 1339 | | |
1339 | 1340 | | |
1340 | 1341 | | |
1341 | | - | |
| 1342 | + | |
1342 | 1343 | | |
1343 | 1344 | | |
1344 | 1345 | | |
| |||
0 commit comments