Add 100-file PR limit enforcement to doc-type news workflows#1477
Add 100-file PR limit enforcement to doc-type news workflows#1477
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 |
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>
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
There was a problem hiding this comment.
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 commitinstructions 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. |
| # 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 |
There was a problem hiding this comment.
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.
| # 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 |
| # 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 |
There was a problem hiding this comment.
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.
| # 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 |
| # 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 |
There was a problem hiding this comment.
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.
| # 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 |
| # 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" |
There was a problem hiding this comment.
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.
| # 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 |
The
news-motionsworkflow failed withE003: Cannot create pull request with more than 100 files (received 189). The commit step lacked theSTAGED_COUNTenforcement thatSHARED_PROMPT_PATTERNS.mdalready defines as the canonical pattern for doc-type workflows.Changes
news-motions.md— Replace inlinegit add && git commitwith the staged file count enforcement blocknews-propositions.md,news-interpellations.md,news-committee-reports.md— Same fix; all four doc-type workflows had the identical missing safeguardThe enforcement progressively prunes to stay under the limit:
This matches the pattern already working in
news-evening-analysis.mdandnews-realtime-monitor.md. Lock files useruntime-importfor the.mdprompt body, so no recompilation needed.