Skip to content

Fix attack path Mermaid rendering when mmdc is not installed (spec 112 follow-up) #130

@davidmatousek

Description

@davidmatousek

Idea

Adopt pymmdc (pure Python) as the primary Mermaid renderer for attack path pages, with mmdc as an optional fallback, to reliably ship rendered diagram images regardless of whether Node.js is installed. Closes the spec 112 AC#2 gap.

Detail

Spec 112 follow-up — fix attack path Mermaid rendering when mmdc is not installed.

Current behavior

The text fallback at templates/tachi/security-report/attack-path.typ ships ~40 lines of raw flowchart TD source per attack path page when mmdc is missing. This silently fails spec 112 AC#2 at specs/112-attack-path-pages/spec.md:34 ("a rendered diagram image of the attack tree") while the pipeline reports success.

Root cause

specs/112-attack-path-pages/research.md:80 documented pymmdc as a pure-Python alternative, but the recommendations at research.md:91-93 picked mmdc + text fallback without capturing a rationale for dropping pymmdc. spec.md:135 then codified "text fallback is acceptable," which contradicts AC#2.

Proposed fix (pick one)

  1. pymmdc as primary, mmdc as optional fallback — wire pymmdc into render_mermaid_to_png() in scripts/extract-report-data.py; zero Node.js footprint; honors the "Determinism" constraint at research.md:66. Recommended.
  2. mmdc as hard dependency — add a pre-flight shutil.which("mmdc") check to /tachi.security-report matching the Typst check at .claude/commands/tachi.security-report.md; delete the text fallback branch; document npm install -g @mermaid-js/mermaid-cli as a prerequisite in README and install script.
  3. Kroki HTTP integration — call kroki.io or a local container; no local binaries but adds network/Docker requirement.

Impact scope

  • Affects every first-time user without @mermaid-js/mermaid-cli installed globally
  • Blocks the "show to exec board" flagship use case from spec.md:25
  • Data correctness unaffected — cosmetic failure only
  • Observed failure mode: /Users/david/Projects/second-brain-mcp/docs/security/2026-04-09T19-13-20/ before mmdc install

Acceptance criteria

  • Fresh tachi install on a machine without Node.js produces a security PDF where attack path pages show rendered diagram images, not raw Mermaid source
  • specs/112-attack-path-pages/spec.md:135 text-fallback clause is removed or reframed as a last-resort error state, not a supported shipping mode
  • README and install docs reflect the final dependency posture (no Node.js requirement, or clearly documented prerequisite)
  • Spec 112 spec.md:135 research.md update: document why pymmdc was not adopted in the original 112 research (if still rejected) or adopt it (if chosen)

ICE Score

Impact: 9, Confidence: 9, Effort: 9 = 27

Evidence

Team Observation: Directly observed in second-brain-mcp PDF at 2026-04-09T19-13-20 — 214 pages of character-bullet text (separate bug, now fixed) plus raw Mermaid source in the attack path section.

User Story

As a template adopter running /tachi.security-report, I want attack path diagrams to render as images by default on a fresh install, so that the generated PDF is board-presentation ready without requiring an undocumented Node.js prerequisite.

Metadata

  • Source: Team Idea
  • Priority: P0 (Critical)
  • Date: 2026-04-09
  • Status: Validated

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions