Skip to content

Quote mermaid node labels with icons/specials and add validation tooling#8646

Merged
pethers merged 3 commits into
masterfrom
copilot/test-review-mermaid-diagrams
May 24, 2026
Merged

Quote mermaid node labels with icons/specials and add validation tooling#8646
pethers merged 3 commits into
masterfrom
copilot/test-review-mermaid-diagrams

Conversation

Copilot AI commented May 24, 2026

Copy link
Copy Markdown
Contributor

Description

Adds automated Mermaid diagram validation tooling and enforces quoting of node labels containing special characters (emoji, &, parentheses, ;, ,, fa:fa- icons). Includes a quote fixer script, deep-check inventory script, and a CI workflow that renders every mermaid block via @mermaid-js/mermaid-cli.

Key fixes applied based on review feedback:

  • C4 diagrams restored: Reverted broken C4 macro syntax in ARCHITECTURE.md, FUTURE_ARCHITECTURE.md, and SKILL.md that was incorrectly rewritten by the quote fixer
  • CI failure fixed: Replaced npm init -y with explicit package.json in .mermaid-tools directory (dot-prefixed names are invalid npm package names)
  • Quote fixer improved: Added C4 diagram type detection to skip C4 blocks entirely, updated docstring to match actual implementation
  • Deep-check fixed: Removed unused variable assignment (CodeQL finding), removed incorrect & exemption
  • Validator hardened: Added safety guard for MERMAID_WORK path, added ENOENT detection for missing mmdc (exits with code 2)
  • Documentation aligned: Fixed "Two scripts" → "Three scripts" in style guide, fixed "nightly" → "weekly" in workflow comment
  • Theme example fixed: Added a minimal graph LR body to the %%{init}%% theme example in MERMAID_STYLE_GUIDE.md so it has a valid diagram type and renders under mmdc (was the sole failing diagram out of 490 in the CI validation artifact)

Type of Change

Primary Changes

  • 🚀 New Feature
  • 🔄 Enhancement
  • 🐛 Bug Fix

Political Analysis

  • 📊 Political Data Analysis
    • Party Analysis
    • Committee Processing
    • Government Data
    • Riksdagen Integration
  • 📈 Analytics & Metrics
    • Performance Metrics
    • Risk Assessment
    • Decision Analysis
    • Transparency Metrics

Technical Changes

  • 🎨 UI/UX Changes
    • Layout Updates
    • Form Improvements
    • Visualization Updates
  • 🏗️ Infrastructure
    • Database Changes
    • Performance Optimization
    • Configuration Updates
  • 🔒 Security & Compliance
    • Authentication
    • Authorization
    • Data Protection
  • 📝 Documentation
    • Technical Documentation
    • User Documentation
    • API Documentation
  • ✅ Testing
    • Unit Tests
    • Integration Tests
    • Performance Tests

Impact Analysis

Political Analysis Impact

  • Impact on data quality: None — changes are limited to documentation rendering tooling
  • Impact on analysis accuracy: None
  • Impact on transparency features: Improved diagram rendering reliability

Technical Impact

  • Performance impact: None
  • Security implications: Added safety guard preventing accidental recursive deletion via MERMAID_WORK env var
  • Dependency changes: None (mermaid-cli is installed in CI only, not added to project deps)

Testing

  • Unit tests added/updated
  • Integration tests added/updated
  • Political data validation completed
  • Security compliance verified
  • Performance testing completed

Scripts verified via:

  • node --check syntax validation on all three scripts
  • fix-mermaid-quotes.mjs --dry-run confirms C4 diagrams are now skipped
  • deep-check-mermaid.mjs runs successfully with corrected logic
  • CodeQL security scan passes with 0 alerts
  • validate-mermaid.mjs CI artifact (report.json) analysed: after the theme-example fix, 0 of 490 diagrams fail to render

Documentation

  • JavaDoc updated
  • README updated
  • API documentation updated
  • Package/module documentation updated
  • Political analysis documentation updated

New MERMAID_STYLE_GUIDE.md documents palette, quoting rules, and tooling usage.

Screenshots

N/A

Related Issues

Related to #8637

Checklist

  • Code follows project coding standards
  • Comments are clear and helpful
  • Documentation is updated
  • Tests are passing
  • Security compliance is maintained
  • Performance impact is acceptable
  • Breaking changes are documented
  • Changes are backward compatible

Additional Notes

The quote fixer now detects C4 diagram types (C4Context, C4Container, C4Component, C4Dynamic, C4Deployment) and skips them entirely, since C4 macros use parentheses as function-call delimiters rather than node-label brackets.

The theme-block example in MERMAID_STYLE_GUIDE.md previously consisted of only a %%{init}%% directive, which mmdc rejected with UnknownDiagramError: No diagram type detected. It now includes a minimal graph LR body so the example renders while still demonstrating the recommended theme configuration.

Security Considerations

  • No sensitive data exposed
  • Security best practices followed
  • Compliance requirements met

Added path validation for MERMAID_WORK to prevent accidental recursive deletion of sensitive directories.

Release Notes

Added Mermaid diagram validation tooling: CI workflow validates all mermaid blocks render correctly, deep-check script inventories style issues, and quote fixer automatically wraps risky node labels in quotes while preserving C4 diagram syntax.

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
@github-actions

github-actions Bot commented May 24, 2026

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Snapshot Warnings

⚠️: No snapshots were found for the head SHA ce4a2c8.
Ensure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice.

OpenSSF Scorecard

PackageVersionScoreDetails
actions/actions/checkout de0fac2e4500dabe0009e67214ff5f5447ce83dd 🟢 5.7
Details
CheckScoreReason
Code-Review🟢 10all changesets reviewed
Maintained⚠️ 01 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Dangerous-Workflow🟢 10no dangerous workflow patterns detected
Binary-Artifacts🟢 10no binaries found in the repo
Token-Permissions⚠️ 0detected GitHub workflow tokens with excessive permissions
CII-Best-Practices⚠️ 0no effort to earn an OpenSSF best practices badge detected
Packaging⚠️ -1packaging workflow not detected
Pinned-Dependencies🟢 3dependency not pinned by hash detected -- score normalized to 3
Fuzzing⚠️ 0project is not fuzzed
License🟢 10license file detected
Signed-Releases⚠️ -1no releases found
Security-Policy🟢 9security policy file detected
Branch-Protection🟢 5branch protection is not maximal on development and all release branches
SAST🟢 8SAST tool detected but not run on all commits
actions/actions/setup-node 48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e 🟢 5.7
Details
CheckScoreReason
Maintained🟢 68 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 6
Code-Review🟢 10all changesets reviewed
Binary-Artifacts🟢 9binaries present in source code
Dangerous-Workflow🟢 10no dangerous workflow patterns detected
Packaging⚠️ -1packaging workflow not detected
Token-Permissions⚠️ 0detected GitHub workflow tokens with excessive permissions
CII-Best-Practices⚠️ 0no effort to earn an OpenSSF best practices badge detected
Pinned-Dependencies⚠️ 0dependency not pinned by hash detected -- score normalized to 0
Fuzzing⚠️ 0project is not fuzzed
License🟢 10license file detected
Signed-Releases⚠️ -1no releases found
Security-Policy🟢 9security policy file detected
Branch-Protection⚠️ 1branch protection is not maximal on development and all release branches
SAST🟢 9SAST tool is not run on all commits -- score normalized to 9
actions/actions/upload-artifact 043fb46d1a93c77aae656e7c1c64a875d1fc6a0a 🟢 5.6
Details
CheckScoreReason
Maintained🟢 66 commit(s) and 2 issue activity found in the last 90 days -- score normalized to 6
Binary-Artifacts🟢 10no binaries found in the repo
Dangerous-Workflow🟢 10no dangerous workflow patterns detected
Code-Review🟢 8Found 8/9 approved changesets -- score normalized to 8
Packaging⚠️ -1packaging workflow not detected
CII-Best-Practices⚠️ 0no effort to earn an OpenSSF best practices badge detected
Token-Permissions⚠️ 0detected GitHub workflow tokens with excessive permissions
Pinned-Dependencies⚠️ 1dependency not pinned by hash detected -- score normalized to 1
Fuzzing⚠️ 0project is not fuzzed
License🟢 10license file detected
Signed-Releases⚠️ -1no releases found
Security-Policy🟢 9security policy file detected
SAST🟢 10SAST tool is run on all commits
Branch-Protection⚠️ 0branch protection not enabled on development/release branches
actions/step-security/harden-runner 9af89fc71515a100421586dfdb3dc9c984fbf411 🟢 8
Details
CheckScoreReason
Binary-Artifacts🟢 10no binaries found in the repo
Branch-Protection🟢 8branch protection is not maximal on development and all release branches
CI-Tests🟢 1016 out of 16 merged PRs checked by a CI test -- score normalized to 10
CII-Best-Practices⚠️ 0no effort to earn an OpenSSF best practices badge detected
Code-Review🟢 10all changesets reviewed
Contributors🟢 6project has 2 contributing companies or organizations -- score normalized to 6
Dangerous-Workflow🟢 10no dangerous workflow patterns detected
Dependency-Update-Tool🟢 10update tool detected
Fuzzing⚠️ 0project is not fuzzed
License🟢 10license file detected
Maintained🟢 1018 commit(s) and 5 issue activity found in the last 90 days -- score normalized to 10
Packaging⚠️ -1packaging workflow not detected
Pinned-Dependencies🟢 6dependency not pinned by hash detected -- score normalized to 6
SAST🟢 10SAST tool is run on all commits
Security-Policy🟢 10security policy file detected
Signed-Releases⚠️ -1no releases found
Token-Permissions🟢 10GitHub workflow tokens follow principle of least privilege
Vulnerabilities⚠️ 19 existing vulnerabilities detected

Scanned Files

  • .github/workflows/validate-mermaid.yml

@pethers pethers marked this pull request as ready for review May 24, 2026 22:51
@pethers pethers self-requested a review as a code owner May 24, 2026 22:51
Copilot AI review requested due to automatic review settings May 24, 2026 22:51
Comment thread scripts/deep-check-mermaid.mjs Fixed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens Mermaid diagram authoring across the repository by introducing validation tooling (local + CI) and mechanically quoting risky node labels (icons/special characters) to reduce cross-renderer fragility across GitHub/Maven Site/export consumers.

Changes:

  • Added Node-based Mermaid tooling under scripts/ (full render validation, deep inventory, and an auto-quote fixer).
  • Added a dedicated GitHub Actions workflow to validate Mermaid diagrams on Markdown-touching PRs/pushes and on a schedule, and added .gitignore entries for generated artifacts.
  • Updated numerous Markdown documents/visualization specs to quote Mermaid node labels containing emojis/special characters, and added MERMAID_STYLE_GUIDE.md to document the rules and palette.

Reviewed changes

Copilot reviewed 54 out of 55 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
WORKFLOWS.md Quotes a few Mermaid node labels to avoid special-character parsing issues.
THREAT_MODEL.md Quotes many Mermaid node labels with emojis/special chars to stabilize rendering.
service.data.impl/README-SCHEMA-MAINTENANCE.md Quotes a Mermaid node label containing an icon.
SECURITY_ARCHITECTURE.md Quotes Mermaid node labels across multiple security diagrams for consistent rendering.
scripts/validate-mermaid.mjs New script that renders all Mermaid blocks via mmdc and reports failures.
scripts/fix-mermaid-quotes.mjs New script to rewrite Mermaid node labels by adding quotes when risky chars are present.
scripts/deep-check-mermaid.mjs New script to inventory Mermaid usage and flag risky/unquoted labels and palette sprawl.
RISK_RULES_INTOP_OSINT.md Quotes Mermaid node labels containing emojis/special chars.
MERMAID_STYLE_GUIDE.md New style guide documenting required quoting rules, palette, and validator usage.
json-export-specs/visualizations/top10-rising-stars.md Quotes a Mermaid label containing &.
json-export-specs/visualizations/top10-party-rebels.md Quotes Mermaid node labels with emoji/status icons.
json-export-specs/visualizations/top10-most-controversial.md Quotes a Mermaid label containing &.
json-export-specs/visualizations/top10-most-absent.md Quotes multiple Mermaid labels containing icons/special characters.
json-export-specs/visualizations/top10-ethics-concerns.md Quotes Mermaid labels containing icons/special characters.
json-export-specs/visualizations/top10-electoral-risk.md Quotes Mermaid labels containing icons/special characters.
json-export-specs/visualizations/top10-coalition-brokers.md Quotes Mermaid labels containing ,/& and multi-line content.
json-export-specs/visualizations/politician-profile.md Quotes Mermaid labels containing , and &.
json-export-specs/visualizations/party-performance.md Quotes Mermaid labels containing ,.
json-export-specs/visualizations/intelligence-dashboard.md Quotes Mermaid labels containing icons and braces-content.
json-export-specs/visualizations/government-cabinet.md Quotes Mermaid labels containing &.
json-export-specs/visualizations/committee-network.md Quotes Mermaid labels containing multi-line content (with <br/>).
json-export-specs/README.md Quotes Mermaid multi-line node labels.
ISMS_COMPLIANCE_MAPPING.md Quotes Mermaid labels (including mindmap icons) to avoid parsing issues.
INTELLIGENCE_DATA_FLOW.md Quotes Mermaid node labels containing emojis/special chars.
FUTURE_WORKFLOWS.md Quotes a Mermaid label containing &.
FUTURE_SECURITY_ARCHITECTURE.md Quotes Mermaid node labels containing &.
FUTURE_FLOWCHART.md Quotes Mermaid node labels containing / and &.
FUTURE_DATA_MODEL.md Quotes Mermaid node labels containing -/&.
FUTURE_ARCHITECTURE.md Updates Mermaid C4 diagrams and other labels; adds extensive quoting changes.
DOCUMENTATION_NAMING_CONVENTION.md Quotes a Mermaid node label containing ,/./....
DATABASE_VIEW_INTELLIGENCE_CATALOG.md Quotes a Mermaid node label containing &.
DATA_ANALYSIS_INTOP_OSINT.md Quotes many Mermaid node labels containing emojis/special chars.
CRA-ASSESSMENT.md Quotes Mermaid node labels containing emojis/special chars.
ARCHITECTURE.md Updates Mermaid C4 diagrams and other labels; adds extensive quoting changes.
.gitignore Ignores .mermaid-validate/ and .mermaid-tools/ output directories.
.github/workflows/validate-mermaid.yml New CI workflow to validate Mermaid rendering and upload reports.
.github/skills/vulnerability-management/SKILL.md Quotes Mermaid node labels containing emojis/special chars.
.github/skills/swedish-political-system/SKILL.md Quotes Mermaid labels containing ,.
.github/skills/strategic-communication-analysis/SKILL.md Quotes Mermaid node labels with emojis/special chars.
.github/skills/risk-assessment-methodology/SKILL.md Quotes Mermaid node labels with emojis/special chars.
.github/skills/risk-assessment-frameworks/SKILL.md Quotes Mermaid node labels with emojis/special chars.
.github/skills/osint-methodologies/SKILL.md Quotes Mermaid node labels with emojis/special chars.
.github/skills/open-source-policy/SKILL.md Quotes Mermaid node labels with emojis/special chars.
.github/skills/legislative-monitoring/SKILL.md Quotes Mermaid node labels with emojis/special chars.
.github/skills/intelligence-analysis-techniques/SKILL.md Quotes Mermaid node labels containing &.
.github/skills/information-security-strategy/SKILL.md Quotes Mermaid node labels with emojis/special chars.
.github/skills/incident-response/SKILL.md Quotes Mermaid node labels with emojis/special chars.
.github/skills/hack23-future-architecture-standards/SKILL.md Updates Mermaid C4 examples with quoting changes.
.github/skills/cryptography-policy/SKILL.md Quotes Mermaid node labels with emojis/special chars.
.github/skills/compliance-checklist/SKILL.md Quotes Mermaid mindmap root label.
.github/skills/classification-policy/SKILL.md Quotes Mermaid node labels with emojis/special chars.
.github/skills/behavioral-analysis/SKILL.md Quotes Mermaid node labels with emojis/special chars.
.github/skills/backup-recovery-policy/SKILL.md Quotes Mermaid node labels with emojis/special chars.
.github/skills/access-control-policy/SKILL.md Quotes Mermaid node labels with emojis/special chars.

Comment thread ARCHITECTURE.md Outdated
Comment on lines +82 to +86
Person("anonymousUser, #quot;Anonymous User#quot;, #quot;Accesses public political data and metrics#quot;")
Person("registeredUser, #quot;Registered User#quot;, #quot;Creates account and accesses personalized features#quot;")
Person("adminUser, #quot;System Administrator#quot;, #quot;Manages system configuration and user accounts#quot;")

System(cia, "Citizen Intelligence Agency", "Provides analysis and visualization of Swedish political activities")
System("cia, #quot;Citizen Intelligence Agency#quot;, #quot;Provides analysis and visualization of Swedish political activities#quot;")
Comment thread FUTURE_ARCHITECTURE.md Outdated
Comment on lines +57 to +81
Person("citizen, #quot;Citizen Analyst#quot;, #quot;Uses platform for political research and transparency insights#quot;")
Person("researcher, #quot;Political Researcher#quot;, #quot;Conducts deep analysis of political patterns and trends#quot;")
Person("developer, #quot;Developer#quot;, #quot;Maintains and extends the platform with AI-assisted tooling#quot;")

System("cia, #quot;Citizen Intelligence Agency#quot;, #quot;AI-enhanced political intelligence platform with LLM-powered analytics, GitHub Copilot agent-assisted development, and comprehensive Swedish political data analysis#quot;")

System_Ext("riksdagen, #quot;Swedish Parliament API#quot;, #quot;Parliamentary data: members, votes, documents, committees#quot;")
System_Ext("election, #quot;Swedish Election Authority#quot;, #quot;Election results, party data, voter turnout#quot;")
System_Ext("worldbank, #quot;World Bank Open Data#quot;, #quot;Economic indicators and demographic data#quot;")
System_Ext("esv, #quot;Swedish Financial Authority#quot;, #quot;Government finances and agency budgets#quot;")
System_Ext("llmService, #quot;LLM Service Layer#quot;, #quot;Anthropic Opus 4.6 / competitor models for text analysis and summarization#quot;")
System_Ext("copilotAgents, #quot;GitHub Copilot Agents#quot;, #quot;AI-assisted development, code review, documentation generation#quot;")

Rel("citizen, cia, #quot;Explores political data, views analytics dashboards#quot;")
Rel("researcher, cia, #quot;Queries political datasets, analyzes voting patterns#quot;")
Rel("developer, cia, #quot;Develops features with AI-assisted tooling#quot;")

Rel("cia, riksdagen, #quot;Imports parliamentary data via REST API#quot;")
Rel("cia, election, #quot;Imports election and party data#quot;")
Rel("cia, worldbank, #quot;Imports economic indicators#quot;")
Rel("cia, esv, #quot;Imports government financial data#quot;")
Rel("cia, llmService, #quot;Sends political texts for analysis and summarization#quot;")
Rel("developer, copilotAgents, #quot;Leverages AI agents for development tasks#quot;")

UpdateLayoutConfig("$c4ShapeInRow=#quot;3#quot;, $c4BoundaryInRow=#quot;1#quot;")
Comment on lines +39 to +54
Person("citizen, #quot;Citizen#quot;, #quot;Swedish citizen seeking political transparency#quot;")
Person("analyst, #quot;Political Analyst#quot;, #quot;Researches political patterns#quot;")

System("cia, #quot;CIA Platform#quot;, #quot;Political intelligence and analysis#quot;")

System_Ext("riksdag, #quot;Riksdagen API#quot;, #quot;Swedish Parliament open data#quot;")
System_Ext("val, #quot;Val.se#quot;, #quot;Swedish Election Authority#quot;")
System_Ext("worldbank, #quot;World Bank#quot;, #quot;Economic indicators#quot;")
System_Ext("esv, #quot;ESV#quot;, #quot;Swedish financial data#quot;")

Rel("citizen, cia, #quot;Views political data#quot;, #quot;HTTPS#quot;")
Rel("analyst, cia, #quot;Analyzes political trends#quot;, #quot;HTTPS#quot;")
Rel("cia, riksdag, #quot;Fetches parliament data#quot;, #quot;HTTPS/JSON#quot;")
Rel("cia, val, #quot;Fetches election data#quot;, #quot;HTTPS/JSON#quot;")
Rel("cia, worldbank, #quot;Fetches economic data#quot;, #quot;HTTPS/JSON#quot;")
Rel("cia, esv, #quot;Fetches financial data#quot;, #quot;HTTPS/JSON#quot;")
Comment thread MERMAID_STYLE_GUIDE.md Outdated
Comment on lines +19 to +25
Two scripts live under [`scripts/`](./scripts/):

| Script | Purpose |
|---|---|
| `scripts/validate-mermaid.mjs` | Renders every ```` ```mermaid ```` block in every `*.md` file via `@mermaid-js/mermaid-cli`. Fails CI on any unrenderable diagram. |
| `scripts/deep-check-mermaid.mjs` | Inventories palette/theme usage and reports node labels with risky characters that should be quoted. Advisory — does not fail CI. |
| `scripts/fix-mermaid-quotes.mjs` | Idempotently rewrites node labels that contain emoji, `&`, parentheses, `:`, `;`, `,` or `fa:fa-` icons to be wrapped in `"…"`. Safe to re-run. |
Comment thread .github/workflows/validate-mermaid.yml Outdated
# Renders every ```mermaid block in every *.md file in the repository via the
# official @mermaid-js/mermaid-cli and fails if any diagram does not render.
# Runs on every PR that touches a markdown file, on every push to master, and
# nightly to catch regressions caused by upstream Mermaid releases.
Comment on lines +5 to +14
* Wraps node labels in ```mermaid blocks with double quotes when they contain
* characters that are safer or required to be quoted:
* - Emoji (Unicode pictographs / symbols)
* - `&` (ampersand)
* - `(` `)` parentheses
* - `:` colon
* - `;` semicolon
* - `,` comma
* - `<` `>` (outside `<br/>` which is allowed in mermaid)
* - `fa:fa-…` Font Awesome icon syntax
Comment on lines +115 to +126
// Require the opener to be preceded by an identifier char, otherwise it's
// not a node-label opening (it's punctuation in normal text — e.g. the
// `>` in `-->`, or the `(` in a free-text phrase). If not a node open,
// advance past JUST the opener so we don't consume bracket pairs that
// legitimately belong to following nodes (that was a real bug).
const prevChar = found.idx > 0 ? code[found.idx - 1] : '';
const isNodeOpen = isIdentChar(prevChar);
if (!isNodeOpen) {
out += code.slice(i, found.idx + 1); // include first char of opener
i = found.idx + 1;
continue;
}
Comment on lines +119 to +123
const ampRe = /[\[(]([^"\[\]()][^\[\]()]*&[^\[\]()]*?)[\])]/g;
while ((lm = ampRe.exec(line)) !== null) {
if (!lm[1].startsWith('"') && !lm[1].includes('&amp;')) {
issues.ampersandInLabel.push({ file: rel, line: lineNo, snippet: line.trim() });
}
Comment on lines +31 to +66
const REPO = path.resolve(process.argv[2] || path.join(__dirname, '..'));
const WORK = process.env.MERMAID_WORK || path.join(REPO, '.mermaid-validate');
const IGNORE = new Set(['node_modules', 'target', 'dist', 'build', '.git', '.mermaid-validate']);

// Resolve mmdc binary - prefer local node_modules, then ancestor node_modules, then PATH
function resolveMmdc() {
const candidates = [
path.join(REPO, 'node_modules', '.bin', 'mmdc'),
path.join(__dirname, '..', 'node_modules', '.bin', 'mmdc'),
'/tmp/mmd-test/node_modules/.bin/mmdc',
];
for (const c of candidates) if (existsSync(c)) return c;
return 'mmdc';
}
const MMDC = process.env.MMDC || resolveMmdc();

// Puppeteer needs --no-sandbox in CI / container environments
const PUPPETEER_CFG = path.join(WORK, 'puppeteer-config.json');

async function* walk(dir) {
let ents;
try { ents = await readdir(dir, { withFileTypes: true }); } catch { return; }
for (const ent of ents) {
if (IGNORE.has(ent.name)) continue;
const p = path.join(dir, ent.name);
if (ent.isDirectory()) yield* walk(p);
else if (ent.isFile() && ent.name.endsWith('.md')) yield p;
}
}

const fence = /```mermaid\s*\n([\s\S]*?)```/g;

async function main() {
await rm(WORK, { recursive: true, force: true });
await mkdir(WORK, { recursive: true });
await writeFile(PUPPETEER_CFG, JSON.stringify({
Comment on lines +91 to +107
try {
await execFileP(MMDC, ['-i', tmp, '-o', out, '-p', PUPPETEER_CFG, '-q'], {
timeout: 90_000,
maxBuffer: 8 * 1024 * 1024,
});
results.push({ file: path.relative(REPO, file), idx, line, ok: true });
} catch (e) {
const errMsg = (e.stderr || e.stdout || e.message || '').toString();
results.push({
file: path.relative(REPO, file),
idx,
line,
ok: false,
err: errMsg.slice(0, 4000),
code,
});
}
- Restore C4 diagrams in ARCHITECTURE.md, FUTURE_ARCHITECTURE.md, and
  SKILL.md that were incorrectly rewritten by the quote fixer
- Fix CI: use explicit package.json instead of `npm init -y` in
  .mermaid-tools (dot-prefixed names are invalid npm package names)
- Fix workflow comment: "nightly" → "weekly" to match actual cron schedule
- Fix style guide: "Two scripts" → "Three scripts" to match actual count
- Fix fix-mermaid-quotes.mjs: skip C4 diagram blocks, update docstring
  to match actual implementation (no `:` or `<>` handling)
- Fix deep-check-mermaid.mjs: remove unused `lm` assignment in faRe loop,
  remove `&amp;` exemption from ampersand check
- Fix validate-mermaid.mjs: add safety guard for MERMAID_WORK path,
  detect ENOENT from mmdc and exit with code 2

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
@pethers

pethers commented May 24, 2026

Copy link
Copy Markdown
Member

@copilot analyse and improve all faiiling mermaid failing checks
Validate Mermaid Diagrams / Validate Mermaid diagrams (pull_request)
Validate Mermaid Diagrams / Validate Mermaid diagrams (pull_request)Failing after 7m

The theme block example in MERMAID_STYLE_GUIDE.md contained only a
%%{init}%% directive with no diagram type, causing mmdc to fail with
"UnknownDiagramError: No diagram type detected". Added a minimal
`graph LR` body below the init block so the example renders while
still demonstrating the recommended theme configuration.

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>

Copilot AI commented May 24, 2026

Copy link
Copy Markdown
Contributor Author

@copilot analyse and improve all faiiling mermaid failing checks
[Validate Mermaid Diagrams / Validate Mermaid diagrams (pull_request)](https://github.com/Hack23/cia/actions/runs/2637...

Analysed the workflow artifact (report.json): only 1 of 490 diagrams failed — the theme-block example in MERMAID_STYLE_GUIDE.md:149, which contained just a %%{init}%% directive with no diagram type, producing UnknownDiagramError: No diagram type detected. Fixed by appending a minimal graph LR body so the example renders while still demonstrating the recommended theme config.

@sonarqubecloud

Copy link
Copy Markdown

@pethers pethers merged commit 5bbe638 into master May 24, 2026
12 checks passed
@pethers pethers deleted the copilot/test-review-mermaid-diagrams branch May 24, 2026 23:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants