Skip to content

fix(utils): open frontmatter only on an exact --- line - #7

Closed
vchamarthi wants to merge 1 commit into
mainfrom
fix/frontmatter-opening-fence
Closed

vchamarthi wants to merge 1 commit into
mainfrom
fix/frontmatter-opening-fence

Conversation

@vchamarthi

Copy link
Copy Markdown
Owner

Summary

parse_frontmatter closes a block only on a line that is exactly ---, but it opened one on any text that starts with ---. A document that begins with a thematic break (-----) or a --- title line and has a --- line later was read as frontmatter. Its leading text was dropped from the body and the YAML between the two lines was discarded as invalid metadata. The same function also returned an unterminated block with its BOM still attached, where every other branch strips it.

The opening line now has to be exactly ---, the same rule as the closing fence. frontmatter_block in scripts/sync_skilltext_profile.py says it mirrors parse_frontmatter, so it gets the same one-line change.

Evidence

  • base: 5c70cbf90f4eab95b30dcd6ad7ae60a4f37de268
  • command: pytest -p no:cacheprovider -p no:logging tests/test_treatments.py tests/test_sync_skilltext_profile.py -q --tb=short, run through the lab's experiment_safe.py sandbox with a Python 3.14 environment.
  • before: exit 1, 3 failed and 54 passed. parse_frontmatter("-----\nintro paragraph\n---\nrest") returned body rest. An unterminated block with a BOM returned the BOM in the body. frontmatter_block returned -----\nintro\n---\n as a header.
  • after: exit 0, 57 passed in 0.11s. The existing basic, none, unterminated and BOM tests still pass.
  • not claimed: not a live evaluation, and no real skill file was found with a --- look-alike first line. This is a parser-consistency fix, not a skill-efficacy result.

Blast radius

Two functions change by a few lines each: parse_frontmatter in dokimi/dokimi/utils.py and frontmatter_block in dokimi/scripts/sync_skilltext_profile.py. Callers are the skill loader, the agent profile loader, the skill treatment and benchflow skill metadata reads. A file whose first line is exactly ---, with or without trailing spaces or a BOM, parses as before. Only a first line that merely starts with --- changes, and it is now body. Two tests are added to tests/test_treatments.py, one to tests/test_sync_skilltext_profile.py, plus a changelog fragment.

Overlap

Created with claude-sonnet-5-5.

Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>
@vchamarthi
vchamarthi force-pushed the fix/frontmatter-opening-fence branch from 8aa3dbd to e5158ad Compare October 21, 2026 19:00
@vchamarthi

Copy link
Copy Markdown
Owner Author

Superseded by intel#149 and intel#150.

@vchamarthi vchamarthi closed this Oct 21, 2026
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