Processing extension contract#
SAFE ingestion belongs to raster core in every build. The optional Sentinel-2 processing extension owns surface reflectance, atmospheric lookup/correction, and processing-specific geometry, QA and visibility. The common C ABI exposes its Rust implementation to thin C++ and Python bindings. Applications can also compose public raster operations without registration.
extension-sentinel2 selects the processing implementation under
extensions/sentinel2/. It does not select SAFE I/O or physical-model
availability. The ownership inventory locates each
source and public surface; the capability matrix describes
execution support. Inclusion establishes no qualification claim.
One distribution and one native owner#
cugeo-raster has one distribution and coordinated release. Standard artifacts include the delivered first-party processing extensions. Inclusion neither invokes a processor nor downloads its dependencies or data. Python extras add optional dependencies; they do not select Python files or compiled extensions. Redistribution clearance remains a separate requirement.
Processing extensions link into libcugeo_raster.so, selected by
Cargo features. They
use the same core instance, native handle owners and resource accounting.
There is no generic plugin registry, callback registration or plugin loader.
The physical Sentinel model has a separately built optional native-artifact
boundary to isolate its ERFA 2.0.1 dependency. Its installed Rust, C, C++ and Python interfaces expose explicit preparation
and CUDA direct grids independently of processing selection. Linked execution
requires separate qualification.
Explicit physical preparation is the activation boundary for that artifact,
its astronomical preparation and caller-supplied physical resources. Core
imports, ordinary opening, catalog access and capability inspection remain
independent of those resources. This exception adds no generic plugin registry
or separate distribution.
An application can build a consumer library against the installed public C ABI. The processing author guide and its executed host example show this composition. That application artifact remains outside the cugeo-raster distribution and registers no first-party extension.
Dependencies follow this direction:
Rust extension API C ABI -> C++ and Python bindings
\ /
product and sensor policy
|
core I/O, grids, sampling,
terrain, memory and completion
|
codec/CUDA leaves and cugeo-proj
Core owns reusable raster operations, generic TIFF/JPEG2000, RPC polynomial evaluation and transformation, registered geolocation arrays and their inverse, and sensor-independent geometry. cugeo-proj owns terrestrial and vertical coordinate transformations. Astronomical preparation for the optional physical model belongs to that artifact and its prepared owner, using ERFA 2.0.1. An extension consumes these facilities; it does not copy a CUDA inverse, projection engine, allocator, decoder pool or completion owner.
Source layout and public names#
The required extension identifier is lower snake case, such as sentinel2.
Cargo uses extension-<identifier>, with underscores changed to hyphens in the
feature name. The Sentinel extension uses extension-sentinel2.
The source and installed interfaces use these locations:
Surface |
Location and interface |
|---|---|
Rust |
|
Core SAFE implementation |
|
Core SAFE C adapters |
|
Radiometry |
|
Radiometry C adapters |
|
Specialized kernels |
|
C declarations |
The single installed |
Core C++ SAFE catalog |
|
C++ radiometry |
|
Core Python SAFE catalog |
|
Core Python group reader |
|
Python processing |
|
The Rust crate exposes the external source directory through one explicit
#[path = "../extensions/mod.rs"] pub mod extensions; declaration in
src/lib.rs. The surface_reflectance module in extensions/sentinel2/mod.rs has
#[cfg(feature = "extension-sentinel2")]; its CUDA-only items additionally
require cuda. Omitted processing Rust APIs compile out. The physical module
remains available in every selection. Physical
preparation reports typed missing-artifact errors, and device preparation also
requires core CUDA and a CUDA physical artifact. The API inspector and snapshots
retain each item’s availability conditions. The inspector must follow the
explicit source path within the packaged crate and retain fail-closed
resolution. Complete source archives contain this directory, including excluded implementations;
compiled artifacts contain only their selected implementation. Python package mappings
install the extension-owned sources into the namespace above; package selection
does not remove their thin declarations. Core SAFE types retain their existing ordinary and I/O facade exports.
The core SAFE implementation has one owner across all facades. No extension catalog aliases or forwarding namespaces are installed. C names retain their sole spelling, and every selection shares one header and ABI snapshot.
Ordinary SAFE opening#
cugeo.raster.open(path) opens admitted SAFE products and granules through the
core catalog. Typed subdataset names reopen their selected group through the
core group reader. Discovery preserves identity, ordering, XML metadata and
selected-source ownership. product.open_band(...) returns an ordinary
DatasetReader backed by the shared JPEG2000 source; asset and grouped readers
retain their native-grid/raw-sample contracts.
Catalog parsing and metadata discovery require no processing code, physical module, atmospheric resources, CUDA or codec activation. Device pixel execution requires its independently selected JPEG2000 backend and retains ordinary backend/error admission. Core-only SAFE opening uses the same validation and errors as standard opening. Discovery and import never download resources. See the SAFE contract for admitted profiles, groups, metadata and raw reads.
Build selection and availability#
Select extensions independently of backend features:
Selection |
Cargo features |
Source-wheel setting |
|---|---|---|
Standard |
|
Unset |
Core-only |
|
|
Selected |
|
|
The wheel setting accepts all, none or a comma-separated list of known
extension identifiers. Empty or unknown identifiers, duplicates, and lists
that mix all or none with identifiers or with each other fail the build.
It controls Cargo selection through
config/production-build.txt,
the existing build/package authority. Selecting an extension cannot silently
drop it. Selecting a backend with missing build inputs also fails explicitly.
The supported initial matrix is standard-complete and core-only, with focused
selection/omission checks; it promises no exhaustive combination matrix.
Extension selection is independent of backend selection. Catalog parsing needs
neither CUDA nor a codec. Sentinel device reads need the existing cuda and
nvjpeg2k features and admitted inputs; radiometry CUDA primitives need cuda.
extensions-all does not enable NVIDIA backends. Core-only may still enable a
backend for generic raster operations and raw SAFE reads. cugeo-proj remains a base dependency.
Wheel/sdist generation, Cargo packaging and CMake installation use the selected library and package the complete headers and thin bindings. For omitted extensions, the common C ABI retains callable stubs and installed Python/C++ declarations remain thin adapters to that ABI. Rust extension APIs compile out under their documented feature conditions. Omitted implementations, specialized kernels and extension-only runtime artifacts are excluded. Reusing a package directory must not leak a prior build’s artifacts. CMake installs the supplied Cargo artifact; it does not make a second extension selection. A prebuilt wheel input must report the requested extension set and backend selection.
The cugeo_raster_capabilities JSON reports the object
"extensions":{"sentinel2":true} in a standard build and false in a
core-only build. Every known extension has an explicit boolean. This reports processing inclusion only. It does not describe core SAFE I/O,
physical-model availability, runtime readiness, schema admission or qualification. The existing Python cugeo.raster.diagnostics.capabilities()
exposes the same fact. Unknown or missing required capability fields fail
validation.
An extension needing an external runtime checks or loads it only on explicit use of the operation that requires it. Import, capability queries, core loading and unrelated operations must remain usable without that runtime. Catalog opening activates only catalog work. No current inventoried Sentinel component requires an external Sen2Cor or Sen2VM runtime. An external XDR table is data, not a dependency on the program that produced it. Lazy-runtime isolation is a contract requirement without a current extension-runtime execution result.
Errors and omitted interfaces#
Use the existing native Rust Error enum, C cugeo_raster_error_code and error
record, C++ typed errors and Python exceptions. There is no separate raster ErrorKind
or extension status namespace. Classify by codes, never message text.
Cause |
Native Rust error |
C status |
Python through the common result adapter |
|---|---|---|---|
Omitted extension; unavailable optional runtime or backend; unsupported meaning |
|
|
|
Malformed admitted arguments or metadata |
|
|
|
Short caller storage |
|
|
|
Missing/unreadable explicitly named data file, corrupt admitted source |
|
|
|
CUDA unavailable |
|
|
Common adapter: |
CUDA execution failure |
|
|
|
Capacity retained by pending work |
|
|
Existing busy/result handling, retaining code 7 |
Resource exhaustion or insufficient declared budget |
|
|
|
Missing optional resources discovered by cugeo-proj preserve its established translation: cugeo-proj missing-resource code 10 becomes raster unsupported code 2. A selected missing local asset uses I/O code 4. Neither condition uses buffer code 3 as a general resource code. Pixel-level coordinate, terrain and sensor failures retain pixel statuses 3, 4 and 5, distinct from these call-level statuses.
Rust processing APIs compile out when their feature conditions are false.
The omitted C implementation uses Error::Unsupported internally; it does not
create a public Rust stub surface. C declarations, value records and exports
remain available, as do the installed Python/C++ thin declarations:
Interface shape |
Required omitted behavior |
|---|---|
Rust processing items |
Require |
Python/C++ construction or execution |
Imports and thin declarations remain available; omitted operations call the common C ABI and report typed unsupported code 2. |
C processing create/open or returned processing handle |
Validate required output slots, clear writable handle outputs to null, then return 2 without opening files or loading runtimes. |
C versioned record output |
Apply the existing size/flags/reserved-field checks. An invalid header returns 1 without overrunning the caller record; a valid record is initialized through the shared helper, then returns 2. |
C string/count query |
Initialize writable counts to zero and a writable nonempty string to an empty NUL-terminated string; validate required control pointers and null-buffer/capacity pairs, then return 2. No omitted query reports successful empty discovery. |
C |
Shared |
C |
Null is a no-op. An omitted implementation has no valid live object to release; its disabled release follows the existing no-op stub convention, has no status and does not dereference the pointer. Handles from another library instance or artifact are outside the contract. |
Required pointer, size, alignment, accessible-extent and control-alias policies
remain owned by the existing FFI boundary. Disabled processing operations do not inspect
product payloads or manufacture successful handles. There is no promise of
diagnosing arbitrary invalid foreign pointers. Python closed-object and
argument-shape errors keep their existing ValueError/TypeError behavior.
Memory, streams and receipts#
The array contract, pixel execution contract and memory-resource contract remain authoritative. Extensions use existing raster views, native descriptors, memory resources, admissions, source handles and completion chains. No adapter introduces another memory owner or interprets a handle from a different core.
Caller output retains its identity, dtype, residency and admitted strides. Python imagery follows scalar HW/sequence CHW and batch NCHW rules. Writable samples and forbidden input/output aliases remain caller non-overlap obligations; extensions do not add runtime pixel-alias validation. Pointer extent, context and control-record safety checks remain in force.
Host execution is synchronous. Ordinary GPU reads retain selected-stream ordering and their documented error-observation waits. Python CUDA calls use the shared current-CuPy-stream selection on omission, explicit overrides and prepared/session inheritance as specified by their interfaces. Native calls receive the resolved stream, including default streams. Surface-reflectance calls currently synchronize their caller stream; moving them does not turn them into asynchronous operations. Retain arrays, backing allocations, streams, decoders, prepared state and auxiliary resources through completion and failure draining. A failed fallible close preserves its owner for retry under the existing context-restoration policy. A band source and copied metadata survive catalog closure.
Budgets count whole retained allocations and overlapping live work, including staging, scratch, prepared tables and outputs according to their existing owners. A view does not shrink its backing charge. Capacity held by pending work remains distinct from exhaustion. Use existing operation receipts for backend, transfers, allocations, waits, fallback and unknown foreign costs; do not fabricate zero costs. Composition adds no rollback, per-query attribution, isolation or run-to-run determinism guarantee.
Metadata and independent references#
An extension’s reference description must identify the following facts. Keep source metadata, effective operation configuration and execution evidence distinct. These requirements do not introduce a metadata registry or persisted format. Existing source catalogs describe source facts; typed operation inputs and receipts describe processing. Unavailable facts remain unavailable.
Required fact |
Representation and interpretation |
|---|---|
Identity |
Stable extension identifier ( |
Configuration |
Effective typed plan parameters, backend choice, interpolation/correction mode, band selection and explicitly supplied defaults; record them with the result evidence rather than reconstructing them from message text |
Inputs |
Ordered physical band IDs and stored representations, dtype/precision, raw DN or physical units, scale/offset source state, source identity and admitted level/schema/profile |
Outputs |
Ordered bands and their units/dtype, explicit conversion/calibration, grid shape/transform/CRS and pixel registration; distinguish a physical result from encoded DN |
Validity and QA |
Nodata, saturation and masks with independent availability and units; named QA bit/category meanings and resampling rules; pixel status is not a QA class |
Auxiliary resources |
Explicit caller-supplied paths/bytes, content identities, provenance/licence, reference/configuration revision, applicability and coverage for LUTs, DEMs, geoids, calibration, orbit/attitude and Earth-orientation inputs |
Comparison |
Independent reference/build/configuration and resource identities, complete nonempty comparison population, exactness or justified tolerances with units, and separate input, encoding, interpolation and model errors |
Reuse MetadataCatalog, MetadataValue, native band records, GeoGrid,
georeference/geolocation descriptors and existing receipts where applicable.
Do not relabel generated processing facts as MetadataOrigin::SafeProduct or
infer a value from numeric convenience defaults. Persist raster data and
metadata through the supported raster/Arrow/GeoArrow/Parquet/WKB representations;
there is no custom extension file format. Resources are explicitly acquired;
neither a missing table nor a missing geoid authorizes a download.
For the existing Sentinel catalog, the algorithm is native SAFE catalog and raw
band access. Sentinel2BandMetadata and Python Sentinel2Radiometry preserve
the difference between absent, numeric and not-applicable source offsets and
optional conversion. Reads do not apply reflectance calibration. Stored
resolution, JPEG2000 discard level and output sampling are separate choices.
L1B source footprint/angles are descriptive text, with no invented map affine,
CRS or physical sensor accuracy. Stored TCI, classification, probability, AOT and WVP planes remain core raw
assets/groups; their presence is separate from computed processing QA.
GDAL 3.8.4 defines raster metadata and raw-pixel comparisons; the pinned Rasterio reference defines the applicable Python presentation. Neither is a runtime fallback or an oracle for physical sensor location. Sen2Cor-compatible table parsing and individual radiometry primitives do not establish a complete Sen2Cor processor or equivalence campaign. A physical Sentinel implementation requires its independent sensor reference, approved frame/terrain/resource envelope and justified numerical acceptance. Existing offline Sen2VM direct-node evidence does not by itself qualify a native installed physical model, every spacecraft or absolute accuracy.