use uor_foundation::enforcement::{
BinaryProjectionMap, CompileUnitBuilder, ConstrainedTypeInput, Grounded, Sinking, Term,
Utf8ProjectionMap,
};
use uor_foundation::pipeline::run;
use uor_foundation::{VerificationDomain, WittLevel};
use uor_foundation_test_helpers::Fnv1aHasher16;
static ROOT_TERMS: &[Term] = &[Term::Literal {
value: 42,
level: WittLevel::W8,
}];
static DOMAINS: &[VerificationDomain] = &[VerificationDomain::Enumerative];
struct WitnessReport;
impl Sinking for WitnessReport {
type Source = ConstrainedTypeInput;
type ProjectionMap = Utf8ProjectionMap;
type Output = String;
fn project(&self, grounded: &Grounded<ConstrainedTypeInput>) -> String {
format!(
"witt_bits={} unit_address={:?} sigma={:.6}",
grounded.witt_level_bits(),
grounded.unit_address(),
grounded.sigma().value()
)
}
}
struct FingerprintBytes;
impl Sinking for FingerprintBytes {
type Source = ConstrainedTypeInput;
type ProjectionMap = BinaryProjectionMap;
type Output = Vec<u8>;
fn project(&self, grounded: &Grounded<ConstrainedTypeInput>) -> Vec<u8> {
grounded.content_fingerprint().as_bytes().to_vec()
}
}
fn main() {
let unit = CompileUnitBuilder::new()
.root_term(ROOT_TERMS)
.witt_level_ceiling(WittLevel::W32)
.thermodynamic_budget(4096)
.target_domains(DOMAINS)
.result_type::<ConstrainedTypeInput>()
.validate()
.expect("unit is well-formed");
let grounded =
run::<ConstrainedTypeInput, _, Fnv1aHasher16>(unit).expect("pipeline admits the unit");
let report = WitnessReport.project(&grounded);
let bytes = FingerprintBytes.project(&grounded);
println!("WitnessReport → {report}");
println!(
"FingerprintBytes → {} bytes: {:02x?}",
bytes.len(),
&bytes[..bytes.len().min(8)]
);
println!(
"\nTarget §3 guarantee upheld: both sinks consumed &Grounded<{}>,\n\
not raw primitives. The sealing of Grounded<T> is the sole\n\
structural assurance that unverified data cannot be laundered outward.",
std::any::type_name::<ConstrainedTypeInput>()
);
}