Known limitations¶
Omnist's schema algebra, formats, and depth handling are all deliberately scoped. This page collects the edges in one place — each one is a design decision documented in full elsewhere, not a bug waiting to be filed. Follow the links for the reasoning and worked examples; this page is the map, not the territory.
The four expressiveness gaps¶
OSD's schema algebra can't express every shape a real-world format uses. Running four external formats (none designed for Omnist) through the whole pipeline surfaced exactly four gap categories — see Real-world examples: overview for the full taxonomy and worked examples from real fixtures:
- Union — a field that's legitimately more than one shape (a string
or a table). OSD's field type is always exactly one scalar or one
Ref; there's no "A or B" combinator. See pyproject.toml'slicenseand GitHub Actions' three-wayon. - Open key set — a record whose label set isn't fixed by the format.
OSD records are closed by design; see
the schema model's refusals section for why
Mapwas refused andanywas shipped instead. - Cross-field constraint — a rule spanning sibling fields (a field
required unless another says otherwise). OSD's cardinality is per-field
only. See pyproject.toml's
version/dynamic. - Value refinement — the right type but a restricted value set or
range (an enum, a numeric range). See
sitemap.xml's
changefreq/priority, the only one of the four examples formal enough to expose this gap on its own.
Programmatic schemas and max = 0¶
A Schema built in code is held to the same rules as one parsed from text
(omnist-spec S-8, S-22; no conformance vector pins them, so this port's unit
tests do): a record or Ref name that is not [A-Za-z_][A-Za-z0-9_]* is
schema.invalid-name at $, and a field label that does not encode to UTF-8
(a lone surrogate) is schema.invalid-label at the record. Cardinality
[0,0] stays representable, but to_osd refuses it with
write.unsupported-value at the record, since no reader accepts [0].
prune() removes such fields, except from an unsatisfiable root, which it
keeps intact; prune before writing. This port has no OSD-OML schema writer,
and no caller-supplied record ordering, so schema.unknown-record (S-23)
cannot arise.
any and the vacuity of compatible_with¶
A field typed any accepts any value, unchecked — the escape hatch for
genuinely open-ended data. The cost is stated loudly in
the any type chapter: checking ends exactly
where any begins. compatible_with is vacuously True inside an any
region, because there is no structure left to compare — a schema that's 40%
any gives compatibility verdicts that are 40% meaningless while looking
authoritative.
from omnist import parse_schema
s = parse_schema('''
record Event {
"id": string,
"data": any,
}
root Event
''')
# Two independently-parsed but identical schemas compare equivalent --
# there's nothing inside `data`'s `any` region left to distinguish.
s2 = parse_schema('''
record Event {
"id": string,
"data": any,
}
root Event
''')
assert s.equivalent(s2)
See the schema model's refusals section for why any opens
only the value domain (never the label alphabet), and why that line is what
keeps the algebra decidable at all.
Configurable limits¶
Every reader (read_json, read_yaml, read_toml, read_xml, read_oml
and the matching Doc.from_*, plus Doc.from_format) takes the three safety
limits of spec section 2.4 per call, like max_input_bytes:
| Option | Default | Ceiling | Refusal |
|---|---|---|---|
max_depth |
200 | 200 | document.limit.depth, path $ |
max_nodes |
1 000 000 | 10 000 000 | document.limit.nodes, path $ |
max_int_digits |
4300 | 4300 | document.limit.int-digits, path of the literal |
They may be lowered, and raised only to the ceiling, because the writers,
validate and infer enforce 200 levels and CPython cannot convert an integer
of more than 4300 digits. A value outside 1 .. ceiling raises ValueError
(TypeError for a non-int). max_int_digits counts the decimal digits of the
value (D-28): 0xFFF and 4_095 have four (so does TOML's 0o7777; YAML 1.1 octal is 07777), a sign is not a
digit. The refusal carries the Document path of the leaf holding the literal,
including for a literal beyond CPython's own conversion guard and for the
schema-directed pretyping of an XML integer leaf. A number literal beyond
binary64 (1e999) reads as an infinity, underflow as 0.0 (D-29).
The 200-level depth limit¶
Documents nest at most 200 levels deep: the value of an edge in a node at
depth n sits at depth n + 1, a scalar as much as a subtree, so 200 nested
levels end in a leaf at depth 200 (omnist-spec D-9: levels of node nesting, counted from the Document root). The default is
_MAX_DEPTH, a single shared constant enforced by every reader, every writer, and — as of
this release — infer and validate too, so the same document either
passes or fails consistently everywhere it's touched. Past the limit, a
reader raises a clean DocumentError (or WriteError on the write side)
naming the limit, rather than exhausting the call stack. See
the API reference and each format page
(for example XML) for the exact exception types.
from omnist import doc, infer, DocumentError
deep = {"a": 1}
for _ in range(205):
deep = {"a": deep}
try:
infer([doc(deep)])
raised = False
except DocumentError as e:
raised = "nesting exceeds the maximum depth" in str(e)
assert raised
The 64 MiB input-size limit¶
Every read of a Document from text refuses an input of more than 64 MiB
(64 * 1024 * 1024 bytes) with document.limit.input-size at $
(D-23).
The size is in bytes, not characters (é counts as two), and a leading
byte-order mark is counted, because the length is taken before the mark is
stripped and before anything is decoded. The check comes first, so an
oversized input is refused with this code even if it is also invalid UTF-8 or
malformed. An input of exactly the maximum is accepted. The CLI reads at most
one byte past the maximum from a file or standard input and then refuses;
--max-input-bytes N (on format, convert, check, validate and
infer) raises or lowers it. The limit applies to Documents, not to OSD
schema files.
This is a behaviour change as of 0.14.0: a document above 64 MiB used to
be parsed (slowly, at the cost of memory) and is now refused. Every reader
takes max_input_bytes= to choose another maximum; 0, a negative number or
a non-integer is a ValueError/TypeError, as for the other limits.
from omnist import ParseError, read_json
read_json('{"a":"xxxxxxxxxxxx"}', max_input_bytes=20) # 20 bytes: accepted
try:
read_json('{"a":"xxxxxxxxxxxxx"}', max_input_bytes=20) # 21 bytes
except ParseError as e:
assert (e.code, e.path) == ("document.limit.input-size", "$")
else:
raise AssertionError("not refused")
A cap bounds what is parsed; it does not make any parse fast. PyYAML, for example, still spends seconds on a megabyte-sized mapping.
Format lossiness¶
Every non-OML codec makes documented adjustments when a Document shape
doesn't map cleanly onto the target format — a stringified date, a
sanitized key, a dropped XML attribute. OML is the only format with zero
adjustments, because its edge-list syntax is the Document model rather
than a projection of it. See
the formats overview's feature table
for the full list, and
adjustment reports for how to
inspect (or strict=True to reject) any of them at write time. Each
per-format page (JSON, YAML,
TOML, XML) documents its own specific
adjustments in context.
XML's narrow data profile¶
The XML codec targets a deliberately narrow data-XML profile: elements
only, used to carry the same Documents as the other formats. Attributes and
CDATA are outside the profile and silently dropped on read, with no path
back out on write; namespace prefixes are stripped; mixed content (text
alongside child elements) is rejected outright rather than silently
discarded. See XML for the full list of what's in
and out of scope, and why defusedxml is a hard dependency for security
reasons independent of the profile's narrowness.
Performance is not a promise¶
Timings, memory use, and algorithmic constants may change between releases
without notice — see
the stability policy. Published
benchmark numbers describe a point in time,
not a floor. A weekly, non-gating benchmark
(.github/workflows/bench.yml) prints current numbers to the CI log for
trend-watching, with no pass/fail threshold — shared-runner timings are too
noisy to gate on.
None of the above is accidental. Each gap traces back to a deliberate
line — decidability over expressiveness for the schema algebra, a narrow
and secure profile for XML, a shared depth bound over unbounded recursion.
Where a limitation can be worked around (tightening an any region with
infer, choosing OML for lossless storage), the linked pages above show
how.