Skip to content

id(web): YAML front matter is destroyed on save — fences become a rule + setext heading, metadata fused into body text #1369

Closed

Description

@dezren39

Problem

A .md file that starts with YAML front matter is destroyed by one open → save cycle in the id web editor. The front matter is not preserved, hidden, or rejected — it is silently rewritten into unrelated document structure.

Evidence (verified this run on main 0cbb91b1)

Probe: verbatim copy of pkgs/id/src/web/markdown.rs in a standalone crate (comrak 0.56.0), markdown_to_prosemirror → prosemirror_to_markdown round-trip. Logs: fleet bookkeeping probe-2026-10-27-creator-a/out.log + out4.log.

Input:

---
title: Hello World
date: 2026-01-02
tags: [a, b]
---

# Heading

Body text.

Parsed PM doc: a horizontal_rule, then a level-2 heading whose text is title: Hello World date: 2026-01-02 tags: [a, b] (the YAML lines fused by soft breaks; the closing --- became the setext underline), then the real heading and body.

Saved output:

-----

## title: Hello World date: 2026-01-02 tags: \[a, b\]

# Heading

Body text.

The front matter is gone as metadata: any static-site/tooling consumer of the file loses title/date/tags, and the document gains a spurious rule and a nonsense heading. The mangled form is a fixpoint, so the loss is silent and permanent after the first save. A blank line inside the YAML block mangles differently again (first key becomes a paragraph, a later key becomes the heading) — no front-matter shape survives.

Root cause: commonmark_options (pkgs/id/src/web/markdown.rs:81-91) enables strikethrough/tasklist/table/footnotes but not comrak's front-matter support, and the codec has no node representation for front matter, so the --- fences parse as a thematic break + setext heading.

Why it matters

Front matter is the default header format for markdown notes and docs (Obsidian, Hugo, Jekyll, Astro, Docusaurus, GitHub Pages). id is a general markdown file editor; any user who opens such a file and saves — including an unrelated one-character edit, or autosave — silently corrupts the file's metadata and structure. Same loss class as #1306/#1307 (plain-mode fidelity), but for the much more common .md path.

Acceptance criteria

  • A .md doc beginning with YAML front matter round-trips byte-identically (or semantically identically with the front-matter block verbatim) through open → save, including multi-key blocks, blocks containing blank lines, and a doc whose body starts with a heading or with plain text.
  • The front matter is not editable-as-body by accident: whatever representation is chosen (dedicated PM node, codec-level strip-and-restore, or equivalent), the editor does not present the YAML lines as a heading/paragraph the user can half-delete.
  • A leading --- that is NOT front matter (e.g. a thematic break after a paragraph, Para one.\n\n---\n\nPara two.) still round-trips as a horizontal rule — verified control case in the probe.
  • Regression tests in pkgs/id/src/web/markdown.rs cover the shapes above (round-trip + fixpoint), mirroring the existing codec test style.
  • TOML (+++) front matter is either supported the same way or explicitly documented as out of scope in the fix PR.

Activity

  1. developing-today commented on Oct 27, 2026

    @developing-today
    Contributor
  2. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    queue/queuedHas a queued task in the Supabase agent queue
    source/creatorFiled by the new-issue-creator job
    task/triageQueue packet kind: verify, reproduce, and route this item
    priority/highImportant and time-sensitive
    app/idPackage/app: id (pkgs/ or apps/ in this repo)
    effort/mMedium: expected under 1 day of work
    on Oct 27, 2026
  3. dezren39 commented on Oct 27, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

    • Agent: new-issue-creator (new-issue-creator-code-a)
    • Session / ID: cron job new-issue-creator-code-a, run 2026-10-27 03:05 CDT
    • Found via: filed this run
    • Task: Filed after verifying on main 0cbb91b with a verbatim-codec probe crate: YAML front matter round-trips into a horizontal rule + a setext H2 fusing every YAML line; metadata silently destroyed on first save. Probe logs in fleet bookkeeping (probe-2026-10-27-creator-a/out.log, out4.log).
    • Expectation: effort/m — triage picks a front-matter representation (dedicated node vs strip-and-restore), then codec + tests; a leading non-front-matter --- must keep round-tripping as a rule.
    • Links: queue packet enqueued to repo-health-code-pilot (triage) in the same run.
  4. dezren39 commented on Oct 27, 2026

    @dezren39
    MemberAuthor

    Intake review

    Front matter is destroyed by one open-save cycle: fences become a horizontal rule plus a setext heading and the YAML lines fuse into body text (probe on main 0cbb91b). Silent data corruption on a common file shape. Risk: a fix must not break documents that legitimately start with ---. Suggested approach: detect a leading front-matter block in the codec, carry it as an opaque/preserved node (or out-of-band metadata) through the PM doc, and re-emit it verbatim on save; round-trip regression test with the probed input.

    Related: Related: #1370 (same codec round-trip family).

    Still live: checked this run — no merged PR in the recent merged list of this repo implements or resolves this issue, and no closing reference was found; the issue stays open.

    🤖 Agent note · filed

  5. added
    meta/enrichedIntake review done: acceptance criteria, links, and normalized labels added
    work/assignedQueue worker lifecycle state
    and removed on Oct 27, 2026
  6. 50 remaining items

  7. dezren39 commented on Nov 3, 2026

    @dezren39
    MemberAuthor

    Handed off: task 7467 (triage, issue #1369) was re-claimed by lane code-l and assigned to the opencode execution lane. The laptop claimant launches the bound opencode session, which drives task 7467 to its terminal state. Lead preserved from the prior checkpoint: triage was done under task 1340 and the fix task 1675 was parked 2026-10-28 on a laptop SSH outage — verify task 1675's state and the latest notes on issue #1369, and fix any desynced labels. Labels synced to this claim (queue/claimed + status/in-progress + work/assigned; stale queue/needs-review + status/needs-review removed). This note also replaces the handoff note for issue #1369 that failed with a GitHub secondary rate limit 403 at 2026-11-03T11:44Z.

  8. added
    queue/queuedHas a queued task in the Supabase agent queue
    and removed
    queue/queuedHas a queued task in the Supabase agent queue
    on Nov 3, 2026
  9. dezren39 commented on Nov 3, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · handed off

  10. dezren39 commented on Nov 3, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · handed off

  11. removed
    queue/queuedHas a queued task in the Supabase agent queue
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    on Nov 3, 2026
  12. added
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    status/parkedDeliberately paused with a recorded resume condition
    on Nov 3, 2026
  13. developing-today commented on Nov 3, 2026

    @developing-today
    Contributor

    agent-note:v1
    state: reviewed (coverage loop-back)
    Coverage pass 2026-11-03, loop-back review: this issue was re-reviewed (drift / overlap / already-handled / stale / blockers / ordering) so every open issue in the four repos is reviewed and in the system. Verdict: still live; in the system as task 7467 (triage, claimed, priority 30) in repo-health-code-pilot. Labels audited and synced. If it is already handled at current main, its triage closes it with evidence; if oversized, the triage files the split; blockers belong on this issue.
    Found via: coverage loop-back 2026-11-03

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

app/idPackage/app: id (pkgs/ or apps/ in this repo)effort/mMedium: expected under 1 day of workkind/bugSomething isn't working (prefixed form of the classic bug label)meta/enrichedIntake review done: acceptance criteria, links, and normalized labels addedpriority/highImportant and time-sensitivequeue/parkedQueue task is parked (waiting on CI, time, or an event)queue/queuedHas a queued task in the Supabase agent queuesource/creatorFiled by the new-issue-creator jobstatus/parkedDeliberately paused with a recorded resume conditiontask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions