feat(template): add column/nth to Anchor for disambiguation (P1-1)#27
Merged
Conversation
68b07c2 to
c32faa6
Compare
A cover sheet that stacks two side-by-side blocks — for example a ``REPORTING`` block in column A and a ``BILLING`` block in column D, each carrying its own ``Company:`` / ``Email:`` rows — used to force both anchored fields to bind to the first occurrence of the shared label. The canonical output would then carry the reporting block's company under both ``reporting_company`` and ``billing_company`` keys with no signal that the bind had collapsed. Adds two optional fields on ``Anchor``: - ``column: int`` — restrict the label scan to a single 0-indexed column. Skipping cells outside that column means the label_match in one block can't accidentally hit the parallel block. - ``nth: int`` (default ``1``) — pick the N-th match (1-indexed) when the same label legitimately appears multiple times. Both default to no-op behavior (``column=None`` scans the whole sheet, ``nth=1`` picks the first match), so existing templates continue to extract identically. Graduates the two P1-1 xfail tests in ``tests/test_field_scan_gaps.py`` and documents the disambiguators in ``docs/guides/templates.md``. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
c32faa6 to
ed98c2d
Compare
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
Closes P1-1 — disambiguating anchored fields when the same label appears more than once on a cover sheet.
A worksheet that stacks two cover-sheet-style blocks side by side and reuses the same labels in each (a "REPORTING" block in column A and a "BILLING" block in column D, each with its own
Company:/Email:rows) used to force every field withlabel_match: "Company:"to bind to the first hit. The canonical output would then carry the reporting block's company in both fields with no signal that the bind had collapsed.This PR adds two optional fields on
Anchor:column: int— restrict the label scan to a single 0-indexed column. Cells outside that column are skipped during the match, so the same label_match in one block can't drift into the parallel block.nth: int— pick the N-th match (1-indexed; default1). Lets a single template field intentionally bind to the second occurrence of a repeated label.Both default to no-op behavior, so existing templates extract identically.
Test plan
uv run pytest tests/test_field_scan_gaps.py -q— two P1-1 tests graduate.uv run pytest -q— 106 passed, 35 xfailed.uvx --from 'ruff==0.6.9' ruff check .andruff format --check .— clean.All fixtures and copy use only fictitious values per CLAUDE.md.
🤖 Generated with Claude Code