Skip to content

Upgrade ai-driven-analysis-guide to v3.0 and improve all news workflow AI prompts#1522

Merged
pethers merged 20 commits intomainfrom
copilot/improve-ai-driven-analysis-methodologies
Apr 3, 2026
Merged

Upgrade ai-driven-analysis-guide to v3.0 and improve all news workflow AI prompts#1522
pethers merged 20 commits intomainfrom
copilot/improve-ai-driven-analysis-methodologies

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 2, 2026

  • Fix PR review comments (stray fence, symbol refs, nested code blocks)
  • Add pipeline artifact relocation steps to 7 workflows
  • Make relocation idempotent (guard on files-to-move, not directory existence)
  • Persist HHMM to env file in realtime-monitor
  • Use dedicated article-generator-HHMM subfolder for multi-type runs
  • Capture _AG_HHMM once in article-generator for breaking type consistency
  • Fix documents/ relocation to merge-safe (prevent documents/documents nesting on reruns) in all 7 workflows
  • Use cp -f (not mv) for batch *.md in SHARED_PROMPT_PATTERNS to preserve unscoped originals for analysis-reader.ts
  • Fix article-generator blank-input detection: separate raw input from resolved type so schedule runs reach multi-type branch
  • Persist ANALYSIS_SUBFOLDER to temp env file for cross-block consistency in article-generator commit step
  • Use cp -f (not mv) for batch *.md in all 7 non-doc-type workflow files to preserve unscoped originals for analysis-reader.ts
  • Source persisted ANALYSIS_SUBFOLDER/_RELOC_SUBFOLDER in article-generator ANALYSIS_SUBFOLDER block for deterministic cross-block consistency
  • Use cp -R -f (not mv) for documents/ in realtime-monitor to preserve unscoped originals for downstream per-file analysis
  • Persist _AG_HHMM/_RELOC_SUBFOLDER/ANALYSIS_SUBFOLDER immediately after computation in article-generator relocation block for cross-block determinism

Copilot AI and others added 5 commits April 2, 2026 22:26
…ic patterns, AI-first analysis, title/description generation prompts, and analysis-to-article linking

Agent-Logs-Url: https://github.com/Hack23/riksdagsmonitor/sessions/0de5c0c8-e89e-4ae5-9e35-4838e5fd2086

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
…TERNS with 2026-04-02 quality audit

Agent-Logs-Url: https://github.com/Hack23/riksdagsmonitor/sessions/0de5c0c8-e89e-4ae5-9e35-4838e5fd2086

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
…ared prompt blocks to SHARED_PROMPT_PATTERNS.md

Agent-Logs-Url: https://github.com/Hack23/riksdagsmonitor/sessions/b373dbb2-7cc6-4a16-a455-a217599ce3ea

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
…structions to all 11 news workflow prompts

Agent-Logs-Url: https://github.com/Hack23/riksdagsmonitor/sessions/b373dbb2-7cc6-4a16-a455-a217599ce3ea

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
…ss.ts, and shared.ts per ai-driven-analysis-guide.md Rule 2

Agent-Logs-Url: https://github.com/Hack23/riksdagsmonitor/sessions/b373dbb2-7cc6-4a16-a455-a217599ce3ea

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
@github-actions github-actions bot added documentation Documentation updates workflow GitHub Actions workflows ci-cd CI/CD pipeline changes refactor Code refactoring news News articles and content generation agentic-workflow Agentic workflow changes size-l Large change (250-1000 lines) labels Apr 2, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 2, 2026

🏷️ Automatic Labeling Summary

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

Applied Labels: documentation,workflow,ci-cd,refactor,size-l,news,agentic-workflow

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

github-actions bot commented Apr 2, 2026

🔍 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

@pethers pethers marked this pull request as ready for review April 2, 2026 23:41
Copilot AI review requested due to automatic review settings April 2, 2026 23:41
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.

Pull request overview

Updates the AI-driven analysis methodology and standardizes stronger AI prompt requirements across all news-generation workflows, while marking legacy script-based analysis generators as deprecated fallbacks.

Changes:

  • Bumps ai-driven-analysis-guide.md to v3.0 with AI-first protocols for titles/meta and mandatory analysis-to-article linking.
  • Expands SHARED_PROMPT_PATTERNS.md with shared “AI title/meta” and “GitHub analysis references” blocks for reuse across workflows.
  • Adds a new post-generation step (Step 3b/3c) to all news workflows to enforce AI-written titles/meta descriptions and insert “📊 Analysis & Sources” links.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
scripts/generate-news-enhanced/ai-analysis-pipeline.ts Adds deprecation notice clarifying analysis-prose functions are fallback stubs.
scripts/data-transformers/content-generators/shared.ts Adds deprecation notice for template-driven analysis prose generators.
scripts/data-transformers/content-generators/newsworthiness.ts Adds deprecation notice for heuristic significance scoring as editorial output.
analysis/methodologies/ai-driven-analysis-guide.md Upgrades methodology to v3.0 with new AI-first protocols and reference-linking requirements.
.github/workflows/SHARED_PROMPT_PATTERNS.md Adds reusable prompt blocks and updates quality audit findings and enforcement guidance.
.github/workflows/news-committee-reports.md Adds Step 3b to require AI title/meta rewrite and analysis GitHub links.
.github/workflows/news-propositions.md Adds Step 3b to require AI title/meta rewrite and analysis GitHub links.
.github/workflows/news-interpellations.md Adds Step 3c to require AI title/meta rewrite and analysis GitHub links (after existing Step 3b).
.github/workflows/news-motions.md Adds Step 3b to require AI title/meta rewrite and analysis GitHub links.
.github/workflows/news-evening-analysis.md Adds Step 3b to require AI title/meta rewrite and link to all relevant analysis folders for the day.
.github/workflows/news-article-generator.md Adds Step 3b to require AI title/meta rewrite and analysis GitHub links for generated articles.
.github/workflows/news-realtime-monitor.md Adds Step 3b to require AI title/meta rewrite and references for realtime analysis folders.
.github/workflows/news-week-ahead.md Adds Step 3b to require AI title/meta rewrite and references for week-ahead analysis.
.github/workflows/news-month-ahead.md Adds Step 3b to require AI title/meta rewrite and references for month-ahead analysis.
.github/workflows/news-weekly-review.md Adds Step 3b to require AI title/meta rewrite and references for weekly-review analysis.
.github/workflows/news-monthly-review.md Adds Step 3b to require AI title/meta rewrite and references for monthly-review analysis.

Comment on lines +277 to 279
**These scripts may still be called for data downloading and HTML formatting functions**, but their analysis output (SWOT entries, risk scores, classifications, titles, descriptions, editorial judgments) MUST be treated as stubs that the AI agent MUST overwrite with real template-compliant analysis.
````

Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

There’s an unmatched closing fence (````) here after the deprecated scripts table. Nothing opens a 4-backtick fence in this section, so this line will break Markdown rendering for the remainder of the document. Remove it (or add the corresponding opening fence if one is intended).

Copilot uses AI. Check for mistakes.
Comment on lines +932 to +941
| Deprecated Function | File | Replacement |
|---------------------|------|-------------|
| `buildDynamicSwot()` | `ai-analysis-pipeline.ts:561-659` | AI prompt: "Generate SWOT for all 8 stakeholder groups with dok_id evidence" |
| `buildStrategicImplications()` | `ai-analysis-pipeline.ts:661-730` | AI prompt: "Write strategic implications paragraph citing specific policy signals" |
| `buildKeyTakeaways()` | `ai-analysis-pipeline.ts:734-774` | AI prompt: "Extract 5 key takeaways with confidence levels and evidence" |
| `buildLegislativeImpact()` | `ai-analysis-pipeline.ts:248-264` | AI prompt: "Assess legislative impact using committee + vote data" |
| `buildCrossPartyImplications()` | `ai-analysis-pipeline.ts:266-280` | AI prompt: "Analyze cross-party dynamics from voting records and motions" |
| `generateDeepAnalysisSection()` | `shared.ts:456-590` | AI prompt: "Write 5W deep analysis (Who/What/When/Why/Winners)" |
| `scoreNewsworthiness()` | `newsworthiness.ts:251-305` | AI prompt: "Score newsworthiness 0-100 with dimension breakdown" |
| All `*Text()` templates | `shared.ts:396-857` | AI prompt: "Write editorial analysis based on actual document data" |
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

This “Deprecated Code Functions” table includes hard-coded line ranges (e.g., ai-analysis-pipeline.ts:248-264 / :266-280) that don’t match the current file (these functions start later). Since line numbers will drift, either update them to be accurate now or remove the ranges and link to symbols/sections instead to avoid future documentation rot.

Suggested change
| Deprecated Function | File | Replacement |
|---------------------|------|-------------|
| `buildDynamicSwot()` | `ai-analysis-pipeline.ts:561-659` | AI prompt: "Generate SWOT for all 8 stakeholder groups with dok_id evidence" |
| `buildStrategicImplications()` | `ai-analysis-pipeline.ts:661-730` | AI prompt: "Write strategic implications paragraph citing specific policy signals" |
| `buildKeyTakeaways()` | `ai-analysis-pipeline.ts:734-774` | AI prompt: "Extract 5 key takeaways with confidence levels and evidence" |
| `buildLegislativeImpact()` | `ai-analysis-pipeline.ts:248-264` | AI prompt: "Assess legislative impact using committee + vote data" |
| `buildCrossPartyImplications()` | `ai-analysis-pipeline.ts:266-280` | AI prompt: "Analyze cross-party dynamics from voting records and motions" |
| `generateDeepAnalysisSection()` | `shared.ts:456-590` | AI prompt: "Write 5W deep analysis (Who/What/When/Why/Winners)" |
| `scoreNewsworthiness()` | `newsworthiness.ts:251-305` | AI prompt: "Score newsworthiness 0-100 with dimension breakdown" |
| All `*Text()` templates | `shared.ts:396-857` | AI prompt: "Write editorial analysis based on actual document data" |
| Deprecated Function | File / Symbol Reference | Replacement |
|---------------------|-------------------------|-------------|
| `buildDynamicSwot()` | `ai-analysis-pipeline.ts` (`buildDynamicSwot`) | AI prompt: "Generate SWOT for all 8 stakeholder groups with dok_id evidence" |
| `buildStrategicImplications()` | `ai-analysis-pipeline.ts` (`buildStrategicImplications`) | AI prompt: "Write strategic implications paragraph citing specific policy signals" |
| `buildKeyTakeaways()` | `ai-analysis-pipeline.ts` (`buildKeyTakeaways`) | AI prompt: "Extract 5 key takeaways with confidence levels and evidence" |
| `buildLegislativeImpact()` | `ai-analysis-pipeline.ts` (`buildLegislativeImpact`) | AI prompt: "Assess legislative impact using committee + vote data" |
| `buildCrossPartyImplications()` | `ai-analysis-pipeline.ts` (`buildCrossPartyImplications`) | AI prompt: "Analyze cross-party dynamics from voting records and motions" |
| `generateDeepAnalysisSection()` | `shared.ts` (`generateDeepAnalysisSection`) | AI prompt: "Write 5W deep analysis (Who/What/When/Why/Winners)" |
| `scoreNewsworthiness()` | `newsworthiness.ts` (`scoreNewsworthiness`) | AI prompt: "Score newsworthiness 0-100 with dimension breakdown" |
| All `*Text()` templates | `shared.ts` (`*Text()` template functions) | AI prompt: "Write editorial analysis based on actual document data" |

Copilot uses AI. Check for mistakes.
Comment on lines +971 to +979
```
[Active Verb] + [Specific Actor/Institution] + [Concrete Policy Action] + [Political Significance]
```

Examples from data:
- "Riksdag Approves Stricter Deportation Rules as Coalition Unites on Justice Reform"
- "Hultqvist Challenges Government on Scandinavian Mountain Airport Emergency Gaps"
- "Four Propositions Signal Government's Spring Security Offensive"
```
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

The fenced markdown block for the title-generation prompt is broken: this fence closes the prompt block early (since it uses the same fence length), so the remainder renders incorrectly. Use a longer outer fence (e.g., ````markdown) so you can include inner ``` blocks, or remove the inner fence and format the formula as plain text within the prompt block.

Suggested change
```
[Active Verb] + [Specific Actor/Institution] + [Concrete Policy Action] + [Political Significance]
```
Examples from data:
- "Riksdag Approves Stricter Deportation Rules as Coalition Unites on Justice Reform"
- "Hultqvist Challenges Government on Scandinavian Mountain Airport Emergency Gaps"
- "Four Propositions Signal Government's Spring Security Offensive"
```
- Formula: `[Active Verb] + [Specific Actor/Institution] + [Concrete Policy Action] + [Political Significance]`
Examples from data:
- "Riksdag Approves Stricter Deportation Rules as Coalition Unites on Justice Reform"
- "Hultqvist Challenges Government on Scandinavian Mountain Airport Emergency Gaps"
- "Four Propositions Signal Government's Spring Security Offensive"

Copilot uses AI. Check for mistakes.
- "Riksdag Approves Stricter Deportation Rules as Coalition Unites on Justice Reform"
- "Hultqvist Challenges Government on Scandinavian Mountain Airport Emergency Gaps"
- "Four Propositions Signal Government's Spring Security Offensive"
```
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

This standalone ``` line is an extra/unmatched fence (the title-generation prompt block has already been closed earlier), which will start a new code block and likely garble the surrounding sections. Remove this fence (or adjust the surrounding fencing so it closes the intended block).

Suggested change
```

Copilot uses AI. Check for mistakes.
@pethers
Copy link
Copy Markdown
Member

pethers commented Apr 3, 2026

@copilot apply changes based on the comments in this thread

Copilot stopped work on behalf of pethers due to an error April 3, 2026 00:18
Copilot AI requested a review from pethers April 3, 2026 00:21
Copilot stopped work on behalf of pethers due to an error April 3, 2026 00:21
…d table, fix nested code blocks

Agent-Logs-Url: https://github.com/Hack23/riksdagsmonitor/sessions/b6935d35-ec0b-40ba-a45e-7159d8095d57

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

Copilot AI commented Apr 3, 2026

@copilot apply changes based on the comments in this thread

Applied all 4 review comments in commit 7e95b4a:

  1. Removed the unmatched ```````` closing fence in SHARED_PROMPT_PATTERNS.md (line 278)
  2. Replaced hard-coded line ranges (e.g., ai-analysis-pipeline.ts:248-264) with symbol references (e.g., ai-analysis-pipeline.ts (buildLegislativeImpact)) in the deprecated functions table
  3. Fixed the broken nested code fence in the title-generation prompt by converting the formula to inline code and removing the inner ``` blocks
  4. Removed the extra/unmatched ``` fence at the end of the title construction section

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 3, 2026

🔍 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

@pethers
Copy link
Copy Markdown
Member

pethers commented Apr 3, 2026

@copilot apply changes based on the comments in this thread

…kflows

Preserves unscoped originals in analysis/daily/$DATE/ so that
analysis-reader.ts / getAnalysisEnrichment() can still read batch
artifacts from the canonical unscoped path. Documents continue
using merge-safe find+mv relocation since they don't have the
same reader-compatibility requirement.

Agent-Logs-Url: https://github.com/Hack23/riksdagsmonitor/sessions/a730fed9-8727-4f9e-8eca-26018b008fcc

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

github-actions bot commented Apr 3, 2026

🔍 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

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 3, 2026

@copilot apply changes based on the comments in this thread

Applied all 3 review comments in commit 1fe6324:

All 7 non-doc-type workflows now use cp -f (not mv) for batch *.md artifacts, preserving unscoped originals in analysis/daily/$DATE/ so analysis-reader.ts / getAnalysisEnrichment() continues to work. The documents/ relocation remains merge-safe (mkdir -p + find -exec mv + rmdir). This matches the pattern already documented in SHARED_PROMPT_PATTERNS.md.

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.

Pull request overview

Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.

Comment on lines +414 to +431
# Use dedicated folder for multi-type/schedule runs; reuse _AG_HHMM for breaking consistency
_AG_HHMM=${_AG_HHMM:-$(date -u +%H%M)}
if [ "$_IS_SCHEDULE_OR_MULTI" = true ]; then
ANALYSIS_SUBFOLDER="article-generator-${_AG_HHMM}"
else
case "$REQUESTED_TYPE" in
*committee-reports*) ANALYSIS_SUBFOLDER="committeeReports" ;;
*interpellation*) ANALYSIS_SUBFOLDER="interpellations" ;;
*motions*) ANALYSIS_SUBFOLDER="motions" ;;
*propositions*) ANALYSIS_SUBFOLDER="propositions" ;;
*week-ahead*) ANALYSIS_SUBFOLDER="week-ahead" ;;
*month-ahead*) ANALYSIS_SUBFOLDER="month-ahead" ;;
*weekly-review*) ANALYSIS_SUBFOLDER="weekly-review" ;;
*monthly-review*) ANALYSIS_SUBFOLDER="monthly-review" ;;
*breaking*) ANALYSIS_SUBFOLDER="realtime-${_AG_HHMM}" ;;
*deep-inspection*) ANALYSIS_SUBFOLDER="deep-inspection" ;;
*) echo "⚠️ Unknown article type '$REQUESTED_TYPE' — using as-is for subfolder"; ANALYSIS_SUBFOLDER="$REQUESTED_TYPE" ;;
esac
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

This block defaults _AG_HHMM via $(date -u +%H%M) if it’s unset. If the earlier relocation block ran in a different minute (or _AG_HHMM wasn’t persisted), ANALYSIS_SUBFOLDER here can diverge from _RELOC_SUBFOLDER, causing the workflow to miss existing analysis artifacts and potentially stage/commit the wrong directory. To make this deterministic, source a persisted _AG_HHMM/ANALYSIS_SUBFOLDER set during relocation (or compute once and reuse everywhere).

Suggested change
# Use dedicated folder for multi-type/schedule runs; reuse _AG_HHMM for breaking consistency
_AG_HHMM=${_AG_HHMM:-$(date -u +%H%M)}
if [ "$_IS_SCHEDULE_OR_MULTI" = true ]; then
ANALYSIS_SUBFOLDER="article-generator-${_AG_HHMM}"
else
case "$REQUESTED_TYPE" in
*committee-reports*) ANALYSIS_SUBFOLDER="committeeReports" ;;
*interpellation*) ANALYSIS_SUBFOLDER="interpellations" ;;
*motions*) ANALYSIS_SUBFOLDER="motions" ;;
*propositions*) ANALYSIS_SUBFOLDER="propositions" ;;
*week-ahead*) ANALYSIS_SUBFOLDER="week-ahead" ;;
*month-ahead*) ANALYSIS_SUBFOLDER="month-ahead" ;;
*weekly-review*) ANALYSIS_SUBFOLDER="weekly-review" ;;
*monthly-review*) ANALYSIS_SUBFOLDER="monthly-review" ;;
*breaking*) ANALYSIS_SUBFOLDER="realtime-${_AG_HHMM}" ;;
*deep-inspection*) ANALYSIS_SUBFOLDER="deep-inspection" ;;
*) echo "⚠️ Unknown article type '$REQUESTED_TYPE' — using as-is for subfolder"; ANALYSIS_SUBFOLDER="$REQUESTED_TYPE" ;;
esac
# Reuse previously persisted relocation/analysis folder when available so later blocks
# do not recompute a different minute-based directory.
if [ -n "${ANALYSIS_SUBFOLDER:-}" ]; then
ANALYSIS_SUBFOLDER="$ANALYSIS_SUBFOLDER"
elif [ -n "${_RELOC_SUBFOLDER:-}" ]; then
ANALYSIS_SUBFOLDER="$_RELOC_SUBFOLDER"
else
# Use dedicated folder for multi-type/schedule runs; reuse _AG_HHMM for breaking consistency
_AG_HHMM=${_AG_HHMM:-$(date -u +%H%M)}
if [ "$_IS_SCHEDULE_OR_MULTI" = true ]; then
ANALYSIS_SUBFOLDER="article-generator-${_AG_HHMM}"
else
case "$REQUESTED_TYPE" in
*committee-reports*) ANALYSIS_SUBFOLDER="committeeReports" ;;
*interpellation*) ANALYSIS_SUBFOLDER="interpellations" ;;
*motions*) ANALYSIS_SUBFOLDER="motions" ;;
*propositions*) ANALYSIS_SUBFOLDER="propositions" ;;
*week-ahead*) ANALYSIS_SUBFOLDER="week-ahead" ;;
*month-ahead*) ANALYSIS_SUBFOLDER="month-ahead" ;;
*weekly-review*) ANALYSIS_SUBFOLDER="weekly-review" ;;
*monthly-review*) ANALYSIS_SUBFOLDER="monthly-review" ;;
*breaking*) ANALYSIS_SUBFOLDER="realtime-${_AG_HHMM}" ;;
*deep-inspection*) ANALYSIS_SUBFOLDER="deep-inspection" ;;
*) echo "⚠️ Unknown article type '$REQUESTED_TYPE' — using as-is for subfolder"; ANALYSIS_SUBFOLDER="$REQUESTED_TYPE" ;;
esac
fi

Copilot uses AI. Check for mistakes.
@pethers
Copy link
Copy Markdown
Member

pethers commented Apr 3, 2026

@copilot apply changes based on the comments in this thread

…inute-boundary divergence

The ANALYSIS_SUBFOLDER block now sources /tmp/analysis_subfolder.env
(written by the relocation block) before falling back to recomputation.
This ensures cross-block determinism: if the relocation ran in minute N,
later blocks reuse that same value instead of potentially computing N+1.

Agent-Logs-Url: https://github.com/Hack23/riksdagsmonitor/sessions/27787538-96df-41a0-aef2-bd94f668c6f9

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
@github-actions github-actions bot added the size-xl Extra large change (> 1000 lines) label Apr 3, 2026
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 3, 2026

@copilot apply changes based on the comments in this thread

Applied in commit b1a663e. The ANALYSIS_SUBFOLDER block now sources /tmp/analysis_subfolder.env (persisted by the relocation block) before falling back to recomputation, and checks _RELOC_SUBFOLDER as an intermediate fallback. This prevents minute-boundary divergence between the relocation and analysis-subfolder blocks when agentic workflow steps execute independently.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 3, 2026

🔍 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

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.

Pull request overview

Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.

Comment on lines +273 to +276
find "$UNSCOPED_DIR/documents" -mindepth 1 -maxdepth 1 -exec mv {} "$SCOPED_DIR/documents/" \;
rmdir "$UNSCOPED_DIR/documents" 2>/dev/null || true
echo "📁 Relocated pipeline documents/ contents → $SCOPED_DIR/documents"
fi
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

The relocation step moves analysis/daily/$ARTICLE_DATE/documents/ into the scoped realtime-${HHMM} folder, but later in this workflow the per-file analysis instructions still reference analysis/daily/$ARTICLE_DATE/documents/ for listing downloaded documents. After relocation, that path will be gone, so the instruction will fail and could lead to missing/incorrect per-file analysis. Either keep a copy of documents/ in the unscoped directory (copy instead of move), or update downstream instructions to point at $SCOPED_DIR/documents / analysis/daily/$ARTICLE_DATE/realtime-${HHMM}/documents.

Suggested change
find "$UNSCOPED_DIR/documents" -mindepth 1 -maxdepth 1 -exec mv {} "$SCOPED_DIR/documents/" \;
rmdir "$UNSCOPED_DIR/documents" 2>/dev/null || true
echo "📁 Relocated pipeline documents/ contents → $SCOPED_DIR/documents"
fi
find "$UNSCOPED_DIR/documents" -mindepth 1 -maxdepth 1 -exec cp -R -f {} "$SCOPED_DIR/documents/" \;
echo "📁 Copied pipeline documents/ contents → $SCOPED_DIR/documents (kept unscoped originals for downstream per-file analysis)"
fi
fi

Copilot uses AI. Check for mistakes.
Comment on lines +339 to +358
# Capture HHMM once for breaking type to prevent minute-boundary divergence between relocation and ANALYSIS_SUBFOLDER
_AG_HHMM=$(date -u +%H%M)
if [ "$_IS_SCHEDULE_OR_MULTI" = true ]; then
# Multi-type or schedule-driven run — use a dedicated workflow-scoped folder
_RELOC_SUBFOLDER="article-generator-${_AG_HHMM}"
else
case "$REQUESTED_TYPE" in
*committee-reports*) _RELOC_SUBFOLDER="committeeReports" ;;
*interpellation*) _RELOC_SUBFOLDER="interpellations" ;;
*motions*) _RELOC_SUBFOLDER="motions" ;;
*propositions*) _RELOC_SUBFOLDER="propositions" ;;
*week-ahead*) _RELOC_SUBFOLDER="week-ahead" ;;
*month-ahead*) _RELOC_SUBFOLDER="month-ahead" ;;
*weekly-review*) _RELOC_SUBFOLDER="weekly-review" ;;
*monthly-review*) _RELOC_SUBFOLDER="monthly-review" ;;
*breaking*) _RELOC_SUBFOLDER="realtime-${_AG_HHMM}" ;;
*deep-inspection*) _RELOC_SUBFOLDER="deep-inspection" ;;
*) _RELOC_SUBFOLDER="$REQUESTED_TYPE" ;;
esac
fi
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

_AG_HHMM / _RELOC_SUBFOLDER are computed here for relocation, but they aren’t persisted. Later blocks may run independently and recompute a different minute-based value, which can cause the workflow to stage/validate a different analysis folder than the one relocation copied into. Persist the chosen subfolder immediately here (e.g., write ANALYSIS_SUBFOLDER=$_RELOC_SUBFOLDER and _AG_HHMM to /tmp/analysis_subfolder.env) and consistently source it in subsequent blocks to guarantee cross-block determinism.

Suggested change
# Capture HHMM once for breaking type to prevent minute-boundary divergence between relocation and ANALYSIS_SUBFOLDER
_AG_HHMM=$(date -u +%H%M)
if [ "$_IS_SCHEDULE_OR_MULTI" = true ]; then
# Multi-type or schedule-driven run — use a dedicated workflow-scoped folder
_RELOC_SUBFOLDER="article-generator-${_AG_HHMM}"
else
case "$REQUESTED_TYPE" in
*committee-reports*) _RELOC_SUBFOLDER="committeeReports" ;;
*interpellation*) _RELOC_SUBFOLDER="interpellations" ;;
*motions*) _RELOC_SUBFOLDER="motions" ;;
*propositions*) _RELOC_SUBFOLDER="propositions" ;;
*week-ahead*) _RELOC_SUBFOLDER="week-ahead" ;;
*month-ahead*) _RELOC_SUBFOLDER="month-ahead" ;;
*weekly-review*) _RELOC_SUBFOLDER="weekly-review" ;;
*monthly-review*) _RELOC_SUBFOLDER="monthly-review" ;;
*breaking*) _RELOC_SUBFOLDER="realtime-${_AG_HHMM}" ;;
*deep-inspection*) _RELOC_SUBFOLDER="deep-inspection" ;;
*) _RELOC_SUBFOLDER="$REQUESTED_TYPE" ;;
esac
fi
# Capture and persist HHMM/subfolder once so later blocks can source the same values
ANALYSIS_SUBFOLDER_ENV=/tmp/analysis_subfolder.env
if [ -f "$ANALYSIS_SUBFOLDER_ENV" ]; then
# Reuse the previously selected subfolder to keep relocation/staging/validation deterministic
# shellcheck source=/tmp/analysis_subfolder.env
. "$ANALYSIS_SUBFOLDER_ENV"
[ -n "${ANALYSIS_HHMM:-}" ] && _AG_HHMM="$ANALYSIS_HHMM"
[ -n "${ANALYSIS_SUBFOLDER:-}" ] && _RELOC_SUBFOLDER="$ANALYSIS_SUBFOLDER"
fi
if [ -z "${_AG_HHMM:-}" ]; then
_AG_HHMM=$(date -u +%H%M)
fi
if [ -z "${_RELOC_SUBFOLDER:-}" ]; then
if [ "$_IS_SCHEDULE_OR_MULTI" = true ]; then
# Multi-type or schedule-driven run — use a dedicated workflow-scoped folder
_RELOC_SUBFOLDER="article-generator-${_AG_HHMM}"
else
case "$REQUESTED_TYPE" in
*committee-reports*) _RELOC_SUBFOLDER="committeeReports" ;;
*interpellation*) _RELOC_SUBFOLDER="interpellations" ;;
*motions*) _RELOC_SUBFOLDER="motions" ;;
*propositions*) _RELOC_SUBFOLDER="propositions" ;;
*week-ahead*) _RELOC_SUBFOLDER="week-ahead" ;;
*month-ahead*) _RELOC_SUBFOLDER="month-ahead" ;;
*weekly-review*) _RELOC_SUBFOLDER="weekly-review" ;;
*monthly-review*) _RELOC_SUBFOLDER="monthly-review" ;;
*breaking*) _RELOC_SUBFOLDER="realtime-${_AG_HHMM}" ;;
*deep-inspection*) _RELOC_SUBFOLDER="deep-inspection" ;;
*) _RELOC_SUBFOLDER="$REQUESTED_TYPE" ;;
esac
fi
fi
printf 'ANALYSIS_SUBFOLDER=%s\nANALYSIS_HHMM=%s\n_RELOC_SUBFOLDER=%s\n_AG_HHMM=%s\n' \
"$_RELOC_SUBFOLDER" "$_AG_HHMM" "$_RELOC_SUBFOLDER" "$_AG_HHMM" > "$ANALYSIS_SUBFOLDER_ENV"
echo "ANALYSIS_SUBFOLDER=$_RELOC_SUBFOLDER" >> "$GITHUB_ENV"
echo "ANALYSIS_HHMM=$_AG_HHMM" >> "$GITHUB_ENV"

Copilot uses AI. Check for mistakes.
@pethers
Copy link
Copy Markdown
Member

pethers commented Apr 3, 2026

@copilot apply changes based on the comments in this thread

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 3, 2026

🔍 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

…LOC_SUBFOLDER immediately in article-generator relocation block

Agent-Logs-Url: https://github.com/Hack23/riksdagsmonitor/sessions/be063d3d-6eca-413a-a91c-1d7ba57fe82f

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

github-actions bot commented Apr 3, 2026

🔍 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

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 3, 2026

@copilot apply changes based on the comments in this thread

Applied both review comments in commit 67a890b:

realtime-monitor documents/ preservation: Changed find -exec mv to find -exec cp -R -f for documents/ contents, preserving unscoped originals so downstream per-file analysis instructions can still reference analysis/daily/$ARTICLE_DATE/documents/.

article-generator cross-block persistence: The relocation block now sources /tmp/analysis_subfolder.env first (if present from a rerun), then computes _AG_HHMM/_RELOC_SUBFOLDER only if not already set, and persists all four variables (ANALYSIS_SUBFOLDER, ANALYSIS_HHMM, _AG_HHMM, _RELOC_SUBFOLDER) immediately after computation. This guarantees the later ANALYSIS_SUBFOLDER block and commit step always use the exact same values.

@pethers pethers merged commit ed54b97 into main Apr 3, 2026
16 checks passed
@pethers pethers deleted the copilot/improve-ai-driven-analysis-methodologies branch April 3, 2026 04:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agentic-workflow Agentic workflow changes ci-cd CI/CD pipeline changes documentation Documentation updates news News articles and content generation refactor Code refactoring size-l Large change (250-1000 lines) size-xl Extra large change (> 1000 lines) workflow GitHub Actions workflows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants