Skip to content

fix(vote-detail): risolvi --group-acronym contro le sigle reali del voto#80

Merged
aborruso merged 4 commits into
mainfrom
fix/77-group-acronym-alignment
Jul 26, 2026
Merged

fix(vote-detail): risolvi --group-acronym contro le sigle reali del voto#80
aborruso merged 4 commits into
mainfrom
fix/77-group-acronym-alignment

Conversation

@aborruso

Copy link
Copy Markdown
Member

Closes #77

Il problema

--group-acronym filtrava lato SPARQL con FILTER(STR(?_sg) = "…") sulla sigla passata dall'utente. Le sigle del dataset votazioni non coincidono con l'acronym di groups list (AZ-PER-REAPERRE, IV-CRIVICRE, Misto disaggregato in M-ALT/M-MIN/M-+EUR), quindi seguendo il flusso documentato lookup→filtro si otteneva un risultato vuoto, con exit 0 e nessun avviso: indistinguibile da "il gruppo non ha votato".

Cosa fa questa PR

Quando --group-acronym è valorizzato, una query leggera (SELECT DISTINCT ?siglaGruppo sulla votazione, ~12 righe) recupera le sigle reali. La sigla richiesta viene risolta contro quelle: esatta → case-insensitive → normalizzata (senza punteggiatura). Se risolve, la query principale resta identica con il FILTER sulla sigla vera: performance e semantica di LIMIT invariate.

Se non risolve, il risultato è vuoto ma con un hint (stderr in CLI, testo nell'MCP) che elenca le sigle presenti nella votazione, mette in testa la più simile e spiega che il Misto è disaggregato.

Nessuna mappatura hardcoded. Il disallineamento è nel grafo della Camera, non nel nostro codice: alias del tipo AZ-PER-RE → APERRE si romperebbero al primo cambio di denominazione. Il codice interroga il dato e rende visibile il problema; la segnalazione a monte è nella nota gestori Camera e nel dossier della campagna.

Nota: nemmeno group_uri sarebbe stata una chiave utilizzabile — per Azione è gr4135 in groups e gr4212 nel voto (quest'ultimo senza triple come soggetto), e le componenti del Misto ce l'hanno vuoto.

Verifica

V=http://dati.camera.it/ocd/votazione.rdf/vs19_456_018

# prima: header e basta. ora: vuoto + hint con "Forse cercavi APERRE"
node dist/cli.js vote-detail show --vote-uri $V --group-acronym "AZ-PER-RE" --format csv

# invariato: 10 righe
node dist/cli.js vote-detail show --vote-uri $V --group-acronym APERRE --format csv

# match silenzioso: 117 righe
node dist/cli.js vote-detail show --vote-uri $V --group-acronym fdi --format csv

Con --format csv 2>/dev/null lo stdout resta pulito: l'hint è su stderr, le pipeline non si rompono.

Test: 10 nuovi test sulle due funzioni pure (src/tools/vote-detail.test.ts), suite completa verde (199 test).

🤖 Generated with Claude Code

aborruso and others added 2 commits July 26, 2026 08:48
Il catalogo esisteva solo nella skill Pi: l'agent Claude Code non lo
leggeva né lo aggiornava. Sei run consecutive (17-25 lug) senza sezione
nel catalogo e con le stesse vicende riproposte ogni volta.

Porta nell'agent la Fase 0 (lettura + regola di equivalenza) e la Fase 4
(append), con la deroga esplicita alla regola di analisi vergine.
Nella spec: naming sezione e formato riga canonico, divieto di
annotazioni di copertura, regola di compattazione, verifica eseguibile.

Il catalogo è in .gitignore: backfill delle sei sezioni fatto in locale.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…oto (#77)

Le sigle di ocd:siglaGruppo non coincidono con l'acronym di `groups list`
(AZ-PER-RE → APERRE, IV-CR → IVICRE, Misto disaggregato): il FILTER su una
sigla inesistente restituiva zero righe senza dire perché.

La sigla richiesta viene ora risolta contro quelle effettivamente presenti
nella votazione (query leggera), con confronto tollerante a maiuscole e
punteggiatura. Se non esiste: risultato vuoto + hint con le sigle reali e la
più simile. Nessuna mappatura hardcoded: il disallineamento è della fonte e
va risolto lì, il codice si limita a renderlo visibile.

Closes #77

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 26, 2026 07:26
@greptile-apps

greptile-apps Bot commented Jul 26, 2026

Copy link
Copy Markdown

Greptile Summary

The PR resolves vote-detail group filters against the acronyms present in each vote.

  • Adds exact, case-insensitive, and punctuation-normalized acronym matching.
  • Returns a diagnostic hint when no vote acronym matches.
  • Centralizes SPARQL string-literal escaping and adds helper and live integration tests.

Important Files Changed

Filename Overview
src/tools/vote-detail.ts Adds data-driven acronym discovery, matching, filtering, and unresolved-acronym hints.
src/tools/vote-detail.test.ts Covers the pure acronym resolution and hint-generation helpers.
src/tools/tools.test.ts Adds live execute-path checks for matched and unresolved group acronyms.
src/core/sparql-literal.ts Extracts shared SPARQL string-literal escaping for safe query construction.
src/tools/bill-progress.ts Replaces the local SPARQL literal serializer with the shared implementation.

Reviews (3): Last reviewed commit: "fix(vote-detail): escape del letterale S..." | Re-trigger Greptile

Comment thread src/tools/vote-detail.test.ts

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Not ready to approve

There are a couple of concrete correctness/UX issues in the new vote-detail hint/query string handling that should be fixed before merge.

Pull request overview

This PR improves the vote-detail tool’s groupAcronym filtering so that user-provided acronyms are resolved against the actual ocd:siglaGruppo values present in the target vote, avoiding silent empty results when groups list acronyms don’t match the vote dataset.

Changes:

  • Add acronym resolution + “empty-but-explained” hinting for vote-detail --group-acronym when the requested acronym isn’t present in that specific vote.
  • Add unit tests for acronym resolution and hint construction.
  • Document the news-driven CLI gap analyzer’s catalog/dedup workflow (spec + agent instructions).
File summaries
File Description
src/tools/vote-detail.ts Resolves groupAcronym against acronyms present in the vote and returns a hint on mismatch.
src/tools/vote-detail.test.ts Adds focused unit tests for acronym resolution + hint text behavior.
docs/superpowers/specs/2026-07-15-news-catalog-design.md Specifies the append-only catalog format and dedup/growth rules.
.claude/agents/news-driven-cli-gap-analyzer.md Aligns the agent workflow with the catalog-driven dedup and update steps.

Review details

  • Files reviewed: 4/4 changed files
  • Comments generated: 2
  • Review effort level: Low

Note

Your feedback helps us improve the quality of this feature.
Please use 👍 or 👎 to tell us whether this assessment is correct.

Comment thread src/tools/vote-detail.ts
Comment thread src/tools/vote-detail.ts
aborruso and others added 2 commits July 26, 2026 09:29
I messaggi citavano AZ-PER-RE → APERRE e la forma "M-*" delle componenti
Misto: sono fatti di oggi sulla fonte, che diventerebbero testo sbagliato e
branch morta se la Camera allinea le sigle. L'hint mantiene il valore
diagnostico senza codificarli, perché nomina già il candidato reale e elenca
le sigle restituite dalla query; la nota sul Misto ora dipende dalla stringa
richiesta, non dalla forma dei dati.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Da review PR #80:
- la sigla risolta finiva interpolata cruda nel FILTER: ora passa per
  sparqlStringLiteral, estratto in src/core (era duplicato in bill-progress)
  con i suoi test. Il valore viene dal grafo, non dall'utente, ma una
  virgoletta nel dato romperebbe comunque la query.
- l'hint sul caso "nessuna sigla registrata" citava il flag --group-acronym,
  che per un client MCP non significa nulla: formulazione neutra.
- due test di integrazione su voteDetailTool.execute: match risolto (sigla
  minuscola → righe, nessun hint) e sigla di groups list → vuoto con hint.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@aborruso
aborruso merged commit 2994cb1 into main Jul 26, 2026
2 checks passed
@aborruso
aborruso deleted the fix/77-group-acronym-alignment branch July 26, 2026 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vote-detail --group-acronym: sigle disallineate con groups list, zero righe silenziose

2 participants