Conversation
🏷️ Automatic Labeling SummaryThis PR has been automatically labeled based on the files changed and PR metadata. Applied Labels: size-xs Label Categories
For more information, see |
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
…eline interfaces and tests - Create interfaces.ts with typed pipeline stage contracts (PipelineResult, ReadStageInput, WriteStageOutput, etc.) - Create pipeline.ts composable orchestrator (runArticlePipeline) wrapping aggregateAnalysis - Extract heading-demotion.ts from structural.ts (demoteHeadings) - Extract link-rewriting.ts from structural.ts (rewriteRelativeLinks) - Extract deduplication.ts from structural.ts (dedupeAdjacentDuplicateLines, collapseRepeatedFooterBlocks) - structural.ts reduced from 314 → 164 lines (under 200-line target) - Add comprehensive test file (article-pipeline.test.ts) with 36 tests covering: - Pipeline interface type contracts - Happy path (minimal folder, title/description extraction, front-matter, ordering) - Error cases (missing folder, missing executive-brief, empty files, malformed YAML) - Edge cases (README exclusion, article.md exclusion, supplementary artifacts) - Extracted module tests (heading-demotion, link-rewriting) - Update Article-Generation.md with new architecture diagram - Export new types/functions from barrel (index.ts) and render-lib/index.ts - All 263 existing + new tests pass, TypeScript strict check clean, ESLint clean Agent-Logs-Url: https://github.com/Hack23/riksdagsmonitor/sessions/68311a88-b977-4f8d-a9fc-6083bd194104 Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Hack23/riksdagsmonitor/sessions/68311a88-b977-4f8d-a9fc-6083bd194104 Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
There was a problem hiding this comment.
Pull request overview
Refactors the existing aggregateAnalysis() → article.md generation flow into clearer bounded-context modules by extracting cleaning utilities, introducing a typed pipeline wrapper (runArticlePipeline), and adding comprehensive Vitest coverage plus updated documentation.
Changes:
- Introduces typed pipeline contracts in
interfaces.tsand a wrapper orchestrator inpipeline.ts(runArticlePipeline) while keepingaggregateAnalysis()as the underlying implementation. - Extracts structural cleaning helpers into dedicated modules (heading demotion, relative-link rewriting, deduplication) and re-exports them from
structural.tsto preserve existing imports. - Adds a new end-to-end and unit-test suite for the article pipeline and updates
Article-Generation.mdto reflect the new directory structure.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/article-pipeline.test.ts | Adds unit + integration tests for the pipeline wrapper and extracted cleaning modules. |
| scripts/render-lib/index.ts | Exposes runArticlePipeline and new pipeline types via the top-level render-lib barrel. |
| scripts/render-lib/aggregator/pipeline.ts | Adds runArticlePipeline() wrapper returning PipelineResult<WriteStageOutput>. |
| scripts/render-lib/aggregator/interfaces.ts | Defines shared pipeline type contracts (result, stage, stage I/O types). |
| scripts/render-lib/aggregator/index.ts | Re-exports new pipeline entry point + types from the aggregator barrel. |
| scripts/render-lib/aggregator/cleaning/structural.ts | Switches to imported leaf cleaners and re-exports extracted functions for compatibility. |
| scripts/render-lib/aggregator/cleaning/link-rewriting.ts | New leaf module for rewriting relative markdown links to GitHub blob URLs. |
| scripts/render-lib/aggregator/cleaning/heading-demotion.ts | New leaf module for demoting inner headings (fence-aware). |
| scripts/render-lib/aggregator/cleaning/deduplication.ts | New leaf module for adjacent-line + footer-block deduplication (fence-aware). |
| Article-Generation.md | Updates responsibility table and adds bounded-context directory tree for the refactor. |
| export interface PipelineResult<T> { | ||
| readonly ok: boolean; | ||
| readonly value?: T; | ||
| readonly error?: string; | ||
| readonly warnings?: readonly string[]; | ||
| } | ||
|
|
| /** | ||
| * SEO and metadata fields added during enrichment. | ||
| */ | ||
| export interface EnrichmentMetadata { | ||
| readonly title: string; | ||
| readonly description: string; | ||
| readonly date: string; | ||
| readonly subfolder: string; | ||
| readonly slug: string; | ||
| readonly sourceFolder: string; | ||
| readonly generatedAt: string; | ||
| readonly language: string; | ||
| } |
| * @param input - Filesystem location and metadata for the analysis folder. | ||
| * @param config - Optional pipeline configuration overrides. | ||
| * @returns A typed result with either the generated article or an error. | ||
| */ | ||
| export function runArticlePipeline( | ||
| input: ReadStageInput, | ||
| _config?: ArticlePipelineConfig, | ||
| ): PipelineResult<WriteStageOutput> { |
|
@copilot apply changes based on the comments in this thread |
…s, wire config through pipeline - PipelineResult<T>: change from interface with optional fields to discriminated union type (ok:true branch has `value:T`, ok:false branch has `error:string`, no invalid states possible) - EnrichmentMetadata + ArticlePipelineConfig: align field names to snake_case matching FrontMatterFields contract (sourceFolder→source_folder, generatedAt→generated_at, add layout) - AggregationInput: extend with optional generated_at/language/layout fields - aggregate.ts: use input.generated_at/language/layout overrides in buildFrontMatter call - pipeline.ts: rename _config to config, wire all three fields through to aggregationInput - Tests: add requireOk() helper to eliminate non-null assertions on success branch; replace result.value! with requireOk(result); add config-override test Agent-Logs-Url: https://github.com/Hack23/riksdagsmonitor/sessions/72e4fc96-94a0-48c5-97c0-3b18f1174e19 Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
Applied all three changes in commit
|
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
| import { stripLeadingAdminBylines } from './admin-bylines.js'; | ||
| import { stripProcessMetaLines } from './process-meta.js'; | ||
| import { demoteHeadings } from './heading-demotion.js'; | ||
| import { rewriteRelativeLinks } from './link-rewriting.js'; |
|
@copilot apply changes based on the comments in this thread |
…Lint no-unused-vars) Agent-Logs-Url: https://github.com/Hack23/riksdagsmonitor/sessions/d6cd90ad-eb9c-44f0-9d91-e1a24f227e64 Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
Fixed in |
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
PipelineResult<T>EnrichmentMetadata/ArticlePipelineConfigfield names to snake_case matchingFrontMatterFields; add missinglayoutconfig(generated_at/language/layout) throughrunArticlePipeline→AggregationInput→buildFrontMatterimport { rewriteRelativeLinks }fromstructural.ts— the binding was only re-exported, never used locally, causing ESLintno-unused-varserror