Delivery: stores, catalog, API, uploads
The pointer/manifest contract is in architecture.md; running uploads is in publishing.md.
Zarr store
Every bundle of one resolution tier of a run or round is published in one
shared store, bundles.zarr/ / bundles.<tier>.zarr/ (profile 2; a series
store and every run published earlier are one store per bundle, profile 1);
zarr-profile.md is normative. Choices the spec does
not explain:
- One store per tier, not per bundle. A per-bundle store repeated its
group document and three coordinate arrays (seven objects) beside every
bundle’s few shards: 88 % of the objects a run wrote, at a Class A
operation each. Shared, they are written once per tier; the group
document is then the one object several bundles share, so it is a merge
of per-bundle parts written last (
assemble-runin a fan-out) and its CRC-32 is every entry’s?v=. - One shard per array (whole axis, whole grid). A bucket bills per object: per-time-chunk shards made a GFS run ~5 000 objects. The shard index, one suffix range, is the whole index. Readers take the shard length from the chunk shape, so earlier per-time-chunk stores still read.
- Inner chunks are regular six-frame chunks of the bundle’s tiles. They match the container’s temporal groups only up to the first step change, so every chunk is encoded from the codes, never copied out of a container.
Writing:
- A build writes each bundle’s arrays straight from its codes:
binconvertper bundle job throughzarrstore.write_bundle_arraysover aCodesSource(NumPy only), the native encoder throughencode/zarrstore.rs, both with up to four tiers in flight over one compression pool, then the store’s part and group document (write_part,finalize_store; the native path’s group document is written byxuebuild/native.py, encoder.md). A bundle’s arrays are a function of the metadata, the codes, the tile, the predictors and its dimension names, so no container is read;tests/test_native.pyandtests/test_zarr.pyhold the two writers byte-identical. Every chunk is decompressed again and compared after compression, and the native writer parses each document and index back with the decoder’s own validators. - A tier’s manifest
bandwidthhint is computed from the delivery it ships: the container’s size where one is written, the store’s otherwise. build-binandshowcase buildwrite the stores alone and the manifest names nothing else;--xue(container=Truein the Python and wheel APIs) writes each bundle’s.xuebeside its store and names both. A store is never derived from a finished.xue.- The
zarrdependency group is for tests and for reading delta stores with zarr-python (xuebuild/zarrcodec.py).
Manifest: a bundle entry and each variant may carry zarr: {path, byteLength, crc32} (crc32 of the group zarr.json, also the store’s
?v=, the same on every entry naming a shared store; byteLength the
bundle’s share), validated by all three validators and stamped by
assemble-run. Entries of one tier share the store’s path, the one
exception to the validators’ unique-path rule. The container fields are present whole or absent whole; an
entry with neither delivery is refused.
Browser (web/src/decode/zarr/, the default channel unless ?backend=xue):
- Fallback order: store by ranges →
.xueby ranges →.xuewhole → store by whole objects (only when there is no container). Probes stream or fail. decode/zarr/worker.tsspeaks theworker.tsprotocol. The format is read in wasm (rust/xue/src/zarr.rsthroughrust/xue-wasm): the group and array documents, the CRC-32C-checked index once per shard, the span of a frame’s tile (a chunk may straddle container groups), the decoded tiles of the time chunk being read, the frame assembled from them and a cell’s series.store.tscoalesces one shard’s ranges per microtask (gap ≤ 64 KB), keeps at most sixteen of a worker’s requests on the wire, and asks again (after 250 ms, then 1 s) for one that died there: every request to the origin rides one HTTP/2 connection, and an edge that closes it takes all of them at once. A request that goes quiet — no response, or no further piece of its body, for ten seconds — is aborted and asked again the same way. A request on a connection the edge closed is not always answered or failed (in Safari a pinned point’s rows were seen to stay empty with no error after one), and one that never settles would keep its place under the limit for good, sixteen of them leaving a worker that reads nothing. Range support is probed once per object (sessions.ts), and the probe’s byte is read rather than cancelled.- A layer’s session has a worker to itself. A pinned point’s sessions —
one per meteogram row, and four per pressure level with a model column on
the chart — share at most four hub workers (
decode/zarr/hub.worker.ts), each hosting many channels: the loop is the same one (decode/zarr/endpoint.ts), the messages travel in an envelope naming the channel, andchannel.tshands the session aDecodeChannelthat hides it.probepanel.tsopens them six at a time. A hub outlives its channels, so closing one frees its reader’s WASM memory (ZarrReader.dispose) once its reads in flight have returned; a dedicated worker frees everything by being terminated. - Compressed chunks sit in an LRU under
payloadBudgetBytes(budget.ts::zarrPayloadBudgetBytes), bounding memory by the prefetch window rather than the axis; a decode re-fetches what eviction took. - A tab that refuses a live manifest or cannot open a live store reloads
once per manifest (
primaryswitch.ts::reloadForNewerShell), the insurance behind shell-first deploys. tests/web/zarr.test.tsholds frames and series byte-identical to the.xuepath;npm run measure:backendscompares backends.
STAC catalog (xuebuild/stac.py)
A static STAC 1.1.0 catalog beside the shell’s JSON; the frontend never reads it. stac.md defines the documents, including the point products'.
- Every document is a pure function of the manifest (or a point
product’s
index.json), the catalog row andsources.py: no timestamps, no hosts, relative links. So the split-build and top-up identity tests cover them. - Written by the CLI, not the converter:
build-bin(whole run),assemble-run,xue stac. A--bundlespiece writes none. Point products write theirs in their own build, after the index and the pointer (write_point_product_documents). - The live Item
<source>/item.jsonis the run’s Item relocated (relocate_item) so its path outlives the run. - Licence and provider prose:
xuebuild/stac_prose.json, held to the registry bytests/test_stac.py.stacindex.pyrenders the rootindex.htmlfrom the same prose; its hostnames mirrorweb/src/site/site.ts. - Uploads: the run Item no-cache with the manifest; Collection, live Item
and root through
upload-r2-stac-collection(run byupload-r2-pointer); showcase documents byupload-r2-showcase; a point product’s byupload-r2-<product>.
Data API (rust/xue-worker)
The endpoint contract is api.md. Production runs the crate as
the native xue-api-server on a self-hosted origin behind a Cloudflare
Tunnel (api-origin.md); no Worker is deployed, and the
Workers build runs only under wrangler dev. What follows is how the crate
is built; the Worker-specific parts (R2 binding, wrangler dev, upload
size) apply to that build only.
- Resolves Collection → pointer → manifest, reads stores by R2 range
(
DATAbinding) and decodes with the crate’sdecode_chunk. - The point products go through
products.rs(pointer → index, theissue=pin, the spatial selection, one cached range read per station) and a module per product (sounding.rs,airport.rs,synop.rs,tc.rs) that only reshapes the product’s JSON: compact rows to objects, fixed point to units, epoch seconds to ISO. The products’ goldens undertests/fixtures/<product>/expected/are their test bucket, so a change to a product’s schema that regenerates a golden also runs these tests. Adding a product is aPRODUCTSrow plus a module; the routes are listed inroute.rs. - Read geometry lives IO-free in
rust/xue/src/zarr.rs, held to zarr-profile.md. The browser reads through the same code (rust/xue-wasm/src/zarr.rs); it keeps the requests and the cache of compressed chunks. A point read and the browser’s series share the cell arithmetic (tile_cell) and the chunk decode (decode_inner_chunk). - The binding is
remote: true(honoured bywrangler devonly), somake api-devruns locally against the real bucket;make api-dev-cdn(DATA_SOURCE=cdn) reads the public origin when the network blocks that. timezone.rsanswers the point’s IANA zone fromtzf-rswith its bundled polygon file compiled into the wasm. That file is most of the upload (4.8 MiB uncompressed perwrangler deploy --dry-run, against a 64 MiB limit on every plan; only the uncompressed size counts). The finder opens on the first point request of an isolate, not at startup, so the 1 s startup limit is untouched.- Only
runtime.rsand the framing half oferror.rstouch the Workers runtime;route.rsand the handlers return plain values, socargo test -p xue-workerruns them natively over the web fixtures through an in-memoryDatathat logs every read.
Uploads to R2 (scripts/aws-config)
All uploads go through the AWS CLI ($(S3) in mk/r2.mk).
- One operation per object. R2 bills each multipart step as Class A, and
the CLI’s 8 MiB default split large shards into ~7.
AWS_CONFIG_FILEpoints atscripts/aws-config, which setss3.multipart_thresholdto 5 GB. It names no profile; credentials stay in the environment. The workflows’ credential probe is ahead-object(Class B), not a listing. - Order:
upload-r2-bundles(artifacts), thenupload-r2-manifest(check-pointer, manifest + run Item, thenupload-r2-pointer);upload-r2is both. The pointer goes last because it takes the run live;check-pointerrefuses a pointer that names another run or whose CRC32 disagrees with the manifest on disk. columns.zarrgoes up bymake cut-columnsin the run’scolumnsjob, before finalize: the store’s objects (immutable; the group document carries every shard’s CRC-32, so a changed cut is a new?v=) and their edge warm-up, with the descriptor handed to finalize, which names it in the one manifest it writes, only for a run R2 does not serve yet (a top-up or forced rebuild of the live run never cuts before the flip). A run already live without its store is attached bymake publish-columns: the manifest and Item, then the pointer last, each behind a check that the live pointer still names the run and manifest the job started from (the manifest is rewritten at its own key, as a top-up does; its?v=changes with the pointer’smanifestCrc32). Shards stay under Cloudflare’s 512 MB cache limit per object (up to ~140 MB, a few GB per run) by sharding along latitude.prune-r2runs in its own job after a successful finalize, six minutes late: open pages poll the pointer every five minutes, so one poll has happened by then; a page that missed it keeps reading the old run until its next one.- Nothing is overwritten under an unchanged
?v=(seepublishing.md).