Skip to main content

vyre_conform/proof/oracles/
mod.rs

1//! Filesystem-registered proof oracles.
2
3use crate::pipeline::certify::Violation;
4use crate::spec::types::OpSpec;
5use crate::spec::types::OracleKind;
6
7/// Context supplied to an oracle verification pass.
8pub struct VerifyCtx<'a> {
9    /// Operation specification being verified.
10    pub op: &'a OpSpec,
11    /// Backend identifier whose output is under verification.
12    pub backend_id: &'a str,
13    /// Input bytes for the verification case.
14    pub input: &'a [u8],
15    /// CPU reference bytes for the verification case.
16    pub reference_output: &'a [u8],
17    /// Backend output bytes for the verification case.
18    pub backend_output: &'a [u8],
19}
20
21/// Result of an oracle verification pass.
22pub type VerifyResult = Result<(), Violation>;
23
24/// Independent proof source for expected conformance output.
25pub trait Oracle: Send + Sync {
26    /// Stable oracle identifier.
27    fn id(&self) -> &'static str;
28
29    /// Oracle hierarchy kind.
30    fn kind(&self) -> OracleKind;
31
32    /// Whether this oracle can verify the supplied operation.
33    fn applicable_to(&self, op: &OpSpec) -> bool;
34
35    /// Verify a backend output against this oracle.
36    fn verify(&self, ctx: &VerifyCtx<'_>) -> VerifyResult;
37}
38
39automod::dir!(pub(crate) "src/proof/oracles");
40
41include!(concat!(env!("OUT_DIR"), "/oracles_registry.rs"));