Skip to content

Parser/converter follow-ups from #3: open links + LLM output validate-retry #6

Description

@thorwhalen

Follow-ups deliberately left out of scope in #3, which fixed MermaidParser silently dropping edge lines.

1. Open links (a --- b) are still unsupported

Mermaid's undirected/open link form is not recognized. After #3 it warns (via MermaidParseWarning, recorded in MermaidParser.unparsed_lines) instead of vanishing silently, so it is no longer a data-loss bug — but it is still unparsed.

Work: add the open-link form to the edge pattern table (#3 consolidated node/edge shapes into a single SSOT table, so this should be a table entry plus a test). Decide how an undirected link is represented in the graph model — probably an Edge with a direction/undirected flag rather than two opposite edges.

2. LLMConverter has no validate-then-retry on model output

LLMConverter now refuses output that contains no valid diagram (raising with the raw output in the message, added in #3), but it does not retry. Model drift therefore still surfaces as a hard failure rather than a self-correcting one.

This was scoped out of #3 on purpose: doing it properly needs decisions that belong in their own change —

  • retry budget (how many attempts, and does it back off?)
  • prompt repair — feed the parse error / unparsed_lines back to the model, or just re-ask?
  • cost policy — retries cost real tokens; should it be opt-in, and configurable per call?
  • what counts as "valid enough" to accept (currently: at least one parseable node/edge)

Useful signal is already available: after a parse, MermaidParser.unparsed_lines holds exactly the lines the model got wrong, which is a good basis for a targeted repair prompt.

Context

The bug fixed in #3 is worth reading before touching this area: inline node definitions on an edge line (A[Start] --> B[End], the most common Mermaid idiom) were parsed to one node and zero edges on the pre-#3 code — and a passing test masked it, because the test only asserted validate(), which an under-populated diagram satisfies.

Surfaced during the 2026-07-30 wave-0 rollout batch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions