Skip to content

Implement full-text analysis, department impact, and debate context for propositions#604

Merged
pethers merged 3 commits intomainfrom
copilot/add-full-text-analysis-tools-again
Feb 27, 2026
Merged

Implement full-text analysis, department impact, and debate context for propositions#604
pethers merged 3 commits intomainfrom
copilot/add-full-text-analysis-tools-again

Conversation

Copy link
Contributor

Copilot AI commented Feb 26, 2026

propositions.ts was generating articles from get_propositioner metadata alone — no policy substance, no department context, no debate reactions. REQUIRED_TOOLS had been reverted to 1 tool to silence validation failures caused by the missing implementations.

MCP Tool Integrations

  • search_dokument_fulltext — fetches full policy text for the top proposition; extracts title/summary for a "Policy Substance" section
  • analyze_g0v_by_department — queries a 7-day rolling window of government documents by department; renders a "Department Impact" list
  • search_anforanden — retrieves parliamentary speeches mentioning the proposition; renders attributed blockquotes in a "Parliamentary Debate" section

All three calls use non-fatal try/catch — articles generate successfully even when enrichment tools are unavailable.

Article Template Additions (content-generators.ts)

Three new sections appended to generatePropositionsContent(), each with 14-language heading maps and consistent display limits:

const MAX_DISPLAY_ITEMS = 3;
const MAX_SPEECH_PREVIEW_LENGTH = 200;
// sections: .policy-substance, .department-impact, .debate-context

Data Flow

  • ArticleContentData extended with fullTextResults, departmentAnalysis, speechDebates
  • REQUIRED_TOOLS restored to full 4-tool list: get_propositioner, search_dokument_fulltext, analyze_g0v_by_department, search_anforanden
  • generateSources() updated to reflect all 4 tools

Test Coverage

  • Mock extended with request and searchSpeeches on MCPClient
  • New tests: 4-tool REQUIRED_TOOLS assertion, all-tools-called assertion, graceful degradation when enrichment tools throw
Original prompt

This section details on the original issue you should resolve

<issue_title>Improve Propositions: Add full-text analysis, department impact, and debate context</issue_title>
<issue_description>## 📋 Issue Type
Enhancement — Implement missing MCP tools for government propositions: full-text analysis, department impact, and debate context

🎯 Objective

Implement the three TODO MCP tools in scripts/news-types/propositions.ts: search_dokument_fulltext (full policy text analysis), analyze_g0v_by_department (government department impact mapping), and search_anforanden (parliamentary debate context). These tools will transform proposition articles from basic metadata summaries into comprehensive policy analysis pieces.

📊 Current State

  • File: scripts/news-types/propositions.ts (401 lines)
  • Implemented tools: get_propositioner ✅ (only tool)
  • Missing tools: search_dokument_fulltext ❌, analyze_g0v_by_department ❌, search_anforanden
  • REQUIRED_TOOLS: Only 1 tool (get_propositioner) — reduced from original 4 to avoid validation failures
  • Impact: Proposition articles only show basic metadata (title, date, document ID) without policy substance, department context, or debate reactions

🚀 Desired State

  • Full-text analysis extracts key policy provisions, budget allocations, and regulatory changes
  • Department impact mapping shows which ministries are affected and their responsibilities
  • Debate context includes ministerial presentations and opposition reactions
  • Articles explain what propositions actually propose (not just that they exist)
  • Budget impact estimates where available
  • Timeline for implementation (when laws take effect)
  • Cross-reference with related motions and committee assignments

🔧 Implementation Approach

1. Add search_dokument_fulltext integration (~80 lines)

// Extract policy substance from proposition full text
const fullText = await mcpClient.call('search_dokument_fulltext', {
  query: proposition.titel,
  limit: 3
});
  • Parse key policy provisions from full text
  • Extract budget figures and regulatory changes
  • Identify implementation timelines and affected populations
  • Use scripts/data-transformers/policy-analysis.ts for domain detection

2. Add analyze_g0v_by_department integration (~60 lines)

// Map proposition to responsible departments
const departmentAnalysis = await mcpClient.call('analyze_g0v_by_department', {
  dateFrom: propositionDate,
  dateTo: propositionDate
});
  • Identify lead ministry and supporting departments
  • Track ministerial ownership of policy areas
  • Add department context to article (who's responsible for implementation)

3. Add search_anforanden integration (~60 lines)

// Find debate speeches about this proposition
const debates = await mcpClient.call('search_anforanden', {
  text: proposition.titel,
  rm: currentRiksmote,
  limit: 10
});
  • Extract ministerial presentation quotes
  • Capture opposition reaction highlights
  • Identify party positions on the proposition

4. Update REQUIRED_TOOLS

Restore full 4-tool list: get_propositioner, search_dokument_fulltext, analyze_g0v_by_department, search_anforanden

5. Enhanced article templates

  • Add "Policy Substance" section with key provisions
  • Add "Department Impact" sidebar
  • Add "Parliamentary Debate" quotes section
  • Add "Budget Impact" where applicable
  • Update all 14 language templates

🤖 Recommended Agent

code-quality-engineer — TypeScript implementation matching existing MCP integration patterns

✅ Acceptance Criteria

  • search_dokument_fulltext integrated for policy substance extraction
  • analyze_g0v_by_department integrated for department impact mapping
  • search_anforanden integrated for debate context
  • REQUIRED_TOOLS restored to full 4-tool specification
  • REQUIRED_TOOLS validation passes without warnings
  • Article templates include "Policy Substance", "Department Impact", "Debate" sections
  • All 14 language templates updated
  • No regression in existing proposition generation
  • Performance within 20-second batch target for all languages
  • Error handling for tools that return empty results (graceful degradation)

📚 References

  • File: scripts/news-types/propositions.ts:49-52 (TODO comments)
  • File: scripts/news-types/propositions.ts:187-196 (REQUIRED_TOOLS update comment)
  • MCP Tools: search_dokument_fulltext, analyze_g0v_by_department, search_anforanden
  • Policy analysis: scripts/data-transformers/policy-analysis.ts
  • Document analysis: scripts/data-transformers/document-analysis.ts
  • Pattern reference: scripts/news-types/weekly-review.ts (full enrichment pipeline example)
    </issue_description>

<agent_instructions>Implement the three TODO MCP tools in scripts/news-types/propositions.ts: search_dokument_fulltext, analyze_g0v_by_department, search_anforanden. Resto...


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI and others added 2 commits February 26, 2026 21:10
…_anforanden in propositions.ts; restore REQUIRED_TOOLS to 4 tools; add Policy Substance, Department Impact, Debate sections

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

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
Copilot AI changed the title [WIP] Enhance propositions with full-text analysis and departmental impact Implement full-text analysis, department impact, and debate context for propositions Feb 26, 2026
@pethers pethers requested a review from Copilot February 27, 2026 02:12
@github-actions github-actions bot added testing Test coverage refactor Code refactoring size-m Medium change (50-250 lines) labels Feb 27, 2026
@github-actions
Copy link
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

Copy link
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

This PR enhances government propositions articles by implementing three MCP tool integrations that were previously marked as TODOs: search_dokument_fulltext (full policy text analysis), analyze_g0v_by_department (government department impact mapping), and search_anforanden (parliamentary debate context). The implementation transforms proposition articles from basic metadata summaries into comprehensive policy analysis pieces with graceful degradation when enrichment tools are unavailable.

Changes:

  • Integrated 3 enrichment MCP tools (search_dokument_fulltext, analyze_g0v_by_department, search_anforanden) with non-fatal error handling
  • Restored REQUIRED_TOOLS from 1 tool to full 4-tool specification
  • Extended ArticleContentData type with 3 new optional fields for enrichment data
  • Added 3 new article template sections (Policy Substance, Department Impact, Parliamentary Debate) with 14-language support and display limits

Reviewed changes

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

File Description
scripts/news-types/propositions.ts Implemented 3 enrichment tool integrations (Steps 2-4) with try/catch blocks, updated REQUIRED_TOOLS to 4 tools, passed enrichment data to content generators and sources
scripts/data-transformers/types.ts Extended ArticleContentData interface with 3 optional fields for fullTextResults, departmentAnalysis, and speechDebates
scripts/data-transformers/content-generators.ts Added 3 enrichment sections to generatePropositionsContent with 14-language headings, display limits (MAX_DISPLAY_ITEMS=3, MAX_SPEECH_PREVIEW_LENGTH=200), proper HTML escaping, and conditional rendering
tests/news-types/propositions.test.ts Extended mock with request and searchSpeeches methods, added tests for 4-tool REQUIRED_TOOLS assertion, all-tools-called verification, and graceful degradation on enrichment failures

@pethers pethers marked this pull request as ready for review February 27, 2026 06:40
@pethers pethers merged commit ac0c237 into main Feb 27, 2026
21 checks passed
@pethers pethers deleted the copilot/add-full-text-analysis-tools-again branch February 27, 2026 06:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Code refactoring size-m Medium change (50-250 lines) testing Test coverage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve Propositions: Add full-text analysis, department impact, and debate context

3 participants