#!/usr/bin/env julia # Runs the same checks with two Julia optimization settings and compares every # deterministic certificate byte for byte. No external packages or downloads. using TOML, SHA, Dates root=normpath(joinpath(@__DIR__,".."));evidence=joinpath(root,"evidence") mkpath(evidence) records=Dict{String,Any}[] for level in (0,3) tag="O$level";out=joinpath(evidence,tag);mkpath(out) cmd=`$(Base.julia_cmd()) --startup-file=no --project=$root -O$level --check-bounds=yes $(joinpath(root,"run_proofs.jl")) $out` started=string(now(UTC));t0=time_ns() status=open(joinpath(evidence,tag*".log"),"w") do io run(pipeline(ignorestatus(cmd),stdout=io,stderr=io)).exitcode end elapsed=(time_ns()-t0)/1e9 push!(records,Dict("mode"=>tag,"command"=>string(cmd),"exit_status"=>status, "started_utc"=>started,"elapsed_seconds_empirical"=>elapsed)) println(tag," exit=",status," elapsed_seconds=",round(elapsed;digits=3)) open(joinpath(evidence,"run_manifest.toml"),"w") do io TOML.print(io,Dict("julia_version"=>string(VERSION),"runs"=>records);sorted=true) end status==0 || error("$tag failed; inspect evidence/$tag.log") end names=sort(readdir(joinpath(evidence,"O0"))) names==sort(readdir(joinpath(evidence,"O3"))) || error("certificate file sets differ") open(joinpath(evidence,"optimization_comparison.tsv"),"w") do io println(io,"file\tsha256_O0\tsha256_O3\tidentical_bytes") for name in names a=read(joinpath(evidence,"O0",name));b=read(joinpath(evidence,"O3",name)) a==b || error("optimization-dependent certificate: $name") println(io,name,"\t",bytes2hex(sha256(a)),"\t",bytes2hex(sha256(b)),"\ttrue") end end println("Both runs completed; ",length(names)," certificate files agree byte for byte.")