# OIP-0029: Crosswalks for the live schemas

| Field | Value |
|---|---|
| Status | DRAFT |
| Functions | `describe` (§5.3) and `exchange` (§5.10); no new function (the register keeps exactly twelve) |
| Affects | new crosswalks `crosswalks/cf-conventions.yaml`, `crosswalks/wigos-metadata.yaml`, `crosswalks/senml.yaml`, `crosswalks/iso19115.yaml`, `crosswalks/odrl.yaml`, `crosswalks/ucum.yaml` and their examples; `registers/relations.yaml` (new `EXT-CFCONV`, `EXT-WMDS`, `EXT-SENML`, `EXT-ISO19115`, `EXT-ODRL`, `EXT-UCUM`); `registers/implements-edges.json` and `registers/requirements.yaml` (regenerated); new cases CT-PROVIDER-160 to CT-PROVIDER-164 and CT-CONSUMER-160 to CT-CONSUMER-163; `tests/test_crosswalk_examples.py` |
| Protocol version | obsp/0.1 |
| Work package | WP-IM-09 (crosswalks for the live schemas) |
| Requires | nothing: every crosswalk points only at fields of schemas in the live tree, so the patches apply on their own and do not need another draft |
| Last call | 30 days (additive: data files and cases, no schema or specification text changes) unless the editors rule otherwise |

## Problem

The specification says it maps to standards and never replaces them, but the live tree holds no crosswalk: the
`crosswalks/` folder has its schema and its README and no file. A receiver that holds observation records, sensor
passports, calibration records, node, product and source manifests, a request context or a provider manifest, and
that must hand them to a meteorological, climate, geospatial or rights-management system, has to guess which field
becomes which term, which fields have no counterpart, and what is lost on the way. Six standards are asked for
first:

1. NetCDF Climate and Forecast conventions, the exchange format of climate and ocean data;
2. the WMO WIGOS Metadata Standard, which every national weather service files observing-system metadata in;
3. SenML (RFC 8428), the measurement list of constrained devices;
4. ISO 19115-1, the metadata standard of geospatial catalogues;
5. W3C ODRL, the usage-policy vocabulary;
6. UCUM, the unit code the schemas already name.

## Change

Six crosswalk files, written as data against `crosswalks/crosswalk.schema.json` and checked by
`python3 tools/validate.py --only crosswalks` (the schemas they name exist, every pointer resolves, every required
property of every schema in scope has a row, a `match: none` row gives its reason):

| File | Standard and edition | Schemas in scope |
|---|---|---|
| `cf-conventions.yaml` | NetCDF Climate and Forecast Metadata Conventions 1.11 | observation-record, sensor-passport, calibration-record |
| `wigos-metadata.yaml` | WMO-No. 1192 WIGOS Metadata Standard, 2019 edition | sensor-passport, node-manifest, calibration-record |
| `senml.yaml` | RFC 8428, August 2018 | observation-record |
| `iso19115.yaml` | ISO 19115-1:2014 | product-manifest, source-manifest |
| `odrl.yaml` | W3C ODRL Information Model 2.2 | source-manifest, request-context, provider-manifest (the existing policy-related fields only) |
| `ucum.yaml` | UCUM 2.1 | observation-record, sensor-passport, calibration-record (every unit field) |

There is no deployment schema in the live tree; the WIGOS crosswalk maps deployment information from the sensor
passport's `mounting` and its node and site references and from the node manifest. The ODRL crosswalk maps nothing
beyond `rightsState`, `purpose`, `principalUni`, `jurisdictionContext`, `policyDigest` and `rights`; a usage policy of
the protocol's own is the subject of other proposals.

**Every row says `checked: not checked`.** The standards were not opened when the files were written. Where a clause
number is a recollection, the row says "(number not checked)"; the editors confirm each row against the published
edition, then change it to `opened`. A partial match is `close`, `narrower` or `broader`, never `exact`.

### Requirements

Each file states requirements for a mapper, as `XW-<STD>-NN` rows in its `requirements` list, each with the case that
covers it: `XW-CF-01` to `XW-CF-04`, `XW-WMDS-01` to `XW-WMDS-04`, `XW-SENML-01` to `XW-SENML-04`,
`XW-ISO19115-01` to `XW-ISO19115-04`, `XW-ODRL-01` to `XW-ODRL-04` and `XW-UCUM-01` to `XW-UCUM-03`. The statements
that carry the most weight, because each stops a mapping from saying more than the record does:

1. a unit travels in its case-sensitive UCUM form and is never converted silently (`XW-UCUM-01`, `XW-UCUM-02`); CF
   writes UDUNITS syntax and keeps the UCUM code beside it (`XW-CF-01`);
2. a record whose state is not `PRESENT` is not given a value in any target (`XW-CF-02`, `XW-SENML-02`);
3. `rightsState` is a review state and never becomes a legal constraint, a licence, a permission or a prohibition
   (`XW-ISO19115-02`, `XW-ODRL-01`); a policy digest is never an ODRL policy identifier (`XW-ODRL-03`);
4. no WIGOS station identifier is derived from a UNI, `NOT_CLASSIFIED` yields no siting class, and the traceability
   chain keeps its order (`XW-WMDS-01` to `XW-WMDS-03`); a mapped record is not called a complete WMDS record
   (`XW-WMDS-04`);
5. acceptance tests never become a conformance result in ISO 19115-1 data quality (`XW-ISO19115-03`).

### Cases

Nine automated cases (kind `invariant`, `obsp.golden.crosswalk_roundtrip`): the implementer supplies the text of its mapping and the source documents it was made from (`crosswalk-<id>-<label>` evidence, `conformance/BINDING-EVIDENCE.md`); the suite validates the sources, checks that every two-way exact row survives, and applies the crosswalk's rules about what a mapping must not write or must keep where a function can state them on the text (`sdk/python/src/obsp/inv_oip0029.py`). The cases: CT-PROVIDER-160 (CF),
CT-PROVIDER-161 (WIGOS), CT-PROVIDER-162 (ISO 19115, source manifest), CT-PROVIDER-163 (ODRL, rights state),
CT-PROVIDER-164 (UCUM) under `describe`; CT-CONSUMER-160 (CF), CT-CONSUMER-161 (SenML), CT-CONSUMER-162 (ISO 19115,
product manifest), CT-CONSUMER-163 (ODRL) under `exchange`. Their evidence in the example sets is
the crosswalk's own example mapping. `registers/requirements.yaml` lists them under the `describe` and `exchange` requirements it
generates.

### Examples and the round trip

`crosswalks/examples/<id>/` holds `source.<schema>.json`, a valid document of each schema the example uses, and
`mapped.*`, the same content in the standard's serialisation: a CDL file for CF, a JSON object keyed by WMDS category
names, a SenML pack, ISO 19115-1 XML, ODRL JSON-LD, and the UCUM code list. The mapped documents are illustrations: they
follow the rows and have not been validated against the standards' own schemas. The new test
`tests/test_crosswalk_examples.py` checks that each source validates against its live schema and that every field of
an `exact`, `both` row appears unchanged in the mapped document, as `crosswalks/README.md` requires.

## Compatibility

Not breaking. No schema, specification text, enumeration or existing case changes, and no existing record changes.
One live-tree test is edited to stay true: `tests/test_validate.py` counts the demo crosswalk on top of the shipped
ones (the same edit as OIP-0006 and OIP-0013). The conformance-runner service test is unchanged: no case waits for an
attestation, so the provider example uploaded as JSON still passes.

Rebase list: with these patches applied, the patches of other drafts that still apply are all but the following, which
touch the same generated or shared files. Generated files (`registers/implements-edges.json`,
`registers/requirements.yaml`) are regenerated by the proposal accepted second.

| Draft | Patch | Why it no longer applies |
|---|---|---|
| OIP-0005 | `registers` | `implements-edges.json` count; `relations.yaml` hunk |
| OIP-0006 | `cases-invariants`, `registers` | `tests/test_validate.py` crosswalk count (identical edit); `implements-edges.json` count |
| OIP-0008 | `registers` | `implements-edges.json` count |
| OIP-0009 | `registers` | `implements-edges.json`; `requirements.yaml` |
| OIP-0010, OIP-0011, OIP-0012, OIP-0017 | `spec` (OIP-0012 also `registers`) | `requirements.yaml` case lists |
| OIP-0013 | `crosswalks`, `registers`, `spec` | `tests/test_validate.py` crosswalk count (identical edit); `implements-edges.json`; `requirements.yaml` |
| OIP-0014, OIP-0020, OIP-0023 | `cases-invariants`, `spec`, `registers` respectively | `requirements.yaml` case lists |
| OIP-0019 | `registers` | `implements-edges.json`; `relations.yaml` hunk |

The same holds for steps of the integration series (`oips/integration/0.2/`), which is rebuilt from the drafts when
this proposal is accepted. Two relation rows overlap with other drafts: `EXT-UCUM` is also added by OIP-0006 (without
`artefacts`; the editors keep one row and add `crosswalks/ucum.yaml` to it) and OIP-0013 adds `EXT-CF` for
`crosswalks/cf-trajectory.yaml` beside this proposal's `EXT-CFCONV`; the two CF files may be folded under one row.

## Tests

- `python3 tools/validate.py --only crosswalks`: six crosswalks, 235 rows, every required property covered, every
  pointer resolving in the live schemas.
- `tests/test_crosswalk_examples.py` (4 tests): sources valid, exact two-way fields survive, a lost field is reported,
  looser rows may lose detail, every edition is published and every row `checked` is `opened` or `not checked`.
- the nine automated cases and their invariants (`sdk/python/tests/test_inv_oip0029.py`: each passes on the example sets, fails without its evidence, fails when a value is lost or a forbidden element is written), run on the OBSP-PROVIDER and OBSP-CONSUMER example sets.
- `registers/implements-edges.json` (47 edges) and `registers/requirements.yaml` are regenerated and checked by the
  existing tests.

## Open questions

1. Every row is unchecked. Which editor opens each standard, and may a file go to REVIEW before its rows are `opened`?
2. Editions: CF 1.11 (a later edition may be current), WMDS 2019 (a later WMDS edition may have replaced it), UCUM 2.1
   (a later edition may exist), ISO 19115-1:2014 (an amendment of 2018 exists and is not cited). Which does the
   register pin?
3. The WIGOS and CF files cite category and section names from memory. The WMDS element names in particular must be
   confirmed before any row is `opened`.
4. SenML extension labels: the example uses `obsp_unit`; the editors confirm the RFC's rules on extension labels and
   on must-understand fields before the requirement `XW-SENML-03` is accepted.
5. The ODRL crosswalk leaves the commercial-use purpose value to a profile. Should the protocol publish one?
6. The cases check the mapped text of the implementer's own mapper, not a mapper the repository ships. Should a later proposal add
   a mapper reference implementation, so that the round trip runs on the repository's own examples? Rows that are close or one-way
   (CF, SenML and ODRL have no exact two-way scalar) are checked by the rule functions only, not by the round trip.
7. The ISO 19115-1 and CF examples use encodings (XML namespaces, CDL attributes) that were written without network
   access to the standards; an editor with access validates them or replaces them.
