pub struct ValidationCache { /* private fields */ }Expand description
Successful-program validation cache shared by concrete drivers.
Implementations§
Source§impl ValidationCache
impl ValidationCache
Sourcepub fn new(
max_hash_entries: usize,
max_vsa_entries: usize,
vsa_shards: usize,
) -> Self
pub fn new( max_hash_entries: usize, max_vsa_entries: usize, vsa_shards: usize, ) -> Self
Create a validation cache with bounded hash and VSA storage.
Sourcepub fn program_hash(program: &Program) -> Hash
pub fn program_hash(program: &Program) -> Hash
Compute the validation hash for a program.
Sourcepub fn contains_hash(&self, hash: &Hash) -> bool
pub fn contains_hash(&self, hash: &Hash) -> bool
Return whether a validation hash is cached.
Sourcepub fn remember_hash(&self, hash: Hash)
pub fn remember_hash(&self, hash: Hash)
Remember a successful validation hash.
Sourcepub fn remember_success(
&self,
hash: Hash,
vsa: &[u32],
) -> Result<(), BackendError>
pub fn remember_success( &self, hash: Hash, vsa: &[u32], ) -> Result<(), BackendError>
Remember a successful validation hash and its VSA fingerprint.
§Errors
Returns if a VSA shard lock is poisoned.
Sourcepub fn clear(&self) -> Result<(), BackendError>
pub fn clear(&self) -> Result<(), BackendError>
Sourcepub fn get_or_validate(
&self,
program: &Program,
validation_options: ValidationOptions<'_>,
supported_ops: &HashSet<OpId>,
caps: ProgramValidationCaps,
) -> Result<(), BackendError>
pub fn get_or_validate( &self, program: &Program, validation_options: ValidationOptions<'_>, supported_ops: &HashSet<OpId>, caps: ProgramValidationCaps, ) -> Result<(), BackendError>
Validate program once, memoizing the complete backend contract.
This is the shared driver validation path: foundation invariants, backend supported-op coverage, program capability requirements, and VSA cache insertion all happen in one place. Concrete drivers supply only their actual capability values.
§Errors
Returns when validation fails or a VSA shard lock is poisoned.
Sourcepub fn get_or_validate_backend<B>(
&self,
program: &Program,
backend: &B,
) -> Result<(), BackendError>where
B: VyreBackend + BackendValidationCapabilities,
pub fn get_or_validate_backend<B>(
&self,
program: &Program,
backend: &B,
) -> Result<(), BackendError>where
B: VyreBackend + BackendValidationCapabilities,
Validate program against a concrete backend and cache successful
results.
This is the canonical driver-owned validation-cache entry point for backends that implement both the runtime backend contract and the foundation capability-validation contract.
§Errors
Returns when validation fails or cache mutation fails.