Shared libraries for the Mapomo pipeline: ingestion, provenance, unit costs, uncertainty, storage
# core
**Shared libraries for the Mapomo pipeline:** ingestion, provenance, unit-cost
engine, uncertainty propagation, storage adapters.
Everything the four applications have in common lives here, so that a correction
lands once and benefits six countries.
Status: **0.1.0, running.** The six modules are implemented against contract
v0.1.0 and covered by tests. What lands during the Lab is the country coverage
and the calibration, not the shape.
```bash
pip install -e . && MAPOMO_SCHEMAS=../schemas pytest
```
## Modules
| Module | Responsibility |
|---|---|
| `mapomo_core.ingestion` | Bring raw material in and turn it into schema-valid observations. Never prices anything. |
| `mapomo_core.provenance` | Build, validate and hash provenance records. Refuses records without a source. |
| `mapomo_core.costs` | Resolve a unit cost for an observation: country, type, validity, scope, in that order of specificity. |
| `mapomo_core.uncertainty` | Monte Carlo propagation of count, duration and price error, with correlation handling and the coverage penalty. |
| `mapomo_core.storage` | Adapters. The pipeline never talks to a database directly. |
| `mapomo_core.config` | Load and validate a country configuration. The only place a country is allowed to matter. |
| `mapomo_core.entities` | Resolve a raw collector string to a registry entity, following the alias rules of the contract. |
| `mapomo_core.ids` | Identifier form, the normalisation used before every comparison, content hashing. |
| `mapomo_core.validation` | Validate a document against the published schemas. Finds the contract, never vendors it. |
## The rule this repository enforces
**No country-specific code.** A `if country == "NG"` anywhere in `core` is a
defect. Countries are configuration loaded by `mapomo_core.config` and reference
data resolved by `mapomo_core.costs`. If the engine cannot express what a country
needs, the engine gains a general capability; the country never gains a special
case.
See ADR 0 …