fix: consolidated rows carry per-cell provenance, not the first row's (26.6.9) - #33
Merged
Merged
Conversation
… (26.6.9) _rebuild_rows threaded row-level provenance from cited contributors but still stamped every output cell's bbox/pages/confidence from rows[0] via a single template_by_name map, and dropped each cell's judge/notes to the default uncertain/0. A cross-document consolidation (e.g. a current cap table merged across several deeds) therefore gave every member the first member's bounding box, page and confidence, so UI overlays pointed every row at the same rectangle and row-level pages stopped matching cell pages. Resolve each output row's provenance source in priority order: cited _source_rows -> positional 1:1 for a pure rewrite -> distinctive-identity match for an uncited row -> rows[0] as a last resort. Within a row each cell takes its best-grounded contributor cell (bbox present first, then higher confidence), and judge/notes now survive the transform.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a provenance-loss bug in the post-extraction consolidation transform: a cross-document consolidated group (e.g. a "current cap table" merged across several deeds) gave every output row the first input row's bounding box, page, confidence and judge verdict.
Root cause
_rebuild_rows(llm_transformer.py) already computed each output row's row-level pages/confidence from its cited contributors (26.6.8), but every cell still borrowed itsbbox/pages/confidencefromrows[0]through a singletemplate_by_namemap, and dropped each cell'sjudge/notesto the defaultuncertain/0.Observable symptoms in
GET /workflows/{id}→context.consolidated_field_groups:cap_table_vigenteshared one identical bbox/pages/confidence fingerprint — byte-for-byte equal to the first source document's first row.pages(from real contributors) no longer matched the cell-levelpages(fromrows[0]).judge.status = uncertain,confidence = 0.UI overlays drawn from these bboxes pointed every member at the same rectangle on the same (wrong) page.
Fix
Resolve each output row's provenance source in priority order:
_source_rows;rows[0]as a last resort.Within a row, each field takes its best-grounded contributor cell (one with a bbox wins over one without, then higher confidence), and
judge/notesnow survive the transform. Value-rewriting transforms are unchanged when no contributor is matched.Test plan
test_llm_transformer_provenance.py(best-per-cell across contributors, single cited contributor, judge propagation, positional rewrite, identity fallback) — written failing first, then green.ruff check/ruff format --check: clean.pyright: 0 errors.🤖 Generated with Claude Code