aihydro-core
Robustness substrate for the AI-Hydro ecosystem.
Provides the single hashing and provenance vocabulary (content_hash, param_hash,
ProvenanceRecord) shared across all AI-Hydro packages, plus the Store protocol and
AsyncJobRegistry used by higher-level layers.
Zero heavy dependencies — pure Python stdlib. Designed to be the lowest layer in the stack so it can be safely depended on by any AI-Hydro package without pulling in numpy, pandas, or geo libraries.
Scientific records (aihydro_core.records)
The canonical record contract for runs, evidence and bundles (AI-Hydro 2040 program, ADR-001). It is stdlib-only.
digest(obj)returns asha256:<64 hex>digest of a strict canonical encoding (aihydro.c14n/1). This is a small Python tagging step followed by the JSON Canonicalization Scheme (RFC 8785), so any JCS implementation, for example in TypeScript, can verify digests. Golden vectors are intests/data/c14n_vectors.json. Unknown types raiseUnencodableErrorrather than being stringified, so abbreviated reprs (large arrays, DataFrames) can never alias. Masked-array masks, structured-dtype field names, big integers, non-finite floats, dates, bytes and sets all have tagged, deterministic encodings.RunRecord(schemaaihydro.run/2) records a run's tool, version, input and output digests, input references, parent runs, environment digest, actor and an explicitrecord_error.seal()andverify()detect accidental or unsophisticated modification. A seal proves integrity, not origin: anyone who can write the record can edit it and re-seal it. Origin needs a signature or an independent store. Unknown fields round-trip unchanged.ClaimRevision(schemaaihydro.claim_revision_record/1) is one sealed, append-only revision of a claim:session_id,claim_id,revision(>= 0),supersedes(the previousrevision_digest),revision_digest(digest of the authority fields, computed by the writer),content,cause({tool, run_id?, reason}), a requiredactor,recorded_atandrecord_digest.verify_chain()checks a claim's whole chain. The same integrity-not-origin caveat asRunRecordapplies.BasinRef/OutletRef/ReachRef/PlaceAlias(records/place.py, ADR-003) are the canonical place-identity types, withto_dict/from_dictthat preserve unknown fields.BasinRef.idis"aihydro:basin:" + digest(anchor), where the anchor is{kind, network, network_version, element}; aliases and geometry are excluded, so the id is stable when an alias is added or the polygon is re-delineated. Different delineation methods give different ids; sameness across methods is asserted by shared aliases or an explicit comparison record.verify_basin_ref_dictrecomputes the id. This package defines the types and algorithms; aihydro-watershed is the only minter.geometry_id(geojson)implementsaihydro.geom/1: EPSG:4326 lon/lat quantised to 1e-6 degrees (integers), duplicate and closing vertices dropped, degenerate rings dropped, exterior CCW / holes CW, rings rotated to the smallest vertex, holes and polygons sorted, Polygon emitted as a one-member MultiPolygon, thendigest(). It is invariant to ring rotation, reversal, duplicate vertices and hole/polygon order, and not tolerance-invariant: a coordinate that crosses a quantisation boundary changes the digest, which is why identity is the anchor and the digest names only one geometry realisation. Antimeridian-crossing polygons must be split first (crosses_antimeridianflags them). Golden vectors are intests/data/place_vectors.json;tests/data/place_crosscheck.jsre-derives them independently in Node.Bundle(schemaaihydro.bundle/1,records/bundle.py) is the sealed identity of one session's evidence set: content-addressedobjectsplusrecordslocated by JSON Pointer (~0/~1escaping).bundle_idcovers{schema, session_id, objects, records}only; assessments (created_at, the replay level, recordcoverage, gates) sit in the sealed envelope. It points at records and never copies them.aihydro.entry/1(records/entry.py) is the generic body binding: the digest of a row minus itsrecordkey. Golden vectors:tests/data/entry_vectors.json.ReplayStatusstays at five values. Partial coverage is a separatecoveragerecord, not an enum member;read_legacy_replay_statusmaps the persisted stringarchive_integrity_partialto(ARCHIVE_INTEGRITY, complete=False).environment_fingerprint(...)describes the running interpreter, platform and named distributions.ReplayStatusnames what a replay established:not_performed,archive_integrity,cross_check,recomputedorindependently_reproduced(a new researcher, same data; Essawy et al. 2020 / NASEM 2019 reproducibility). The platform never asserts replicability (new data). The old persisted spellingindependently_replicatedis still read and maps toindependently_reproduced. Mapping to Essawy:archive_integrityis the sub-floor prerequisite,cross_checkis internal consistency (no re-fetch, no recomputation),recomputedis repeatability/runnability (the recomputation entity must record actor and machine).
RO-Crate export (aihydro_core.export)
A deterministic projection of a sealed Bundle into an RO-Crate 1.3 /
Process Run Crate 0.6 ro-crate-metadata.json (stdlib only; ADR-005).
to_rocrate(bundle, records, bodies, files, license=None) builds it;
validate_crate(dir) checks structural MUSTs plus honesty, claim-basis and
privacy rules by id; verify_crate(dir) re-verifies every file digest and
record seal, re-checks body bindings and claim chains, regenerates the crate
from the bundle and byte-compares it with the shipped one. CLI:
python -m aihydro_core.export.rocrate {validate,verify} DIR. Exit codes:
validate 0 (no errors) or 1; verify 0 (ok), 1 (failed) or 3 (verified but
partial: privacy-withheld records or heads, or only unsealed rows; --json gives
status and partial_reasons, so a consumer can reject partial results by
policy). The crate states that integrity is not origin. Its few AI-Hydro terms
live under an unregistered namespace (PROFILE_NS, OPEN-8); the crate
claims no AI-Hydro profile. Golden fixture: tests/data/rocrate/capsule/.
Legacy 16-hex content_hash/param_hash values are a different algorithm.
They remain valid as cache keys and are not mapped onto record digests.
Install
pip install aihydro-core
Part of the AI-Hydro ecosystem
- aihydro-data — global hydrology dataverse
- AI-Hydro — AI-native hydrologic modelling platform
Citation
If you use aihydro-core in your research, please cite:
@software{aihydro_core_2026,
title = {aihydro-core: Zero-Dependency Substrate for Scientific Defensibility},
author = {Galib, Mohammad and Merwade, Venkatesh},
year = {2026},
version = {0.2.0},
doi = {10.5281/zenodo.20823444},
url = {https://doi.org/10.5281/zenodo.20823444}
}
Metadata
Release files for aihydro-core 0.2.11
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| aihydro_core-0.2.11.tar.gz | 146.4 kB | Without provenance | Details for aihydro_core-0.2.11.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| aihydro_core-0.2.11-py3-none-any.whl | Python 3 | none | any | Details for aihydro_core-0.2.11-py3-none-any.whl |
Total release size: 254.2 kB
Release files / aihydro_core-0.2.11.tar.gz
| Download URL | aihydro_core-0.2.11.tar.gz |
|---|---|
| Size | 146.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e1957c499bedac0fd82e2c28bf6c43d796d54795021c82a761405032ed0d7350
|
|
BLAKE2b-256 checksum How to use checksums |
5d759d7f4f51d8d075ab7ff1163d0ed2f254c6041761d9bf9f799fd8651e967f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.2
|
Release files / aihydro_core-0.2.11-py3-none-any.whl
| Download URL | aihydro_core-0.2.11-py3-none-any.whl |
|---|---|
| Size | 107.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
40f5fc60e2005217cf09959d726a4c4eb833ed679ecd596f3b49755ef2ce3ac3
|
|
BLAKE2b-256 checksum How to use checksums |
c797388f19f6427ff6eb80d0e9ec23cddd60ff9b8409e06f9c44e300d3b33f40
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.2
|
Security for aihydro-core 0.2.11
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.