Mapping-set selection and rc.2 x-oold-context transform - #154
simontaurus wants to merge 3 commits into
Conversation
- add oold.utils.mappings: promote, mapping_sets, chain, context_of, synonym_entries; the selection OOLD-EXT-4966 describes, complementing validation's promoted_terms which deliberately never chooses - replace the name* alias notation in oold.utils.transform with to_rdf/from_rdf/transform over x-oold-context: exactMatch rewriting, @reverse inversion, @graph framing, @nest shape bridging under a named set (OO-LD/oold-schema#135) - re-encode the alias-notation test cases as x-oold-context, same inputs and expected outputs
Release previewMerging this PR would release v1.1.0 (current: Changelog preview (truncated)## v1.1.0 (2026-09-20)
### Features
- **utils**: Rewrite synonyms in JSON-LD rather than in RDF
([`d57172b`](https://github.com/OO-LD/oold-python/commit/d57172bb87ea58e9e8d031d3a1ba43de2c23b184))
Preview via python-semantic-release and conventional commits. |
📊 Benchmark ResultsClick to see benchmark comparisonThreshold: 1.3x (30% slower triggers a regression warning) Note: Benchmarks are informational only and won't fail the build. 💡 Tip: Download the |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
Reviewed at 156b9b0 merged with current Blocking: silent, total data loss. schema = {"@context": CTX, "x-oold-instance-rdf-type": ["ex:Person"], "properties": {...}}
inst = {"id": "https://ex.org/p1", "name": "Jane", "address": {...}}
transform(inst, [schema], [schema])
# -> {'@context': {...}} every triple gone, no error
The RDF detour is not needed, and the reason is not cost. Measured over the schemas.oo-ld.org cases and synthetic graphs, all three candidates agree on every corpus case and separate only on constructed input: So rewriting the dataset dict is the faster of the two viable options, and it still cannot be made correct. An RDF dataset carries no term definitions, so nothing in it separates a Separately, Correctness
Process
|
- bridge terms carry the rewrite: compact under a context where the term means the synonym IRI, redefine it to the primary IRI, flatten, recompact - a dataset carries no term definitions, so rewriting RDF cannot tell a @vocab-coerced value from a reference to a node - from_rdf reads a JSON-LD document as it stands instead of sending it through RDF and back, keeping @index and @direction - keep jsonld_to_jsonld and json_to_json, deprecated, with their tests - Dataset.default_union, else triples() drops every quad in a named graph
📊 Benchmark ResultsClick to see benchmark comparisonThreshold: 1.3x (30% slower triggers a regression warning) Note: Benchmarks are informational only and won't fail the build. 💡 Tip: Download the |
Changes
oold.utils.mappings(new):promote,mapping_sets,chain,context_of,synonym_entries. This is the profile-based selectionOOLD-EXT-4966describes; it complementsvalidation.context_resolution.promoted_terms, which deliberately never chooses a synonym (OOLD-EXT-8f62). Ported fromoold-reference-schemas/scripts/{_shared,build_docs}.pyand verified equivalent against that implementation on thequantitiesmodule (all schemas, all three mapping sets plus consensus). Two deliberate extensions over the port:mapping_set_idmay be a list (the spec allows it), and a@reversesynonym promotes to@reverserather than an invalid@id+@reversepair.oold.utils.transform(replaced):to_rdf/from_rdf/transformoverx-oold-context. Export promotes a named set; import rewrites everyexactMatchsynonym onto the primary IRI (no set needed), inverts@reverserelations, frames@graphinput viavalidation.frame.schema_to_frame, and bridges document shapes when a promoted fragment carries@nestand a set is named. Readings A/B/C/E of Mapping-set selection can bridge document shapes via @nest, and the spec should say so oold-schema#135 are reproduced exactly and pinned as regression tests, including the boundary that vocabulary is bridged without a selection and shape is not.tests/test_transform.pyrewritten: thename*alias cases are re-encoded asx-oold-contextwith the same inputs and expected outputs, so the change of notation provably does not change what the transformation produces.Breaking change
jsonld_to_jsonld/json_to_jsonand the pre-specname*alias notation are removed. Onlytests/test_transform.pyreferenced them in this repository. The commit is deliberately typedfeat:rather thanfeat!:so semantic-release does not force a major bump; retype if a major is wanted.Verification
main;make checkgreen.schema-playgroundin https://github.com/OO-LD/oold-playgrounds/tree/feat/schema-playground vendors exactly these modules pending this PR; once released they can be deleted there.Closes the mappings/transform part of the migration listed in https://github.com/OO-LD/oold-playgrounds/blob/feat/schema-playground/schema-playground/README.md#pending-upstream-migration