Skip to content

feat(template): add column/nth to Anchor for disambiguation (P1-1)#27

Merged
dev360 merged 1 commit into
mainfrom
feat/p1-1-anchor-column
May 22, 2026
Merged

feat(template): add column/nth to Anchor for disambiguation (P1-1)#27
dev360 merged 1 commit into
mainfrom
feat/p1-1-anchor-column

Conversation

@dev360
Copy link
Copy Markdown
Owner

@dev360 dev360 commented May 21, 2026

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 with label_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; default 1). 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 . and ruff format --check . — clean.

All fixtures and copy use only fictitious values per CLAUDE.md.

🤖 Generated with Claude Code

@dev360 dev360 force-pushed the feat/p1-1-anchor-column branch from 68b07c2 to c32faa6 Compare May 22, 2026 13:43
@dev360 dev360 enabled auto-merge (squash) May 22, 2026 15:48
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>
@dev360 dev360 force-pushed the feat/p1-1-anchor-column branch from c32faa6 to ed98c2d Compare May 22, 2026 15:48
@dev360 dev360 merged commit 052db8c into main May 22, 2026
8 checks passed
@dev360 dev360 deleted the feat/p1-1-anchor-column branch May 22, 2026 15:49
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.

1 participant