Skip to content

Add 100-file PR limit enforcement to doc-type news workflows#1477

Merged
pethers merged 2 commits intomainfrom
copilot/aw-fix-opposition-motions-workflow
Mar 31, 2026
Merged

Add 100-file PR limit enforcement to doc-type news workflows#1477
pethers merged 2 commits intomainfrom
copilot/aw-fix-opposition-motions-workflow

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 31, 2026

The news-motions workflow failed with E003: Cannot create pull request with more than 100 files (received 189). The commit step lacked the STAGED_COUNT enforcement that SHARED_PROMPT_PATTERNS.md already defines as the canonical pattern for doc-type workflows.

Changes

  • news-motions.md — Replace inline git add && git commit with the staged file count enforcement block
  • news-propositions.md, news-interpellations.md, news-committee-reports.md — Same fix; all four doc-type workflows had the identical missing safeguard

The enforcement progressively prunes to stay under the limit:

# Enforce safe-outputs 100-file PR limit
STAGED_COUNT=$(git diff --cached --name-only | wc -l)
if [ "$STAGED_COUNT" -gt 90 ]; then
  git reset HEAD -- "analysis/daily/${ARTICLE_DATE}/motions/documents/" 2>/dev/null || true
  STAGED_COUNT=$(git diff --cached --name-only | wc -l)
fi
if [ "$STAGED_COUNT" -gt 90 ]; then
  git reset HEAD -- "analysis/daily/${ARTICLE_DATE}/motions/" 2>/dev/null || true
  STAGED_COUNT=$(git diff --cached --name-only | wc -l)
fi

This matches the pattern already working in news-evening-analysis.md and news-realtime-monitor.md. Lock files use runtime-import for the .md prompt body, so no recompilation needed.

Copilot AI linked an issue Mar 31, 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 31, 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

The news-motions workflow failed with E003 (189 files > 100 limit).
Add STAGED_COUNT enforcement following the canonical pattern from
SHARED_PROMPT_PATTERNS.md to all 4 doc-type workflows:
- news-motions.md
- news-propositions.md
- news-interpellations.md
- news-committee-reports.md

The enforcement progressively prunes analysis artifacts if staged
file count exceeds 90:
1. First removes per-document analysis files (documents/)
2. Then removes all analysis artifacts if still over limit

Fixes #1476

Agent-Logs-Url: https://github.com/Hack23/riksdagsmonitor/sessions/019ceafa-9d13-4a42-b29e-0095d606120a

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 31, 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 workflow failure for opposition motions Add 100-file PR limit enforcement to doc-type news workflows Mar 31, 2026
Copilot AI requested a review from pethers March 31, 2026 08:59
@pethers pethers marked this pull request as ready for review March 31, 2026 09:03
Copilot AI review requested due to automatic review settings March 31, 2026 09:03
@pethers pethers merged commit 8055cd8 into main Mar 31, 2026
14 checks passed
@pethers pethers deleted the copilot/aw-fix-opposition-motions-workflow branch March 31, 2026 09:03
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

Adds staged-file-count pruning guidance to doc-type news workflows to prevent safeoutputs___create_pull_request failures when more than 100 files are included in a PR.

Changes:

  • Replaces inline git add && git commit instructions with a staged file count (STAGED_COUNT) pruning block.
  • Applies the same safeguard across motions, propositions, interpellations, and committee reports doc-type workflows.

Reviewed changes

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

File Description
.github/workflows/news-motions.md Adds staged file count pruning instructions before commit to stay under the PR file limit.
.github/workflows/news-propositions.md Same enforcement block added for propositions content PR creation steps.
.github/workflows/news-interpellations.md Same enforcement block added for interpellations content PR creation steps.
.github/workflows/news-committee-reports.md Same enforcement block added for committee reports content PR creation steps.

Comment on lines +331 to +342
# 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 per-document analysis files."
git reset HEAD -- "analysis/daily/${ARTICLE_DATE:-$(date -u +%Y-%m-%d)}/motions/documents/" 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 all analysis artifacts."
git reset HEAD -- "analysis/daily/${ARTICLE_DATE:-$(date -u +%Y-%m-%d)}/motions/" 2>/dev/null || true
STAGED_COUNT=$(git diff --cached --name-only | wc -l)
fi
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

The pruning block triggers when STAGED_COUNT > 90, but the warning text says it "exceeds 100-file PR limit", which is misleading (90 appears to be a safety buffer). Also, after pruning it still proceeds to commit even if the staged count remains over the limit; to actually enforce the limit and avoid repeated safeoutputs___create_pull_request failures, add a final guard that errors out (or prunes further) when the staged count is still above the threshold after resets.

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 per-document analysis files."
git reset HEAD -- "analysis/daily/${ARTICLE_DATE:-$(date -u +%Y-%m-%d)}/motions/documents/" 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 all analysis artifacts."
git reset HEAD -- "analysis/daily/${ARTICLE_DATE:-$(date -u +%Y-%m-%d)}/motions/" 2>/dev/null || true
STAGED_COUNT=$(git diff --cached --name-only | wc -l)
fi
# Enforce safe-outputs 100-file PR limit (use 90-file safety buffer for staging)
STAGED_COUNT=$(git diff --cached --name-only | wc -l)
if [ "$STAGED_COUNT" -gt 90 ]; then
echo "⚠️ Staged $STAGED_COUNT files exceeds 90-file staging safety threshold (for 100-file PR limit). Removing per-document analysis files."
git reset HEAD -- "analysis/daily/${ARTICLE_DATE:-$(date -u +%Y-%m-%d)}/motions/documents/" 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 staged after first pruning. Removing all analysis artifacts to stay within 100-file PR limit."
git reset HEAD -- "analysis/daily/${ARTICLE_DATE:-$(date -u +%Y-%m-%d)}/motions/" 2>/dev/null || true
STAGED_COUNT=$(git diff --cached --name-only | wc -l)
fi
if [ "$STAGED_COUNT" -gt 90 ]; then
echo "❌ Staged file count $STAGED_COUNT still exceeds 90-file staging safety threshold. Aborting commit to avoid exceeding 100-file PR limit. Please manually reduce the number of staged files and retry."
exit 1
fi

Copilot uses AI. Check for mistakes.
Comment on lines +329 to +343
# Stage articles and analysis — scoped to article type to stay within 100-file PR limit
git add news/ || true
git add "analysis/daily/${ARTICLE_DATE:-$(date -u +%Y-%m-%d)}/propositions/" || true
# 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 per-document analysis files."
git reset HEAD -- "analysis/daily/${ARTICLE_DATE:-$(date -u +%Y-%m-%d)}/propositions/documents/" 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 all analysis artifacts."
git reset HEAD -- "analysis/daily/${ARTICLE_DATE:-$(date -u +%Y-%m-%d)}/propositions/" 2>/dev/null || true
STAGED_COUNT=$(git diff --cached --name-only | wc -l)
fi
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

The pruning block triggers when STAGED_COUNT > 90, but the warning text says it "exceeds 100-file PR limit", which is misleading (90 appears to be a safety buffer). Also, after pruning it still proceeds to commit even if the staged count remains over the limit; to actually enforce the limit and avoid repeated safeoutputs___create_pull_request failures, add a final guard that errors out (or prunes further) when the staged count is still above the threshold after resets.

Suggested change
# Stage articles and analysis — scoped to article type to stay within 100-file PR limit
git add news/ || true
git add "analysis/daily/${ARTICLE_DATE:-$(date -u +%Y-%m-%d)}/propositions/" || true
# 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 per-document analysis files."
git reset HEAD -- "analysis/daily/${ARTICLE_DATE:-$(date -u +%Y-%m-%d)}/propositions/documents/" 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 all analysis artifacts."
git reset HEAD -- "analysis/daily/${ARTICLE_DATE:-$(date -u +%Y-%m-%d)}/propositions/" 2>/dev/null || true
STAGED_COUNT=$(git diff --cached --name-only | wc -l)
fi
# Stage articles and analysis — scoped to article type to stay within 90-file safety threshold for 100-file PR limit
git add news/ || true
git add "analysis/daily/${ARTICLE_DATE:-$(date -u +%Y-%m-%d)}/propositions/" || true
# Enforce safe-outputs 100-file PR limit with a 90-file safety buffer
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 (tooling 100-file PR limit). Removing per-document analysis files."
git reset HEAD -- "analysis/daily/${ARTICLE_DATE:-$(date -u +%Y-%m-%d)}/propositions/documents/" 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 above 90-file safety threshold. Removing all analysis artifacts."
git reset HEAD -- "analysis/daily/${ARTICLE_DATE:-$(date -u +%Y-%m-%d)}/propositions/" 2>/dev/null || true
STAGED_COUNT=$(git diff --cached --name-only | wc -l)
fi
if [ "$STAGED_COUNT" -gt 90 ]; then
echo "❌ Staged file count $STAGED_COUNT remains above 90-file safety threshold after pruning."
echo " Aborting commit to avoid safeoutputs___create_pull_request failures. Please unstage or remove files and retry."
exit 1
fi

Copilot uses AI. Check for mistakes.
Comment on lines +332 to +343
# 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 per-document analysis files."
git reset HEAD -- "analysis/daily/${ARTICLE_DATE:-$(date -u +%Y-%m-%d)}/interpellations/documents/" 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 all analysis artifacts."
git reset HEAD -- "analysis/daily/${ARTICLE_DATE:-$(date -u +%Y-%m-%d)}/interpellations/" 2>/dev/null || true
STAGED_COUNT=$(git diff --cached --name-only | wc -l)
fi
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

The pruning block triggers when STAGED_COUNT > 90, but the warning text says it "exceeds 100-file PR limit", which is misleading (90 appears to be a safety buffer). Also, after pruning it still proceeds to commit even if the staged count remains over the limit; to actually enforce the limit and avoid repeated safeoutputs___create_pull_request failures, add a final guard that errors out (or prunes further) when the staged count is still above the threshold after resets.

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 per-document analysis files."
git reset HEAD -- "analysis/daily/${ARTICLE_DATE:-$(date -u +%Y-%m-%d)}/interpellations/documents/" 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 all analysis artifacts."
git reset HEAD -- "analysis/daily/${ARTICLE_DATE:-$(date -u +%Y-%m-%d)}/interpellations/" 2>/dev/null || true
STAGED_COUNT=$(git diff --cached --name-only | wc -l)
fi
# 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 exceeds 90-file safety threshold for 100-file PR limit. Removing per-document analysis files."
git reset HEAD -- "analysis/daily/${ARTICLE_DATE:-$(date -u +%Y-%m-%d)}/interpellations/documents/" 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 after document-level pruning. Removing all analysis artifacts to stay under 100-file PR limit."
git reset HEAD -- "analysis/daily/${ARTICLE_DATE:-$(date -u +%Y-%m-%d)}/interpellations/" 2>/dev/null || true
STAGED_COUNT=$(git diff --cached --name-only | wc -l)
fi
if [ "$STAGED_COUNT" -gt 90 ]; then
echo "❌ Staged file count $STAGED_COUNT remains above 90-file safety threshold. Aborting commit to avoid exceeding the 100-file PR limit."
exit 1
fi

Copilot uses AI. Check for mistakes.
Comment on lines +336 to +348
# 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 per-document analysis files."
git reset HEAD -- "analysis/daily/${ARTICLE_DATE:-$(date -u +%Y-%m-%d)}/committeeReports/documents/" 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 all analysis artifacts."
git reset HEAD -- "analysis/daily/${ARTICLE_DATE:-$(date -u +%Y-%m-%d)}/committeeReports/" 2>/dev/null || true
STAGED_COUNT=$(git diff --cached --name-only | wc -l)
fi
echo "📊 Final staged file count: $STAGED_COUNT"
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

The pruning block triggers when STAGED_COUNT > 90, but the warning text says it "exceeds 100-file PR limit", which is misleading (90 appears to be a safety buffer). Also, after pruning it still proceeds to commit even if the staged count remains over the limit; to actually enforce the limit and avoid repeated safeoutputs___create_pull_request failures, add a final guard that errors out (or prunes further) when the staged count is still above the threshold after resets.

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 per-document analysis files."
git reset HEAD -- "analysis/daily/${ARTICLE_DATE:-$(date -u +%Y-%m-%d)}/committeeReports/documents/" 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 all analysis artifacts."
git reset HEAD -- "analysis/daily/${ARTICLE_DATE:-$(date -u +%Y-%m-%d)}/committeeReports/" 2>/dev/null || true
STAGED_COUNT=$(git diff --cached --name-only | wc -l)
fi
echo "📊 Final staged file count: $STAGED_COUNT"
# 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 exceeds 90-file safety threshold for 100-file PR limit. Removing per-document analysis files."
git reset HEAD -- "analysis/daily/${ARTICLE_DATE:-$(date -u +%Y-%m-%d)}/committeeReports/documents/" 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 after document-level pruning. Removing all analysis artifacts."
git reset HEAD -- "analysis/daily/${ARTICLE_DATE:-$(date -u +%Y-%m-%d)}/committeeReports/" 2>/dev/null || true
STAGED_COUNT=$(git diff --cached --name-only | wc -l)
fi
echo "📊 Final staged file count: $STAGED_COUNT"
if [ "$STAGED_COUNT" -gt 90 ]; then
echo "❌ Unable to reduce staged files below 90-file safety threshold (currently $STAGED_COUNT). Aborting commit to stay within safe-outputs 100-file PR limit."
exit 1
fi

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: Opposition Motions failed

3 participants