Skip to content

Scope git add per article type to prevent cross-workflow conflicts and 100-file PR limit#1451

Merged
pethers merged 4 commits intomainfrom
copilot/fix-news-realtime-monitor-failure
Mar 30, 2026
Merged

Scope git add per article type to prevent cross-workflow conflicts and 100-file PR limit#1451
pethers merged 4 commits intomainfrom
copilot/fix-news-realtime-monitor-failure

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 30, 2026

The news-realtime-monitor workflow failed with E003: Cannot create pull request with more than 100 files (received 644). Two layered problems:

  1. Broad directory staginggit add analysis/daily/ analysis/data/ accumulated all historical files across dates
  2. Cross-workflow conflicts — date-scoping alone (analysis/daily/$DATE/) is insufficient because committee-reports, motions, propositions, and interpellations all run concurrently on the same date

pre-article-analysis.ts already writes to doc-type subdirectories via --doc-type, but the workflow .md files weren't matching that scoping.

Doc-type workflows — scope to article-type subdirectory

# Before: stages ALL doc-types for this date (conflicts with concurrent workflows)
git add "analysis/daily/${ARTICLE_DATE}/"

# After: isolated per workflow
git add "analysis/daily/${ARTICLE_DATE}/committeeReports/"
  • news-committee-reports.mdcommitteeReports/
  • news-motions.mdmotions/
  • news-propositions.mdpropositions/
  • news-interpellations.mdinterpellations/

General workflows — date-scoped with file-count safety

Realtime-monitor, evening-analysis, article-generator keep date-level scoping (no --doc-type) with progressive pruning if staged count exceeds 90:

git add "analysis/daily/${ARTICLE_DATE:-$(date -u +%Y-%m-%d)}/" || true
git add analysis/data/ || true
STAGED_COUNT=$(git diff --cached --name-only | wc -l)
if [ "$STAGED_COUNT" -gt 90 ]; then
  git reset HEAD -- analysis/data/ 2>/dev/null || true
fi

SHARED_PROMPT_PATTERNS.md — canonical reference updated

  • Dual pattern documentation (doc-type vs general)
  • Workflow-to-doctype mapping table
  • New PROHIBITED rule: doc-type workflows must never stage parent date directory

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI linked an issue Mar 30, 2026 that may be closed by this pull request
@github-actions github-actions bot added the size-xs Extra small change (< 10 lines) label Mar 30, 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: size-xs

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

…flows

Replace broad `git add news/ analysis/daily/ analysis/weekly/ analysis/data/`
with date-scoped adds and file-count safety checks across all 12 news
workflow .md files and SHARED_PROMPT_PATTERNS.md.

Root cause: broad git add staged ALL accumulated analysis files across
all dates, causing 644 files to exceed the safe-outputs 100-file limit.

Fix: Scope analysis staging to current ARTICLE_DATE only, add STAGED_COUNT
safety check that progressively prunes bulk data and weekly analysis if
the count exceeds 90 files.

Agent-Logs-Url: https://github.com/Hack23/riksdagsmonitor/sessions/d464e6e9-4c02-430b-ba84-9bc6e598a2e5

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 news News articles and content generation agentic-workflow Agentic workflow changes size-m Medium change (50-250 lines) labels Mar 30, 2026
@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 changed the title [WIP] Fix news realtime monitor workflow failure Fix 100-file PR limit in all news workflows by scoping git add to current date Mar 30, 2026
Copilot AI requested a review from pethers March 30, 2026 00:15
Copilot AI and others added 2 commits March 30, 2026 00:28
…orkflow conflicts

Doc-type workflows (committee-reports, motions, propositions, interpellations)
now scope git add to their article-type subdirectory instead of the parent
date directory. This prevents conflicts when multiple doc-type workflows
run concurrently on the same date.

Before: git add "analysis/daily/${ARTICLE_DATE}/" (all doc-types share)
After:  git add "analysis/daily/${ARTICLE_DATE}/committeeReports/" (isolated)

Updated SHARED_PROMPT_PATTERNS.md with dual pattern documentation:
- Doc-type workflows: scope to analysis/daily/$DATE/{docType}/
- General workflows: scope to analysis/daily/$DATE/ (unchanged)

Agent-Logs-Url: https://github.com/Hack23/riksdagsmonitor/sessions/28e0a4c0-d4f2-4825-b81e-a61f066b5810

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

Add table mapping each doc-type workflow to its --doc-type value and
DOC_TYPE variable. Clarify that --doc-type is a flag for pre-article-analysis.ts.

Agent-Logs-Url: https://github.com/Hack23/riksdagsmonitor/sessions/28e0a4c0-d4f2-4825-b81e-a61f066b5810

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 changed the title Fix 100-file PR limit in all news workflows by scoping git add to current date Scope git add per article type to prevent cross-workflow conflicts and 100-file PR limit Mar 30, 2026
@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

@pethers pethers marked this pull request as ready for review March 30, 2026 00:33
Copilot AI review requested due to automatic review settings March 30, 2026 00:33
@pethers pethers merged commit 17c1a67 into main Mar 30, 2026
13 checks passed
@pethers pethers deleted the copilot/fix-news-realtime-monitor-failure branch March 30, 2026 00:33
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 agentic workflow instructions to stage artifacts more narrowly (per-date for general workflows; per-doc-type subdirectory for doc-type workflows) to avoid cross-workflow conflicts and prevent exceeding the safe-outputs 100-file PR limit.

Changes:

  • Doc-type workflows: scope git add to analysis/daily/$ARTICLE_DATE/{docType}/ instead of the parent date directory.
  • General workflows: scope git add to analysis/daily/$ARTICLE_DATE/ and add staged-file-count pruning guidance to stay under the limit.
  • SHARED_PROMPT_PATTERNS.md: document the canonical scoping patterns and prohibitions.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
.github/workflows/news-weekly-review.md Scope staging of daily artifacts to the current ARTICLE_DATE directory.
.github/workflows/news-week-ahead.md Scope staging of daily artifacts to the current ARTICLE_DATE directory.
.github/workflows/news-realtime-monitor.md Add date-scoped staging + staged-count pruning guidance to avoid 100-file PR failures.
.github/workflows/news-propositions.md Scope staging to analysis/daily/$ARTICLE_DATE/propositions/ to avoid same-date conflicts.
.github/workflows/news-motions.md Scope staging to analysis/daily/$ARTICLE_DATE/motions/ to avoid same-date conflicts.
.github/workflows/news-monthly-review.md Scope staging of daily artifacts to the current ARTICLE_DATE directory.
.github/workflows/news-month-ahead.md Scope staging of daily artifacts to the current ARTICLE_DATE directory.
.github/workflows/news-interpellations.md Scope staging to analysis/daily/$ARTICLE_DATE/interpellations/ to avoid same-date conflicts.
.github/workflows/news-evening-analysis.md Add date-scoped staging + staged-count pruning guidance.
.github/workflows/news-committee-reports.md Scope staging to analysis/daily/$ARTICLE_DATE/committeeReports/ to avoid same-date conflicts.
.github/workflows/news-article-generator.md Add date-scoped staging + staged-count pruning guidance.
.github/workflows/SHARED_PROMPT_PATTERNS.md Document canonical git staging patterns (doc-type vs general) and prohibit broad staging.

git add news/ || true
git add "analysis/daily/${ARTICLE_DATE:-$(date -u +%Y-%m-%d)}/" || true
git add analysis/weekly/ || true
git add analysis/data/ || true
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

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

These workflow instruction changes are in the .md source, but the corresponding compiled .lock.yml workflow files are what GitHub Actions actually runs. This PR doesn’t include updated .lock.yml outputs, so the runtime workflows will still use the old (broad) git add behavior. Re-run gh aw compile for the modified workflow .md files and commit the regenerated *.lock.yml files (or trigger the repo’s compile workflow) so the fix takes effect.

Suggested change
git add analysis/data/ || true
git add "analysis/data/${ARTICLE_DATE:-$(date -u +%Y-%m-%d)}/" || true

Copilot uses AI. Check for mistakes.
Comment on lines +703 to +711
# Enforce safe-outputs 100-file PR limit
STAGED_COUNT=$(git diff --cached --name-only | wc -l)
if [ "$STAGED_COUNT" -gt 90 ]; then
echo "⚠️ Staged $STAGED_COUNT files exceeds 100-file PR limit. Removing bulk data."
git reset HEAD -- analysis/data/ 2>/dev/null || true
STAGED_COUNT=$(git diff --cached --name-only | wc -l)
fi
if [ "$STAGED_COUNT" -gt 90 ]; then
echo "⚠️ Still $STAGED_COUNT files. Removing weekly analysis."
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

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

The prune threshold is STAGED_COUNT > 90, but the log message says the staged files "exceeds 100-file PR limit". With 91–100 staged files this message is inaccurate/misleading; either change the condition to > 100 (or >= 100) or update the message to reflect that 90 is a safety buffer (e.g., "approaching/exceeding the safe-outputs limit").

Suggested change
# Enforce safe-outputs 100-file PR limit
STAGED_COUNT=$(git diff --cached --name-only | wc -l)
if [ "$STAGED_COUNT" -gt 90 ]; then
echo "⚠️ Staged $STAGED_COUNT files exceeds 100-file PR limit. Removing bulk data."
git reset HEAD -- analysis/data/ 2>/dev/null || true
STAGED_COUNT=$(git diff --cached --name-only | wc -l)
fi
if [ "$STAGED_COUNT" -gt 90 ]; then
echo "⚠️ Still $STAGED_COUNT files. Removing weekly analysis."
# Enforce safe-outputs 100-file PR limit with 90-file safety buffer
STAGED_COUNT=$(git diff --cached --name-only | wc -l)
if [ "$STAGED_COUNT" -gt 90 ]; then
echo "⚠️ Staged $STAGED_COUNT files is approaching the 100-file safe-outputs limit (90-file safety buffer). Removing bulk data."
git reset HEAD -- analysis/data/ 2>/dev/null || true
STAGED_COUNT=$(git diff --cached --name-only | wc -l)
fi
if [ "$STAGED_COUNT" -gt 90 ]; then
echo "⚠️ Still $STAGED_COUNT files, near the 100-file safe-outputs limit (90-file safety buffer). Removing weekly analysis."

Copilot uses AI. Check for mistakes.
4. **Create/rewrite ALL 7 daily synthesis files** in `analysis/daily/$ARTICLE_DATE/` — each MUST follow its template EXACTLY (metadata header, Mermaid diagrams, evidence tables, confidence labels, no `[REQUIRED]` placeholders).

5. **Commit data AND analysis together** — `git add analysis/data/ analysis/daily/`
5. **Commit data AND analysis together** — stage scoped to current date: `git add analysis/data/ "analysis/daily/${ARTICLE_DATE:-$(date -u +%Y-%m-%d)}/"` (see Step 5 for full file-count safety pattern)
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

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

This line says “see Step 5 for full file-count safety pattern” but it is already Step 5 in this section, which makes the reference confusing. Consider pointing to the specific later subsection (e.g., “see the ‘Commit & Create PR’ snippet below”) or renumbering the reference.

Suggested change
5. **Commit data AND analysis together** — stage scoped to current date: `git add analysis/data/ "analysis/daily/${ARTICLE_DATE:-$(date -u +%Y-%m-%d)}/"` (see Step 5 for full file-count safety pattern)
5. **Commit data AND analysis together** — stage scoped to current date: `git add analysis/data/ "analysis/daily/${ARTICLE_DATE:-$(date -u +%Y-%m-%d)}/"` (see the "Commit & Create PR" snippet below for full file-count safety pattern)

Copilot uses AI. Check for mistakes.
Comment on lines +176 to +179
# Enforce safe-outputs 100-file PR limit
STAGED_COUNT=$(git diff --cached --name-only | wc -l)
if [ "$STAGED_COUNT" -gt 90 ]; then
echo "⚠️ Staged $STAGED_COUNT files exceeds 100-file PR limit. Removing weekly analysis."
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

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

The doc-type example prunes when STAGED_COUNT > 90, but the message claims the PR already “exceeds 100-file PR limit”. Either align the condition with the 100-file limit or adjust the message to clarify that 90 is an early safety cutoff.

Suggested change
# Enforce safe-outputs 100-file PR limit
STAGED_COUNT=$(git diff --cached --name-only | wc -l)
if [ "$STAGED_COUNT" -gt 90 ]; then
echo "⚠️ Staged $STAGED_COUNT files exceeds 100-file PR limit. Removing weekly analysis."
# Enforce safe-outputs 100-file PR limit (90-file early cutoff for safety margin)
STAGED_COUNT=$(git diff --cached --name-only | wc -l)
if [ "$STAGED_COUNT" -gt 90 ]; then
echo "⚠️ Staged $STAGED_COUNT files approaching 100-file PR limit. Removing weekly analysis as safety margin."

Copilot uses AI. Check for mistakes.
Comment on lines +172 to +173
# Stage analysis scoped to article type — avoids conflicts with other doc-type workflows on the same date
DOC_TYPE="committeeReports" # One of: committeeReports, motions, propositions, interpellations
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

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

Step 6 is titled “Commit Data AND Analysis Together”, but the doc-type workflow snippet stages only analysis/daily/.../${DOC_TYPE}/ and analysis/weekly/ (no analysis/data/). That conflicts with the later PROHIBITED rule about not committing analysis without downloaded data (unless pruned). Please clarify what “data” means for doc-type workflows (e.g., manifest-only vs raw analysis/data/), and align the snippet/commit message/rules accordingly to avoid agents doing the wrong thing.

Suggested change
# Stage analysis scoped to article type — avoids conflicts with other doc-type workflows on the same date
DOC_TYPE="committeeReports" # One of: committeeReports, motions, propositions, interpellations
# Stage data + analysis scoped to article type — avoids conflicts with other doc-type workflows on the same date
DOC_TYPE="committeeReports" # One of: committeeReports, motions, propositions, interpellations
git add "analysis/data/daily/${ARTICLE_DATE:-$(date -u +%Y-%m-%d)}/${DOC_TYPE}/" || true

Copilot uses AI. Check for mistakes.
# Enforce safe-outputs 100-file PR limit
STAGED_COUNT=$(git diff --cached --name-only | wc -l)
if [ "$STAGED_COUNT" -gt 90 ]; then
echo "⚠️ Staged $STAGED_COUNT files exceeds 100-file PR limit. Removing weekly analysis."
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

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

The prune threshold is STAGED_COUNT > 90, but the message says the staged files “exceeds 100-file PR limit”. Either adjust the condition to match the actual 100-file limit or reword the message to indicate this is an early safety cutoff.

Suggested change
echo "⚠️ Staged $STAGED_COUNT files exceeds 100-file PR limit. Removing weekly analysis."
echo "⚠️ Staged $STAGED_COUNT files approaching 100-file PR limit (safety cutoff at 90). Removing weekly analysis."

Copilot uses AI. Check for mistakes.
Comment on lines +574 to +577
# Enforce safe-outputs 100-file PR limit
STAGED_COUNT=$(git diff --cached --name-only | wc -l)
if [ "$STAGED_COUNT" -gt 90 ]; then
echo "⚠️ Staged $STAGED_COUNT files exceeds 100-file PR limit. Removing weekly analysis."
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

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

The prune threshold is STAGED_COUNT > 90, but the message says the staged files “exceeds 100-file PR limit”. Either adjust the condition to match the actual 100-file limit or reword the message to indicate this is an early safety cutoff.

Suggested change
# Enforce safe-outputs 100-file PR limit
STAGED_COUNT=$(git diff --cached --name-only | wc -l)
if [ "$STAGED_COUNT" -gt 90 ]; then
echo "⚠️ Staged $STAGED_COUNT files exceeds 100-file PR limit. Removing weekly analysis."
# Enforce safe-outputs 100-file PR limit (with 90-file safety threshold)
STAGED_COUNT=$(git diff --cached --name-only | wc -l)
if [ "$STAGED_COUNT" -gt 90 ]; then
echo "⚠️ Staged $STAGED_COUNT files exceeds 90-file safety threshold for 100-file PR limit. Removing weekly analysis."

Copilot uses AI. Check for mistakes.
Comment on lines +194 to +197
STAGED_COUNT=$(git diff --cached --name-only | wc -l)
if [ "$STAGED_COUNT" -gt 90 ]; then
echo "⚠️ Staged $STAGED_COUNT files exceeds 100-file PR limit. Removing bulk data."
git reset HEAD -- analysis/data/ 2>/dev/null || true
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

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

The general-workflow prune condition triggers at STAGED_COUNT > 90, but the log line says it “exceeds 100-file PR limit”. With 91–100 files staged, that’s misleading; either tighten/loosen the numeric threshold to match the message or update the message to reflect that 90 is a safety buffer.

Copilot uses AI. Check for mistakes.
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 size-m Medium change (50-250 lines) size-xs Extra small change (< 10 lines) workflow GitHub Actions workflows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[aw] News Realtime Monitor failed

3 participants