diff --git a/.github/workflows/news-article-generator.md b/.github/workflows/news-article-generator.md index 86f426e5..f2f6fcbe 100644 --- a/.github/workflows/news-article-generator.md +++ b/.github/workflows/news-article-generator.md @@ -139,17 +139,22 @@ Before generating ANY articles, verify MCP connectivity: ### 2. MANDATORY Pull Request Creation (Final Step) -**CRITICAL: Workflow MUST create a PR with articles or FAIL** - -From a reader's perspective: **Where's the article?** +> **🚀 HOW SAFE PR CREATION WORKS — READ THIS FIRST** +> +> The `safeoutputs___create_pull_request` tool handles **everything**: branch creation, pushing commits, and opening the PR. You do NOT create branches or push manually. +> +> **Exact steps:** +> 1. Write article files to `news/` using `bash` or `edit` tools +> 2. Stage and commit locally: `git add news/ && git commit -m "Add news articles"` +> 3. Call `safeoutputs___create_pull_request` with `title`, `body`, and `labels` +> +> **❌ DO NOT** run `git push`, `git checkout -b`, `git branch`, or use GitHub API to create PRs. +> **❌ DO NOT** try alternative approaches if the tool call works — one call is all you need. +> **❌ DO NOT** call `safeoutputs___noop` if articles were generated but PR creation failed — let the workflow FAIL instead. - ✅ **REQUIRED:** `safeoutputs___create_pull_request` - When articles generated -- ✅ **ONLY USE `noop` if genuinely no new data** (checked riksdag-regering-mcp, found no committee reports, no propositions, no significant updates, AND force_generation=false) -- ❌ **NEVER use `noop` as a fallback for PR creation failures** - If articles were generated but PR fails, the workflow MUST FAIL - -**⚠️ If you generated articles but cannot create PR → workflow FAILS (not noop)** - -Readers expect articles. No PR = No articles = FAILURE. +- ✅ **ONLY USE `safeoutputs___noop` if genuinely no new data** (checked riksdag-regering-mcp, found no committee reports, no propositions, no significant updates, AND force_generation=false) +- ❌ **NEVER use `safeoutputs___noop` as a fallback for PR creation failures** ## Required Reference Materials & Available Skills @@ -1271,153 +1276,28 @@ fi ### Step 10: Create Pull Request -**IMPORTANT: Use MCP Safe-Outputs Tools (NOT git push)** - -In the agentic workflow sandbox, you **cannot** use `git push` directly. Instead, you MUST use the **safeoutputs MCP tools** which handle branch creation, pushing, and PR creation automatically. - -**Required steps:** -1. Commit your changes locally (`git add` + `git commit`) -2. Call `safeoutputs___create_pull_request` with your changes - -The **safeoutputs MCP tools** are available through the MCP gateway: - -#### Available Safe-Output MCP Tools - -1. **`safeoutputs___create_pull_request`** - Create a PR with your changes - ```json - { - "title": "📰 Automated News Generation - 2026-02-14", - "body": "## Automated News Generation\n\nThis PR contains...", - "labels": ["automated-news", "news-generation", "needs-editorial-review"] - } - ``` - -2. **`safeoutputs___add_comment`** - Add a comment to the triggering issue/PR - ```json - { - "body": "News generation completed successfully. 4 articles generated.", - "item_number": 123 - } - ``` - -3. **`safeoutputs___noop`** - ONLY when genuinely no new data exists - ```json - { - "message": "No new articles to generate. Checked riksdag-regering-mcp: no new committee reports, propositions, or motions since last generation. Last: 2026-02-14T13:00:00Z. Use force_generation=true to override." - } - ``` - - **⚠️ CRITICAL: Only use noop if:** - - You checked riksdag-regering-mcp and found NO new data - - No articles were generated - - force_generation=false - - **❌ NEVER use noop if:** - - Articles were generated but PR creation failed - - You encountered errors after creating content - - In those cases, let the workflow FAIL - -4. **`safeoutputs___missing_tool`** - Report missing capabilities -5. **`safeoutputs___missing_data`** - Report missing data - -#### How to Create the PR - -After committing your changes locally with `git add` and `git commit`, call the `safeoutputs___create_pull_request` MCP tool: +> **🚀 REMINDER: How safe PR creation works** +> +> 1. Stage and commit: `git add news/ && git commit -m "Add news articles for YYYY-MM-DD"` +> 2. Call `safeoutputs___create_pull_request` — it handles branch creation, push, and PR automatically +> 3. Done. **One call. No retries needed. No alternative approaches.** +> +> **❌ DO NOT** run `git push`, `git checkout -b`, or use GitHub API. +Call `safeoutputs___create_pull_request` with: ```json { - "title": "📰 Automated News Generation - 2026-02-17", - "body": "## Automated News Generation...", - "labels": ["automated-news", "news-generation"] + "title": "📰 Automated News Generation - {date}", + "body": "## Automated News Generation\n\nArticles: {count}\nTypes: {types}\nLanguages: {list}\nMCP tools used: {tools}", + "labels": ["automated-news", "news-generation", "needs-editorial-review"] } ``` -**If create_pull_request fails with "no-commits-found":** -- ❌ **DO NOT call `safeoutputs___noop`** - this hides the failure -- ✅ **Let the workflow FAIL** by throwing an error or exiting non-zero -- The failure will be visible in GitHub Actions and can be investigated -- From reader's perspective: No PR = No article = FAILURE - -**Only use `safeoutputs___noop` if:** -- You checked riksdag-regering-mcp and genuinely found NO new data -- No articles were generated at all -- force_generation=false - -**Example of correct failure handling:** -```javascript -// After committing articles -const result = await safeoutputs___create_pull_request({ - title: "📰 Automated News - 2026-02-17", - body: prBody, - labels: ["automated-news"] -}); - -if (!result || result.error) { - // PR creation failed - workflow MUST fail - console.error("PR creation failed:", result); - throw new Error("Failed to create PR after generating articles - workflow must fail"); -} -``` - -Call the `safeoutputs___create_pull_request` MCP tool with: - -**Title:** `📰 Automated News Generation - {date}` - -**Body:** -```markdown -## Automated News Generation - -This PR contains automatically generated news articles from riksdag-regering-mcp data. - -### Summary -- **Articles Generated**: {count} -- **Types**: {article_types} -- **Timestamp**: {ISO 8601} -- **MCP Tools Used**: {list of tools} - -### Articles Created -- {list of files with descriptions} - -### Data Sources -- **riksdag-regering-mcp**: Swedish Parliament and Government data -- **32 specialized tools**: Documents, MPs, votes, speeches, calendar events - -### Quality Checks -- [x] HTML validation passed -- [x] Metadata validation passed -- [x] No broken links detected -- [x] SEO metadata complete -- [x] Source attribution included -- [x] Multi-language support (EN/SV) -- [x] News indexes regenerated (at build time) -- [x] Sitemap updated (at build time) -- [ ] Editorial review recommended - -### Validation Results -``` -HTML Validation: PASSED (0 errors) -Link Check: PASSED (0 broken links) -Metadata: COMPLETE -SEO Score: {score}/100 -``` - -### References -- MCP Server: riksdag-regering-mcp (npm) -- Data: Swedish Riksdag Open Data API -- Style Guide: The Economist -- Workflow: {workflow_run_url} - ---- -*This PR was automatically created by the News Article Generator agent* - -**Next Steps:** -1. Review articles for accuracy and tone -2. Verify source citations and links -3. Check multi-language consistency -4. Approve and merge if quality standards met -``` +**If no new data exists** (genuinely no data from riksdag-regering-mcp AND force_generation=false): +- Call `safeoutputs___noop` with message describing what was checked +- ❌ NEVER use `safeoutputs___noop` if articles were generated — let the workflow FAIL instead -**Branch:** `news-generation/automated-{timestamp}` +**Other safe output tools:** `safeoutputs___add_comment`, `safeoutputs___missing_tool`, `safeoutputs___missing_data` **Labels:** `automated-news`, `news-generation`, `needs-editorial-review` diff --git a/.github/workflows/news-committee-reports.md b/.github/workflows/news-committee-reports.md index a4ea971c..252db911 100644 --- a/.github/workflows/news-committee-reports.md +++ b/.github/workflows/news-committee-reports.md @@ -139,9 +139,22 @@ Before generating ANY articles, verify MCP connectivity: ## MANDATORY PR Creation +> **🚀 HOW SAFE PR CREATION WORKS — READ THIS FIRST** +> +> The `safeoutputs___create_pull_request` tool handles **everything**: branch creation, pushing commits, and opening the PR. You do NOT create branches or push manually. +> +> **Exact steps:** +> 1. Write article files to `news/` using `bash` or `edit` tools +> 2. Stage and commit locally: `git add news/ && git commit -m "Add committee-reports articles"` +> 3. Call `safeoutputs___create_pull_request` with `title`, `body`, and `labels` +> +> **❌ DO NOT** run `git push`, `git checkout -b`, `git branch`, or use GitHub API to create PRs. +> **❌ DO NOT** try alternative approaches if the tool call works — one call is all you need. +> **❌ DO NOT** call `safeoutputs___noop` if articles were generated but PR creation failed — let the workflow FAIL instead. + - ✅ **REQUIRED:** `safeoutputs___create_pull_request` when articles generated -- ✅ **ONLY USE `noop` if genuinely no new committee reports** from riksdag-regering-mcp -- ❌ **NEVER use `noop` as fallback for PR creation failures** +- ✅ **ONLY USE `safeoutputs___noop` if genuinely no new committee reports** from riksdag-regering-mcp +- ❌ **NEVER use `safeoutputs___noop` as fallback for PR creation failures** ## MCP Tools diff --git a/.github/workflows/news-evening-analysis.md b/.github/workflows/news-evening-analysis.md index 35438901..f4320732 100644 --- a/.github/workflows/news-evening-analysis.md +++ b/.github/workflows/news-evening-analysis.md @@ -149,19 +149,24 @@ Before generating ANY articles, verify MCP connectivity: ### 2. MANDATORY Pull Request Creation (Final Step) -**CRITICAL: Workflow MUST create a PR with analysis or FAIL** - -From a reader's perspective: **Where's the analysis?** +> **🚀 HOW SAFE PR CREATION WORKS — READ THIS FIRST** +> +> The `safeoutputs___create_pull_request` tool handles **everything**: branch creation, pushing commits, and opening the PR. You do NOT create branches or push manually. +> +> **Exact steps:** +> 1. Write article files to `news/` using `bash` or `edit` tools +> 2. Stage and commit locally: `git add news/ && git commit -m "Add evening-analysis articles"` +> 3. Call `safeoutputs___create_pull_request` with `title`, `body`, and `labels` +> +> **❌ DO NOT** run `git push`, `git checkout -b`, `git branch`, or use GitHub API to create PRs. +> **❌ DO NOT** try alternative approaches if the tool call works — one call is all you need. +> **❌ DO NOT** call `safeoutputs___noop` if articles were generated but PR creation failed — let the workflow FAIL instead. - ✅ **REQUIRED:** `safeoutputs___create_pull_request` - When analysis articles generated -- ✅ **ONLY USE `noop` if genuinely insufficient data** (checked riksdag-regering-mcp, found no votes, no debates, no documents, no calendar events for the lookback period) -- ❌ **NEVER use `noop` as a fallback for PR creation failures** - If articles were generated but PR fails, the workflow MUST FAIL - -**⚠️ If you generated analysis articles but cannot create PR → workflow FAILS (not noop)** - -Readers expect analysis. No PR = No analysis = FAILURE. +- ✅ **ONLY USE `safeoutputs___noop` if genuinely insufficient data** (checked riksdag-regering-mcp, found no votes, no debates, no documents, no calendar events for the lookback period) +- ❌ **NEVER use `safeoutputs___noop` as a fallback for PR creation failures** -The workflow will **FAIL** if no safe output is generated. This is by design to ensure all runs produce actionable output. +The workflow will **FAIL** if no safe output is generated. This is by design. You are the **Evening Analysis Editor** for Riksdagsmonitor. Your mission is to produce a comprehensive wrap-up of Swedish parliamentary and government activity, written in **The Economist style** with deeper analytical depth than breaking coverage. @@ -921,77 +926,32 @@ If validation fails, review the error messages, fix the issues, regenerate index ### Step 7: Create Pull Request -**IMPORTANT: Use MCP Safe-Outputs Tools (NOT git push)** - -In the agentic workflow sandbox, you **cannot** use `git push` directly. Instead, you MUST use the **safeoutputs MCP tools** available through the MCP gateway. These tools are already registered and available to you: - -#### Available Safe-Output MCP Tools - -1. **`safeoutputs___create_pull_request`** - Create a PR with your changes - ```json - { - "title": "🌆 Evening Analysis: {Lead headline} - {date}", - "body": "## Evening Parliamentary Analysis\n\nThis PR contains...", - "labels": ["automated-news", "evening-analysis", "needs-editorial-review"] - } - ``` - -2. **`safeoutputs___add_comment`** - Add a comment to the triggering issue/PR - ```json - { - "body": "Evening analysis completed successfully. {count} articles generated.", - "item_number": 123 - } - ``` - -3. **`safeoutputs___noop`** - ONLY when genuinely no data exists - ```json - { - "message": "No significant parliamentary activity for evening analysis. Checked riksdag-regering-mcp: no votes, debates, documents, or calendar events in last {lookback_hours} hours. Last analysis: {timestamp}." - } - ``` - - **⚠️ CRITICAL: Only use noop if:** - - You checked riksdag-regering-mcp and found NO parliamentary activity - - No analysis articles were generated - - The day was genuinely quiet (no votes, no debates, no documents) - - **❌ NEVER use noop if:** - - Articles were generated but PR creation failed - - You encountered errors after creating content - - In those cases, let the workflow FAIL - -4. **`safeoutputs___missing_tool`** - Report missing capabilities -5. **`safeoutputs___missing_data`** - Report missing data - -#### How to Create the PR - -**CRITICAL: Understanding the Container Isolation Bug** - -Due to a known bug in safe-outputs, `create_pull_request` may fail with "no-commits-found" even though you've committed changes. If this happens: -- ❌ **DO NOT call `safeoutputs___noop`** - this hides the failure -- ✅ **Let the workflow FAIL** by throwing an error -- From reader's perspective: No PR = No analysis = FAILURE - -After committing your changes locally with `git add` and `git commit`, call the `safeoutputs___create_pull_request` MCP tool with: - -**Title:** `🌆 Evening Analysis: {Lead headline} - {date}` -**Branch:** `news-evening/{date}` -**Labels:** `automated-news`, `evening-analysis`, `needs-editorial-review` - -**Example failure handling:** -```javascript -const result = await safeoutputs___create_pull_request({ - title: "🌆 Evening Analysis: Coalition Tensions - 2026-02-17", - body: prBody, - labels: ["automated-news", "evening-analysis"] -}); - -if (!result || result.error) { - throw new Error("Failed to create PR after generating analysis - workflow must fail"); +> **🚀 REMINDER: How safe PR creation works** +> +> 1. Stage and commit: `git add news/ && git commit -m "Add evening-analysis articles for YYYY-MM-DD"` +> 2. Call `safeoutputs___create_pull_request` — it handles branch creation, push, and PR automatically +> 3. Done. **One call. No retries needed. No alternative approaches.** +> +> **❌ DO NOT** run `git push`, `git checkout -b`, or use GitHub API. + +Call `safeoutputs___create_pull_request` with: +```json +{ + "title": "🌆 Evening Analysis: {Lead headline} - {date}", + "body": "## Evening Parliamentary Analysis\n\nArticles: {count}\nLanguages: {list}\nMCP tools used: {tools}\nValidation: passed", + "labels": ["automated-news", "evening-analysis", "needs-editorial-review"] } ``` +**If no parliamentary activity was found** (genuinely no data from riksdag-regering-mcp): +- Call `safeoutputs___noop` with message describing what was checked +- ❌ NEVER use `safeoutputs___noop` if articles were generated — let the workflow FAIL instead + +**Other safe output tools available:** +- `safeoutputs___add_comment` — comment on triggering issue/PR +- `safeoutputs___missing_tool` — report missing capabilities +- `safeoutputs___missing_data` — report missing data + **PR Body should include:** - Summary of articles generated - Key findings and significance rating diff --git a/.github/workflows/news-month-ahead.md b/.github/workflows/news-month-ahead.md index cdb60ab3..73b5ac95 100644 --- a/.github/workflows/news-month-ahead.md +++ b/.github/workflows/news-month-ahead.md @@ -135,9 +135,22 @@ Before generating ANY articles, verify MCP connectivity: ## MANDATORY PR Creation +> **🚀 HOW SAFE PR CREATION WORKS — READ THIS FIRST** +> +> The `safeoutputs___create_pull_request` tool handles **everything**: branch creation, pushing commits, and opening the PR. You do NOT create branches or push manually. +> +> **Exact steps:** +> 1. Write article files to `news/` using `bash` or `edit` tools +> 2. Stage and commit locally: `git add news/ && git commit -m "Add month-ahead articles"` +> 3. Call `safeoutputs___create_pull_request` with `title`, `body`, and `labels` +> +> **❌ DO NOT** run `git push`, `git checkout -b`, `git branch`, or use GitHub API to create PRs. +> **❌ DO NOT** try alternative approaches if the tool call works — one call is all you need. +> **❌ DO NOT** call `safeoutputs___noop` if articles were generated but PR creation failed — let the workflow FAIL instead. + - ✅ `safeoutputs___create_pull_request` when articles generated -- ✅ `noop` ONLY if genuinely no upcoming events in next 30 days -- ❌ NEVER use `noop` as fallback for PR creation failures +- ✅ `safeoutputs___noop` ONLY if genuinely no upcoming events in next 30 days +- ❌ NEVER use `safeoutputs___noop` as fallback for PR creation failures ## MCP Tools diff --git a/.github/workflows/news-monthly-review.md b/.github/workflows/news-monthly-review.md index 365a1093..7da15b7d 100644 --- a/.github/workflows/news-monthly-review.md +++ b/.github/workflows/news-monthly-review.md @@ -135,9 +135,22 @@ Before generating ANY articles, verify MCP connectivity: ## MANDATORY PR Creation +> **🚀 HOW SAFE PR CREATION WORKS — READ THIS FIRST** +> +> The `safeoutputs___create_pull_request` tool handles **everything**: branch creation, pushing commits, and opening the PR. You do NOT create branches or push manually. +> +> **Exact steps:** +> 1. Write article files to `news/` using `bash` or `edit` tools +> 2. Stage and commit locally: `git add news/ && git commit -m "Add monthly-review articles"` +> 3. Call `safeoutputs___create_pull_request` with `title`, `body`, and `labels` +> +> **❌ DO NOT** run `git push`, `git checkout -b`, `git branch`, or use GitHub API to create PRs. +> **❌ DO NOT** try alternative approaches if the tool call works — one call is all you need. +> **❌ DO NOT** call `safeoutputs___noop` if articles were generated but PR creation failed — let the workflow FAIL instead. + - ✅ `safeoutputs___create_pull_request` when articles generated -- ✅ `noop` ONLY if genuinely no parliamentary activity in past month -- ❌ NEVER use `noop` as fallback for PR creation failures +- ✅ `safeoutputs___noop` ONLY if genuinely no parliamentary activity in past month +- ❌ NEVER use `safeoutputs___noop` as fallback for PR creation failures ## MCP Tools diff --git a/.github/workflows/news-motions.md b/.github/workflows/news-motions.md index 65d85661..92dd866c 100644 --- a/.github/workflows/news-motions.md +++ b/.github/workflows/news-motions.md @@ -133,9 +133,22 @@ Before generating ANY articles, verify MCP connectivity: ## MANDATORY PR Creation +> **🚀 HOW SAFE PR CREATION WORKS — READ THIS FIRST** +> +> The `safeoutputs___create_pull_request` tool handles **everything**: branch creation, pushing commits, and opening the PR. You do NOT create branches or push manually. +> +> **Exact steps:** +> 1. Write article files to `news/` using `bash` or `edit` tools +> 2. Stage and commit locally: `git add news/ && git commit -m "Add opposition-motions articles"` +> 3. Call `safeoutputs___create_pull_request` with `title`, `body`, and `labels` +> +> **❌ DO NOT** run `git push`, `git checkout -b`, `git branch`, or use GitHub API to create PRs. +> **❌ DO NOT** try alternative approaches if the tool call works — one call is all you need. +> **❌ DO NOT** call `safeoutputs___noop` if articles were generated but PR creation failed — let the workflow FAIL instead. + - ✅ `safeoutputs___create_pull_request` when articles generated -- ✅ `noop` ONLY if genuinely no new motions -- ❌ NEVER use `noop` as fallback for PR creation failures +- ✅ `safeoutputs___noop` ONLY if genuinely no new motions +- ❌ NEVER use `safeoutputs___noop` as fallback for PR creation failures ## MCP Tools diff --git a/.github/workflows/news-propositions.md b/.github/workflows/news-propositions.md index e3b6c8c7..0e13c92d 100644 --- a/.github/workflows/news-propositions.md +++ b/.github/workflows/news-propositions.md @@ -133,9 +133,22 @@ Before generating ANY articles, verify MCP connectivity: ## MANDATORY PR Creation +> **🚀 HOW SAFE PR CREATION WORKS — READ THIS FIRST** +> +> The `safeoutputs___create_pull_request` tool handles **everything**: branch creation, pushing commits, and opening the PR. You do NOT create branches or push manually. +> +> **Exact steps:** +> 1. Write article files to `news/` using `bash` or `edit` tools +> 2. Stage and commit locally: `git add news/ && git commit -m "Add propositions articles"` +> 3. Call `safeoutputs___create_pull_request` with `title`, `body`, and `labels` +> +> **❌ DO NOT** run `git push`, `git checkout -b`, `git branch`, or use GitHub API to create PRs. +> **❌ DO NOT** try alternative approaches if the tool call works — one call is all you need. +> **❌ DO NOT** call `safeoutputs___noop` if articles were generated but PR creation failed — let the workflow FAIL instead. + - ✅ `safeoutputs___create_pull_request` when articles generated -- ✅ `noop` ONLY if genuinely no new propositions -- ❌ NEVER use `noop` as fallback for PR creation failures +- ✅ `safeoutputs___noop` ONLY if genuinely no new propositions +- ❌ NEVER use `safeoutputs___noop` as fallback for PR creation failures ## MCP Tools diff --git a/.github/workflows/news-realtime-monitor.md b/.github/workflows/news-realtime-monitor.md index c38cb2ae..ec669e31 100644 --- a/.github/workflows/news-realtime-monitor.md +++ b/.github/workflows/news-realtime-monitor.md @@ -92,11 +92,12 @@ You are the **Real-Time Political Monitor** for Riksdagsmonitor. Your mission is > **⚠️ NON-NEGOTIABLE — read before anything else:** > Every run **MUST** end by calling exactly one safe output tool: -> - Found no significant events → `safeoutputs___noop({"message": "Real-time monitor: No significant parliamentary events in this window. Checked: votes, debates, questions, documents, calendar."})` -> - Generated articles → `safeoutputs___create_pull_request({...})` +> - Found no significant events → `safeoutputs___noop({"message": "..."})` +> - Generated articles → `git add news/ && git commit -m "..."` then `safeoutputs___create_pull_request({...})` > - Required tool unavailable → `safeoutputs___missing_tool({"reason": "..."})` > -> **Exiting without calling one of these = workflow failure.** When in doubt, call `safeoutputs___noop`. +> **`safeoutputs___create_pull_request` handles branch creation and push automatically. Do NOT run `git push` or create branches.** +> **Exiting without calling one of these = workflow failure.** When in doubt **and no articles were generated**, call `safeoutputs___noop` (otherwise follow the detailed rules below). ## 🚨 CRITICAL REQUIREMENTS (MUST COMPLETE) @@ -204,19 +205,25 @@ Sometimes, due to cold start timing, the MCP tools may not appear in your tools ### 2. MANDATORY Pull Request Creation (Final Step) -**CRITICAL: Workflow behavior depends on whether events found** +> **🚀 HOW SAFE PR CREATION WORKS — READ THIS FIRST** +> +> The `safeoutputs___create_pull_request` tool handles **everything**: branch creation, pushing commits, and opening the PR. You do NOT create branches or push manually. +> +> **Exact steps:** +> 1. Write article files to `news/` using `bash` or `edit` tools +> 2. Stage and commit locally: `git add news/ && git commit -m "Add breaking-news articles"` +> 3. Call `safeoutputs___create_pull_request` with `title`, `body`, and `labels` +> +> **❌ DO NOT** run `git push`, `git checkout -b`, `git branch`, or use GitHub API to create PRs. +> **❌ DO NOT** try alternative approaches if the tool call works — one call is all you need. +> **❌ DO NOT** call `safeoutputs___noop` if articles were generated but PR creation failed — let the workflow FAIL instead. -- ✅ **If significant events found:** Generate articles → `safeoutputs___create_pull_request` (MUST succeed or FAIL) +- ✅ **If significant events found:** Generate articles → `safeoutputs___create_pull_request` - ✅ **If genuinely no events:** `safeoutputs___noop` → Workflow succeeds (legitimate) -- ❌ **NEVER use `noop` as fallback for PR failures:** If articles generated but PR fails → FAIL - -**⚠️ From reader's perspective: No PR when articles exist = FAILURE** -- ✅ `safeoutputs___create_pull_request` - When articles generated +- ❌ **NEVER use `safeoutputs___noop` as fallback for PR failures** **⚠️ FAILURE TO CALL A SAFE OUTPUT TOOL = WORKFLOW FAILURE** -The workflow will **FAIL** if no safe output is generated, even if the agent job technically succeeds. This is by design to ensure all runs produce actionable output. - ## ⚠️ CRITICAL REQUIREMENT: Multi-Language Translation **YOU MUST TRANSLATE ALL SWEDISH CONTENT INTO EACH TARGET LANGUAGE. THIS IS MANDATORY.** @@ -760,88 +767,35 @@ If validation shows errors, try to fix them. If elapsed >= 38 minutes, proceed t ### Step 6: Create PR (if articles generated) -**IMPORTANT: Use MCP Safe-Outputs Tools (NOT git push)** - -In the agentic workflow sandbox, you **cannot** use `git push` directly. Instead, you MUST use the **safeoutputs MCP tools** available through the MCP gateway. - -#### Available Safe-Output MCP Tools - -1. **`safeoutputs___create_pull_request`** - Create a PR with your changes - ```json - { - "title": "🔴 Breaking: {primary headline} - {date}", - "body": "## Breaking News\n\nThis PR contains...", - "labels": ["automated-news", "breaking-news", "needs-editorial-review"] - } - ``` - -2. **`safeoutputs___add_comment`** - Add a comment to the triggering issue/PR - ```json - { - "body": "Real-time monitor detected significant events. {count} articles generated.", - "item_number": 123 - } - ``` - -3. **`safeoutputs___noop`** - ONLY when genuinely no events detected - ```json - { - "message": "Real-time monitor: No significant parliamentary events in this window. Checked: votes, debates, questions, documents, calendar. Next check: {schedule}." - } - ``` - - **⚠️ CRITICAL: Only use noop if:** - - You monitored all sources and found NO significant events - - No articles were generated - - This is the legitimate "quiet period" case - - **❌ NEVER use noop if:** - - Articles were generated but PR creation failed - - You encountered errors after creating content - - In those cases, let the workflow FAIL - -4. **`safeoutputs___missing_tool`** - Report missing capabilities -5. **`safeoutputs___missing_data`** - Report missing data - -#### How to Create the PR - -**CRITICAL: Understanding the Container Isolation Bug** - -Due to a known bug in safe-outputs, `create_pull_request` may fail with "no-commits-found". If this happens: -- ❌ **DO NOT call `safeoutputs___noop`** - this hides the failure -- ✅ **Let the workflow FAIL** - readers need the article - -After committing your changes locally with `git add` and `git commit`, call the `safeoutputs___create_pull_request` MCP tool. +> **🚀 REMINDER: How safe PR creation works** +> +> 1. Stage and commit: `git add news/ && git commit -m "Add breaking-news articles for YYYY-MM-DD"` +> 2. Call `safeoutputs___create_pull_request` — it handles branch creation, push, and PR automatically +> 3. Done. **One call. No retries needed. No alternative approaches.** +> +> **❌ DO NOT** run `git push`, `git checkout -b`, or use GitHub API. -**Example failure handling:** -```javascript -const result = await safeoutputs___create_pull_request({ - title: "🔴 Breaking: Coalition Crisis - 2026-02-17", - body: prBody, - labels: ["automated-news", "breaking-news"] -}); - -if (!result || result.error) { - throw new Error("Failed to create PR after generating breaking news - workflow must fail"); +Call `safeoutputs___create_pull_request` with: +```json +{ + "title": "🔴 Breaking: {primary headline} - {date}", + "body": "## Breaking News\n\nArticles: {count}\nLanguages: {list}\nSources: riksdag-regering-mcp", + "labels": ["automated-news", "breaking-news", "needs-editorial-review"] } ``` -**Title:** `🔴 Breaking: {primary headline} - {date}` -**Branch:** `news-realtime/{timestamp}` -**Labels:** `automated-news`, `breaking-news`, `needs-editorial-review` - #### If No Significant Events Detected (LEGITIMATE NOOP CASE) **THIS IS THE MOST COMMON OUTCOME** - Parliament is often inactive between sessions. When genuinely no breaking news is detected: - 1. Verify you monitored all sources (votes, debates, questions, documents, calendar) -2. Document what was checked -3. Call `safeoutputs___noop` with detailed message -4. Workflow succeeds (legitimate quiet period) +2. Call `safeoutputs___noop` with message describing what was checked +3. Workflow succeeds (legitimate quiet period) + +**❌ NEVER use `safeoutputs___noop` if articles were generated — let the workflow FAIL instead.** -**⚠️ But if articles were generated and PR fails:** workflow MUST FAIL, not noop. +**Other safe output tools:** `safeoutputs___add_comment`, `safeoutputs___missing_tool`, `safeoutputs___missing_data` ## Available MCP Tools diff --git a/.github/workflows/news-week-ahead.md b/.github/workflows/news-week-ahead.md index abf3416f..493fe11c 100644 --- a/.github/workflows/news-week-ahead.md +++ b/.github/workflows/news-week-ahead.md @@ -133,9 +133,22 @@ Before generating ANY articles, verify MCP connectivity: ## MANDATORY PR Creation +> **🚀 HOW SAFE PR CREATION WORKS — READ THIS FIRST** +> +> The `safeoutputs___create_pull_request` tool handles **everything**: branch creation, pushing commits, and opening the PR. You do NOT create branches or push manually. +> +> **Exact steps:** +> 1. Write article files to `news/` using `bash` or `edit` tools +> 2. Stage and commit locally: `git add news/ && git commit -m "Add week-ahead articles"` +> 3. Call `safeoutputs___create_pull_request` with `title`, `body`, and `labels` +> +> **❌ DO NOT** run `git push`, `git checkout -b`, `git branch`, or use GitHub API to create PRs. +> **❌ DO NOT** try alternative approaches if the tool call works — one call is all you need. +> **❌ DO NOT** call `safeoutputs___noop` if articles were generated but PR creation failed — let the workflow FAIL instead. + - ✅ `safeoutputs___create_pull_request` when articles generated -- ✅ `noop` ONLY if genuinely no upcoming calendar events -- ❌ NEVER use `noop` as fallback for PR creation failures +- ✅ `safeoutputs___noop` ONLY if genuinely no upcoming calendar events +- ❌ NEVER use `safeoutputs___noop` as fallback for PR creation failures ## MCP Tools diff --git a/.github/workflows/news-weekly-review.md b/.github/workflows/news-weekly-review.md index 51feb9ab..fac8c2ec 100644 --- a/.github/workflows/news-weekly-review.md +++ b/.github/workflows/news-weekly-review.md @@ -135,9 +135,22 @@ Before generating ANY articles, verify MCP connectivity: ## MANDATORY PR Creation +> **🚀 HOW SAFE PR CREATION WORKS — READ THIS FIRST** +> +> The `safeoutputs___create_pull_request` tool handles **everything**: branch creation, pushing commits, and opening the PR. You do NOT create branches or push manually. +> +> **Exact steps:** +> 1. Write article files to `news/` using `bash` or `edit` tools +> 2. Stage and commit locally: `git add news/ && git commit -m "Add weekly-review articles"` +> 3. Call `safeoutputs___create_pull_request` with `title`, `body`, and `labels` +> +> **❌ DO NOT** run `git push`, `git checkout -b`, `git branch`, or use GitHub API to create PRs. +> **❌ DO NOT** try alternative approaches if the tool call works — one call is all you need. +> **❌ DO NOT** call `safeoutputs___noop` if articles were generated but PR creation failed — let the workflow FAIL instead. + - ✅ `safeoutputs___create_pull_request` when articles generated -- ✅ `noop` ONLY if genuinely no parliamentary activity in the past week -- ❌ NEVER use `noop` as fallback for PR creation failures +- ✅ `safeoutputs___noop` ONLY if genuinely no parliamentary activity in the past week +- ❌ NEVER use `safeoutputs___noop` as fallback for PR creation failures ## MCP Tools diff --git a/tests/workflow-architecture.test.ts b/tests/workflow-architecture.test.ts index 4f9711f5..879d5304 100644 --- a/tests/workflow-architecture.test.ts +++ b/tests/workflow-architecture.test.ts @@ -147,6 +147,42 @@ describe('Workflow Architecture', () => { } }); + it('should have safe PR creation how-to in all workflows', () => { + const allWorkflows = [ + ...Object.values(ARTICLE_TYPE_WORKFLOWS), + 'news-evening-analysis.md', + 'news-realtime-monitor.md', + 'news-article-generator.md' + ]; + + for (const workflowFile of allWorkflows) { + const filepath = path.join(WORKFLOWS_DIR, workflowFile); + expect( + fs.existsSync(filepath), + `Workflow ${workflowFile} should exist on disk` + ).toBe(true); + + const content = fs.readFileSync(filepath, 'utf-8'); + const hasDoNotGitPush = /DO\s+NOT[\s\S]{0,80}`git push`/i.test(content); + expect( + hasDoNotGitPush, + `Workflow ${workflowFile} should have explicit DO NOT git push instruction` + ).toBe(true); + expect( + content.includes('safeoutputs___create_pull_request'), + `Workflow ${workflowFile} should reference safeoutputs___create_pull_request` + ).toBe(true); + expect( + content.includes('git add') && content.includes('git commit'), + `Workflow ${workflowFile} should document git add + git commit before safe PR creation` + ).toBe(true); + expect( + content.includes('HOW SAFE PR CREATION WORKS'), + `Workflow ${workflowFile} should include the standardized HOW SAFE PR CREATION WORKS header block` + ).toBe(true); + } + }); + it('should have least privilege permissions on all workflows', () => { for (const [_articleType, workflowFile] of Object.entries(ARTICLE_TYPE_WORKFLOWS)) { const filepath = path.join(WORKFLOWS_DIR, workflowFile);