Skip to content

init wizard: preserve YAML frontmatter on Add-to-it merge #322

@dep0we

Description

@dep0we

Surfaced in: PR #94 PR 2 of 2 (init-wizard arc closer), Round 3 adversarial review LOW finding.

Symptom: When an operator adds YAML frontmatter (e.g., Obsidian-style `---\ntags: [...]\n---`) to a schema-owned scaffold file like `persona/IDENTITY.md` and then re-runs `atomic-agents init` choosing the Add-to-it merge branch, the frontmatter is silently dropped from the merged output.

Root cause: `_split_sections` in `atomic_agents/init/wizard.py` skips YAML frontmatter at file top during parsing for header-detection state, but the skipped lines are not preserved in the returned blocks. `_join_sections` then reproduces a frontmatter-free file.

Impact today: Low (no shipped template uses frontmatter; no framework code depends on operator-added frontmatter). The scenario is an operator who adds Obsidian metadata to a scaffold file then re-runs init.

Fix options:

  • (a) Preserve frontmatter as a `(None, body_with_frontmatter)` preamble block in `_split_sections` (current preamble handling extends).
  • (b) Detect frontmatter at parse time and fail-closed via `failed_files` so the operator chooses overwrite/cancel knowingly.
  • (c) Document the limitation in spec/35 MUST 15 and skip the fix.

Recommendation: option (a). Keeps the operator's metadata intact and matches the spec/35 MUST 15 "operator content preserved verbatim" contract.

Suggested test: `test_compute_merged_content_preserves_yaml_frontmatter` writes a YAML frontmatter block to a schema file pre-merge, runs the merge, asserts the frontmatter survives byte-identical in the merged output.

Effort: ~30 min implementation + 1 test + spec/35 MUST 15 wording tweak.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions