Repository navigation
feat(compat): DoclingDocument downgrade projector system - #703
Merged
Merged
Conversation
Adds docling_core/compat.py with a register_projector decorator, project_to() API, and five retroactive projectors (1.10→1.9→1.8→1.7→ 1.6→1.5). Adds scripts/check_compat_projectors.py as a pre-commit hook that detects unannounced structural breaking changes and enforces that every schema minor bump ships a projector, a JSON Schema snapshot, and a test class. 36 new tests in test/test_compat.py; CONTRIBUTING.md documents the change-classification table and 7-step checklist. Signed-off-by: Cesar Berrospi Ramis <ceb@zurich.ibm.com>
Signed-off-by: Cesar Berrospi Ramis <ceb@zurich.ibm.com>
Contributor
|
✅ DCO Check Passed Thanks @ceberam, all your commits are properly signed off. 🎉 |
Contributor
Merge Protections🟢 All 2 merge protections satisfied — ready to merge. Show 2 satisfied protections🟢 Enforce conventional commitMake sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
🟢 Require two reviewer for test updatesWhen test data is updated, we require two reviewers
|
PeterStaar-IBM
self-requested a review
August 6, 2026 10:45
dolfim-ibm
approved these changes
Aug 6, 2026
dolfim-ibm
left a comment
Member
There was a problem hiding this comment.
very nice and needed!
I just wonder if docling_core/compat.py will become a huge file, at some point we could split it apart, and maybe declare all of it as "internal".
cau-git
approved these changes
Aug 18, 2026
cau-git
added a commit
that referenced
this pull request
Aug 18, 2026
…ct bump Integrates the 1.11.0 schema bump with the downgrade-projector framework (#703) landed upstream. 1.11 and 1.10 are structurally identical; the only difference is that 1.11 inline runs own their boundary whitespace, so the projector just re-stamps the version (a 1.10 client re-applies its own join, yielding the documented harmless double space). - add @register_projector(from_minor=11, to_minor=10) + TestProjector_1_11_to_1_10 - add the auto-generated 1.11 JSON Schema snapshot - re-format the 1.11 SCHEMA_VERSION_HISTORY entry (ruff) - update the stale dclq CLI expectation (old join produced 'public class'; faithful join now yields 'public class') Signed-off-by: Christoph Auer <cau@zurich.ibm.com>
This was referenced Oct 4, 2026
nanhanq1
pushed a commit
to nanhanq1/docling-core
that referenced
this pull request
Oct 6, 2026
…ct bump Integrates the 1.11.0 schema bump with the downgrade-projector framework (docling-project#703) landed upstream. 1.11 and 1.10 are structurally identical; the only difference is that 1.11 inline runs own their boundary whitespace, so the projector just re-stamps the version (a 1.10 client re-applies its own join, yielding the documented harmless double space). - add @register_projector(from_minor=11, to_minor=10) + TestProjector_1_11_to_1_10 - add the auto-generated 1.11 JSON Schema snapshot - re-format the 1.11 SCHEMA_VERSION_HISTORY entry (ruff) - update the stale dclq CLI expectation (old join produced 'public class'; faithful join now yields 'public class') Signed-off-by: Christoph Auer <cau@zurich.ibm.com> Signed-off-by: nanhanq1 <157583847+nanhanq1@users.noreply.github.com>
nanhanq1
pushed a commit
to nanhanq1/docling-core
that referenced
this pull request
Oct 14, 2026
…ct bump Integrates the 1.11.0 schema bump with the downgrade-projector framework (docling-project#703) landed upstream. 1.11 and 1.10 are structurally identical; the only difference is that 1.11 inline runs own their boundary whitespace, so the projector just re-stamps the version (a 1.10 client re-applies its own join, yielding the documented harmless double space). - add @register_projector(from_minor=11, to_minor=10) + TestProjector_1_11_to_1_10 - add the auto-generated 1.11 JSON Schema snapshot - re-format the 1.11 SCHEMA_VERSION_HISTORY entry (ruff) - update the stale dclq CLI expectation (old join produced 'public class'; faithful join now yields 'public class') Signed-off-by: Christoph Auer <cau@zurich.ibm.com> Signed-off-by: nanhanq1 <157583847+nanhanq1@users.noreply.github.com>
Leewwp
pushed a commit
to Leewwp/docling-core
that referenced
this pull request
Oct 26, 2026
…ject#703) * feat(compat): add DoclingDocument version-downgrade projector system Adds docling_core/compat.py with a register_projector decorator, project_to() API, and five retroactive projectors (1.10→1.9→1.8→1.7→ 1.6→1.5). Adds scripts/check_compat_projectors.py as a pre-commit hook that detects unannounced structural breaking changes and enforces that every schema minor bump ships a projector, a JSON Schema snapshot, and a test class. 36 new tests in test/test_compat.py; CONTRIBUTING.md documents the change-classification table and 7-step checklist. Signed-off-by: Cesar Berrospi Ramis <ceb@zurich.ibm.com> * chore: upgrade uv.lock dependencies Signed-off-by: Cesar Berrospi Ramis <ceb@zurich.ibm.com> --------- Signed-off-by: Cesar Berrospi Ramis <ceb@zurich.ibm.com>
vagenas
added a commit
that referenced
this pull request
Nov 3, 2026
* fix(doclang): preserve leading text before a lone formatting tag `_get_children_simple_text_block` guarded against a second *text* fragment but the Element branch just overwrote `result`, so `<text>2<superscript>nd</superscript></text>` returned "nd" and the leading `2` was silently discarded. Guard both branches so the element is routed to `_parse_inline_group`, which already handles mixed children. * feat: inline runs carry their own whitespace; serializers concatenate faithfully The Markdown, HTML, LaTeX and DocLang inline serializers joined runs with a hard `" "`, inventing spaces the model never asked for: `2nd` -> `2 nd`, `O2.` -> `O 2 .`, `italic text.` -> `italic text .`. Those artifacts can never be removed while the separator lives in the serializer. Serializers: - join inline parts with `""`; DocLang keeps its delimiter between the element head and the body only, where `<content>` is the whitespace channel - hoist edge whitespace around the *complete* decoration stack (formatting and hyperlink together) for Markdown, HTML and LaTeX. Decorating it verbatim emits `**bold ** tail`, which CommonMark renders as literal asterisks; hoisting inside one formatter would let the hyperlink recapture it. DocLang opts out: it keeps whitespace inside the markup, in `<content>`. DocLang deserializer: - `_get_text` stripped every fragment and joined with `""`, collapsing `Advanced <bold>Topics</bold>` into `AdvancedTopics`. It now trims the outer block boundary only, and never trims whitespace delivered by `<content>`. - bare text nodes use the standard XML heuristic: a whitespace run containing a newline is pretty-print indentation, one without it is content. This is what hand-written and VLM-emitted DocLang needs, since it will not use `<content>`. - element-head children (`<caption>`, `<description>`, `<summary>`, `<custom>`) no longer bleed into body text, where they were also double-modelled in `item.meta`. Data at rest: schema minor bumped to 1.11.0 and a `mode="before"` validator re-injects the legacy separator for documents stamped below it, preserving their previous *visible* output including its extra-space bugs (`H 2 O` stays `H 2 O`). It must run before `check_version_is_compatible`, which rewrites `version` and destroys the evidence. Versionless input is left alone. The validator works on a copy, so the caller's dict is untouched and re-validating the same raw value cannot compound separators. A separator can never land inside a delimiter. Code and formula runs are wrapped in `` ` ``/`$` by the serializers, so the space goes on the plain neighbour; when both neighbours are delimited it becomes a plain run of its own, because `` `a``b` `` and `$a$$b$` are both corrupt. Chunk text changes too, since ChunkingDocSerializer inherits the Markdown join -- anyone with a persisted vector index gets silent retrieval drift, so that needs its own line in the release notes. DocTags code is untouched. Its golden gains one empty `<text></text>` for the legacy fixture because that document now carries an extra whitespace run, which DocTags renders empty by its own pre-existing strip-per-run behaviour. Ships as a minor, not a major: `feat!:` would make python-semantic-release (7.34.6, both repos) bump to 3.0, and a 3.0 is not affordable on either package. * DCO Remediation Commit for Christoph Auer <cau@zurich.ibm.com> I, Christoph Auer <cau@zurich.ibm.com>, hereby add my Signed-off-by to this commit: 64404b3 I, Christoph Auer <cau@zurich.ibm.com>, hereby add my Signed-off-by to this commit: 66040cb Signed-off-by: Christoph Auer <cau@zurich.ibm.com> * feat(compat): register 1.11->1.10 projector for the whitespace-contract bump Integrates the 1.11.0 schema bump with the downgrade-projector framework (#703) landed upstream. 1.11 and 1.10 are structurally identical; the only difference is that 1.11 inline runs own their boundary whitespace, so the projector just re-stamps the version (a 1.10 client re-applies its own join, yielding the documented harmless double space). - add @register_projector(from_minor=11, to_minor=10) + TestProjector_1_11_to_1_10 - add the auto-generated 1.11 JSON Schema snapshot - re-format the 1.11 SCHEMA_VERSION_HISTORY entry (ruff) - update the stale dclq CLI expectation (old join produced 'public class'; faithful join now yields 'public class') Signed-off-by: Christoph Auer <cau@zurich.ibm.com> * fix(dclq): use typer's vendored click; require typer>=0.25 typer >=0.25 vendors its own copy of click (typer._click) and raises those exceptions instead of the external click package's. The dclq CLI referenced the external click, so on typer >=0.25 bad input escaped the exit-code handlers and the context-flag callback (-C/-A/-B/--context-scope) silently no-op'd because the isinstance(param, click.Option) check no longer matched. Import the exception and Parameter types from typer._click, duck-type the option check, raise the [dclq] typer floor to >=0.25, and drop the now-unused external click dependency. Signed-off-by: Christoph Auer <cau@zurich.ibm.com> * fix(doclang): keep inherited formatting on <content> runs in inline groups <content> is the explicit whitespace-preserving text wrapper, so inside an inline group it is a run, not a nested item: it must inherit the formatting accumulated while descending through <bold>/<italic>/... . Dispatching it through _dispatch_element dropped that formatting, which surfaced after the rebase as <bold><content>x </content></bold> coming back unformatted and broke the doclang round-trip for whitespace_inside_bold / _link. Signed-off-by: nanhanq1 <157583847+nanhanq1@users.noreply.github.com> * chore(compat): point schema 1.11.0 at the next minor release The whitespace-contract bump was first written against v2.86.0; main is now at v2.104.0, so record v2.105.0 as the placeholder release that ships schema 1.11.0. Adjust to the actual version at release time. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Christoph Auer <cau@zurich.ibm.com> * test: rebaseline goldens for the inline whitespace contract Regenerated with DOCLING_GEN_TEST_DATA=1. The only change is the schema version stamp 1.10.0 -> 1.11.0 in goldens added or moved on main (including the six test/ -> tests/ renames and misplaced_list_items.out.yaml). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Christoph Auer <cau@zurich.ibm.com> * fix: join inline runs faithfully in the plain-text reader _collect_subtree_text (TextItem._get_plain_text, FloatingItem.caption_text, nested rich table cells) still joined the runs of an InlineGroup with " ", so mixed captions read "Table 1 : results". It now concatenates the runs of an inline group; every other join, including a host text item's own text and its children, keeps its space. Children of a text item are block structure (producers put a section's paragraphs under its heading), so the host text stays apart from its inline group, as on main; add_inline_group documents this. Tests that asserted the invented run spacing now expect the contract output, fixtures that built runs without boundary whitespace now carry it, and a new test pins the host-text boundary for headings and captions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Christoph Auer <cau@zurich.ibm.com> * docs: note that load_from_doctags cannot restore inline run whitespace DocTags stores inline runs trimmed, so the boundary whitespace the inline whitespace contract expects is not in the source. Document the limitation instead of guessing separators back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Christoph Auer <cau@zurich.ibm.com> * fix(md): keep the host separator before a list item's inline group The Markdown list serializer glued an inline group onto the preceding list item with no separator, so a list item "Intro" whose child group starts with "more" exported "- Intromore". Captions, headings and the plain-text reader keep a space between host text and its inline group; the list serializer now does the same when the group is the child of a text item with its own text. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Christoph Auer <cau@zurich.ibm.com> * fix(compat): keep migrated separators between code or formula runs in page filters A legacy document with two adjacent code or formula runs gets a standalone " " run between them on load. It had no provenance, so filter(page_nrs=...) and export_to_markdown(page_no=...) dropped it and rendered `$a$$b$`. The separator now takes the left run's location when both runs are on the same page, so it survives a page filter exactly when both runs do. Runs on different pages keep the unlocated separator, which matches the old join. Inline group locations in DocLang and DocTags are a union of the runs, so they do not change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Christoph Auer <cau@zurich.ibm.com> * fix(compat): count empty inline hosts and nested inline groups as legacy runs The legacy separator migration counted only direct text children with non-empty text as runs. An empty-text item whose content is a child inline group (a formula or footnote host) and an inline group nested directly in another were skipped, so `left`, host(`x`), `right` loaded as `left $x$right` instead of the old `left $x$ right`. The DocLang deserializer writes both shapes for nested mixed-content elements. A child now counts as a run when it or its subtree has text. Only a plain run with its own text takes the separator; an empty host must keep its empty text to render its group, so it is treated like a code or formula run and the separator stays outside it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Christoph Auer <cau@zurich.ibm.com> * docs(doclang): note that pre-contract archives load without legacy separators DocLang has no schema version, so a .dclx written before schema 1.11.0 cannot be told apart from a current one and is not migrated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Christoph Auer <cau@zurich.ibm.com> * chore(dclq): move the vendored-click fix to its own PR This reverts 6a8b837; the change is unrelated to the whitespace contract. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Christoph Auer <cau@zurich.ibm.com> * fix(compat): don't run the legacy inline migration in project_to project_to validated the projected dict under its target stamp. For 1.10.0 that ran the load-time separator migration on runs that already carry their whitespace, so 'Normal ', 'bold', ' tail' came back as 'Normal ', 'bold ', ' tail'. Validate under the source stamp and restore the target stamp afterwards. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Christoph Auer <cau@zurich.ibm.com> * fix(compat): strip inline runs when projecting 1.11 to 1.10 A 1.10 client joins inline runs with " ", so runs that keep their boundary whitespace rendered with double spaces and with the space inside the markup (**bold **, which CommonMark does not render as bold). The projector now strips each inline-group child's text to the shape old producers emitted. Whitespace-only runs become "", which old serializers skip, so no refs move. orig and text outside inline groups are left alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Christoph Auer <cau@zurich.ibm.com> * fix(compat): reuse the stripped separator run when migrating Between two code or formula runs the migration inserts a plain " " run. The 1.11 -> 1.10 projector strips it to "", and the next migration skipped the empty run and inserted another, so every projection round trip added a run. Refill an empty plain run between the two neighbours instead. Old serializers skipped empty runs, so legacy output is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Christoph Auer <cau@zurich.ibm.com> * DCO Remediation Commit for Christoph Auer <cau@zurich.ibm.com> I, Christoph Auer <cau@zurich.ibm.com>, hereby add my Signed-off-by to this commit: 7600953 I, Christoph Auer <cau@zurich.ibm.com>, hereby add my Signed-off-by to this commit: f0e26b6 Signed-off-by: Christoph Auer <cau@zurich.ibm.com> * feat(doclang): read and write whitespace per DocLang 0.9 - Deserializer applies spec rules to the DOM before parsing: a whitespace sequence reads as one space, none at block edges, <content> is literal. - Serializer keeps each text block body on one line; text with non-single-space whitespace goes in <content>, unwrapped where the rules read it the same bare. - Emit version 0.9; validate against doclang 0.9. Signed-off-by: Panos Vagenas <pva@zurich.ibm.com> * fix(doclang): keep inline code and formula in virtual text In a list item or cell with text of its own, <code> and <formula> are inline, so whitespace around them reads as a space under DocLang 0.9. - Reader applies the whitespace rules across them instead of treating them as blocks. - Pretty-printer writes such a virtual text on one line, so it no longer adds spaces next to inline code or formulas. Signed-off-by: Panos Vagenas <pva@zurich.ibm.com> * chore(compat): point schema 1.11.0 at v2.106.0 v2.105.0 was released without the whitespace contract, so record the next minor release as the one that ships schema 1.11.0. Signed-off-by: Panos Vagenas <pva@zurich.ibm.com> * docs(compat): name schema 1.11 as current in the projectors header Signed-off-by: Panos Vagenas <pva@zurich.ibm.com> * fix(doclang): harden the DocLang 0.9 whitespace reader and writer - read list items with leading inline code or formula as virtual text - keep whitespace-only content between inline code runs - keep blank lines in content when pretty printing - keep inline handwriting and rtl text as runs - trim only XML whitespace when reading text - keep content literal in headings, captions and list items - read table cells with inline elements as virtual text - keep text beside a whitespace-only formatted run - read spaces around an empty content as one sequence - read a checkbox as part of virtual text - keep a whitespace-only inline code run Signed-off-by: Christoph Auer <cau@zurich.ibm.com> * fix(doclang): preserve checkbox spaces and formatted whitespace runs Signed-off-by: Christoph Auer <cau@zurich.ibm.com> --------- Signed-off-by: Christoph Auer <cau@zurich.ibm.com> Signed-off-by: nanhanq1 <157583847+nanhanq1@users.noreply.github.com> Signed-off-by: Panos Vagenas <pva@zurich.ibm.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: nanhanq1 <157583847+nanhanq1@users.noreply.github.com> Co-authored-by: Panos Vagenas <pva@zurich.ibm.com>
wittjeff
added a commit
to wittjeff/docling-core
that referenced
this pull request
Nov 3, 2026
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.11.0 -> 1.12.0 with the full docling-project#703 regime: history entry, a 1.12 -> 1.11 projector stripping the four keys, the 1.12 snapshot, and a TestProjector_1_12_to_1_11 class. FieldItem is a strict model, so an unannounced addition would have broken 1.11 clients outright. Schema 1.11.0 went to the inline whitespace contract (docling-project#693) while this was in review, so the bump moved up one minor; the history entry records v2.107.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>
wittjeff
added a commit
to wittjeff/docling-core
that referenced
this pull request
Nov 27, 2026
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 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
Introduces a server-side downgrade projector system so that a
docling-serveinstance running a newerdocling-corecan serve aDoclingDocumentJSON that is still parseable by a client running an older version.Closes #702
What changed
docling_core/compat.py(new)register_projector(*, from_minor, to_minor)— decorator that registers a single-step downgrade function in a module-level registry.project_to(doc, target_version)— walks the registry chain from the document's current schema version down totarget_version, applying each projector in sequence, then returns a validatedDoclingDocumentwith the version field restored to the target.list_projectors()— returns sorted(from_minor, to_minor)pairs; useful for introspection and tests.Five retroactive projectors covering every schema step from the current version back to the oldest v2.x schema:
field_regions,field_items, 8 newDocItemLabelvalues, newCodeLanguageLabelvalues, newPictureClassificationLabelvalues,TableData.orientation, newBaseMetasub-fieldsDocItem.comments,DocItem.sourceNodeItem.metaTableCell.fillableRichTableCell.refdocling_core/types/doc/common/constants.py(modified)SCHEMA_VERSION_HISTORY— ordered list of every schema version in the v2.x era with the first library release that introduced it._CURRENT_MINORandFIRST_SUPPORTED_MINOR— derived constants consumed by the check script and tests to stay in sync withCURRENT_VERSIONwithout duplication.scripts/check_compat_projectors.py(new)A standalone enforcement script run as a pre-commit hook and in CI.
Nine checks in a single pass:
_CURRENT_MINOR - FIRST_SUPPORTED_MINOR.N → N-1has a registered function.SCHEMA_VERSION_HISTORYhas the right number of entries.CURRENT_VERSION.6–7. JSON Schema snapshots exist for every target minor version and for the current version; missing snapshots are auto-generated by copying
docs/DoclingDocument.json(guaranteed to run before thedocshook regenerates it).model_validate()to raise on old clients: new enum values, new fields on strict models (additionalProperties: false), new required fields, newanyOfunion subtypes. If any are found without a matchingCURRENT_VERSIONbump, the hook fails with a precise diagnostic.docs/schemas/(new)JSON Schema snapshots for every supported minor version (
DoclingDocument_1_5.jsonthroughDoclingDocument_1_10.json). Versions 1.5–1.9 are bootstrap copies of the current schema (permissive superset); going forward each snapshot is captured automatically at the moment of the version bump, beforegenerate_docsoverwrites the live schema.test/test_compat.py(new)36 tests across 8 classes:
TestProjectorCoverage— parametrised count, step-coverage, history-length, history-sort,list_projectorssort, single-step-key, output-shape (every projector), and test-class-name presence checks.TestProjector_1_{N}_to_1_{N-1}— one class per projector with at least one non-trivial field-level assertion.TestChainProjection,TestNoOpProjection,TestErrorPaths.CONTRIBUTING.md(modified)New section "Breaking changes and schema bumps" covering:
schema diff.
project_to()..pre-commit-config.yaml(modified)Added
check-compat-projectorshook (runs beforemypy,pytest, anddocs) so the schema snapshot is captured beforegenerate_docsoverwritesdocs/DoclingDocument.json.How to use on the server side
What happens the next time a breaking change lands
A contributor adds a new field or enum value, then:
$defsentry.CURRENT_VERSION, appends aSCHEMA_VERSION_HISTORYentry, adds a@register_projectorfunction, and adds aTestProjector_1_{N+1}_to_1_{N}test class.CI (pytest) enforces that the new test class exists and the projector output validates against the target-version snapshot.