[P3/high] feat(forms): official IRS AcroForm output layer (subsystem + f1040 template)#22
Draft
ne-groomer[bot] wants to merge 1 commit into
Draft
[P3/high] feat(forms): official IRS AcroForm output layer (subsystem + f1040 template)#22ne-groomer[bot] wants to merge 1 commit into
ne-groomer[bot] wants to merge 1 commit into
Conversation
…mplate)
Adds src/telos/forms/ — the "official-form output at the back" of the pipeline:
transcribe engine line values into fillable IRS PDFs and assemble a
print-and-mail package. Lives entirely outside src/telos/engine/ (imports
nothing from it) and writes filled output only under TELOS_DATA_DIR.
Modules:
- paths.py template lookup (in-tree) + filled-output resolution (data dir only)
- profile.py FormProfile: {engine line key -> AcroForm field} map + `verified` gate
- filler.py fill an AcroForm — unknown-field guard, XFA drop, NeedAppearances
- package.py concatenate filled forms in filing order
- introspect.py dump each field's name/type/rect/nearest printed label (mapping aid)
Robustness verified against the REAL f1040.pdf (hybrid AcroForm+XFA, 229 fields):
the filler drops /XFA so viewers render the values we set, and rejects a
mapped-but-absent field rather than silently no-op'ing. Full subsystem validated
on a synthetic AcroForm fixture (controlled field names) plus a mechanical
round-trip on the real template. 43 new tests; telos.forms coverage 96%; full
suite 477 passed / 98% total.
The one piece intentionally NOT shipped is the *verified semantic field map* for
f1040: the AcroForm has opaque positional field names and zero /TU tooltips, so
which field is which 1040 line cannot be read from the PDF and a read-back test
proves only that a value lands, never that it lands in the correct box. A
mis-mapped dollar amount is a silent, high-stakes defect on a form mailed to the
IRS, so profiles/f1040.yaml ships verified:false with an empty map and
require_verified() refuses filing-grade use until it is confirmed. See
forms/README.md for the two ways to establish that map (hand-authored+confirmed
vs geometric auto-mapper) — the one decision this needs from a human.
Also fixes a pre-existing .gitignore defect: the `!forms/templates/**/*.pdf`
negation carried an inline comment, which git treats as part of the pattern, so
it never matched and the blank templates stayed ignored.
Toward nousergon/telos-ops#10
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: groom-bot <[email protected]>
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.
Priority: P3 · Complexity: high
Toward nousergon/telos-ops#10 (does not fully close it — see "Decision needed").
What
Greenfield
src/telos/forms/— the "official-form output at the back" of telos: transcribe the engine's computed line values into official fillable IRS AcroForm PDFs and assemble a print-and-mail package. Lives entirely outsidesrc/telos/engine/(imports nothing from it); filled output goes only underTELOS_DATA_DIR.paths.pyTELOS_DATA_DIRonly, escape-guarded)profile.pyFormProfile—{engine line key → AcroForm field}map + load-bearingverifiedgatefiller.pyDecimalformattingpackage.pyintrospect.pyThe engine's
Form1040Result.linesis already keyed by 1040 line labels ("1a","2b","16"…) — those are exactly the profile's semantic keys, so this layer plugs onto the existing output with no engine change.Validated (CI-green)
telos.formscoverage 96%; full suite 477 passed / 98.41% total (gate 90).ruff check .clean. DCO-signed. No secrets; the committedf1040.pdfis a public-domain IRS work.f1040.pdf— which is a hybrid AcroForm+XFA form (229 fields). Naive fillers get hybrid forms wrong; this drops/XFAso viewers render the AcroForm values, and rejects a mapped-but-absent field instead of silently no-op'ing..gitignoredefect: the!forms/templates/**/*.pdfnegation carried an inline comment, which git treats as part of the pattern — so it never matched and the blank templates stayed ignored. (The issue assumed the exception already worked; it didn't.)Decision needed (why this is a DRAFT,
gate:decision)The one piece intentionally not shipped is the verified semantic field map for f1040. Verified against the live artifact: the AcroForm has opaque positional field names (
topmostSubform[0].Page1[0].f1_11[0]) and zero/TUtooltips, so which field is which 1040 line cannot be read from the PDF. A read-back test proves a value lands in a named field — never that the field is the semantically correct box. A mis-mapped dollar amount is a silent, high-stakes defect on a document mailed to the IRS, so I refuse to ship a guessed map (the same discipline as the params contract's refusal of uncited constants).profiles/f1040.yamltherefore shipsverified: falsewith an empty map, andrequire_verified()blocks filing-grade use until it is confirmed.The fork (pick one; then a tier groom can execute — the map is data-only YAML, no code rework):
field_mapfromdescribe_fields()output (it already emits each field's nearest printed label), visually confirm each entry against the rendered form once, flipverified: true. What commercial tax software does; durable.nearest_textgeometric heuristic into a validated auto-mapper subsystem (removes the hand step but is itself a design-bearing component needing its own validation across multi-column layouts, checkboxes, ~7 forms).Validate locally
Groom-Run: 844608d4415945c6a5e710825122c5d4