Skip to content

feat(form): give AcroForm field metadata typed slots on FieldItem - #838

Draft
wittjeff wants to merge 4 commits into
docling-project:mainfrom
wittjeff:feat/field-metadata-slots
Draft

wittjeff wants to merge 4 commits into
docling-project:mainfrom
wittjeff:feat/field-metadata-slots

Conversation

@wittjeff

@wittjeff wittjeff commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Note

Stacked on #878. Schema 1.12.0 went to TrackItem (#940), and #878 (BlockQuoteGroup) holds 1.13.0, so this PR now takes 1.14.0 and sits on top of the #878 branch. The first three commits belong to #878. Only the last commit, feat(form): give AcroForm field metadata typed slots on FieldItem, is this PR. It is a draft until #878 merges; after that it is rebased on main and shows one commit again.

Summary

Gives AcroForm field metadata a typed home at document level, which is the follow-up @cau-git invited in docling#4055:

Tooltip (/TU), field type, required/read-only, radio-group semantics don't have typed slots yet — better to leave those on FormFieldInfo for a docling-core follow-up than to smuggle them into free-form text.

The page-level half already landed in #733, so PdfWidget carries widget_description, widget_field_type, widget_field_flags and widget_appearance_state. This adds the document-level destination those can be read into.

What changed

Four fields on FieldItem:

field derived from notes
control: FieldControl | None /FT plus flags New enum: text, checkbox, radio, choice, signature, button, other
description: str | None /TU tooltip Producer-supplied, not drawn on the page
required: bool /Ff Required bit
options: list[str] /Opt, or radio export values

FieldControl is the document-level reading of the control rather than the raw PDF entry: an AcroForm /Btn resolves to CHECKBOX, RADIO or BUTTON by its flags, and the untouched /FT name stays available on PdfWidget.widget_field_type. The enum sits next to the models in items/form.py, following the precedent of Orientation in items/table/table_data.py.

description is deliberately distinct from FieldHintItem: a hint is text drawn on the page, while this is metadata the producer attached to the field and that never appears in the rendering.

options is what makes a radio group legible at document level — one FieldItem whose value is the selection, plus the set it was selected from. It covers /Ch dropdowns in the same slot.

add_field_item() takes all four as keyword arguments, and options is copied on the way in so a caller's list cannot mutate the document.

One deliberate omission

Read-only is not among them, though the invitation listed "required/read-only". FieldValueItem.kind already carries read_only / fillable, and duplicating it on the parent would leave two places free to disagree. The FieldItem docstring records that the editability of a field lives on its value. Happy to add it if you would rather have it on both.

Schema version

FieldItem is a strict model (additionalProperties: false), so this would break 1.13 clients outright. Bumped 1.13.0 → 1.14.0 with the full #703 regime:

  • SCHEMA_VERSION_HISTORY entry (v2.110.0 is a placeholder for the release that ships it, to adjust at release time as feat: make inline serializers concatenate runs faithfully #693 did)
  • _project_1_14_to_1_13 stripping the four keys, leaving the page-level PdfWidget state it derives from untouched
  • docs/schemas/DoclingDocument_1_14.json
  • TestProjector_1_14_to_1_13

While this PR was in review, schema 1.11.0 went to the inline whitespace contract (#693) and 1.12.0 to TrackItem (#940), and #878 holds 1.13.0. The projector chain is now 1.14 → 1.13 → 1.12 → … with no change to the other projectors.

The projector test class includes a case that builds a populated document through the public helper and validates the projected dict against the 1.13 snapshot with jsonschema, because the generic test_every_projector_produces_valid_output only exercises a minimal dict and would pass even if this projector stripped nothing.

Validation

Rebased on the #878 branch (1e01d32), which is on main at ede3b17. prek run on the files of this PR's commit is clean (Ruff, projector coverage, ty, docs). Full suite 1901 passed, 12 skipped, 53 xfailed; dclq 13 passed. The groundtruth churn is the required/options keys plus the version stamp; control and description stay off the wire when unset because export_to_dict excludes None. No binary test data changes.

The two tooling gaps found on the first round (snapshot capture order, DOCLING_GEN_TEST_DATA in the unit goldens) were fixed separately in #842.

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

✅ DCO Check Passed

Thanks @wittjeff, all your commits are properly signed off. 🎉

@mergify

mergify Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

🔴 1 of 2 protections blocking · waiting on 👀 reviews

Protection Waiting on
🔴 Require two reviewer for test updates 👀 reviews
🟢 Enforce conventional commit —

🔴 Require two reviewer for test updates

Waiting for

  • #approved-reviews-by >= 2
This rule is failing.

When test data is updated, we require two reviewers

  • #approved-reviews-by >= 2

Show 1 satisfied protection

🟢 Enforce conventional commit

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\(.+\))?(!)?:

@github-actions github-actions Bot added ai:ci-safe AI triage found no CI-safety concern (advisory) document-model DoclingDocument core model, metadata, hierarchy, validation enhancement New feature or request serialization Output serializers: Markdown, HTML, LaTeX, JSON, plain-text, outline labels Nov 3, 2026
@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

AI triage (advisory)

Checked commit 5c4ec26360. The analysis read the diff only. It did not run code from this pull request.

Warning

The AI analysis did not finish. Only the deterministic checks are shown.

CI safety: not assessed.

Possibly related pull requests

PR State Signal Assessment
#878 open referenced as #878; changes the same code not assessed
#882 open changes the same code not assessed
#1069 open changes the same code not assessed
#1081 open changes the same code not assessed
#940 merged referenced as #940 not assessed

Reference data changes

Change Files
text 61
binary 14
added 5
  • text tests/data/doc/2206.01062.yaml.dt.json: item attributes changed
  • text tests/data/doc/2408.09869v3_enriched.out.dt.json: item attributes changed
  • text tests/data/doc/2408.09869v3_enriched_p2_p3_p5.gt.json: item attributes changed
  • text tests/data/doc/barchart.dt.out.json: item attributes changed
  • text tests/data/doc/concatenated.json: item attributes changed
  • text tests/data/doc/constructed_doc.added_extracted_doc.json.gt: +1 / -1 lines
  • text tests/data/doc/constructed_doc.appended_child.json.gt: +1 / -1 lines
  • text tests/data/doc/constructed_doc.bulk_item_addition.json.gt: +1 / -1 lines
  • text tests/data/doc/constructed_doc.bulk_item_insertion.json.gt: +1 / -1 lines
  • text tests/data/doc/constructed_doc.deleted_group.json.gt: +1 / -1 lines
  • text tests/data/doc/constructed_doc.deleted_items_range.json.gt: +1 / -1 lines
  • text tests/data/doc/constructed_doc.deleted_picture.json.gt: +1 / -1 lines
  • text tests/data/doc/constructed_doc.deleted_text.json.gt: +1 / -1 lines
  • text tests/data/doc/constructed_doc.embedded.json.gt: +1 / -1 lines
  • text tests/data/doc/constructed_doc.embedded.yaml.gt: +1 / -1 lines
  • text tests/data/doc/constructed_doc.extracted_with_deletion.json.gt: +1 / -1 lines
  • text tests/data/doc/constructed_doc.inserted_extracted_doc.json.gt: +1 / -1 lines
  • text tests/data/doc/constructed_doc.inserted_items.json.gt: +1 / -1 lines
  • text tests/data/doc/constructed_doc.inserted_list_items.json.gt: +1 / -1 lines
  • text tests/data/doc/constructed_doc.inserted_text.json.gt: +1 / -1 lines
  • text tests/data/doc/constructed_doc.manipulated_table.json.gt: +1 / -1 lines
  • text tests/data/doc/constructed_doc.referenced.json.gt: +1 / -1 lines
  • text tests/data/doc/constructed_doc.referenced.yaml.gt: +1 / -1 lines
  • text tests/data/doc/constructed_doc.replaced_item.json.gt: +1 / -1 lines
  • text tests/data/doc/cross_column_list/deserialized.json: item attributes changed
  • text tests/data/doc/cross_column_list/input.json: item attributes changed
  • text tests/data/doc/cross_page_list/deserialized.json: item attributes changed
  • text tests/data/doc/cross_page_list/input.json: item attributes changed
  • text tests/data/doc/cross_page_paragraph/deserialized.json: item attributes changed
  • text tests/data/doc/cross_page_paragraph/input.json: item attributes changed
  • text tests/data/doc/cross_page_table/deserialized.json: item attributes changed
  • text tests/data/doc/cross_page_table/input.json: item attributes changed
  • text tests/data/doc/doc_with_kv.dt.json: item attributes changed
  • text tests/data/doc/docitem_comments_field.out.yaml: +1 / -1 lines
  • text tests/data/doc/docitem_comments_multiple.out.yaml: +1 / -1 lines
  • text tests/data/doc/doclang_archive/load/two_pages.gt.json: item attributes changed
  • text tests/data/doc/doclang_ref/002a_table_order/output.json: item attributes changed
  • text tests/data/doc/dummy_doc_2_prec.yaml: +1 / -1 lines
  • text tests/data/doc/dummy_doc_with_meta_modified.yaml: +1 / -1 lines
  • text tests/data/doc/field_region_kv/deserialized.json: item attributes changed
  • text tests/data/doc/field_region_kv/input.json: item attributes changed
  • text tests/data/doc/field_region_kv_invoice/deserialized.json: item attributes changed
  • text tests/data/doc/field_region_kv_invoice/input.json: item attributes changed
  • text tests/data/doc/field_region_kv_migration/deserialized.json: item attributes changed
  • text tests/data/doc/field_region_kv_migration/input.json: item attributes changed
  • text tests/data/doc/flattened.json: item attributes changed
  • text tests/data/doc/group_with_metadata.yaml: +1 / -1 lines
  • text tests/data/doc/hierarchized.json: item attributes changed
  • text tests/data/doc/kv.out.json: item attributes changed
  • text tests/data/doc/kv/01d07afe1cb54ecd23eedfe4d91b81dd88e61bf4e0dbe2467784db4177a6c691/deserialized.json: item attributes changed
  • text tests/data/doc/kv/01d07afe1cb54ecd23eedfe4d91b81dd88e61bf4e0dbe2467784db4177a6c691/output.json: item attributes changed
  • text tests/data/doc/kv/08212053e2db1a70dd60a4f85650ceb33d7519af34f502e3ac894389d76663d6/deserialized.json: item attributes changed
  • text tests/data/doc/kv/08212053e2db1a70dd60a4f85650ceb33d7519af34f502e3ac894389d76663d6/output.json: item attributes changed
  • text tests/data/doc/kv/0cb12d33b02867dc8708f4877480743533f1248683091188000d25456ba12d73/deserialized.json: item attributes changed
  • text tests/data/doc/kv/0cb12d33b02867dc8708f4877480743533f1248683091188000d25456ba12d73/output.json: item attributes changed
  • text tests/data/doc/kv/167f6658cd410df8d4d14acc53e8c8f509e94c44b8005e6b76de8d17329363a7/deserialized.json: item attributes changed
  • text tests/data/doc/kv/167f6658cd410df8d4d14acc53e8c8f509e94c44b8005e6b76de8d17329363a7/output.json: item attributes changed
  • text tests/data/doc/kv/1eac20e5ac5fac655a611343f86927d6a76277e170430c1eba741585437a2e90/deserialized.json: item attributes changed
  • text tests/data/doc/kv/1eac20e5ac5fac655a611343f86927d6a76277e170430c1eba741585437a2e90/output.json: item attributes changed
  • text tests/data/doc/kv/587558a074858891bdf1d625a9e9fce4ea116ac61bd276d86a069697744b62a4/deserialized.json: item attributes changed
  • … 20 more file(s) not listed

Only the first 80 of 137 reference files were compared.

The ai:* labels are advisory. They do not approve CI and they do not add tests:full. A new push runs this check again.

@wittjeff
wittjeff force-pushed the feat/field-metadata-slots branch from 6eed59c to 0f9585b Compare November 3, 2026 20:48
@github-actions github-actions Bot removed the ai:ci-safe AI triage found no CI-safety concern (advisory) label Nov 3, 2026
@wittjeff

wittjeff commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto main (1517ab7). #693 took schema 1.11.0 while this was in review, so the bump is now 1.11.0 → 1.12.0: _project_1_12_to_1_11, docs/schemas/DoclingDocument_1_12.json and TestProjector_1_12_to_1_11, with the #693 projector untouched and v2.107.0 recorded as the placeholder release. Goldens regenerated with DOCLING_GEN_TEST_DATA=1; the binary changes from the first push are gone (the kv and viz PNGs match main byte for byte). PR body updated to match. Full suite 1381 passed, hooks clean.

@github-actions github-actions Bot added the ai:ci-safe AI triage found no CI-safety concern (advisory) label Nov 3, 2026
@codecov

codecov Bot commented Nov 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

wittjeff and others added 4 commits November 26, 2026 17:46
Block quotes become a first-class group: GroupLabel.BLOCK_QUOTE and a
BlockQuoteGroup subtype with `cite` (the source URL) and `captions` (the
attribution, a caption text item that is a child of the group and is
referenced here, like the captions of a FloatingItem).

- add_block_quote_group() / insert_block_quote_group(); add_group() and
  insert_group() route the new label; delete_items() and orphan repair
  keep the attribution references in sync.
- BaseBlockQuoteSerializer slot on DocSerializer with a transparent
  default. HTML emits <blockquote cite> inside a <figure> with a
  <figcaption> attribution; Markdown emits '> ' lines with a linked
  attribution; LaTeX a quote environment; DocLang keeps the attribution
  inside the named group; DocTags stays transparent.
- Chunkers treat a BlockQuoteGroup as one unit, like ListGroup.
- Schema 1.13.0 with the downgrade projector to 1.12.0 (relabel to
  unspecified, strip cite and captions), schema snapshot and tests.

Closes docling-project#861

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: Jeff Witt <1848307+wittjeff@users.noreply.github.com>
… line

A GFM table cell holds a single line, and the table serializer replaces
every newline in a cell with a space. A multi-paragraph quote rendered
with a marker on every line therefore came out as "> first > > second",
which reads as a nested quote. Inside a table cell the quote now has one
marker in front of its joined blocks, with the attribution last.

Reported on docling-project/docling#4855 from a judgment whose quotes all
sit in layout table cells.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: Jeff Witt <1848307+wittjeff@users.noreply.github.com>
Codecov flagged eight lines of the block quote change without a test.
Covering them found one defect: a quote with an attribution and no quoted
blocks emitted a bare <figcaption>, which is only valid inside a <figure>
that also holds flow content. The HTML serializer now keeps an empty
<blockquote> with the cite attribute inside the figure in that case.

The isinstance guard in serialize_block_quote_attribution was dead:
get_excluded_refs is abstract on BaseDocSerializer, so every serializer
has it.

New tests cover the group factories' name and content_layer arguments,
orphan repair of a referenced attribution, the transparent DocLang export
of a quote that crosses a page, the attribution-only quote in HTML and
Markdown, and an empty quote.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: Jeff Witt <1848307+wittjeff@users.noreply.github.com>
Follow-up invited in docling#4055, where the suggestion was to leave
tooltip, field type, required and radio-group semantics on FormFieldInfo
until docling-core had somewhere typed to put them.

Adds four fields to FieldItem:

- control: the kind of control, as a new FieldControl enum (text, checkbox,
  radio, choice, signature, button, other). This is the document-level
  reading rather than the raw PDF entry: an AcroForm /Btn resolves to
  CHECKBOX, RADIO or BUTTON by its flags, and the untouched /FT name stays
  on PdfWidget.widget_field_type.
- description: a producer-supplied description of what to enter -- an
  AcroForm /TU tooltip, or an HTML title. Distinct from FieldHintItem,
  which is text drawn on the page.
- required: whether a value must be supplied.
- options: the values a CHOICE or RADIO control accepts, which is what
  makes a radio group legible at document level: one FieldItem whose value
  is the selection, plus the set it was selected from.

Read-only is deliberately not among them. FieldValueItem.kind already
carries read_only/fillable, and duplicating it on the parent would leave
two places to disagree.

The page-level half of this already landed in docling-project#733: PdfWidget carries
widget_description, widget_field_type, widget_field_flags and
widget_appearance_state, so producers have the raw state to derive these
from and this commit only adds the document-level destination.

Schema 1.13.0 -> 1.14.0 with the full docling-project#703 regime: history entry, a
1.14 -> 1.13 projector stripping the four keys, the 1.14 snapshot, and a
TestProjector_1_14_to_1_13 class. FieldItem is a strict model, so an
unannounced addition would have broken 1.13 clients outright. Schema
1.11.0 went to the inline whitespace contract (docling-project#693) and 1.12.0 to
TrackItem (docling-project#940) while this was in review, and 1.13.0 is the
BlockQuoteGroup bump of docling-project#878, which this branch is stacked on. The
history entry records v2.110.0 as the placeholder release, to be
adjusted at release time.

Goldens regenerated with DOCLING_GEN_TEST_DATA=1: the churn is the
version stamp plus the required/options keys on field items.

Signed-off-by: Jeff Witt <1848307+wittjeff@users.noreply.github.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

document-model DoclingDocument core model, metadata, hierarchy, validation enhancement New feature or request serialization Output serializers: Markdown, HTML, LaTeX, JSON, plain-text, outline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant