Skip to content

Fix article language-switcher, enrich header/footer chrome, expand render-lib tests#1981

Merged
pethers merged 5 commits intomainfrom
copilot/analyze-remaining-tasks-for-integration
Apr 24, 2026
Merged

Fix article language-switcher, enrich header/footer chrome, expand render-lib tests#1981
pethers merged 5 commits intomainfrom
copilot/analyze-remaining-tasks-for-integration

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 24, 2026

Round 4 — Code architecture focus

A. Architectural split — scripts/render-lib/ monolith → 6 leaf modules

The former scripts/render-lib/index.ts (960 LOC) mixed four distinct responsibilities: aggregation, markdown→HTML, HTML chrome, and end-to-end article composition. Split into single-responsibility leaf modules linked by a thin barrel:

  • render-lib/constants.ts — zero-dep leaf (unchanged, kept from Round 3)
  • render-lib/url-helpers.ts — new zero-dep leaf: buildGithubBlobUrl / buildGithubTreeUrl
  • render-lib/aggregator.tsAGGREGATION_ORDER, titleForArtifact, all private cleaners (stripPassTwoSection, stripLeadingAdminBylines, cleanArtifactBody, rewriteRelativeLinks), AggregationInput/AggregationResult, aggregateAnalysis, __test__ escape hatch. Does not import unified/remark/rehype — tests that only touch aggregator logic now skip the ~40 ms remark/rehype cold-start cost.
  • render-lib/markdown.tssanitizeSchema + renderMarkdownToHtml (the single trust boundary between AI markdown and user HTML)
  • render-lib/chrome.tsChromeOptions, SiteChrome, renderChromeHead, buildChrome. Pure synchronous string builder, zero I/O, zero async.
  • render-lib/article.tsRenderArticleInput, renderArticleHtml. The only module that orchestrates aggregator + markdown + chrome; owns the Schema.org NewsArticle JSON-LD shape.
  • render-lib/index.tsbarrel re-export only (82 LOC, down from 960); no breaking changes for any downstream consumer (aggregate-analysis.ts, render-articles.ts, analysis-references.ts, tests/render-lib.test.ts).
 scripts/render-lib/index.ts: 960 LOC  →  82 LOC  (barrel re-export only)
 New leaves: aggregator.ts (420) · markdown.ts (100) · chrome.ts (300) ·
             article.ts (140) · url-helpers.ts (45) · constants.ts (57)

B. typedoc.json — sync with current codebase

Added 5 project documents that exist on disk but were missing from TypeDoc output:

  • AGENTS.md (Copilot agents catalogue)
  • SKILLS.md (Copilot skills catalogue)
  • LABELS.md (issue/PR label taxonomy)
  • CODE_OF_CONDUCT.md
  • FUTURE_WORKFLOWS.md
  • Matching sidebar links in sidebarLinks (🤖 Copilot Agents · 🛠 Copilot Skills · 🏷 Labels · 📜 Code of Conduct · 🔄 Future Workflows)

projectDocuments grew from 26 → 31. TypeDoc builds with 0 errors and all 5 new HTML docs (AGENTS.html, SKILLS.html, LABELS.html, CODE_OF_CONDUCT.html, FUTURE_WORKFLOWS.html) appear under api/documents/. No entryPoints change needed — the existing "scripts" entry point with entryPointStrategy: "expand" auto-picks up the 4 new .ts files in scripts/render-lib/.

C. ARCHITECTURE.md

  • Rewrote the "Aggregate → Render Module" Mermaid C4 component diagram to show the 4 discrete modules (aggregator · markdown · chrome · article · constants+url-helpers leaves) with colour-coded nodes.
  • Replaced the 5-row pipeline-stages table with an 8-row per-module contract table including per-module responsibility, CLI driver distinction, and the import-cost rationale for the split.
  • README.md "Anatomy of an article" paragraph extended with one sentence referencing the 6-module split and linking to the ARCHITECTURE pipeline stages.

D. Test coverage expansion

  • New tests/render-lib-architecture.test.ts (25 tests) — imports every leaf module directly by its real path (not via the barrel) to prove:

    1. Each module is importable in isolation (no circular dependencies, no hidden side effects)
    2. Every symbol exported by a leaf is also re-exported identically by the barrel (barrel-↔-leaf parity test — catches accidental drift)
    3. url-helpers.ts is pure (no leading-slash corner-cases break it)
    4. aggregator.ts works standalone (produces valid AggregationResult shape)
    5. markdown.ts sanitiser schema allowlists the mermaid <pre> wrapper and h1-h6 id attributes
    6. chrome.ts is synchronous and deterministic (buildChrome returns identical output for identical inputs)
    7. article.ts composes head + header + body + sources + footer and emits the correct Schema.org NewsArticle JSON-LD
  • Full suite: 1948 passed / 0 failed (was 1923 → +25 architecture tests)

  • npx htmlhint **/*.html — no errors

  • npx typedoc — 0 errors, 52 warnings (all pre-existing, unrelated to this round)

Copilot AI and others added 4 commits April 24, 2026 14:06
…SWOT S4, TRANSLATION_GUIDE

Agent-Logs-Url: https://github.com/Hack23/riksdagsmonitor/sessions/e216b4e1-c6b6-4164-a5ab-5d021d51bc6b

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
… 3, style rm-* chrome

Agent-Logs-Url: https://github.com/Hack23/riksdagsmonitor/sessions/abe2efae-8197-4f0c-8e2c-77f3cd132515

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
…icle render + edge cases; extract constants.ts

Agent-Logs-Url: https://github.com/Hack23/riksdagsmonitor/sessions/13b12282-8808-4491-9c1d-380d43a7ad37

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
…+ breadcrumb) + 3-col footer + secondary lang row; regen 48 articles

Agent-Logs-Url: https://github.com/Hack23/riksdagsmonitor/sessions/fbc5a985-5cec-4337-ac6b-3ac2f690fa1c

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
@github-actions github-actions Bot added documentation Documentation updates html-css HTML/CSS changes i18n Internationalization/localization translation Translation updates testing Test coverage refactor Code refactoring news News articles and content generation size-xl Extra large change (> 1000 lines) labels Apr 24, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🏷️ Automatic Labeling Summary

This PR has been automatically labeled based on the files changed and PR metadata.

Applied Labels: documentation,html-css,i18n,translation,testing,refactor,size-xl,news

Label Categories

  • 🗳️ Content: news, dashboard, visualization, intelligence
  • 💻 Technology: html-css, javascript, workflow, security
  • 📊 Data: cia-data, riksdag-data, data-pipeline, schema
  • 🌍 I18n: i18n, translation, rtl
  • 🔒 ISMS: isms, iso-27001, nist-csf, cis-controls
  • 🏗️ Infrastructure: ci-cd, deployment, performance, monitoring
  • 🔄 Quality: testing, accessibility, documentation, refactor
  • 🤖 AI: agent, skill, agentic-workflow

For more information, see .github/labeler.yml.

@github-actions
Copy link
Copy Markdown
Contributor

🔍 Lighthouse Performance Audit

Category Score Status
Performance 85/100 🟡
Accessibility 95/100 🟢
Best Practices 90/100 🟢
SEO 95/100 🟢

📥 Download full Lighthouse report

Budget Compliance: Performance budgets enforced via budget.json

…rrel; +25 architecture tests; sync typedoc.json (5 new docs); update ARCHITECTURE

Agent-Logs-Url: https://github.com/Hack23/riksdagsmonitor/sessions/a314531c-c28b-449a-8fff-0d5dd0fa79c5

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

🔍 Lighthouse Performance Audit

Category Score Status
Performance 85/100 🟡
Accessibility 95/100 🟢
Best Practices 90/100 🟢
SEO 95/100 🟢

📥 Download full Lighthouse report

Budget Compliance: Performance budgets enforced via budget.json

Copilot AI requested a review from pethers April 24, 2026 16:01
@pethers pethers marked this pull request as ready for review April 24, 2026 16:06
Copilot AI review requested due to automatic review settings April 24, 2026 16:06
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@pethers pethers merged commit 602a6c8 into main Apr 24, 2026
26 checks passed
@pethers pethers deleted the copilot/analyze-remaining-tasks-for-integration branch April 24, 2026 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Documentation updates html-css HTML/CSS changes i18n Internationalization/localization news News articles and content generation refactor Code refactoring size-xl Extra large change (> 1000 lines) testing Test coverage translation Translation updates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants