# Mars Data Dictionary 0.3 (Draft)

A speculative Mars counterpart to the **RESO Data Dictionary 2.1**, built as a thought experiment and teaching tool.
Not adopted by any standards body.

**0.2 → 0.3:** adds measured site data: MOLA elevation source and a pressure estimate, SWIM ground-ice consistency at three depths, Robbins crater facts (host crater, rims within 10 km, nearest rim, rim crossing a claim) and nearest landing site. New rules R16–R18 and sources S17–S20. These fields power the live demo at https://mars.dougdevitre.org.

**0.1 → 0.2:** validation moves from "the data is shaped right" to "the data is internally consistent and sourced."

## What's here

```
mars-data-dictionary/
├── Mars-Data-Dictionary-0.3.xlsx   # human-readable dictionary (RESO column layout)
├── schemas/                        # JSON Schema 2020-12, one per resource (11)
├── examples/                       # one sample record per resource, all computed and valid
├── csv/                            # import templates (header + example rows)
├── metadata.xml                    # OData CSDL (EDMX 4.0): 12 entity types, 14 navigation properties
├── payloads/                       # RESO Common Format: one per resource + Lookup + Habitat.expanded
├── openapi.json                    # OpenAPI 3.1, generated from metadata.xml (OASIS odata-openapi)
├── src/
│   ├── mars24.ts                   # Mars Sol Date, Ls, Mars Year, season, MTC parsing
│   └── rules.ts                    # cross-field rules R01–R18
├── mars24.py / marsrules.py        # Python mirrors (used by CI and the generator)
├── test/
│   ├── rules.test.ts               # 38 tests: NASA vectors, TS==Python, positive + negative per rule (18)
│   ├── vectors.json                # shared test vectors (generated)
│   └── rules.json                  # rule registry (generated)
├── tools/
│   ├── build_workbook.py           # SINGLE SOURCE OF TRUTH: fields, lookups, rules, sources
│   └── generate.py                 # builds xlsx + schemas + examples + CSV + vectors from it
├── ci.py                           # full CI (see below)
└── .github/workflows/ci.yml        # regenerate → git diff (no hand edits) → ci.py
```

## Run it

```bash
npm ci
pip install jsonschema openpyxl
python3 tools/generate.py      # rebuild everything from tools/build_workbook.py
python3 ci.py                  # must print: CI PASSED
```

## What CI checks

| # | Check | Catches |
|---|---|---|
| 1 | JSON Schema validation of every example | wrong types, unknown fields, bad lookup values |
| 2 | Cross-field rules R01–R15 on every example | internally inconsistent records |
| 3 | Negative schema tests | a schema that silently accepts bad data (e.g. `MarsRegion: "Ohio"`, leftover `PostalCode`) |
| 4 | Negative rule tests — one per rule | a rule that never fires |
| 5 | CSV → JSON round-trip | lossy CSV templates |
| 6 | Workbook ↔ schema drift | the xlsx and schemas disagreeing on fields, lookups, sources, privacy |
| 7 | `tsc --noEmit` + `node --test` | type errors; Mars24 off NASA's published values; TS and Python disagreeing |
| 8 | OData semantics + RCF + integrity | EDMX vs JSON Schema type/length drift; missing `LookupName` annotations; Lookup payload ≠ enums; broken navigation partners/constraints; foreign keys in example data that point nowhere |
| 9 | OASIS `odata-csdl-xml2json` + `odata-openapi3` | malformed CSDL that an independent OData toolchain can't parse |

## Conventions

- **Time.** `*Sol` = Mars Sol Date. `*MTC` = Coordinated Mars Time as `MSD <sol> HH:MM:SS` — deliberately **not** ISO-8601,
  so it can't be mistaken for UTC (0.1 bug). `*UTC` = Earth UTC. All derived via Mars24 (Allison & McEwen 2000), with a
  leap-second table for TT−UTC. Mars Year per Clancy et al. 2000 (MY 1 began 1955-04-11).
- **Coordinates.** `MarsLatitude` / `MarsLongitude`: planetocentric, east-positive 0–360 (IAU WGCCRE, Archinal et al. 2018).
- **Claims.** `ClaimBoundaryGeoJSON` is a structured Polygon. RFC 7946 assumes WGS84, so Mars use is a declared extension (`x-crs`).
- **Ordering.** Replicate by `EntityEvent.EntityEventSequence`, never by timestamp.
- **Lookups.** All enforced per version. *Open* lists may gain values in a MINOR release without a vote; *Closed* lists need a vote.

## OData / RESO conventions

- **Lookups** follow RESO DD 2.0 (RCP-40): `Edm.String` / `Collection(Edm.String)` with
  `<Annotation Term="RESO.OData.Metadata.LookupName" String="..."/>`, plus a `Lookup` entity set
  (`LookupKey`, `LookupName`, `LookupValue`, `StandardLookupValue`, `LegacyODataValue`, `ModificationTimestamp`).
- **Relationships:** `Habitat` → `Settlement`, `EarliestArrivalWindow`; `Habitat` ⇄ `Modules`, `LifeSupportSystems`,
  `ConsumablesReserves`, `ResourceClaims`, `Showings` (with `Partner` + `ReferentialConstraint`); `Member`/`Office` → `Settlement`.
- **RESO Common Format** payloads use `{"@reso.context": ..., "value": [...]}` (RCP-25). The context URN is
  `urn:example:marsdd:metadata:0.3:resource:<name>` — **deliberately not** `urn:reso:`, which is an IANA-registered RESO
  namespace. Mars DD is not a RESO standard and must not look like one. To run RESO tooling that requires `urn:reso:`,
  rewrite the context in a private test harness only.
- **Annotations:** `Core.Description` on every property; `MarsDD.Vocabulary.*` terms carry Source, PrivacyClass, Units,
  Rules, Reso21Equivalent, MarsStatus.

## Schema extension keywords

`x-source` (Sources sheet ID) · `x-privacy` (Public / Restricted / Confidential) · `x-rules` · `x-units` · `x-lookup` ·
`x-extensibility` · `x-reso21Equivalent` · `x-marsStatus` · `x-crs`. Validators must run with unknown-keyword tolerance
(Ajv: `strict: false`).

## Privacy

`Restricted` fields (exact coordinates, internal addresses, consumable reserves, member identity, dose data) and
`Confidential` fields must be stripped from public syndication feeds. Enforce at the API layer by `x-privacy`; don't rely on consumers.

## Known limits (honest list)

- **Expert review still required:** 79 of 163 fields (48%) rest on author assumption (Source `S12`). CI proves consistency, not truth.
- **Illustrative example values:** shielding (560 g/cm², assuming ~1.6 g/cm³ overburden), dose rate, leak rate, and
  `OneWayLightTimeSeconds` (560 s; not ephemeris-computed). R13 checks only the physical range.
- **Not RESO-certified.** Metadata follows RESO conventions and passes OASIS tooling, but RESO's certification
  tools have not been run (they expect `urn:reso:` contexts and a live Web API server).
- **Geometry on the OData wire** is GeoJSON serialized as `Edm.String`: OData geography types assume Earth (SRID 4326).
  JSON Schema and RCF payloads carry it as a structured object. A Mars SRID (IAU-registered CRS) is a 0.3 candidate.
- **Vocabulary reference** points to the OASIS Core vocabulary URL; tools resolve it only when online.
- **Mars24 accuracy** is the published algorithm's (~0.01° Ls); not a substitute for SPICE-grade ephemerides.

## Sources

See the **Sources** sheet in the workbook (S01–S12), including Mars24 (NASA GISS), IAU WGCCRE 2015 report,
MOLA, the Outer Space Treaty, the COSPAR Policy on Planetary Protection (2026 version), Hassler et al. 2014 (MSL RAD),
ISO 4217, RFC 7946, and JSON Schema 2020-12.
