Calendar Day
Wednesday, July 2, 2026 (PR 2 of 2)
Planned Effort
3 story points (Medium–High) — sprint item #6
Companion PR: Wednesday PR 1 (SessionMetadataDict #9) — independent; can land in either order.
Problem
The _escape_yaml() helper in utils/md_exporter.py does not handle several YAML-special characters and patterns:
- Colons followed by space (
: ) — interpreted as key-value separator, corrupts frontmatter
- Hash/pound signs (
#) — interpreted as inline comments, truncates values
- Tab characters — YAML spec forbids tabs for indentation
- YAML boolean literals (
true, false, yes, no, on, off) — unquoted values parsed as booleans
Session titles and project paths from Claude Code regularly contain colons (e.g. C:\Users\..., Fix: handle edge case) and hashes. The resulting YAML frontmatter is malformed and fails to parse in downstream consumers.
Goal
One merged PR that makes exported YAML frontmatter round-trip cleanly through yaml.safe_load() for all real-world session metadata inputs, using always-double-quote scalars as the primary fix.
Scope
Touch points
utils/md_exporter.py — _escape_yaml(): always double-quote YAML scalar values in frontmatter; escape internal " as \"; use block scalar (| or >) for multiline values
tests/ — test_yaml_frontmatter_roundtrip: extract YAML between --- delimiters, yaml.safe_load(), assert dict matches original metadata
tests/ — Hypothesis @given(st.text()) property test for round-trip fidelity
Out of scope
- Changes to Markdown body export format
- JS YAML parser compatibility tests (Python round-trip is sufficient)
Acceptance Criteria
Verification
cd C:\Users\Jasen\CppAliance\claude-code-chat-browser
.\.venv\Scripts\Activate.ps1
pytest tests/ -k yaml -q
pytest -q
Manual: export session with title Fix: handle edge case — confirm frontmatter parses via yaml.safe_load().
Calendar Day
Wednesday, July 2, 2026 (PR 2 of 2)
Planned Effort
3 story points (Medium–High) — sprint item #6
Companion PR: Wednesday PR 1 (SessionMetadataDict #9) — independent; can land in either order.
Problem
The
_escape_yaml()helper inutils/md_exporter.pydoes not handle several YAML-special characters and patterns::) — interpreted as key-value separator, corrupts frontmatter#) — interpreted as inline comments, truncates valuestrue,false,yes,no,on,off) — unquoted values parsed as booleansSession titles and project paths from Claude Code regularly contain colons (e.g.
C:\Users\...,Fix: handle edge case) and hashes. The resulting YAML frontmatter is malformed and fails to parse in downstream consumers.Goal
One merged PR that makes exported YAML frontmatter round-trip cleanly through
yaml.safe_load()for all real-world session metadata inputs, using always-double-quote scalars as the primary fix.Scope
Touch points
utils/md_exporter.py—_escape_yaml(): always double-quote YAML scalar values in frontmatter; escape internal"as\"; use block scalar (|or>) for multiline valuestests/—test_yaml_frontmatter_roundtrip: extract YAML between---delimiters,yaml.safe_load(), assert dict matches original metadatatests/— Hypothesis@given(st.text())property test for round-trip fidelityOut of scope
Acceptance Criteria
_escape_yaml()produces valid YAML for values containing:,#,\t, and boolean literals\"before wrappingyaml.safe_load()pytest,mypy --strict, andruffpassVerification
Manual: export session with title
Fix: handle edge case— confirm frontmatter parses viayaml.safe_load().