Skip to main content

libxml_rs/compatibility/
mod.rs

1//! Compatibility profiles, historical behavior, and platform quirks (§68, §69).
2//!
3//! This module provides version-aware compatibility profiles that allow
4//! libxml-rs to emulate the behavior of specific historical upstream versions.
5//!
6//! # Semantic epochs (§68)
7//!
8//! | Epoch | libxml2 range | libxslt range | Characteristics |
9//! |-------|---------------|---------------|-----------------|
10//! | `pre2` | 0.99–1.8.17 | — | Original libxml, libxml.so.1, legacy parser |
11//! | `legacy_parser` | 2.0–2.4 | 0.0.0–1.0.x | SAX1, no SAX2 default |
12//! | `sax2` | 2.5–2.6 | 1.0.x | SAX2 namespace-aware default |
13//! | `validation_era` | 2.6–2.8 | 1.1.x | Schemas/RELAX NG/reader mature |
14//! | `security_hardening` | 2.9.0–2.9.14 | 1.1.x | Entity limits, option system |
15//! | `modern` | 2.10+ | 1.1.33+ | Current ABI, lazy init, hardening |
16//!
17//! # Phase 0 status
18//!
19//! This module is scaffolded. Historical profiling will be built as the
20//! historical delta atlas (§10) is populated and semantic epochs are validated.
21//!
22//! See `atlas/HISTORY.md` for the full history atlas.
23//!
24//! # Upstream contract
25//!
26//! This module is the Rust-side umbrella for emulating historical upstream
27//! behavior. It is NOT part of the C ABI: upstream has no "compatibility"
28//! subsystem, so there is no upstream .c file to mirror. The parity target
29//! is the observable behavior of upstream across versions, evidenced by
30//! SRC-LIBXML2-GIT / SRC-LIBXSLT-GIT (archaeology clones), the historical
31//! oracle matrix (oracle/historical/), and the epoch findings E-001..E-008
32//! in atlas/SEMANTIC_EPOCHS.md. The four submodules own the four evidence
33//! families: `profiles` (capability epochs), `historical` (docs live in
34//! atlas/HISTORY.md), `platform` (atlas/PLATFORM_SURFACE_ATLAS.md), and
35//! `quirks` (atlas/QUIRKS.md).
36//!
37//! # Conceptual behavior
38//!
39//! Version-dependent behavior is modelled as capability epochs: each
40//! behavioral capability whose semantics changed at a documented upstream
41//! boundary resolves to a value for a target version pair, so historical
42//! emulation has one deliberate structure (the resolver in `profiles`)
43//! instead of scattered `if version == ...` branches throughout the engine.
44//!
45//! # Ownership & safety invariants
46//!
47//! - All resolved capabilities are pure, `Copy`-able value data; nothing in
48//!   this module owns heap memory or holds pointers into the engine.
49//! - The resolver is deterministic and read-only: no global state and no
50//!   interior mutability, so profile resolution is thread-safe by
51//!   construction.
52//! - `CompatibilityProfile::for_libxml2` deliberately panics on versions
53//!   newer than the system oracle rather than inventing an unverified epoch
54//!   (a fail-fast invariant).
55//!
56//! # Historical quirks & epochs
57//!
58//! The epoch table above and the capability table in `profiles` are the
59//! core evidence of the module; every boundary is pinned by the historical matrix
60//! and by upstream commits (da35eeae, e85f9b98, 387a952b, 8d04f0ee,
61//! de5b624f — see atlas/SEMANTIC_EPOCHS.md). QUIRK-* entries (atlas/QUIRKS.md)
62//! record confirmed quirks such as the 2.9.0 default parser limits and the
63//! misspelled XML_MAX_TEXT_LENGHT macro.
64//!
65//! # Deliberate oddities
66//!
67//! - `GlobalStateInit` is a capability epoch upstream never documented as a
68//!   behavior change (the 2.12 lazy-init rework); modelling it as an epoch
69//!   keeps emulation uniform rather than special-casing one subsystem.
70//! - The `XslTransform` capability has exactly one value (Stable): E-008
71//!   proved a 15-year stable epoch, so the single-variant enum documents
72//!   the proven absence of a boundary instead of pretending one exists.
73//!
74//! # Proving courts
75//!
76//! The capability boundaries are regressed by the unit tests in
77//! `profiles` (`cargo test`) and by the differential court families that
78//! exercise the behaviors they describe: CLI-XMLLINT-* (xpath
79//! serialization, exit-code epochs), XPATH, PARSER, DTD, HTML, C14N,
80//! XINCLUDE, XSD, RELAXNG, SCHEMATRON and XPOINTER, plus the historical
81//! HIST-EPOCH-* casefiles and their receipts
82//! (courts/receipts/historical-matrix-*).
83//!
84//! # Tempting simplifications that would break parity
85//!
86//! - Replacing the resolver with direct version comparisons at each call
87//!   site would scatter the epoch boundaries across the engine and make
88//!   regression triage against older oracles impossible to audit.
89//! - Deleting single-variant capabilities such as `XslTransform` would
90//!   erase the documented evidence that a boundary does not exist.
91//! - Letting `for_libxml2` extrapolate past the system oracle would
92//!   fabricate epochs for versions no oracle measures — a hazard for every
93//!   future completeness claim.
94
95pub mod historical;
96pub mod platform;
97pub mod profiles;
98pub mod quirks;