Architecture
Xue packs weather runs and observation windows into per-variable Zarr v3
stores and plays them back in a static browser page. The layout began as a
single-file container, .xue: no longer published or written unless a
build asks for it (--xue, container=True), and read by every decoder
forever, since published runs and cases carry it and are never rebuilt.
Both encoders write each store straight from the codes they quantized.
Normative specs, which win over this page: zarr-profile.md, bundle.md, format.md, encoder.md, stac.md. Why the format looks like this: architecture-rationale.md.
Map
xuebuild/— Python pipeline and reference encoder (pipeline.md).sources.py/variables.pyregistries;feeds.pyper-family fetchers overfetch.py+idx.py+grib2.pyrange fetches;binconvert.pythe conversion, in stages overdiscover.py,grid.py,derive.py,ladder.py,metadata.py,poster.pyandreport.py(each beside itsencode/*.rs);quantize.py,temporal.py,binformat.pycodebooks, residuals, container I/O;observation.pyNetCDF ingest;model.pyshared shapes (SourceFrame,PlaneSource);manifest.pymanifest + pointer;zarrstore.pystore export (delivery.md);encoder.py/native.pyencoder dispatch;assemble.pysplit builds;stac.pycatalog;showcase.pycases;satellite/(sources.md);tc/,airport/,sounding/(point-products.md);gdal.py,eccodescli.py,om2nccli.py,jmacli.pytool wrappers;zstdcli.pyin-process zstd.rust/xue/— decoder (src/decode/), byte layout (src/format.rs), Zarr read geometry (src/zarr.rs), native encoder (src/encode/,encoderfeature).rust/xue-wasm/— wasm bindings, built intoweb/src/wasm/(generated).rust/xue-py/— thexuepywheel, imported asxue: native encoder, decoder,gdal_info.rust/xue-worker/— read-only data API (delivery.md).web/src/— frontend (frontend.md).tests/— Python tests, fixtures andprepare_*.pygenerators;tests/web/vitest,tests/e2e/Playwright (testing.md).
Three implementations, one format
Encoder, Rust decoder and TypeScript frontend must stay in agreement.
The order of change and the parity rule (the Python encoder is the
reference; the native encoder, rust/xue/src/encode/, linking GDAL,
grib-rs and zstd, writes identical bytes) are in
.claude/rules/cross-implementation.md
and encoder.md.
xuebuild/encoder.pyconverts through the wheel by default;XUE_ENCODER(auto|native|python) overrides, and which workflows pin it is inencoder.md.- The native encoder writes the stores itself (
encode/zarrstore.rs, held tozarrstore.write_store) but no pointer.native.pystamps the shared stores’ CRCs into the manifest and only then writes the pointer, whose CRC32 covers the finished manifest. - The
encoderfeature is off by default because it links GDAL and the decoder must not. Profiles inrust/Cargo.toml(Cargo reads them only from the workspace root):releaseis tuned for the wasm decoder,encoderinherits it atopt-level = 3.
Delivery contract
- The live pointer (
latest.jsonfor GFS,latest-<model>.jsonotherwise; schema v1) is the only mutable object per source. Uploading it takes a run live. - Everything it names,
manifest.json(schema v5) and every artifact under<model>.<run>/, is immutable and addressed with?v=<crc32>. The optionalcolumnsentry (the column store, the Zarr profile’s fourth branch) is cut by thecolumnsjob before finalize and named in the one manifest finalize writes (a run already live without it gets it by a second manifest and pointer write); a run without it reads exactly as before. - Manifest paths resolve relative to the manifest URL, so a run can be
served from the site or the bucket (
VITE_DATA_BASE_URL,web/.env.deploy). Production hostnames reach the frontend only throughweb/src/site/site.ts. - Shell first: a new shell accepts old manifests, an old cached shell
rejects new ones. When, and what counts, is in
releasing.md. - The bundle set is not schema. The three validators
(
xuebuild/manifest.py,rust/xue/src/encode/manifest.rs,web/src/data/manifest.ts) admit avariableby shape alone (^[a-z][a-z0-9]*$, unique). The only closed set is the source’s core (SourceSpec.core_bundle_ids, mirrored asMODEL_CORE_BUNDLESandcoreBundles), required on a live run. The shell draws an unknown bundle generically. numericId/variableIdis file-local: variables are numbered 1..n in bundle order (vector: 1 = u, 2 = v). Identity is the GRIB2parameterblock (plusaerosolwhere species share a triple,ensemblewhere a statistic of an ensemble shares its field’s), read byweb/src/data/identity.ts; the id string is only a naming convention. Never key across sessions bynumericId(web/src/data/sessionkeys.tsscopes keys per session).
Container versions
FixedHeader.version (format.md §“Container v2”):
- v1 plane-major: a payload is one plane of one frame (
IDX1+PlaneEntry). - v2 tiled: a payload is one tile × one temporal group × one variable
(
IDX2+ variable, group and chunk tables). Order group → tile → variable makes a group, a viewport’s tile row, and a cell’s series (one chunk per group) cheap range reads.
Tiling changes storage only, not metadata, codebooks or residual arithmetic. Encoders write v2; decoders must keep reading v1.
Bundle metadata schema versions
schemaVersion in the bundle metadata JSON is the lowest version a reader
must implement (separate from manifest v5 and pointer v1). v1/v2 are legacy
whole-hour axes; v3, written now, adds the parameter block and a
unit-neutral axis (unitSeconds + firstFrameOffset + frameStep |
frameOffsets).
unitSecondsmust be the coarsest unit that fits (3600 for forecasts, an observation’scadence_secondsotherwise). Decoders reject unimplemented and overdeclared versions, so each file has exactly one valid encoding.- Optional v3 blocks
band,producer,aerosol,ensembleare validated by all readers when present, raise no floor and are ignored by older readers, so adding such a block is one-sided. - A plane is keyed by frame offset, never forecast hour
(
PlaneEntry.frame_offset, the worker’sframeOffset,SourceFrame.lead_seconds). - Must agree:
metadata.py::build_metadata,binformat.py::_parse_metadata,rust/xue/src/decode/metadata.rs,web/src/data/manifest.ts::parseBundleMetadata.
Decoder
rust/xue/src/decode/: Bundle (whole file) and StreamingBundle
(structural prefix, payloads fed in as ranges arrive) in bundle.rs, over
metadata.rs → structure.rs → core.rs (residual replay; its
decode_chunk is also the Zarr decode path in browser and Worker). All
arithmetic on file values is checked; nothing is allocated from a file value
before validation.
rust/xue/src/format.rs holds the byte layout and nothing else. The decoder
unpacks and the native encoder packs through it, so fields cannot drift.
External tools
GDAL, zstd, eccodes and om2nc run as subprocesses; NumPy is the only Python runtime dependency. Exceptions and boundaries:
- zstd runs in process (
compression.zstd); there is no CLI path. Its bytes match the native encoder’s only for the same libzstd version. gdal.dataset_inforeads through the wheel’s GDAL (xue.gdal_info) when converting natively, the subprocess otherwise, followingXUE_ENCODER, so a run never mixes two GDALs and the scheduled workflows need no GDAL (tests/test_gdalinfo.pydiffs the two).gdal_translatehas no in-wheel path:XUE_ENCODER=pythonneeds a system GDAL.- om2nc (
XUE_OM2NC) is GPL-2.0-only: an executable on the PATH only; no om dependency may enterpyproject.toml,Cargo.tomlorweb/.
Errors the user must fix subclass XueError (xuebuild/errors.py); the CLI
prints error: … and exits 2. Any other exception is a bug.