From f262d769ea7b8ad13872c65793a5546a51965bf0 Mon Sep 17 00:00:00 2001 From: Ralf Anton Beier Date: Wed, 22 Apr 2026 06:31:40 +0200 Subject: [PATCH 1/6] fix(markdown): render mermaid fences as
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Artifact descriptions go through rivet-core's pulldown-cmark based
render_markdown. That renderer was emitting pulldown's default
 for fenced mermaid blocks, which
the dashboard's mermaid.js (selector `.mermaid`) never matches — so
diagrams in artifact descriptions rendered as literal source.

Add a tiny event-mapping pass that replaces the Start/End code-block
events for `mermaid` fences with synthetic HTML wrappers (NUL-byte
sentinels that cannot appear in input, rewritten post-html-push). Other
raw HTML events are still dropped for XSS defence, and the sanitize
pass still runs. Non-mermaid fences keep their existing rendering.

Covers the bug end-to-end: markdown unit tests verify the 
 shape and regression for rust fences; architecture.yaml
ARCH-CORE-001 now carries a mermaid diagram as a live fixture, and a
Playwright regression walks the artifact page and asserts mermaid.js
actually produces an SVG.

Fixes: REQ-032
Refs: FEAT-032
---
 artifacts/architecture.yaml        |   9 ++-
 rivet-core/src/markdown.rs         | 125 ++++++++++++++++++++++++++---
 tests/playwright/artifacts.spec.ts |  26 ++++++
 3 files changed, 149 insertions(+), 11 deletions(-)

diff --git a/artifacts/architecture.yaml b/artifacts/architecture.yaml
index 7f8bfee..96aa465 100644
--- a/artifacts/architecture.yaml
+++ b/artifacts/architecture.yaml
@@ -48,10 +48,17 @@ artifacts:
   - id: ARCH-CORE-001
     type: aadl-component
     title: RivetCore process
-    description: >
+    description: |
       Core library process containing all domain logic: config loading,
       schema merging, artifact storage, adapter dispatch, graph building,
       validation, matrix computation, diff, documents, and query.
+
+      ```mermaid
+      flowchart LR
+          Config --> Store
+          Store --> Graph
+          Graph --> Validate
+      ```
     status: implemented
     tags: [aadl, architecture, core]
     links:
diff --git a/rivet-core/src/markdown.rs b/rivet-core/src/markdown.rs
index 2b2a4dd..62a78ee 100644
--- a/rivet-core/src/markdown.rs
+++ b/rivet-core/src/markdown.rs
@@ -49,27 +49,65 @@ fn sanitize_html(html: &str) -> String {
 /// Enables tables, strikethrough, and task lists on top of the CommonMark base.
 /// Used for artifact descriptions, field values, and document content.
 ///
-/// Security: raw HTML events are filtered at the pulldown-cmark level, and a
-/// regex-based sanitization pass strips dangerous tags (`