Skip to content

Commit 4dea511

Browse files
committed
fix(compiler): strip legacy brief: on entity update (parity with concept pages)
1 parent 81a0de6 commit 4dea511

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

openkb/agent/compiler.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -933,6 +933,9 @@ def _build_frontmatter(sources: list[str]) -> str:
933933
fm = existing[:end + 3]
934934
fm = _set_fm_line(fm, "description", brief) if brief else fm
935935
fm = _set_fm_line(fm, "type", type_.capitalize()) if type_ else fm
936+
# Drop any legacy ``brief:`` key (migrated to ``description:``),
937+
# mirroring _write_concept's update path.
938+
fm = re.sub(r"^brief:.*\n?", "", fm, flags=re.MULTILINE)
936939
existing = fm + "\n\n" + clean
937940
else:
938941
# Malformed/absent frontmatter (opening ``---`` with no closing

tests/test_compiler.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,21 @@ def test_update_entity_capitalizes_type_and_writes_description(self, tmp_path):
758758
assert 'description: "b2"' in text
759759
assert "brief:" not in text
760760

761+
def test_update_entity_strips_legacy_brief(self, tmp_path):
762+
entities = tmp_path / "entities"
763+
entities.mkdir(parents=True)
764+
(entities / "anthropic.md").write_text(
765+
'---\nsources: ["summaries/a.md"]\ntype: organization\n'
766+
'brief: Old brief.\n---\n\n# Anthropic\n\nOld.',
767+
encoding="utf-8",
768+
)
769+
_write_entity(tmp_path, "anthropic", "# Anthropic\n\nv2.", "summaries/b.md",
770+
is_update=True, brief="New desc.", type_="organization")
771+
text = (entities / "anthropic.md").read_text(encoding="utf-8")
772+
assert "brief:" not in text
773+
assert "Old brief." not in text
774+
assert 'description: "New desc."' in text
775+
761776

762777
class TestBacklinkSummary:
763778
def test_adds_missing_concept_links(self, tmp_path):

0 commit comments

Comments
 (0)