diffpes.certify¶
JAX-native certified forward execution, scientific evidence, provenance, information-flow analysis, policy evaluation, and certificate inspection.
Certify differentiable DiffPES forward-model executions.
Extended Summary¶
The certification package combines static scientific identity and provenance with numerical evidence from the actual JAX forward program. Canonical records and CRC32 checksums provide non-security bookkeeping at the I/O boundary; they do not establish physical validity. Runtime claims, derivative checks, dependency maps, sensitivities, and information spectra are JAX-native numerical carriers.
The package contains these submodules:
canonicalRepresent scientific records canonically for certification.
checksumsCompute non-security consistency checksums for scientific records.
checksRegister pure JAX scientific certification checks.
contractsDefine semantic contracts for composable certified transformations.
registryRegister certified models and transformations deterministically.
provenanceTrace artifact lineage and semantic information loss.
dependenciesTrace differentiable information flow through forward models.
evidenceBuild differentiable evidence for certified forward models.
resolversResolve certificate artifacts and verify external evidence.
reproductionReproduce a certified forward result from resolved artifacts.
policyEvaluate cumulative scientific-certification policies.
executionExecute JAX-native certified forward models.
inspectRender forward-model certificates in a human-readable form.
modelsRegister built-in certified DiffPES forward models.
waiversValidate bounded policy-waiver records at the I/O boundary.
Routine Listings¶
achieved_levels()Return certification level names achieved by a concrete report.
artifact_ref()Build separate byte, normalized-content, and semantic identities.
build_provenance()Build a deterministic provenance DAG and propagate information.
canonical_json()Return deterministic typed JSON bytes for
value.canonical_pytree()Return canonical bytes for a supported carrier or PyTree.
certify_forward()Execute a prepared model and produce a certified JAX PyTree.
certify_forward_checked()Execute certification and return structured hard-domain errors.
checksum_bytes()Return a non-security consistency checksum for
data.checksum_chunks()Compute a consistency checksum over consecutive byte chunks.
checksum_file()Stream exact file bytes into a consistency checksum.
checksum_pytree()Stream a canonical carrier into a consistency checksum.
compose_transformations()Compose contracts and raise for unsatisfied requirements.
clear_dependency_cache()Clear the eager cache for structural dependency analyses.
dependency_cache_info()Return cache size, hit count, and miss count.
dependency_map()Trace leaf-level structural and local numerical dependencies.
derivative_evidence()Compare JAX information flow with batched finite differences.
diff_certificates()Compare two certificates by scientific meaning and record class.
effective_information()Return propagated semantics, losses, and invalidations for one node.
evaluate_claim()Evaluate a numerical claim and preserve residual and margin leaves.
evaluate_domain()Evaluate a symmetric domain predicate around a reference value.
evaluate_evidence()Compare measured values with an external numerical reference.
evaluate_policy()Derive cumulative certification outcomes from numerical claims.
execute_tb_radial()Execute the radial ARPES model from one certification input PyTree.
explain_claim()Explain one claim and the numerical evidence supporting it.
freeze_registry()Prevent later registration and return the final immutable snapshot.
filesystem_artifact_resolver()Resolve a byte-valued artifact from its local locator.
get_check()Resolve a registered JAX certification check.
get_model()Resolve an exact registered model.
get_transformation()Resolve an exact registered transformation contract.
information_spectrum()Estimate the leading local information spectrum matrix-free.
invalidated_claims()Return every claim invalidated at or upstream of one output.
iter_canonical_pytree_chunks()Yield canonical carrier bytes in bounded chunks.
lineage()Return the transitive parent-node lineage of one output.
linearized_forward()Evaluate a forward model and retain its JVP linearization.
list_checks()List registered checks in deterministic identity order.
list_handshakes()Return owner handshakes in deterministic identity order.
list_models()Return model specifications in deterministic identity order.
list_registered_models()Return an immutable deterministic snapshot including executors.
list_transformations()Return transformation contracts in deterministic identity order.
parse_checksum()Parse and validate one checksum string.
packaged_model_card()Read the packaged generated card for one model identity.
prepare_certification()Resolve static scientific records before compiled execution.
mapping_artifact_resolver()Build a deterministic resolver from normalized in-memory values.
register_handshake()Register declarative requirements from one owning plan.
register_builtin_models()Register built-in models and information-loss transformations.
register_check()Register a stable predicate identity and pure JAX callable.
register_model()Register an exact model identity once.
register_transformation()Register an exact transformation contract once.
registry_snapshot()Return one internally consistent immutable registry snapshot.
registry_manifest()Read the packaged registry manifest.
render_model_card()Render a model card directly from a model specification.
reproduce_forward()Re-execute a registered model and compare its recorded result.
require_active_waivers()Reject malformed, expired, or premature waiver records.
resolve_artifact()Resolve and validate one referenced artifact.
result_checksum()Identify a result under a declared numerical configuration.
semantic_checksum()Identify content together with its declared scientific meaning.
sensitivity_map()Measure scaled JVP sensitivities for a batch of tangent directions.
summarize_certificate()Return a deterministic human-readable certificate summary.
tb_radial_model_spec()Return the stable scientific specification for radial ARPES.
validate_composition()Validate and conservatively compose transformation semantics.
validate_contract()Return structural errors for a raw or deserialized contract.
validate_handshake()Validate one owner handshake against available records.
validate_provenance()Re-evaluate graph structure and derived state independently.
validate_registry()Recompute registry structure and consistency checksums.
validate_registry_manifest()Compare the packaged registry manifest with live entries.
validate_waiver()Validate one waiver against an explicit absolute UTC time.
validate_waivers()Validate multiple waivers against one explicit absolute UTC time.
verify_evidence()Verify referenced artifacts and recorded numerical residuals.
verify_certificate()Re-evaluate numerical claim and policy consistency without a rerun.
- diffpes.certify.canonical_json(value: object) bytes[source]¶
Return deterministic typed JSON bytes for
value.The record preserves scalar, container, array-dtype, and array-shape identity. It rejects values that have no finite deterministic representation.
- See:
Implementation Logic¶
Bind the documented output:
encoded: bytes = CANONICAL_JSON_PREFIX + payload
The function validates and transforms the inputs before it binds the documented output.
- diffpes.certify.canonical_pytree(tree: object) bytes[source]¶
Return canonical bytes for a supported carrier or PyTree.
The record preserves scalar, container, array-dtype, and array-shape identity. It rejects values that have no finite deterministic representation.
- See:
- Parameters:
tree (
object) – Supported nested scientific content. The record represents Equinox modules through their dataclass fields, including static metadata.- Returns:
encoded – Complete versioned canonical record.
- Return type:
Notes
Use
iter_canonical_pytree_chunks()for a streaming checksum of a large array.
- diffpes.certify.iter_canonical_pytree_chunks(tree: object, *, chunk_bytes: int = CANONICAL_ARRAY_CHUNK_BYTES) Iterator[bytes | memoryview][source]¶
Yield canonical carrier bytes in bounded chunks.
The record preserves scalar, container, array-dtype, and array-shape identity. It rejects values that have no finite deterministic representation.
Implementation Logic¶
Bind the documented output:
yield from _iter_value_chunks(tree, chunk_bytes=chunk_bytes)
The function validates and transforms the inputs before it binds the documented output.
- param tree:
A supported scientific carrier or nested PyTree-like value.
- type tree:
- param chunk_bytes:
Maximum payload bytes yielded for each numerical-array chunk.
- type chunk_bytes:
int, default:CANONICAL_ARRAY_CHUNK_BYTES- Yields:
chunk (
bytes | memoryview) – Consecutive chunks of the canonical representation.- raises ValueError:
If
chunk_bytesis not positive. This error also occurs if the tree contains an unsupported or nonfinite value.
- diffpes.certify.get_check(check_id: str) CheckFunction[source]¶
Resolve a registered JAX certification check.
The process-local registry selects pure JAX predicates by stable scientific identity. Registered functions retain continuous margins in compiled execution.
- See:
Implementation Logic¶
Bind the documented output:
check: CheckFunction = _check_registry()[check_id]
The function validates and transforms the inputs before it binds the documented output.
- param check_id:
Exact predicate identifier (static – a compile-time selection).
- type check_id:
- returns:
check – Registered pure JAX predicate implementation.
- rtype:
Callable[[PyTree],DomainResult]- raises KeyError:
If no check has the requested identity.
- diffpes.certify.list_checks() tuple[str, ...][source]¶
List registered checks in deterministic identity order.
The process-local registry selects pure JAX predicates by stable scientific identity. Registered functions retain continuous margins in compiled execution.
- See:
Implementation Logic¶
Bind the documented output:
checks: tuple[str, ...] = tuple(sorted(_check_registry()))
The function validates and transforms the inputs before it binds the documented output.
- diffpes.certify.register_check(check_id: str, check_fn: CheckFunction) None[source]¶
Register a stable predicate identity and pure JAX callable.
The process-local registry selects pure JAX predicates by stable scientific identity. Registered functions retain continuous margins in compiled execution.
- See:
- Parameters:
check_id (
str) – Stable predicate identifier (static – a compile-time selection).check_fn (
Callable[[PyTree],DomainResult]) – Pure JAX predicate implementation (static – a compiled program).
- Raises:
ValueError – If the identity is unstable or already registered.
- Return type:
Notes
Registration occurs at the eager application boundary. The registered callable itself remains pure and traceable inside certification kernels.
- diffpes.certify.artifact_ref(path: str | Path, normalized: object, *, role: str, media_type: str = 'application/octet-stream', semantics: object | None = None, artifact_id: str | None = None) ArtifactRef[source]¶
Build separate byte, normalized-content, and semantic identities.
The CRC32 value detects accidental disagreement in canonical scientific records. It is bookkeeping evidence, not cryptographic authentication.
- See:
Implementation Logic¶
Bind the documented output:
reference: ArtifactRef = make_artifact_ref( artifact_id=resolved_id, media_type=media_type, byte_checksum=byte_value, content_checksum=content_value, semantic_checksum=semantic_value, locator=str(source), role=role, )
The function validates and transforms the inputs before it binds the documented output.
- param path:
Source artifact with a record of its exact bytes.
- type path:
- param normalized:
Parsed, normalized scientific carrier derived from the source.
- type normalized:
- param role:
Scientific role of this artifact in the execution.
- type role:
- param media_type:
Declared media type of the source bytes.
- type media_type:
str, default:"application/octet-stream"- param semantics:
Meaning-bearing declarations. By default, the role and normalized carrier type form the minimal semantic descriptor.
- type semantics:
- param artifact_id:
Stable caller-owned identity. By default, the function derives a local identity from the byte checksum value.
- type artifact_id:
- returns:
reference – Immutable certification carrier with three deliberately separate consistency checksums.
- rtype:
- diffpes.certify.checksum_bytes(data: bytes, *, record_kind: str) str[source]¶
Return a non-security consistency checksum for
data.The CRC32 value detects accidental disagreement in canonical scientific records. It is bookkeeping evidence, not cryptographic authentication.
- See:
Implementation Logic¶
Bind the documented output:
checksum: str = checksum_chunks((data,), record_kind=record_kind)
The function validates and transforms the inputs before it binds the documented output.
- diffpes.certify.checksum_chunks(chunks: Iterable[bytes | memoryview], *, record_kind: str) str[source]¶
Compute a consistency checksum over consecutive byte chunks.
The CRC32 value detects accidental disagreement in canonical scientific records. It is bookkeeping evidence, not cryptographic authentication.
- See:
Implementation Logic¶
Bind the documented output:
checksum: str = _format_checksum(value, record_kind=record_kind)
The function validates and transforms the inputs before it binds the documented output.
- param chunks:
Consecutive byte-like pieces of one record.
- type chunks:
- param record_kind:
Stable description, such as
"normalized-content"or"result".- type record_kind:
- returns:
checksum – Versioned, typed CRC32 consistency checksum.
- rtype:
- diffpes.certify.checksum_file(path: str | Path, *, record_kind: str) str[source]¶
Stream exact file bytes into a consistency checksum.
The CRC32 value detects accidental disagreement in canonical scientific records. It is bookkeeping evidence, not cryptographic authentication.
- See:
Implementation Logic¶
Bind the documented output:
checksum: str = checksum_chunks(chunks(), record_kind=record_kind)
The function validates and transforms the inputs before it binds the documented output.
- diffpes.certify.checksum_pytree(tree: object, *, record_kind: str) str[source]¶
Stream a canonical carrier into a consistency checksum.
The CRC32 value detects accidental disagreement in canonical scientific records. It is bookkeeping evidence, not cryptographic authentication.
- See:
Implementation Logic¶
Bind the documented output:
checksum: str = checksum_chunks(chunks, record_kind=record_kind)
The function validates and transforms the inputs before it binds the documented output.
- diffpes.certify.parse_checksum(checksum: str) tuple[str, str, str, str][source]¶
Parse and validate one checksum string.
The CRC32 value detects accidental disagreement in canonical scientific records. It is bookkeeping evidence, not cryptographic authentication.
- See:
Implementation Logic¶
Bind the documented output:
parsed: tuple[str, str, str, str] = ( CHECKSUM_ALGORITHM, match.group("canonical"), match.group("kind"), match.group("value"), )
The function validates and transforms the inputs before it binds the documented output.
- diffpes.certify.result_checksum(value: object, numerical: object) str[source]¶
Identify a result under a declared numerical configuration.
The CRC32 value detects accidental disagreement in canonical scientific records. It is bookkeeping evidence, not cryptographic authentication.
- See:
Implementation Logic¶
Bind the documented output:
checksum: str = checksum_pytree(payload, record_kind="result")
The function validates and transforms the inputs before it binds the documented output.
- diffpes.certify.semantic_checksum(value: object, semantics: object) str[source]¶
Identify content together with its declared scientific meaning.
The CRC32 value detects accidental disagreement in canonical scientific records. It is bookkeeping evidence, not cryptographic authentication.
- See:
Implementation Logic¶
Bind the documented output:
checksum: str = checksum_pytree(payload, record_kind="semantic")
The function validates and transforms the inputs before it binds the documented output.
- diffpes.certify.compose_transformations(contracts: Sequence[TransformationContract], *, initial_semantics: Iterable[str] = ()) CompositionReport[source]¶
Compose contracts and raise for unsatisfied requirements.
The operation propagates declared semantics and information loss conservatively. It never infers that an undeclared scientific property survives.
Implementation Logic¶
Bind the documented output:
msg: str = "; ".join(report.errors)
The function validates and transforms the inputs before it binds the documented output.
- param contracts:
Ordered transformation pipeline.
- type contracts:
- param initial_semantics:
Properties present before the first step.
- type initial_semantics:
- returns:
report – Valid composition report.
- rtype:
- raises ValueError:
If any registered semantic requirement is missing.
- diffpes.certify.validate_composition(contracts: Sequence[TransformationContract], *, initial_semantics: Iterable[str] = ()) CompositionReport[source]¶
Validate and conservatively compose transformation semantics.
The operation propagates declared semantics and information loss conservatively. It never infers that an undeclared scientific property survives.
- See:
- Parameters:
contracts (
Sequence[TransformationContract]) – Ordered transformation pipeline.initial_semantics (
Iterable[str], default:()) – Properties available on the pipeline inputs.
- Returns:
report – Deterministic semantics, information-loss, and claim-invalidation summary. The report contains invalid composition instead of raising an exception.
- Return type:
Notes
The operation treats a property as lost when
preservesdoes not name it at that step. This rule prevents an undeclared transformation from retaining a scientific claim.
- diffpes.certify.validate_contract(contract: TransformationContract) tuple[str, ...][source]¶
Return structural errors for a raw or deserialized contract.
The operation propagates declared semantics and information loss conservatively. It never infers that an undeclared scientific property survives.
- See:
Implementation Logic¶
Bind the documented output:
result: tuple[str, ...] = tuple(errors)
The function validates and transforms the inputs before it binds the documented output.
- param contract:
Semantic and information-loss declaration to validate.
- type contract:
- returns:
result – Deterministic structural error messages, empty when valid.
- rtype:
- diffpes.certify.clear_dependency_cache() None[source]¶
Clear the eager cache for structural dependency analyses.
The function resets process-local orchestration state between evaluations.
Notes
The function changes orchestration state only. It does not run in a JAX numerical kernel.
- Return type:
- diffpes.certify.dependency_cache_info() tuple[int, int, int][source]¶
Return cache size, hit count, and miss count.
The tuple gives deterministic counters for structural cache tests.
- See:
- Returns:
info – Entry count, hit count, and miss count.
- Return type:
Notes
The counters measure eager structural analysis. They do not measure a JAX compilation cache.
- diffpes.certify.dependency_map(model_id: str, forward_fn: Callable[[PyTree], PyTree], inputs: PyTree, *, threshold: float = 1e-12) DependencyMap[source]¶
Trace leaf-level structural and local numerical dependencies.
Structural dependencies come from typed JAXPR variable flow.
tracedrecords whether an all-ones tangent produces a local response abovethreshold. A false entry is local evidence, not global independence.- See:
Implementation Logic¶
Bind the documented output:
result: DependencyMap = make_dependency_map( model_id=model_id, input_paths=_path_names(inputs), output_paths=_path_names(abstract_output), structural=structural, traced=traced, )
The function validates and transforms the inputs before it binds the documented output.
- param model_id:
Permanent scientific model identity (static).
- type model_id:
- param forward_fn:
Pure differentiable forward model.
- type forward_fn:
Callable[[PyTree],PyTree]- param inputs:
Numerical model inputs in their declared physical units.
- type inputs:
PyTree- param threshold:
Positive local-response threshold. Default 1e-12.
- type threshold:
float, default:1e-12- returns:
result – Structural and local numerical dependency matrices.
- rtype:
Notes
The traced matrix is differentiable only through its continuous JVP source. Thresholded Boolean entries do not carry useful gradients.
- diffpes.certify.information_spectrum(forward_fn: Callable[[PyTree], PyTree], inputs: PyTree, *, input_paths: tuple[str, ...] | None = None, output_weights: Float[Array, 'n_output'] | None = None, rank: int = 8, iterations: int = 8, threshold: float = 1e-10) InformationSpectrum[source]¶
Estimate the leading local information spectrum matrix-free.
The function computes leading eigenpairs of
J.T @ W @ Jthrough JVP and VJP maps. It never materializes the dense Jacobian. Singular values are square roots of the nonnegative information eigenvalues.Implementation Logic¶
Bind the documented output:
result: InformationSpectrum = make_information_spectrum( input_paths=paths, singular_values=singular_values, right_singular_vectors=right_vectors, effective_rank=effective_rank, condition_estimate=condition, threshold=threshold, )
The function validates and transforms the inputs before it binds the documented output.
- param forward_fn:
Pure differentiable forward model.
- type forward_fn:
Callable[[PyTree],PyTree]- param inputs:
Numerical model inputs in their declared physical units.
- type inputs:
PyTree- param input_paths:
Names for flattened real input coordinates (static). Default None.
- type input_paths:
- param output_weights:
Nonnegative metric weights for flattened outputs. Default None.
- type output_weights:
Optional[Float[Array, 'n_output']], default:None- param rank:
Requested leading spectrum rank (static). Default 8.
- type rank:
int, default:8- param iterations:
Number of subspace iterations (static). Default 8.
- type iterations:
int, default:8- param threshold:
Singular-value activity threshold. Default 1e-10.
- type threshold:
float, default:1e-10- returns:
result – Leading singular values, right vectors, rank, and condition estimate.
- rtype:
Notes
The subspace iteration and eigendecomposition remain JAX differentiable. Degenerate eigenvalues can make individual singular vectors non-unique.
- diffpes.certify.linearized_forward(forward_fn: Callable[[PyTree], PyTree], inputs: PyTree) tuple[PyTree, Callable[[PyTree], PyTree]][source]¶
Evaluate a forward model and retain its JVP linearization.
The operation exposes local information flow with JAX linearization and PyTree coordinates. Numerical leaves remain differentiable.
Implementation Logic¶
Bind the documented output:
linearized = jax.linearize(forward_fn, inputs)
The function validates and transforms the inputs before it binds the documented output.
- param forward_fn:
Pure JAX forward function accepting one input PyTree.
- type forward_fn:
Callable[[PyTree],PyTree]- param inputs:
Evaluation point for the forward model.
- type inputs:
PyTree- rtype:
- returns:
output (
PyTree) – Forward-model value atinputs.pushforward (
Callable[[PyTree],PyTree]) – Reusable linear map from input tangents to output tangents.
- diffpes.certify.sensitivity_map(input_paths: tuple[str, ...], output_projection_ids: tuple[str, ...], forward_fn: Callable[[PyTree], Array], inputs: PyTree, directions: PyTree, scales: Float[Array, 'n_input'], *, threshold: float = 1e-12) SensitivityMap[source]¶
Measure scaled JVP sensitivities for a batch of tangent directions.
directionshas the same tree structure asinputsand a leading probe axis on every leaf. The flattened output must correspond tooutput_projection_ids.- See:
Implementation Logic¶
Bind the documented output:
result: SensitivityMap = make_sensitivity_map( input_paths=input_paths, output_projection_ids=output_projection_ids, scales=scales, sensitivities=scaled, threshold=threshold, active=active, )
The function validates and transforms the inputs before it binds the documented output.
- param input_paths:
Stable input-coordinate names (static).
- type input_paths:
- param output_projection_ids:
Stable output-projection names (static).
- type output_projection_ids:
- param forward_fn:
Pure differentiable forward model.
- type forward_fn:
- param inputs:
Numerical model inputs in their declared physical units.
- type inputs:
PyTree- param directions:
Batched tangent directions with a leading probe axis.
- type directions:
PyTree- param scales:
Positive physical scale for each input direction.
- type scales:
Float[Array, 'n_input']- param threshold:
Absolute activity threshold. Default 1e-12.
- type threshold:
float, default:1e-12- returns:
result – Scaled output-by-input sensitivities and activity indicators.
- rtype:
Notes
The sensitivity values carry gradients through
jax.linearize. The thresholded activity matrix is a derived diagnostic.
- diffpes.certify.derivative_evidence(forward_fn: Callable[[PyTree], Float[Array, 'n_output']], inputs: PyTree, directions: PyTree, cotangents: Float[Array, 'n_cotangent n_output'], *, input_paths: tuple[str, ...], output_projection_ids: tuple[str, ...], scales: Float[Array, 'n_probe'], step: float = 6e-6, spectrum_rank: int = 8) DerivativeEvidence[source]¶
Compare JAX information flow with batched finite differences.
The tangent tree has a leading probe axis on every leaf. The function reuses one
jax.linearizeresult for all JVP probes. It appliesjax.vmapto the central differences and the retained VJP. The result also contains a matrix-free local information spectrum.Implementation Logic¶
Compute the derivative residuals:
residuals: Array = jvp_values - reference
The residual retains the difference between JAX linearization and the finite-difference reference before construction of the evidence.
- param forward_fn:
Pure differentiable forward model.
- type forward_fn:
Callable[[PyTree],Float[Array, 'n_output']]- param inputs:
Numerical model inputs in their declared physical units.
- type inputs:
PyTree- param directions:
Tangent probes with one leading probe axis on each numerical leaf.
- type directions:
PyTree- param cotangents:
Output-space probes in the units reciprocal to the forward output.
- type cotangents:
Float[Array, 'n_cotangent n_output']- param input_paths:
Stable names for the probed input coordinates (static).
- type input_paths:
- param output_projection_ids:
Stable names for the output projections (static).
- type output_projection_ids:
- param scales:
Positive physical scale for each tangent probe.
- type scales:
Float[Array, 'n_probe']- param step:
Relative central-difference step. Default 6e-6.
- type step:
float, default:6e-6- param spectrum_rank:
Requested information-spectrum rank (static). Default 8.
- type spectrum_rank:
int, default:8- returns:
evidence – JVP, VJP, finite-difference, and local information-spectrum evidence.
- rtype:
Notes
JVP, VJP, residual, and spectrum leaves remain differentiable. The function derives Boolean evidence fields after it retains the continuous values.
- diffpes.certify.evaluate_claim(claim_id: str, subject_id: str, predicate_id: str, measured: Array, reference: Array, tolerance: Array, *, evidence_ids: tuple[str, ...] = (), checked: bool = True, in_domain: bool = True, severity_code: int = 1) CertificationClaim[source]¶
Evaluate a numerical claim and preserve residual and margin leaves.
The operation retains continuous residuals and margins before it derives Boolean certification outcomes. These leaves remain available to JAX transformations.
- See:
- Parameters:
claim_id (
str) – Stable claim identifier (static – changing it retraces).subject_id (
str) – Scientific subject identifier (static – changing it retraces).predicate_id (
str) – Predicate identity (static – changing it retraces).measured (
Array) – Computed numerical values in the predicate units.reference (
Array) – Reference values in the same units.tolerance (
Array) – Nonnegative component tolerances in the same units.evidence_ids (
tuple[str,...], default:()) – Supporting evidence identifiers (static – changing them retraces).checked (
bool, default:True) – Whether evaluation occurred (static – changing it retraces).in_domain (
bool, default:True) – Whether the subject lies in the validity domain (static).severity_code (
int, default:1) – Numerical severity code (static – changing it retraces).
- Returns:
claim – Claim with continuous residual and signed minimum margin leaves.
- Return type:
- Raises:
ValueError – If measured and reference shapes differ.
Notes
The margin is differentiable almost everywhere with respect to measured values. The function derives the Boolean outcome after it retains that margin.
- diffpes.certify.evaluate_domain(predicate_id: str, measured: Array, reference: Array, tolerance: Array, *, checked: bool = True, severity_code: int = 1) DomainResult[source]¶
Evaluate a symmetric domain predicate around a reference value.
The operation retains continuous residuals and margins before it derives Boolean certification outcomes. These leaves remain available to JAX transformations.
- See:
- Parameters:
predicate_id (
str) – Stable domain-predicate identity (static – changing it retraces).measured (
Array) – Measured physical quantity in the predicate units.reference (
Array) – Domain-center value in the same units.tolerance (
Array) – Symmetric half-width in the same units.checked (
bool, default:True) – Whether evaluation occurred (static – changing it retraces).severity_code (
int, default:1) – Numerical severity code (static – changing it retraces).
- Returns:
result – Traced outcome retaining residual and signed boundary margin.
- Return type:
Notes
The signed margin remains differentiable away from the absolute-value cusp. Optimization can use it directly without differentiating a Boolean.
- diffpes.certify.evaluate_evidence(evidence_id: str, method_id: str, measured: Array, reference: Array, tolerance: Array, *, artifact_refs: tuple[str, ...] = (), source_type: str = 'external_reference', independent: bool = True) EvidenceRef[source]¶
Compare measured values with an external numerical reference.
The operation retains continuous residuals and margins before it derives Boolean certification outcomes. These leaves remain available to JAX transformations.
- See:
- Parameters:
evidence_id (
str) – Stable evidence identifier (static – changing it retraces).method_id (
str) – Stable comparison-method identifier (static – a change retraces).measured (
Array) – Computed numerical values in the declared observable units.reference (
Array) – Independent reference values in the same units.tolerance (
Array) – Nonnegative component tolerances in the same units.artifact_refs (
tuple[str,...], default:()) – Source artifact identifiers (static – changing them retraces).source_type (
str, default:"external_reference") – Evidence-source category (static – changing it retraces).independent (
bool, default:True) – Whether the source is independent (static – changing it retraces).
- Returns:
evidence – Vector evidence retaining measured, reference, residual, and tolerance.
- Return type:
- Raises:
ValueError – If measured and reference shapes differ.
Notes
Residuals remain JAX leaves, so losses may differentiate through the comparison before any Boolean policy reduction.
- diffpes.certify.certify_forward(context: CertificationContext, inputs: PyTree, *, directions: PyTree | None = None, scales: Float[Array, 'n_probe'] | None = None, spectrum_rank: int = 8) CertifiedResult[source]¶
Execute a prepared model and produce a certified JAX PyTree.
The operation binds a registered forward model to explicit evidence and policy records. Numerical outputs and assurance leaves remain differentiable.
- See:
- Parameters:
context (
CertificationContext) – Prepared model, policy, evidence, and domain-check selections.inputs (
PyTree) – Numerical model inputs in the model’s declared physical units.directions (
Optional[PyTree], default:None) – Batched tangent probes. By default, the function builds one probe per real input coordinate.scales (
Optional[Float[Array, 'n_probe']], default:None) – Positive physical scale for every tangent probe.spectrum_rank (
int, default:8) – Requested information-spectrum rank (static – a change retraces).
- Returns:
result – Forward value paired with differentiable evidence and policy outcome.
- Return type:
Notes
The result value, residuals, margins, sensitivities, and information spectrum remain differentiable with respect to numerical input leaves.
- diffpes.certify.certify_forward_checked(context: CertificationContext, inputs: PyTree, *, directions: PyTree | None = None, scales: Float[Array, 'n_probe'] | None = None, spectrum_rank: int = 8) tuple[Any, CertifiedResult][source]¶
Execute certification and return structured hard-domain errors.
The function returns a
checkify.Errorwith the certified result. The caller controls when the structured error becomes an exception.- See:
- Parameters:
context (
CertificationContext) – Prepared model, policy, evidence, and domain-check selections.inputs (
PyTree) – Numerical model inputs in the declared physical units.directions (
Optional[PyTree], default:None) – Batched tangent probes. Default None creates one probe per coordinate.scales (
Optional[Float[Array, 'n_probe']], default:None) – Positive physical scale for every tangent probe. Default None.spectrum_rank (
int, default:8) – Requested information-spectrum rank (static). Default 8.
- Returns:
checked – Structured checkify error and complete certified result.
- Return type:
Notes
The structured error remains compatible with JIT and VMAP. Call
error.throw()only at an eager boundary.
- diffpes.certify.prepare_certification(model_id: str, model_version: str, manifest: ExecutionManifest, *, policy_id: str = 'org.diffpes.policy.research.v1', artifacts: tuple[ArtifactRef, ...] = (), transformations: tuple[TransformationRecord, ...] = (), evidence: tuple[EvidenceRef, ...] = (), check_ids: tuple[str, ...] = (), input_checksums: tuple[str, ...] = (), waivers: tuple[WaiverRecord, ...] = ()) CertificationContext[source]¶
Resolve static scientific records before compiled execution.
The operation binds a registered forward model to explicit evidence and policy records. Numerical outputs and assurance leaves remain differentiable.
Implementation Logic¶
Resolve the registered model:
registered: RegisteredModel = get_model(model_id, model_version)
Exact lookup binds the context to one stable scientific model identity before the function collects evidence and domain checks.
- param model_id:
Permanent model identifier (static – changing it retraces).
- type model_id:
- param model_version:
Exact semantic model version (static – changing it retraces).
- type model_version:
- param manifest:
Prepared execution identity and numerical environment.
- type manifest:
- param policy_id:
Certification policy identity (static – changing it retraces).
- type policy_id:
str, default:"org.diffpes.policy.research.v1"- param artifacts:
Input and derived artifact references.
- type artifacts:
tuple[ArtifactRef,...], default:()- param transformations:
Ordered information-flow records.
- type transformations:
tuple[TransformationRecord,...], default:()- param evidence:
Independent numerical evidence records.
- type evidence:
tuple[EvidenceRef,...], default:()- param check_ids:
Domain checks to run (static – changing them retraces).
- type check_ids:
- param input_checksums:
Bookkeeping identities for inputs (static – a change retraces).
- type input_checksums:
- param waivers:
Policy-waiver records. Default is an empty tuple.
- type waivers:
tuple[WaiverRecord,...], default:()- returns:
context – Cross-validated static selections for compiled execution.
- rtype:
- raises ValueError:
If a waiver does not match the selected policy or active UTC interval.
- diffpes.certify.verify_certificate(certificate: ForwardCertificate, *, resolver: ArtifactResolver | None = None) VerificationReport[source]¶
Re-evaluate numerical claim and policy consistency without a rerun.
The operation binds a registered forward model to explicit evidence and policy records. Numerical outputs and assurance leaves remain differentiable.
- See:
- Parameters:
certificate (
ForwardCertificate) – Concrete certificate. The function checks its internal numerical relations.resolver (
Optional[Callable[[ArtifactRef],tuple[Any,Optional[bytes]]]], default:None) – Artifact resolver for external evidence. Default None checks only internal consistency and does not make a resolution claim.
- Returns:
report – Structural and policy consistency outcome.
- Return type:
Notes
Verification recomputes recorded relations only. It does not rerun the forward model or convert bookkeeping checksums into scientific evidence.
- diffpes.certify.diff_certificates(left: ForwardCertificate, right: ForwardCertificate) CertificateDiff[source]¶
Compare two certificates by scientific meaning and record class.
The inspection result answers a bounded scientific question without loading the associated result arrays. It excludes private source locators.
- See:
Implementation Logic¶
Bind the documented output:
difference: CertificateDiff = make_certificate_diff( scientific=tuple(scientific), numerical=_field_differences(left, right, numerical_names), environment=_field_differences( left.manifest, right.manifest, environment_names, ), audit=tuple(audit), )
The function validates and transforms the inputs before it binds the documented output.
- param left:
Reference certificate.
- type left:
- param right:
Candidate certificate.
- type right:
- returns:
difference – Stable field-name differences grouped into scientific, numerical, environment, and audit categories.
- rtype:
- diffpes.certify.explain_claim(certificate: ForwardCertificate, claim_id: str) str[source]¶
Explain one claim and the numerical evidence supporting it.
The inspection result answers a bounded scientific question without loading the associated result arrays. It excludes private source locators.
- See:
Implementation Logic¶
Bind the documented output:
explanation: str = "\n".join(lines)
The function validates and transforms the inputs before it binds the documented output.
- param certificate:
Certificate containing the claim.
- type certificate:
- param claim_id:
Stable claim identifier to explain.
- type claim_id:
- returns:
explanation – Multiline explanation with status, margin, and evidence arrays.
- rtype:
- raises KeyError:
If the certificate does not contain
claim_id.
- diffpes.certify.summarize_certificate(certificate: ForwardCertificate) str[source]¶
Return a deterministic human-readable certificate summary.
The inspection result answers a bounded scientific question without loading the associated result arrays. It excludes private source locators.
Implementation Logic¶
Bind the documented output:
summary: str = "\n".join(lines)
The function validates and transforms the inputs before it binds the documented output.
- param certificate:
Certificate to summarize. The function does not need or load the associated result arrays.
- type certificate:
- returns:
summary – Compact multiline summary of identity, semantics, provenance, claim status, and derivative diagnostics.
- rtype:
- diffpes.certify.execute_tb_radial(inputs: tuple[Any, ...]) ArpesSpectrum[source]¶
Execute the radial ARPES model from one certification input PyTree.
The tuple order is
(bands, radial, simulation, polarization, work_function, self_energy, radial_grid, momentum_width). Optional entries useNoneand therefore become empty JAX subtrees.- See:
Implementation Logic¶
Bind the documented output:
spectrum: ArpesSpectrum = simulate_tb_radial( bands, radial, simulation, polarization, work_function=work_function, self_energy=self_energy, r_grid=grid, dk=dk, )
The function validates and transforms the inputs before it binds the documented output.
- param inputs:
Eight-position radial-model input PyTree. Its tuple structure is static; a change to the structure triggers retracing.
- type inputs:
- returns:
spectrum – Simulated ARPES intensity and axes in their declared physical units.
- rtype:
- raises ValueError:
If
inputsdoes not contain exactly eight entries.
Notes
Gradients pass through every numerical input accepted by
simulate_tb_radial().
- diffpes.certify.register_builtin_models() None[source]¶
Register built-in models and information-loss transformations.
The operation uses the built-in radial ARPES adapter and its declared conventions. It preserves JAX differentiation through numerical model inputs.
Notes
Registration is explicit and idempotent at the eager application boundary. Numerical model execution and domain predicates remain pure JAX programs.
- Return type:
- diffpes.certify.tb_radial_model_spec() ForwardModelSpec[source]¶
Return the stable scientific specification for radial ARPES.
The operation uses the built-in radial ARPES adapter and its declared conventions. It preserves JAX differentiation through numerical model inputs.
- See:
- Returns:
spec – Versioned assumptions, conventions, domain, and differentiable paths.
- Return type:
Notes
The specification identifies the current tight-binding plus radial dipole model. It does not itself evaluate or certify a numerical result.
- diffpes.certify.achieved_levels(report: PolicyReport) tuple[str, ...][source]¶
Return certification level names achieved by a concrete report.
The cumulative policy derives named levels from explicit claims. It retains the claim truth table as JAX arrays.
- See:
- Parameters:
report (
PolicyReport) – Concrete policy report inspected at the eager boundary.- Returns:
levels – Achieved level identities in cumulative policy order.
- Return type:
Notes
This eager inspection helper converts the traced Boolean vector to a Python tuple. Do not call the helper inside a compiled kernel.
- diffpes.certify.evaluate_policy(claims: Iterable[CertificationClaim], policy_id: str = 'org.diffpes.policy.research.v1', *, waivers: tuple[WaiverRecord, ...] = ()) PolicyReport[source]¶
Derive cumulative certification outcomes from numerical claims.
The cumulative policy derives named levels from explicit claims. It retains the claim truth table as JAX arrays.
- See:
- Parameters:
claims (
Iterable[CertificationClaim]) – Numerical claims evaluated for one forward execution.policy_id (
str, default:"org.diffpes.policy.research.v1") – Built-in cumulative policy identity (static – a change retraces).waivers (
tuple[WaiverRecord,...], default:()) – Valid active waiver records. Default is an empty tuple.
- Returns:
report – Traced truth table and cumulative achieved-level vector.
- Return type:
- Raises:
ValueError – If
policy_idis not a registered built-in policy.
Notes
Required claim selections are static. Boolean outcomes are JAX leaves, so the policy computation remains compatible with
jitandvmap. A waiver never changes a claim outcome. Publication and parity policies do not achieve their final level when a waiver exists.
- diffpes.certify.build_provenance(records: Sequence[TransformationRecord], *, external_inputs: Mapping[str, Iterable[str]] | Iterable[str] = (), strict: bool = True) ProvenanceGraph[source]¶
Build a deterministic provenance DAG and propagate information.
The operation propagates semantic state, information loss, and claim invalidation through a directed artifact graph. It reports contradictions explicitly.
- See:
Implementation Logic¶
Bind the documented output:
graph: ProvenanceGraph = make_provenance_graph( records=normalized_records, external_inputs=input_ids, initial_semantics=semantic_pairs, topological_order=analysis.topological_order, information=analysis.information, validation_errors=analysis.errors, graph_checksum=checksum, )
The function validates and transforms the inputs before it binds the documented output.
- param records:
Transformation executions linking parent and output artifact IDs.
- type records:
- param external_inputs:
Known source-node IDs. A mapping additionally declares the semantic properties initially available on each source.
- type external_inputs:
- param strict:
Raise
ValueErrorfor any invalid graph.Falseis useful to construct an inspectable rejected graph.- type strict:
bool, default:True- returns:
graph – Immutable graph with propagated per-node semantic state.
- rtype:
- raises ValueError:
If strict validation detects a cycle or an invalid node. This error also identifies an unused input or contradictory information.
- diffpes.certify.effective_information(graph: ProvenanceGraph, output_id: str) InformationState[source]¶
Return propagated semantics, losses, and invalidations for one node.
The operation propagates semantic state, information loss, and claim invalidation through a directed artifact graph. It reports contradictions explicitly.
Implementation Logic¶
Bind the documented output:
msg: str = f"unknown provenance node: {output_id}"
The function validates and transforms the inputs before it binds the documented output.
- param graph:
Validated provenance graph to inspect.
- type graph:
- param output_id:
Artifact or result node identifier.
- type output_id:
- returns:
information – Propagated semantic state at the requested node.
- rtype:
- raises KeyError:
If
output_idis absent from the graph.
- diffpes.certify.invalidated_claims(graph: ProvenanceGraph, output_id: str) tuple[str, ...][source]¶
Return every claim invalidated at or upstream of one output.
The operation propagates semantic state, information loss, and claim invalidation through a directed artifact graph. It reports contradictions explicitly.
Implementation Logic¶
Bind the documented output:
claims: tuple[str, ...] = effective_information( graph, output_id, ).invalidated_claims
The function validates and transforms the inputs before it binds the documented output.
- param graph:
Validated provenance graph to inspect.
- type graph:
- param output_id:
Artifact or result node identifier.
- type output_id:
- returns:
claims – Sorted claim identifiers invalidated along the upstream lineage.
- rtype:
- diffpes.certify.lineage(graph: ProvenanceGraph, output_id: str) tuple[str, ...][source]¶
Return the transitive parent-node lineage of one output.
The operation propagates semantic state, information loss, and claim invalidation through a directed artifact graph. It reports contradictions explicitly.
- See:
Implementation Logic¶
Bind the documented output:
result: tuple[str, ...] = tuple(sorted(ancestors))
The function validates and transforms the inputs before it binds the documented output.
- param graph:
Validated provenance graph to inspect.
- type graph:
- param output_id:
Artifact or result node identifier.
- type output_id:
- returns:
result – Sorted transitive ancestor identifiers.
- rtype:
- raises KeyError:
If
output_idis absent from the graph.
- diffpes.certify.validate_provenance(graph: ProvenanceGraph) ProvenanceReport[source]¶
Re-evaluate graph structure and derived state independently.
The operation propagates semantic state, information loss, and claim invalidation through a directed artifact graph. It reports contradictions explicitly.
Implementation Logic¶
Bind the documented output:
report: ProvenanceReport = make_provenance_report( valid=not errors, errors=tuple(errors), roots=analysis.roots, terminal_outputs=analysis.terminal_outputs, orphaned_inputs=analysis.orphaned_inputs, topological_order=analysis.topological_order, graph_checksum=expected_checksum, )
The function validates and transforms the inputs before it binds the documented output.
- param graph:
Graph returned by
build_provenance()or read from storage.- type graph:
- returns:
report – Complete deterministic validation result.
- rtype:
- diffpes.certify.freeze_registry() RegistrySnapshot[source]¶
Prevent later registration and return the final immutable snapshot.
The process-local registry uses exact scientific identities and deterministic ordering. Freezing prevents later mutation of the selected programs.
- See:
- Returns:
snapshot – Final immutable contents after the function disables mutation.
- Return type:
Notes
Freezing is process-local eager registry control and is never invoked from a traced numerical kernel.
- diffpes.certify.get_model(model_id: str, model_version: str) RegisteredModel[source]¶
Resolve an exact registered model.
The process-local registry uses exact scientific identities and deterministic ordering. Freezing prevents later mutation of the selected programs.
- See:
Implementation Logic¶
Bind the documented output:
msg: str = f"unknown model identity: {model_id}@{model_version}"
The function validates and transforms the inputs before it binds the documented output.
- param model_id:
Permanent scientific model identifier.
- type model_id:
- param model_version:
Exact semantic model version.
- type model_version:
- returns:
model – Immutable registered model binding.
- rtype:
- raises KeyError:
If the exact ID and semantic version are absent.
- diffpes.certify.get_transformation(transformation_id: str, transformation_version: str) RegisteredTransformation[source]¶
Resolve an exact registered transformation contract.
The process-local registry uses exact scientific identities and deterministic ordering. Freezing prevents later mutation of the selected programs.
Implementation Logic¶
Bind the documented output:
msg: str = ( "unknown transformation identity: " f"{transformation_id}@{transformation_version}" )
The function validates and transforms the inputs before it binds the documented output.
- param transformation_id:
Permanent transformation identifier.
- type transformation_id:
- param transformation_version:
Exact semantic transformation version.
- type transformation_version:
- returns:
transformation – Immutable registered transformation binding.
- rtype:
- raises KeyError:
If the exact ID and semantic version are absent.
- diffpes.certify.list_handshakes() tuple[RegistrationHandshake, ...][source]¶
Return owner handshakes in deterministic identity order.
The process-local registry returns one immutable tuple.
- See:
- Returns:
handshakes – Immutable sorted handshake declarations.
- Return type:
Notes
The function reads the tuple while the registry lock is active.
- diffpes.certify.list_models() tuple[ForwardModelSpec, ...][source]¶
Return model specifications in deterministic identity order.
The process-local registry uses exact scientific identities and deterministic ordering. Freezing prevents later mutation of the selected programs.
- See:
Implementation Logic¶
Bind the documented output:
models: tuple[ForwardModelSpec, ...] = tuple( entry.spec for entry in state.models )
The function validates and transforms the inputs before it binds the documented output.
- returns:
models – Immutable sorted model specifications without executor callables.
- rtype:
- diffpes.certify.list_registered_models() tuple[RegisteredModel, ...][source]¶
Return an immutable deterministic snapshot including executors.
The process-local registry uses exact scientific identities and deterministic ordering. Freezing prevents later mutation of the selected programs.
Implementation Logic¶
Bind the documented output:
models: tuple[RegisteredModel, ...] = state.models
The function validates and transforms the inputs before it binds the documented output.
- returns:
models – Immutable sorted model bindings including static executor callables.
- rtype:
- diffpes.certify.list_transformations() tuple[TransformationContract, ...][source]¶
Return transformation contracts in deterministic identity order.
The process-local registry uses exact scientific identities and deterministic ordering. Freezing prevents later mutation of the selected programs.
Implementation Logic¶
Bind the documented output:
transformations: tuple[TransformationContract, ...] = tuple( entry.contract for entry in state.transformations )
The function validates and transforms the inputs before it binds the documented output.
- returns:
transformations – Immutable sorted semantic and information-loss contracts.
- rtype:
- diffpes.certify.packaged_model_card(model_id: str, model_version: str) str[source]¶
Read the packaged generated card for one model identity.
The filename combines the permanent model ID with its semantic version.
Implementation Logic¶
Read the generated resource:
filename = f"{model_id}@{model_version}.md"
The package resource contains the canonical generated Markdown view.
- diffpes.certify.register_handshake(handshake: RegistrationHandshake) None[source]¶
Register declarative requirements from one owning plan.
The registry stores requirements before or after the owner registers them.
- See:
- Return type:
Implementation Logic¶
Store the sorted declaration:
state.handshakes = tuple( sorted((*state.handshakes, handshake), key=_handshake_key) )
Stable owner ordering removes import-order effects.
- param handshake:
Exact model, transformation, convention, and evidence references.
- type handshake:
- raises ValueError:
If the owner has a handshake or the registry has a frozen state.
- diffpes.certify.register_model(spec: ForwardModelSpec, executor: Callable[[...], Any]) None[source]¶
Register an exact model identity once.
The process-local registry uses exact scientific identities and deterministic ordering. Freezing prevents later mutation of the selected programs.
- See:
- Return type:
Implementation Logic¶
Bind the documented output:
state.models = tuple(sorted((*state.models, entry), key=_model_key))
The function validates and transforms the inputs before it binds the documented output.
- param spec:
Immutable scientific model specification.
- type spec:
- param executor:
Pure model implementation. Certification later verifies its JAX behavior. Registration only requires a callable.
- type executor:
- raises ValueError:
If the identity is invalid or already exists. The function also raises when the registry no longer accepts changes.
- diffpes.certify.register_transformation(contract: TransformationContract) None[source]¶
Register an exact transformation contract once.
The process-local registry uses exact scientific identities and deterministic ordering. Freezing prevents later mutation of the selected programs.
- See:
- Return type:
Implementation Logic¶
Bind the documented output:
state.transformations = tuple( sorted( (*state.transformations, entry), key=_transformation_key, ) )
The function validates and transforms the inputs before it binds the documented output.
- param contract:
Validated semantic and information-loss declaration.
- type contract:
- raises ValueError:
If the contract is invalid or duplicated. The function also raises when the registry no longer accepts changes.
- diffpes.certify.registry_manifest() dict[str, Any][source]¶
Read the packaged registry manifest.
The manifest records generated model and transformation identities.
- See:
Implementation Logic¶
Parse the package resource:
decoded = json.loads(text)
The function rejects a root that is not a JSON object.
- diffpes.certify.registry_snapshot() RegistrySnapshot[source]¶
Return one internally consistent immutable registry snapshot.
The process-local registry uses exact scientific identities and deterministic ordering. Freezing prevents later mutation of the selected programs.
- See:
Implementation Logic¶
Bind the documented output:
snapshot: RegistrySnapshot = make_registry_snapshot( models=models, transformations=transformations, checksum=checksum, )
The function validates and transforms the inputs before it binds the documented output.
- returns:
snapshot – Models, transformations, and their non-security consistency checksum.
- rtype:
- diffpes.certify.render_model_card(spec: ForwardModelSpec) str[source]¶
Render a model card directly from a model specification.
The generated Markdown contains no separately maintained scientific data.
- See:
Implementation Logic¶
Render registry fields:
card = f"# {spec.model_id}\\n\\nVersion: `{spec.model_version}`."
The complete output also lists assumptions, conventions, and domains.
- param spec:
Registered scientific model specification.
- type spec:
- returns:
card – Deterministic Markdown generated only from registry truth.
- rtype:
- diffpes.certify.validate_handshake(handshake: RegistrationHandshake, *, evidence_ids: tuple[str, ...] = ()) HandshakeReport[source]¶
Validate one owner handshake against available records.
The report names each exact reference that has no available binding.
Implementation Logic¶
Collect missing references:
missing = tuple( reference for required, available in available_groups for reference in required if reference not in available )
The comparison uses exact versioned identities from each registry.
- param handshake:
Declarative requirements supplied by the owning plan.
- type handshake:
- param evidence_ids:
Available evidence record IDs. Default is an empty tuple.
- type evidence_ids:
- returns:
report – Completion state and sorted missing exact references.
- rtype:
- diffpes.certify.validate_registry() RegistryReport[source]¶
Recompute registry structure and consistency checksums.
The process-local registry uses exact scientific identities and deterministic ordering. Freezing prevents later mutation of the selected programs.
- See:
Implementation Logic¶
Bind the documented output:
report: RegistryReport = make_registry_report( valid=not errors, errors=tuple(errors), model_count=len(models), transformation_count=len(transformations), checksum=checksum, frozen=frozen, )
The function validates and transforms the inputs before it binds the documented output.
- returns:
report – Validation errors, entry counts, deterministic checksum, and frozen state. The checksum has bookkeeping meaning only.
- rtype:
- diffpes.certify.validate_registry_manifest() tuple[str, ...][source]¶
Compare the packaged registry manifest with live entries.
The comparison detects missing entries and generated model-card drift.
Implementation Logic¶
Compare packaged entries:
manifest = registry_manifest()
The function compares each manifest identity with the live registry.
- diffpes.certify.reproduce_forward(certificate: ForwardCertificate, *, resolver: ArtifactResolver, tolerance: float = 1e-10) ReproductionReport[source]¶
Re-execute a registered model and compare its recorded result.
The runner resolves one normalized input and one separately stored result.
- See:
Implementation Logic¶
Resolve and re-execute:
reproduced_value = registered.executor(inputs)
Exact registry lookup binds the rerun to the certificate model.
Compare numerical leaves:
absolute = jnp.abs(actual_flat - expected_flat)
The report stores maximum absolute and relative errors.
- param certificate:
Certificate with one normalized-input and one result artifact.
- type certificate:
- param resolver:
Eager resolver for both normalized artifacts.
- type resolver:
- param tolerance:
Nonnegative absolute and relative comparison tolerance. Default 1e-10.
- type tolerance:
float, default:1e-10- returns:
report – Numerical comparison and reproduced result identity.
- rtype:
- raises ValueError:
If required artifact roles or result tree structure are inconsistent.
Notes
The comparison uses
tolerancefor both the absolute and relative terms. Each leaf must satisfyabsolute <= tolerance * (1 + abs(expected)).
- diffpes.certify.filesystem_artifact_resolver(reference: ArtifactRef) tuple[bytes, bytes][source]¶
Resolve a byte-valued artifact from its local locator.
The resolver returns normalized bytes and exact source bytes separately.
Implementation Logic¶
Read the local artifact:
data = Path(reference.locator).read_bytes()
The calling validator checks both returned byte identities.
- param reference:
Artifact with a local filesystem locator.
- type reference:
- returns:
resolved – Normalized byte value and the same exact source bytes.
- rtype:
- raises ValueError:
If the artifact has no local locator.
- diffpes.certify.mapping_artifact_resolver(artifacts: Mapping[str, Any]) ArtifactResolver[source]¶
Build a deterministic resolver from normalized in-memory values.
The resolver uses exact artifact IDs and an immutable mapping copy.
Implementation Logic¶
Freeze the supplied mapping:
frozen = dict(artifacts)
The resolver reads this copy for each exact artifact ID.
- diffpes.certify.resolve_artifact(reference: ArtifactRef, resolver: ArtifactResolver) Any[source]¶
Resolve and validate one referenced artifact.
The function checks normalized content and any available exact bytes.
- See:
Implementation Logic¶
Check normalized content:
content_checksum = checksum_pytree( value, record_kind="normalized-content" )
The function rejects content that differs from the artifact reference.
- param reference:
Expected byte, normalized-content, and semantic identities.
- type reference:
- param resolver:
Eager resolver for the artifact location or backing store.
- type resolver:
- returns:
value – Validated normalized scientific content.
- rtype:
- raises ValueError:
If a returned byte or content identity does not match.
- diffpes.certify.verify_evidence(reference: EvidenceRef, artifacts: tuple[ArtifactRef, ...], resolver: ArtifactResolver) EvidenceReport[source]¶
Verify referenced artifacts and recorded numerical residuals.
The report keeps resolution, compatibility, and tolerance outcomes distinct.
- See:
Implementation Logic¶
Resolve each evidence artifact:
resolve_artifact(artifact, resolver)
The final outcome also requires every numerical residual to fit.
- param reference:
Numerical evidence and the artifact IDs that support it.
- type reference:
- param artifacts:
Available artifact records.
- type artifacts:
- param resolver:
Eager resolver for normalized artifact content.
- type resolver:
- returns:
report – Resolution, compatibility, and numerical tolerance outcome.
- rtype:
- diffpes.certify.require_active_waivers(waivers: tuple[WaiverRecord, ...], *, as_of_utc: str) None[source]¶
Reject malformed, expired, or premature waiver records.
The eager boundary rejects every record without active temporal scope.
- See:
- Parameters:
waivers (
tuple[WaiverRecord,...]) – Static waiver declarations.as_of_utc (
str) – Absolute UTC evaluation time ending inZ.
- Raises:
ValueError – If one waiver lacks valid and active temporal scope.
- Return type:
Notes
Successful validation records the waiver only. It does not change any failed, unchecked, or out-of-domain claim.
- diffpes.certify.validate_waiver(waiver: WaiverRecord, *, as_of_utc: str) WaiverReport[source]¶
Validate one waiver against an explicit absolute UTC time.
The report distinguishes malformed records from records outside their active interval.
- See:
- Parameters:
waiver (
WaiverRecord) – Static waiver declaration.as_of_utc (
str) – Absolute UTC evaluation time ending inZ.
- Returns:
report – Structural validity, temporal activity, and validation errors.
- Return type:
Notes
The function performs static I/O-boundary validation. It does not run in a compiled certification kernel.
- diffpes.certify.validate_waivers(waivers: tuple[WaiverRecord, ...], *, as_of_utc: str) tuple[WaiverReport, ...][source]¶
Validate multiple waivers against one explicit absolute UTC time.
The function rejects duplicate identities. It then validates each interval.
- See:
Implementation Logic¶
Validate each waiver:
reports = tuple( validate_waiver(waiver, as_of_utc=as_of_utc) for waiver in waivers )
Input ordering remains stable in the returned report tuple.
- param waivers:
Static waiver declarations.
- type waivers:
- param as_of_utc:
Absolute UTC evaluation time ending in
Z.- type as_of_utc:
- returns:
reports – Validation reports in input order.
- rtype:
- raises ValueError:
If waiver identities contain duplicates.