Skip to content

fix(grounding): record prose grouped figures so a stated table grounds - #2139

Closed
he-yufeng wants to merge 1 commit into
HKUDS:mainfrom
he-yufeng:fix/grounding-document-grouped-figures
Closed

he-yufeng wants to merge 1 commit into
HKUDS:mainfrom
he-yufeng:fix/grounding-document-grouped-figures

Conversation

@he-yufeng

Copy link
Copy Markdown
Collaborator

Problem

A table flattened to prose (the common PDF-extraction shape, no Markdown pipes) states its cells as bare integers. _ingest_document_text only recorded numbers carrying a mark of measurement, so a document's comma-grouped figure like 220,308 never reached the evidence ledger. A report that faithfully reproduced the table's own cells was then redacted as numeric_claim_conflict / not_in_referenced_call even though the document stated them. Only a cell that also appeared elsewhere with a unit (e.g. the total restated as 63.34 亿元) survived. Closes #2126.

Fix

A comma-grouped number is unambiguously a stated quantity, never a page number, section number or year, so it is now admitted to the ledger alongside measured figures. Plain ungrouped integers stay excluded to keep an invented small figure from matching one by chance, preserving the invariant pinned in the existing tests.

Validation

Red-green on the repro: test_document_prose_grouped_figures_reach_the_ledger fails before the change (grouped figures absent from the ledger) and passes after.

uv run --with pytest pytest agent/tests/test_grounding_document_figures.py -q   # 23 passed
uv run --with pytest pytest agent/tests/ -k grounding -q                          # 1322 passed

The full document-figures file and grounding suite stay green, including test_a_page_number_and_a_year_are_not_findings (page 12, year 2025, ungrouped 3400 remain excluded).

Prepared with an AI assistant and reviewed line by line before posting.

A table flattened to prose (no Markdown pipes) states its cells as bare
integers. The ingest only recorded numbers carrying a mark of measurement,
so a document's comma-grouped figure like 220,308 never reached the ledger,
and a report quoting the table's own cells was redacted as unsourced even
though the document stated them (HKUDS#2126).

A comma-grouped number is unambiguously a quantity, never a page number or
year, so it is now admitted alongside measured figures. Plain ungrouped
integers stay out to keep an invented small figure from matching one by
chance.

Test plan:
```
uv run --with pytest pytest agent/tests/test_grounding_document_figures.py -q
uv run --with pytest pytest agent/tests/ -k grounding -q
```
Red-green: the new test fails before the change (grouped figures absent from
the ledger) and passes after; the full document-figures file and the grounding
suite stay green, including the page-number, year and ungrouped-int
exclusions. Prepared with an AI assistant and reviewed line by line before
posting.

Signed-off-by: Yufeng He <40085740+he-yufeng@users.noreply.github.com>
@he-yufeng

Copy link
Copy Markdown
Collaborator Author

Superseded by #2135, which fixes this at the numeric scanner and covers the source-binding and generated-artifact cases as well. Closing this narrower attempt so #2126 is not fixed twice.

@he-yufeng he-yufeng closed this Nov 1, 2026
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.

[Bug] Document integers never reach the evidence ledger, yet table cells are checked — a 万元 table can never be released

1 participant