mermate-tab-mermaid
Stage 3 tab (Mermaid) of the Mermate pipeline — Mermaid source compile/render to mastered PNG/SVG diagrams, depth scoring, and the run artifacts that TLA+ and TypeScript build from. Use when editing r
SKILL.md.windsurf/skills/mermate-tab-mermaid/SKILL.md
GitHubMermate Tab 3 · Mermaid (mmd)
Operates under mermate master invariants; Lamport standards via specification-master-agent.
Stage Identity (from STAGE_REGISTRY.mmd, public/js/mermaid-gpt-app.js)
- Label: Mermaid · reveal:
STAGE 3 · DIAGRAM· color#818cf8 - Expected duration: ≈5–30s · enhance default: OFF · upload:
.mmd - IPO contract:
- Input: markdown spec or raw .mmd source
- Process: compile + repair + depth scoring
- Output: mastered diagram (PNG/SVG) — the run TLA+/TS build from
Owning Code
- Frontend:
public/js/mermaid-gpt-app.js—renderMermaid()(line ~2287), depth badge, result display - Backend:
server/routes/render.jsPOST /api/render(lines 495–1047) — mermaid-cli (@mermaid-js/mermaid-cli), Python enhancer bridge (MERMAID_ENHANCER_URL, default localhost:8100), inference provider - Depth scoring:
depth_score/depth_tier(shallow|medium|deep), surfaced in response and reported to Opseeq - Artifacts:
flows/(rendered output),archs/(archived sources),runs/(lineage JSON withrun_id)
Stage Invariants
- The mastered run is the anchor:
run_idreturned here is the input contract for/api/render/tlaand/api/render/ts. Never regenerate a diagram implicitly in a later stage. - Success payload carries
paths,diagram_name,run_id,metrics, andprogressionUpdateunlocking['idea','md','mmd','tsx','tla']withnextRecommendedset. - Compile failure emits
render_failedstage event and a structured error — never a fabricated diagram. - Opseeq events
render_start/render_complete/render_failedare fire-and-forget; render succeeds with Opseeq down.
Anti-Patterns (Reject)
- Bypassing mermaid-cli with a hand-rolled renderer or "fixing" diagrams client-side.
- Losing
run_idlineage (e.g. rendering without persisting toruns/). - Duplicating depth-score semantics outside the single scoring path in the render route.
Verification
node --test test/test-compiler.js; render regression →npm run test:regression- Live: render from each input_mode and confirm
flows/+runs/artifacts andprogressionUpdatepayload