Skip to main content

verify_against_kernel

Function verify_against_kernel 

Source
pub fn verify_against_kernel(
    binders: &[Binder],
    kernel: &PolydatKernel,
) -> Result<(), Vec<BinderViolation>>
Expand description

Verify each binder slot’s rvalue (wire) type against its declared lvalue type, using the lookup closure to resolve wire names to their PortType. The closure returns None for unknown wires.

Returns every violation found (not just the first) so the operator fixes them in one pass.

Why a closure instead of &PolydatProgram: the verifier shouldn’t be coupled to one program/kernel surface. Callers supply whatever lookup matches their wire-resolution context — kernel program output table, scope-init constants, auto-externed parent-scope wires, or test fixtures. Verify binders against a crate::kernel::PolydatKernel directly, returning Ok(()) when every slot’s rvalue→lvalue check passes and Err(Vec<BinderViolation>) listing every failure otherwise.

Convenience wrapper around verify_binders for the common case where the wire-type lookup comes from a polydat kernel the host was handed during dispenser init. A host adapter calls this inline while mapping an op — completing the currying stack — to verify any typed binders before returning the constructed dispenser.

Looks up each binder slot’s wire as either an output or an input of the kernel’s program (outputs are checked first; inputs are the fallback for coordinate/extern wires the op-template kernel auto-externs from outer scope). A wire that resolves to neither surfaces as a “not declared” binder violation rather than silent passthrough.