External Solver Integrations¶
TORAX runtime¶
The TORAX caller surface is process-isolated. Importing these contracts does not import TORAX or JAX. Runtime outcomes preserve the complete backend DataTree, while semantic consumers use the deterministic review-only envelope.
Stable, TORAX-free caller surface for real TORAX execution.
- class scpn_fusion.integrations.torax.ToraxArtifact(sidecar_path, sidecar_sha256, sidecar_bytes, manifest_path, manifest_sha256, format='NetCDF-DataTree')[source]¶
Bases:
objectChecksummed complete TORAX output and its inventory manifest.
- Parameters:
- class scpn_fusion.integrations.torax.ToraxClock(domain, epoch, initial_ns, final_ns, timeout_s, max_steps, reset_policy)[source]¶
Bases:
objectExact simulation-monotonic clock and bounded execution policy.
- Parameters:
- classmethod from_dict(value)[source]¶
Parse a strict clock object.
- Return type:
- Parameters:
value (object)
- class scpn_fusion.integrations.torax.ToraxConfigBinding(name, config_path, unit, interpretation, value)[source]¶
Bases:
objectExact typed-to-backend overlap assertion using a JSON object path.
- class scpn_fusion.integrations.torax.ToraxFailureCode(*values)[source]¶
-
Stable failure codes exposed independently of TORAX implementation types.
- classmethod from_sim_error(name)[source]¶
Map every TORAX 1.4.3
SimErrorname one-to-one.- Return type:
- Parameters:
name (str)
- INVALID_REQUEST = 'INVALID_REQUEST'¶
- BACKEND_UNAVAILABLE = 'BACKEND_UNAVAILABLE'¶
- BACKEND_VERSION_MISMATCH = 'BACKEND_VERSION_MISMATCH'¶
- CONFIGURATION_REJECTED = 'CONFIGURATION_REJECTED'¶
- TIMEOUT = 'TIMEOUT'¶
- PROCESS_FAILURE = 'PROCESS_FAILURE'¶
- OUTPUT_SCHEMA_MISMATCH = 'OUTPUT_SCHEMA_MISMATCH'¶
- PROVENANCE_FAILURE = 'PROVENANCE_FAILURE'¶
- NAN_DETECTED = 'NAN_DETECTED'¶
- QUASINEUTRALITY_BROKEN = 'QUASINEUTRALITY_BROKEN'¶
- NEGATIVE_CORE_PROFILES = 'NEGATIVE_CORE_PROFILES'¶
- REACHED_MIN_DT = 'REACHED_MIN_DT'¶
- LOW_TEMPERATURE_COLLAPSE = 'LOW_TEMPERATURE_COLLAPSE'¶
- DID_NOT_REACH_T_FINAL = 'DID_NOT_REACH_T_FINAL'¶
- class scpn_fusion.integrations.torax.ToraxGeometry(kind, frame, major_radius_m, minor_radius_m, magnetic_field_t, radial_coordinate='rho_norm', radial_coordinate_unit='1')[source]¶
Bases:
objectTyped geometry identity shared with external consumers.
- Parameters:
- class scpn_fusion.integrations.torax.ToraxProjection(time_ns, rho_norm, profiles, profile_units, source_totals, source_units, state_budgets, budget_units, numerics, uncertainty, scientific_sha256)[source]¶
Bases:
objectConsumer-critical, unit-bearing projection of one complete TORAX run.
- Parameters:
scientific_sha256 (str)
- class scpn_fusion.integrations.torax.ToraxProvenance(torax_version, torax_license, source_repo_commit, python_version, platform, runtime_backend, precision, request_sha256, config_sha256, deck_sha256, runner_sha256, started_at_utc, finished_at_utc)[source]¶
Bases:
objectRuntime and source identity needed to reproduce one TORAX outcome.
- Parameters:
- class scpn_fusion.integrations.torax.ToraxRunOutcome(request_id, event_id, complete, reached_time_ns, sim_error, provenance, projection, artifact, failure_code, failure_message, schema='scpn-fusion-core.torax-runtime-outcome.v1')[source]¶
Bases:
objectDiscriminated success/failure result for one TORAX request.
- Parameters:
request_id (str)
event_id (str)
complete (bool)
reached_time_ns (int)
sim_error (str)
provenance (ToraxProvenance)
projection (ToraxProjection | None)
artifact (ToraxArtifact | None)
failure_code (ToraxFailureCode | None)
failure_message (str | None)
schema (str)
- classmethod from_dict(value)[source]¶
Parse and validate a v1 outcome with unknown-field refusal.
- Return type:
- Parameters:
value (object)
- require_success()[source]¶
Return this outcome or raise a stable typed runtime exception.
- Return type:
-
provenance:
ToraxProvenance¶
-
projection:
ToraxProjection|None¶
-
artifact:
ToraxArtifact|None¶
-
failure_code:
ToraxFailureCode|None¶
- class scpn_fusion.integrations.torax.ToraxRunRequest(request_id, event_id, model_id, scenario_id, reactor_family, reactor_id, configuration_id, clock, geometry, initial_state, controls, models, torax_config, bindings, custody, expected_torax_version='1.4.3', schema='scpn-fusion-core.torax-runtime-request.v1')[source]¶
Bases:
objectComplete TORAX configuration plus a checked typed consumer view.
- Parameters:
request_id (str)
event_id (str)
model_id (str)
scenario_id (str)
reactor_family (str)
reactor_id (str)
configuration_id (str)
clock (ToraxClock)
geometry (ToraxGeometry)
initial_state (tuple[ToraxSignal, ...])
controls (tuple[ToraxSignal, ...])
bindings (tuple[ToraxConfigBinding, ...])
expected_torax_version (str)
schema (str)
- classmethod from_dict(value)[source]¶
Parse and validate a v1 request with unknown-field refusal.
- Return type:
- Parameters:
value (object)
-
clock:
ToraxClock¶
-
geometry:
ToraxGeometry¶
-
initial_state:
tuple[ToraxSignal,...]¶
-
controls:
tuple[ToraxSignal,...]¶
-
bindings:
tuple[ToraxConfigBinding,...]¶
- class scpn_fusion.integrations.torax.ToraxReviewEnvelope(source_schema, source_revision, model_intersection_schema, event_id, payload, provenance, payload_sha256, schema='scpn-fusion-core.torax-runtime-review-envelope.v1')[source]¶
Bases:
objectCanonical review-only projection with numerical-refinement uncertainty.
- Parameters:
- classmethod from_dict(value)[source]¶
Parse and verify a deterministic review envelope.
- Return type:
- Parameters:
value (object)
- class scpn_fusion.integrations.torax.ToraxRuntimeClient(python_executable, working_directory=None)[source]¶
Bases:
objectLaunch a supplied TORAX Python interpreter through the public CLI.
- load_verified_outcome(*, result_path, expected_sidecar_path)[source]¶
Load an outcome and verify every declared sidecar custody digest.
- Return type:
- Parameters:
- exception scpn_fusion.integrations.torax.ToraxRuntimeError(code, message)[source]¶
Bases:
RuntimeErrorRaised by
ToraxRunOutcome.require_success()for typed failures.- Parameters:
code (ToraxFailureCode)
message (str)
- Return type:
None
- class scpn_fusion.integrations.torax.ToraxSignal(name, role, unit, frame, time_ns, coordinate_name, coordinate_unit, coordinate, values, binding_name, calibration, provenance, uncertainty_kind, uncertainty, application_semantics, model_delay_ns, saturation_minimum, saturation_maximum, maximum_slew_per_s, hardware_limits_status, validity='VALID')[source]¶
Bases:
objectUnit-bearing profile or scalar trajectory bound to one configuration value.
- Parameters:
name (str)
role (str)
unit (str)
frame (str)
coordinate_name (str)
coordinate_unit (str)
binding_name (str)
calibration (str)
provenance (str)
uncertainty_kind (str)
application_semantics (str)
model_delay_ns (int)
saturation_minimum (float | None)
saturation_maximum (float | None)
maximum_slew_per_s (float | None)
hardware_limits_status (str)
validity (str)
- classmethod from_dict(value, *, label='signal')[source]¶
Parse one strict typed signal.
- Return type:
- Parameters:
- scpn_fusion.integrations.torax.build_review_envelope(*, request, refined_request, primary, refined, primary_dt_ns, refined_dt_ns, source_revision, runtime_source_sha256, artifact_content_sha256, manifest_inventory_sha256)[source]¶
Build a deterministic, review-only envelope from two real TORAX runs.
The producer derives all twelve uncertainty records from primary and refined projections aligned at the primary sample times. The D-D reaction value is only the fuel-class identity supported by the deuterium-only deck; it does not claim that fusion burn or fusion power was modeled.
- Raises:
ValueError – If request identity, timing, projection vocabulary, shape, units, or numerical-refinement evidence differs from the frozen U1 contract.
- Return type:
- Parameters:
request (ToraxRunRequest)
refined_request (ToraxRunRequest)
primary (ToraxRunOutcome)
refined (ToraxRunOutcome)
primary_dt_ns (int)
refined_dt_ns (int)
source_revision (str)
runtime_source_sha256 (str)
artifact_content_sha256 (str)
manifest_inventory_sha256 (str)
- scpn_fusion.integrations.torax.review_envelope_from_bytes(payload, *, expected_sha256=None)[source]¶
Decode canonical bytes and refuse size, digest, duplicate, or encoding drift.
- Return type:
- Parameters:
- scpn_fusion.integrations.torax.review_envelope_sha256(envelope)[source]¶
Hash the exact canonical review-envelope bytes.
- Return type:
- Parameters:
envelope (ToraxReviewEnvelope)
- scpn_fusion.integrations.torax.review_envelope_to_bytes(envelope)[source]¶
Return the unique canonical UTF-8 representation of an envelope.
- Return type:
- Parameters:
envelope (ToraxReviewEnvelope)
Runtime client¶
Bounded process-isolated client that never imports TORAX or JAX.
- class scpn_fusion.integrations.torax.client.ToraxRuntimeClient(python_executable, working_directory=None)[source]¶
Bases:
objectLaunch a supplied TORAX Python interpreter through the public CLI.
- run(request, *, request_path, result_path, sidecar_path, environment=None)[source]¶
Execute one request with a whole-process-group wall-time bound.
- Return type:
- Parameters:
Contracts¶
Immutable, versioned contracts for process-isolated TORAX execution.
- class scpn_fusion.integrations.torax.contracts.ToraxArtifact(sidecar_path, sidecar_sha256, sidecar_bytes, manifest_path, manifest_sha256, format='NetCDF-DataTree')[source]¶
Bases:
objectChecksummed complete TORAX output and its inventory manifest.
- Parameters:
- class scpn_fusion.integrations.torax.contracts.ToraxClock(domain, epoch, initial_ns, final_ns, timeout_s, max_steps, reset_policy)[source]¶
Bases:
objectExact simulation-monotonic clock and bounded execution policy.
- Parameters:
- class scpn_fusion.integrations.torax.contracts.ToraxConfigBinding(name, config_path, unit, interpretation, value)[source]¶
Bases:
objectExact typed-to-backend overlap assertion using a JSON object path.
- class scpn_fusion.integrations.torax.contracts.ToraxFailureCode(*values)[source]¶
-
Stable failure codes exposed independently of TORAX implementation types.
- INVALID_REQUEST = 'INVALID_REQUEST'¶
- BACKEND_UNAVAILABLE = 'BACKEND_UNAVAILABLE'¶
- BACKEND_VERSION_MISMATCH = 'BACKEND_VERSION_MISMATCH'¶
- CONFIGURATION_REJECTED = 'CONFIGURATION_REJECTED'¶
- TIMEOUT = 'TIMEOUT'¶
- PROCESS_FAILURE = 'PROCESS_FAILURE'¶
- OUTPUT_SCHEMA_MISMATCH = 'OUTPUT_SCHEMA_MISMATCH'¶
- PROVENANCE_FAILURE = 'PROVENANCE_FAILURE'¶
- NAN_DETECTED = 'NAN_DETECTED'¶
- QUASINEUTRALITY_BROKEN = 'QUASINEUTRALITY_BROKEN'¶
- NEGATIVE_CORE_PROFILES = 'NEGATIVE_CORE_PROFILES'¶
- REACHED_MIN_DT = 'REACHED_MIN_DT'¶
- LOW_TEMPERATURE_COLLAPSE = 'LOW_TEMPERATURE_COLLAPSE'¶
- DID_NOT_REACH_T_FINAL = 'DID_NOT_REACH_T_FINAL'¶
- class scpn_fusion.integrations.torax.contracts.ToraxGeometry(kind, frame, major_radius_m, minor_radius_m, magnetic_field_t, radial_coordinate='rho_norm', radial_coordinate_unit='1')[source]¶
Bases:
objectTyped geometry identity shared with external consumers.
- Parameters:
- class scpn_fusion.integrations.torax.contracts.ToraxProjection(time_ns, rho_norm, profiles, profile_units, source_totals, source_units, state_budgets, budget_units, numerics, uncertainty, scientific_sha256)[source]¶
Bases:
objectConsumer-critical, unit-bearing projection of one complete TORAX run.
- Parameters:
scientific_sha256 (str)
- class scpn_fusion.integrations.torax.contracts.ToraxProvenance(torax_version, torax_license, source_repo_commit, python_version, platform, runtime_backend, precision, request_sha256, config_sha256, deck_sha256, runner_sha256, started_at_utc, finished_at_utc)[source]¶
Bases:
objectRuntime and source identity needed to reproduce one TORAX outcome.
- Parameters:
- class scpn_fusion.integrations.torax.contracts.ToraxRunOutcome(request_id, event_id, complete, reached_time_ns, sim_error, provenance, projection, artifact, failure_code, failure_message, schema='scpn-fusion-core.torax-runtime-outcome.v1')[source]¶
Bases:
objectDiscriminated success/failure result for one TORAX request.
- Parameters:
request_id (str)
event_id (str)
complete (bool)
reached_time_ns (int)
sim_error (str)
provenance (ToraxProvenance)
projection (ToraxProjection | None)
artifact (ToraxArtifact | None)
failure_code (ToraxFailureCode | None)
failure_message (str | None)
schema (str)
-
provenance:
ToraxProvenance¶
-
projection:
ToraxProjection|None¶
-
artifact:
ToraxArtifact|None¶
-
failure_code:
ToraxFailureCode|None¶
- require_success()[source]¶
Return this outcome or raise a stable typed runtime exception.
- Return type:
- class scpn_fusion.integrations.torax.contracts.ToraxRunRequest(request_id, event_id, model_id, scenario_id, reactor_family, reactor_id, configuration_id, clock, geometry, initial_state, controls, models, torax_config, bindings, custody, expected_torax_version='1.4.3', schema='scpn-fusion-core.torax-runtime-request.v1')[source]¶
Bases:
objectComplete TORAX configuration plus a checked typed consumer view.
- Parameters:
request_id (str)
event_id (str)
model_id (str)
scenario_id (str)
reactor_family (str)
reactor_id (str)
configuration_id (str)
clock (ToraxClock)
geometry (ToraxGeometry)
initial_state (tuple[ToraxSignal, ...])
controls (tuple[ToraxSignal, ...])
bindings (tuple[ToraxConfigBinding, ...])
expected_torax_version (str)
schema (str)
-
clock:
ToraxClock¶
-
geometry:
ToraxGeometry¶
-
initial_state:
tuple[ToraxSignal,...]¶
-
controls:
tuple[ToraxSignal,...]¶
-
bindings:
tuple[ToraxConfigBinding,...]¶
- exception scpn_fusion.integrations.torax.contracts.ToraxRuntimeError(code, message)[source]¶
Bases:
RuntimeErrorRaised by
ToraxRunOutcome.require_success()for typed failures.- Parameters:
code (ToraxFailureCode)
message (str)
- Return type:
None
- class scpn_fusion.integrations.torax.contracts.ToraxSignal(name, role, unit, frame, time_ns, coordinate_name, coordinate_unit, coordinate, values, binding_name, calibration, provenance, uncertainty_kind, uncertainty, application_semantics, model_delay_ns, saturation_minimum, saturation_maximum, maximum_slew_per_s, hardware_limits_status, validity='VALID')[source]¶
Bases:
objectUnit-bearing profile or scalar trajectory bound to one configuration value.
- Parameters:
name (str)
role (str)
unit (str)
frame (str)
coordinate_name (str)
coordinate_unit (str)
binding_name (str)
calibration (str)
provenance (str)
uncertainty_kind (str)
application_semantics (str)
model_delay_ns (int)
saturation_minimum (float | None)
saturation_maximum (float | None)
maximum_slew_per_s (float | None)
hardware_limits_status (str)
validity (str)
Deterministic review envelope¶
Deterministic, non-actuating TORAX evidence envelope for SPO consumers.
- class scpn_fusion.integrations.torax.review.ToraxReviewEnvelope(source_schema, source_revision, model_intersection_schema, event_id, payload, provenance, payload_sha256, schema='scpn-fusion-core.torax-runtime-review-envelope.v1')[source]¶
Bases:
objectCanonical review-only projection with numerical-refinement uncertainty.
- Parameters:
- to_dict_without_digest()[source]¶
Return deterministic fields other than the derived payload digest.
- scpn_fusion.integrations.torax.review.build_review_envelope(*, request, refined_request, primary, refined, primary_dt_ns, refined_dt_ns, source_revision, runtime_source_sha256, artifact_content_sha256, manifest_inventory_sha256)[source]¶
Build a deterministic, review-only envelope from two real TORAX runs.
The producer derives all twelve uncertainty records from primary and refined projections aligned at the primary sample times. The D-D reaction value is only the fuel-class identity supported by the deuterium-only deck; it does not claim that fusion burn or fusion power was modeled.
- Raises:
ValueError – If request identity, timing, projection vocabulary, shape, units, or numerical-refinement evidence differs from the frozen U1 contract.
- Return type:
- Parameters:
request (ToraxRunRequest)
refined_request (ToraxRunRequest)
primary (ToraxRunOutcome)
refined (ToraxRunOutcome)
primary_dt_ns (int)
refined_dt_ns (int)
source_revision (str)
runtime_source_sha256 (str)
artifact_content_sha256 (str)
manifest_inventory_sha256 (str)
- scpn_fusion.integrations.torax.review.review_envelope_from_bytes(payload, *, expected_sha256=None)[source]¶
Decode canonical bytes and refuse size, digest, duplicate, or encoding drift.
- Return type:
- Parameters:
- scpn_fusion.integrations.torax.review.review_envelope_sha256(envelope)[source]¶
Hash the exact canonical review-envelope bytes.
- Return type:
- Parameters:
envelope (ToraxReviewEnvelope)
- scpn_fusion.integrations.torax.review.review_envelope_to_bytes(envelope)[source]¶
Return the unique canonical UTF-8 representation of an envelope.
- Return type:
- Parameters:
envelope (ToraxReviewEnvelope)
Uniform-DT operating maps¶
Run a source-pinned, uniform-DT scoping map through public cfspopcon APIs.
Equal D/T, Ti=Te and uniform density/temperature are prescribed. ITER98y2 sets total loss power; alpha heating and prescribed ohmic heating determine required auxiliary power. This is code comparison, not experimental evidence.
- validation.cfspopcon_operating_map.verify_upstream(package_root)[source]¶
Verify installed Python/YAML bytes against the reviewed upstream manifest.
- Parameters:
package_root (Path) – Root of the cfspopcon package being used.
- Returns:
Exact source commit and manifest digest.
- Return type:
- Raises:
ValueError – If a source file is absent, added or changed.
- validation.cfspopcon_operating_map.validate_request(request)[source]¶
Reject unsupported modes, nonfinite values and grids above 256 points.
- Parameters:
request (Mapping[str, object]) – Exact schema plus SI geometry, MA/MW powers and keV temperature axes.
- Raises:
ValueError – If keys, numeric domains or bounded grid dimensions are invalid.
- Return type:
- validation.cfspopcon_operating_map.run_operating_map(request, *, reference_python, reference_root=None)[source]¶
Calculate all requested points without promoting results to evidence.
- Parameters:
request (Mapping[str, object]) – A validated uniform-DT request; see the committed reference input.
reference_python (Path) – Python executable in the existing SCPN environment. The public local reactivity API runs in this separate process to isolate NumPy versions.
reference_root (Path, optional) – SCPN checkout to compare; defaults to this checkout. The actual imported source hash is retained, including for a candidate under review.
- Returns:
Source-bound design-only results, including every refused point.
- Return type:
- Raises:
ValueError – If inputs or installed source custody do not match the contract.
ModuleNotFoundError – If the optional upstream runtime has not been installed.
PROCESS power diagnostics¶
Read actual PROCESS power records without turning convergence into admission.
- validation.process_power_report.read_process_power_report(path, *, expected_sha256, expected_constraints, equality_tolerance)[source]¶
Inspect every scan in a caller-identified PROCESS MFILE artifact.
- Parameters:
path (Path) – Actual PROCESS MFILE.DAT output, read through its public MFile parser.
expected_sha256 (str) – Digest recorded by the producing run; mismatched artifacts are rejected.
expected_constraints (tuple[int, ...]) – Exact active constraint IDs from the input case, including equalities.
equality_tolerance (float) – Explicit finite positive bound for the recorded equality residual norm.
- Returns:
All scan values, inequality violations and separate recorded-check results. These are diagnostics, not source-provenance or physical admission proof. Plasma/reactor/plant imbalance limits use upstream’s 0.1 MW diagnostic threshold. Electrical arithmetic is checked with the same bound.
- Return type:
- Raises:
ValueError – For bad custody, missing constraints/fields, inconsistent scan counts, nonfinite values, conflicting repeated diagnostics, or invalid caller configuration.
ModuleNotFoundError – If the optional PROCESS runtime is unavailable.
Source-bound PROCESS execution¶
Run the pinned real PROCESS evaluation case and preserve diagnostics and custody.
- validation.process_reference_run.verify_process_source()[source]¶
Verify installed package source/data against the immutable reference manifest.
- Returns:
Source commit, manifest digest, installed version and generated-version hash.
- Return type:
- Raises:
ModuleNotFoundError – When the optional upstream package is unavailable.
ValueError – When installed source/data differ, are absent or include unexpected files.
Notes
Python/Numba caches are excluded. The unused build-generated _version.py is recorded separately; all 220 upstream package source/data files are checked. This does not certify transitive dependencies or physical model validity.
- validation.process_reference_run.run_process_reference(case, output_dir, *, equality_tolerance, timeout_seconds=240.0)[source]¶
Execute the pinned case in a separate process, retaining even rejected results.
- Parameters:
case (Path) – Unmodified upstream large_tokamak_eval_IN.DAT from the pinned snapshot.
output_dir (Path) – New directory exclusively created for inputs, log, outputs and JSON receipt.
equality_tolerance (float) – Caller-declared positive finite equality diagnostic tolerance.
timeout_seconds (float) – Finite positive child execution limit in seconds; defaults to 240.
- Returns:
Power diagnostics with local execution/source/file custody. Scientific and control authority remain false regardless of convergence or recorded checks.
- Return type:
- Raises:
ValueError – For input/source mismatch or malformed output diagnostics.
FileExistsError – If the requested output directory exists; nothing is overwritten.
subprocess.SubprocessError – If execution fails or exceeds the timeout. Existing log/input stay available.
Notes
Run this API in the isolated PROCESS environment. The child uses its exact interpreter with two OpenBLAS/Numba threads and a noninteractive plotting backend. Verification is local observed custody, not a signed third-party attestation.
RustBCA particle-surface diagnostics¶
These optional APIs retain local build and run observations. They do not establish independent source attestation or physical/material validation.
Validate bounded ion/material sampling requests before starting RustBCA.
- validation.rustbca_request.validate_rustbca_request(request)[source]¶
Return an independent normalized request for the ergonomic RustBCA APIs.
- Parameters:
request (object) – JSON-shaped mapping with schema, ion, target, energies_eV, angles_deg, samples_per_seed, seeds and threads. Species use Z, mass m in amu, cutoff Ec and surface binding Es in eV; target also requires bulk binding Eb in eV and number density n in m^-3. Both require label and provenance.
- Returns:
Detached request with finite floating-point material/grid values and integer atomic numbers, sample counts, seeds and thread count.
- Return type:
- Raises:
ValueError – For missing/unknown keys, invalid numeric/text values, duplicate grid or seed entries, or requests exceeding the computational sampling contract.
Notes
The contract allows at most eight energies below 100 keV and eight angles from zero up to but excluding 90 degrees, two to sixteen unique unsigned 64-bit seeds, one to eight threads and up to one million incident histories per observable over the grid. These are workload bounds, not physics validity limits. Each energy must exceed the incident-ion cutoff. At least two seeds permit empirical batch dispersion; they do not guarantee a confidence bound. Provenance is caller-supplied attribution, not authenticated material evidence. No defaults, clipping, species inference or source/physical admission occurs.
Execute caller-identified RustBCA binaries and retain per-seed diagnostics.
- validation.rustbca_reference.run_rustbca_reference(request, output_dir, *, python, expected_binary_sha256, timeout_seconds=240.0, build_receipt=None, expected_build_receipt_sha256=None)[source]¶
Run every energy/angle/seed point with a bounded, identified real backend.
- Parameters:
request (object) – Mapping accepted by validate_rustbca_request. Caller attribution is kept.
output_dir (Path) – New directory for the normalized request, per-seed inputs, logs and outputs.
python (Path) – Interpreter in the separately installed optional RustBCA environment.
expected_binary_sha256 (str) – Previously recorded SHA256 of the runtime extension. Each child verifies it.
timeout_seconds (float) – Total execution budget in (0, 3600] seconds, including every batch.
build_receipt (Path or None) – Optional retained native build observation, verified before and after the run.
expected_build_receipt_sha256 (str or None) – Required caller-pinned digest when build_receipt is supplied.
- Returns:
Complete seed batches and empirical means/standard errors with local file hashes. No source, material, physical or actuation approval is inferred.
- Return type:
- Raises:
ValueError – For invalid requests, digest syntax, execution limits or changed custody.
FileExistsError – If the output directory already exists.
subprocess.SubprocessError – For child failure or exhausted execution budget; previous files are retained.
Notes
Binary identity is caller-supplied, not source/build attestation. The two upstream observables use different recoil settings and are not one cascade energy ledger. Seed-batch standard errors describe sampling dispersion only; zero observed events or zero dispersion do not establish zero uncertainty or a confidence bound.
- validation.rustbca_reference.main()[source]¶
Execute an internal worker or a caller-identified RustBCA request from JSON.
- Return type:
Check retained native build inputs without claiming independent attestation.
- validation.rustbca_build_receipt.verify_rustbca_build_receipt(receipt, *, expected_receipt_sha256, expected_binary_sha256)[source]¶
Verify a pinned local build observation and its retained file dependencies.
- Parameters:
receipt (Path) – Native build result.json beside source/, build.log and build_source.py. The recorded binary path must still resolve to the observed build output.
expected_receipt_sha256 (str) – Previously captured SHA256 of the exact observation, supplied by the caller.
expected_binary_sha256 (str) – SHA256 independently selected for the runtime extension to execute.
- Returns:
Input-custody status and pinned identities. Independent attestation and physical admission remain false, even when every file matches.
- Return type:
- Raises:
ValueError – If identities, source inventory, build outcome or retained bytes disagree.
OSError – If any required retained file cannot be read.
Notes
This validates the local record’s consistency, not who produced it or whether its asserted compilation occurred. The source inventory is pinned separately from the caller’s record. Host toolchain hermeticity and binary reproducibility are not established. Recheck after execution to detect changed retained inputs.
Build an optional RustBCA wheel and retain source-to-binary observations.
- tools.build_rustbca_reference.build_rustbca_reference(source_archive, output, *, python, cargo, rustc, timeout_seconds=600.0, fetch_dependencies=False)[source]¶
Build a fresh frozen native library, local-platform wheel and custody receipt.
- Parameters:
source_archive (Path) – Exact pinned upstream tar.gz, already acquired by the caller.
output (Path) – New retained build directory. Existing directories are never overwritten.
python (Path) – CPython interpreter whose ABI the optional extension targets.
cargo (Path) – Explicit compiler executable paths, hashed before and after compilation. Required dependencies must already be available to Cargo’s frozen resolver.
rustc (Path) – Explicit compiler executable paths, hashed before and after compilation. Required dependencies must already be available to Cargo’s frozen resolver.
timeout_seconds (float) – Finite total subprocess budget in seconds, greater than zero and at most 1800. Failed phases additionally allow at most five seconds to reap their leader; failure receipts retain the PID and any signalling or reaping error.
fetch_dependencies (bool) – Explicitly permit Cargo fetch –locked before frozen compilation. Both phases share the deadline; downloaded dependencies remain pinned by the lockfile.
- Returns:
Local observation binding sources, compiler identities, binary and wheel. This does not certify hermetic builds, independent attestation or physics.
- Return type:
- Raises:
ValueError – For invalid limits, source identity, unsupported runtime or changed inputs.
FileExistsError – If output already exists.
subprocess.SubprocessError – If a compiler/probe fails or exceeds the remaining deadline.
OSError – If required input files or executables are unavailable.
Notes
The builder uses two Cargo jobs and a fresh target directory. On failure it retains result.json with a failure status, signals its compiler process group and attempts bounded leader reaping. The receipt distinguishes an unreaped leader from successful reaping; reaping alone does not prove group absence. wheel 0.47.0 is required to write checked RECORD entries. The generated wheel uses the local platform tag, never an unaudited manylinux claim.