Skip to content

id(web): unused link reference definitions are silently deleted on save — a definitions-only document saves as an empty file #1004

Closed

Description

@dezren39

Bug

In the id web editor's markdown ↔ ProseMirror codec (pkgs/id/src/web/markdown.rs), link reference definitions that are not used by a link in the document are silently deleted on save:

body text

[unused]: https://example.com

loads and saves as just:

body text

The extreme case is total: a document consisting only of reference definitions (a shared "link library" page, or a draft whose links are added later)

[a]: https://a.com
[b]: https://b.com

loads as an empty document and saves as an empty file.

Definitions that are used survive in substance — full ([one][r]), collapsed ([text][]) and shortcut ([ref]) references all round-trip, with the reference inlined as [text](url) and the definition consumed. So the loss is specifically: any definition whose label no link in the current document references.

Verified repro (this run, main 3b9d159)

Standalone verbatim-codec probe (evidence log: goal hidden_files/probe-2026-10-26-1415/out4.log):

  • unused-ref-def: "body text\n\n[unused]: https://example.com\n" → PM is a single paragraph body text (the definition appears nowhere) → save returns "body text\n".
  • ref-def-only-doc: "[a]: https://a.com\n[b]: https://b.com\n" → PM is the empty-document placeholder paragraph → save returns "" (empty file).
  • Controls (same log): shortcut-ref, collapsed-ref, multi-ref-same — used definitions round-trip correctly as inlined links.

Why it happens / why it matters

The ProseMirror schema the codec targets has no node for a reference definition, and comrak resolves definitions during parsing without surfacing unused ones as AST nodes — so the parse direction has nowhere to put them and they vanish before the editor ever sees the document. Keeping a block of reference definitions at the foot of a note for later use is a standard markdown authoring pattern; opening such a file in the id web editor and saving (even with no edit) destroys that block with no warning. Same silent-loss-on-save family as #996 (empty links), in a distinct mechanism.

Suggested direction (triage to decide)

The fix needs a deliberate design choice, e.g.: (a) preserve unused definitions verbatim — the parse direction would need a source pre-scan for reference definitions, diff them against the labels comrak actually consumed, and carry the leftovers (e.g. as a trailing raw block the editor displays but does not eat); (b) represent definitions in the PM doc (a dedicated node) — cleaner but touches the editor schema; or (c) if neither is acceptable, document the limitation where the codec's schema is described (module doc comment at the top of markdown.rs) so the loss is at least a known, stated behaviour instead of a silent one. Doing nothing silently is the only unacceptable outcome.

Acceptance criteria

  • A document with an unused reference definition no longer loses it silently on a load/save round trip — either the definition survives (verbatim or in an equivalent reference form), or the limitation is explicitly documented in the codec module docs and this issue is closed citing that documentation.
  • Used references (full, collapsed, shortcut, multiple links sharing one definition) keep round-tripping exactly as today.
  • A definitions-only document does not save as an empty file under the chosen fix (or is covered by the documented limitation).
  • Existing web::markdown tests pass.

Activity

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    task/triageQueue packet kind: verify, reproduce, and route this item
    source/creatorFiled by the new-issue-creator job
    on Oct 26, 2026
  2. developing-today commented on Oct 26, 2026

    @developing-today
    Contributor
  3. added
    priority/normalOrdinary priority (the default)
    app/idPackage/app: id (pkgs/ or apps/ in this repo)
    on Oct 26, 2026
  4. dezren39 commented on Oct 26, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

    • Agent: new-issue-creator job
    • Session / ID: new-issue-creator cron run 2026-10-26 14:10 CDT
    • Found via: filed this run
    • Task: Verified with a standalone verbatim-codec probe on main 3b9d159 (log hidden_files/probe-2026-10-26-1415/out4.log, cases unused-ref-def / ref-def-only-doc): link reference definitions no link uses never reach the ProseMirror doc and are deleted on save; a definitions-only document saves as an empty file. Used references (full/collapsed/shortcut controls in the same log) round-trip fine. Enqueued as a triage packet to repo-health-code-pilot — this one needs a design decision (preserve, represent, or explicitly document), not a quick patch.
    • Expectation: triage picks one of the directions in the issue; done when unused definitions survive a round trip or the limitation is documented in the codec module docs.
    • Links: probe evidence in goal hidden_files (see issue body)
  5. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed on Oct 31, 2026
  6. 177 remaining items

  7. dezren39 commented on Nov 11, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    event: blocked
    task: 14704; worker repo-worker-code; scheduled lane 02cafe76-eafd-4d0b-aaa6-2b7a737d68dc
    state: PR #7170 and #5949 both remain open for this issue; earlier triage called #5949 canonical and #7170 duplicate, while task 14704 has subsequently advanced #7170. Issue already has user/escalated. PR #7170 is Drew-authored and this lane cannot modify it. No PR changed.
    resume: establish the canonical ownership/disposition between both PRs, then reassess CI and review feedback.

  8. removed
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    status/parkedDeliberately paused with a recorded resume condition
    work/assignedQueue worker lifecycle state
    on Nov 11, 2026
  9. dezren39 commented on Nov 11, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    state: parked — CI wait
    task: 14767
    lane: code-o
    issue: #1004
    pr: #5949

    Fresh Codex round on head f1f736b (3 P2s) dispositioned in 0f25337: front-matter boundaries now match comrak split_off_front_matter exactly; multiline blockquoted definition labels strip containers from every line before keying; find_balanced_label_close skips inline code spans. One regression test per finding (each failed before, passes after); full web::markdown suite 279 passed (cargo test --lib --features web). Disposition comment on PR #5949 (6786142186); all review threads resolved.

    Parked as a broker CI wait on PR #5949 at head 0f25337 (checks queued in the Actions stall). Resume: checks green + fresh Codex round clean -> merge PR #5949, verify #1004/#8355 closed by the merge, complete task 14767.

  10. added
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    status/parkedDeliberately paused with a recorded resume condition
    and removed
    status/blockedQueue or user escalation state
    queue/blockedQueue or user escalation state
    on Nov 11, 2026
  11. dezren39 commented on Nov 12, 2026

    @dezren39
    MemberAuthor

    Task 14704 claimed to shepherd duplicate PR #7170. Fresh state: issue #1004 is CLOSED; canonical PR #5949 is MERGED (2026-11-11T06:56:59Z); PR #7170 remains OPEN at f342c4b, with no labels or assignees. #7170 is authored by the fleet account dezren39; I will determine whether any unique content remains before disposition. The earlier conflicting ownership is now resolved by #5949 merging; no branch changes yet.

  12. dezren39 commented on Nov 12, 2026

    @dezren39
    MemberAuthor

    Task 14704 disposition: PR #7170 is CLOSED as superseded by merged canonical PR #5949 (merge commit 8d14e1f; implementation head f1f8ebd). Fresh content-level diff found no unique behavior to salvage; the comparison is on #5949 and the close reason is on #7170. Issue #1004 is CLOSED by #5949. No branch was deleted.

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)mode/onlineFully doable remotely: design, config, code, cloudpriority/normalOrdinary priority (the default)queue/parkedQueue task is parked (waiting on CI, time, or an event)source/creatorFiled by the new-issue-creator jobstatus/parkedDeliberately paused with a recorded resume conditionstatus:donetask/triageQueue packet kind: verify, reproduce, and route this itemuser/escalatedRequires a Drew decision or access

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions