feat(vm): add deterministic gameplay math and domain coverage gates
Intrepid/Prometeu/Runtime/pipeline/pr-master There was a failure building this commit

This commit is contained in:
2026-10-09 10:25:11 +01:00
parent 2e041266f1
commit 9318cf7cd3
47 changed files with 8825 additions and 281 deletions
Generated
+20
View File
@@ -777,6 +777,15 @@ version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b"
[[package]]
name = "fpmath"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f617488244e3bd5aa86da93efaf4072579a301832ca5a9c7e3493563b509a43d"
dependencies = [
"rustc_apfloat",
]
[[package]]
name = "fraction"
version = "0.15.4"
@@ -2159,6 +2168,7 @@ dependencies = [
name = "prometeu-vm"
version = "0.1.0"
dependencies = [
"fpmath",
"prometeu-bytecode",
"prometeu-hal",
"prometeu-test-support",
@@ -2361,6 +2371,16 @@ version = "2.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d"
[[package]]
name = "rustc_apfloat"
version = "0.2.3+llvm-462a31f5a5ab"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "486c2179b4796f65bfe2ee33679acf0927ac83ecf583ad6c91c3b4570911b9ad"
dependencies = [
"bitflags 2.10.0",
"smallvec",
]
[[package]]
name = "rustix"
version = "0.38.44"
+4 -1
View File
@@ -1,4 +1,4 @@
.PHONY: fmt fmt-check clippy test-local test-debugger-socket clean coverage coverage-xml coverage-json coverage-report-json coverage-domain-list coverage-domain-evidence coverage-domain-gate test ci ci-domains cobertura
.PHONY: fmt fmt-check clippy test-local test-debugger-socket clean coverage coverage-xml coverage-json coverage-report-json coverage-domain-list coverage-domain-evidence coverage-domain-audit coverage-domain-gate test ci ci-domains cobertura
fmt:
cargo fmt
@@ -33,6 +33,9 @@ coverage-json:
coverage-domain-list:
./scripts/coverage-domain-evidence.sh --list
coverage-domain-audit:
python3 scripts/audit-coverage-domains.py --report target/llvm-cov/report.json
coverage-domain-evidence:
@if [ -z "$(DOMAIN)" ]; then \
echo "usage: make coverage-domain-evidence DOMAIN=<domain>"; \
@@ -32,6 +32,12 @@ pub const TRAP_INVALID_HANDLE: u32 = 0x0000_000F;
pub const TRAP_RESOURCE_LIMIT: u32 = 0x0000_0010;
/// Known input query unavailable on this platform.
pub const TRAP_UNAVAILABLE: u32 = 0x0000_0011;
/// Mathematical domain is invalid for the supplied finite arguments.
pub const TRAP_NUMERIC_DOMAIN: u32 = 0x0000_0012;
/// Finite input produces an unrepresentable result or integer destination.
pub const TRAP_NUMERIC_RANGE: u32 = 0x0000_0013;
/// A NaN or infinite input cannot enter guest numeric computation.
pub const TRAP_NON_FINITE: u32 = 0x0000_0014;
use serde::{Deserialize, Serialize};
+3 -2
View File
@@ -13,8 +13,9 @@ mod value;
pub use abi::{
SourceSpan, TrapInfo, TRAP_BAD_RET_SLOTS, TRAP_DIV_ZERO, TRAP_EXPLICIT,
TRAP_ILLEGAL_INSTRUCTION, TRAP_INVALID_FUNC, TRAP_INVALID_HANDLE, TRAP_INVALID_INTRINSIC,
TRAP_INVALID_LOCAL, TRAP_INVALID_SYSCALL, TRAP_NULL_REFERENCE, TRAP_OOB, TRAP_RESOURCE_LIMIT,
TRAP_STACK_UNDERFLOW, TRAP_TYPE, TRAP_UNAVAILABLE,
TRAP_INVALID_LOCAL, TRAP_INVALID_SYSCALL, TRAP_NON_FINITE, TRAP_NULL_REFERENCE,
TRAP_NUMERIC_DOMAIN, TRAP_NUMERIC_RANGE, TRAP_OOB, TRAP_RESOURCE_LIMIT, TRAP_STACK_UNDERFLOW,
TRAP_TYPE, TRAP_UNAVAILABLE,
};
pub use assembler::{assemble, AsmError};
pub use decoder::{decode_next, DecodeError, DecodedInstr};
@@ -74,6 +74,7 @@ pub enum LoadReason {
Limit,
Allocation,
ConstantTag,
NonFiniteValue,
DebugRange,
DuplicateSyscall,
UnknownOpcode,
@@ -229,9 +229,17 @@ impl<'a> Reader<'a, '_> {
(|| {
match self.byte()? {
0 => {}
1 | 2 => {
1 => {
self.take(8)?;
}
2 => {
let at = self.pos;
let bits = u64::from_le_bytes(self.take(8)?.try_into().unwrap());
if bits & 0x7ff0_0000_0000_0000 == 0x7ff0_0000_0000_0000 {
return Err(E::new(C::InvalidFormat, R::NonFiniteValue)
.at(self.section.kind, self.section.offset + at));
}
}
3 => {
if self.byte()? > 1 {
return Err(self.error(C::InvalidFormat, R::InvalidFlag));
@@ -8,6 +8,41 @@ fn budget() -> LoadBudget {
LoadBudget::new(LoadLimits::default())
}
#[test]
fn nonfinite_constant_payloads_are_rejected_with_index_and_exact_offset() {
use prometeu_bytecode::model::ConstantPoolEntry as K;
let registry = minimal_registry();
let constants = [K::Float64(1.0)];
let module = PbxModule {
registry: &registry,
constants: &constants,
code: &[1, 0],
debug: None,
exports: &[],
syscalls: &[],
};
let valid = module.serialize(&mut budget()).unwrap();
let envelope = PbxEnvelope::parse(&valid, &mut budget()).unwrap();
let offset = envelope.section(0).unwrap().offset + 5;
for bits in [0x7ff0000000000000u64, 0xfff0000000000000, 0x7ff8000000000042, 0x7ff0000000000001]
{
let mut bytes = valid.clone();
bytes[offset..offset + 8].copy_from_slice(&bits.to_le_bytes());
let error = OwnedPbx::parse(&bytes, &mut budget()).unwrap_err();
assert_eq!(
(error.code, error.reason, error.section, error.offset, error.record),
(LoadCode::InvalidFormat, LoadReason::NonFiniteValue, Some(0), Some(offset), Some(0))
);
}
for bits in [0u64, 1, 0x000fffffffffffff, 0x7fefffffffffffff, 0x8000000000000000] {
let mut bytes = valid.clone();
bytes[offset..offset + 8].copy_from_slice(&bits.to_le_bytes());
let owned = OwnedPbx::parse(&bytes, &mut budget()).unwrap();
let K::Float64(x) = owned.constants[0] else { panic!() };
assert_eq!(x.to_bits(), bits);
}
}
#[test]
fn fn_keys_ignore_names_but_preserve_logical_parameter_and_result_order() {
let signature = Signature { parameters: vec![named(0)], results: vec![TypeId(1)] };
@@ -222,7 +257,7 @@ fn owned_payloads_preserve_utf8_float_bits_names_and_binding_declarations() {
K::Null,
K::Int32(i32::MIN),
K::Int64(i64::MAX),
K::Float64(f64::from_bits(0x7ff8000000000042)),
K::Float64(f64::from_bits(0x0008000000000042)),
K::Boolean(true),
K::String("é猫".into()),
K::String(String::new()),
@@ -253,7 +288,7 @@ fn owned_payloads_preserve_utf8_float_bits_names_and_binding_declarations() {
let module = OwnedPbx::parse(&bytes, &mut b).unwrap();
assert_eq!(&module.constants[..3], &constants[..3]);
let K::Float64(value) = module.constants[3] else { panic!() };
assert_eq!(value.to_bits(), 0x7ff8000000000042);
assert_eq!(value.to_bits(), 0x0008000000000042);
assert_eq!(&module.constants[4..], &constants[4..]);
assert_eq!(module.debug.as_ref(), Some(&debug));
assert_eq!(module.exports, exports);
@@ -319,7 +354,7 @@ fn complete_module_writer_preserves_non_registry_encodings() {
let constants = [
K::Null,
K::Int64(-1),
K::Float64(f64::from_bits(0x7ff8000000001234)),
K::Float64(f64::from_bits(0x0008000000001234)),
K::Boolean(true),
K::String("é".into()),
K::Int32(-2),
@@ -351,7 +386,7 @@ fn complete_module_writer_preserves_non_registry_encodings() {
parsed.section(0).unwrap().bytes,
hex("07 00 00 00 00
01 ff ff ff ff ff ff ff ff
02 34 12 00 00 00 00 f8 7f
02 34 12 00 00 00 00 08 00
03 01 04 02 00 00 00 c3 a9 05 fe ff ff ff 04 00 00 00 00")
);
assert_eq!(
+1
View File
@@ -7,6 +7,7 @@ license.workspace = true
[dependencies]
prometeu-bytecode = { path = "../prometeu-bytecode" }
prometeu-hal = { path = "../prometeu-hal" }
fpmath = { version = "=0.1.1", features = ["soft-float"] }
[dev-dependencies]
prometeu-test-support = { path = "../../dev/prometeu-test-support" }
@@ -0,0 +1,7 @@
fn main() {
if std::env::args().nth(1).as_deref() == Some("constants") {
print!("{}", prometeu_vm::builtin_constant_catalog_csv());
} else {
print!("{}", prometeu_vm::intrinsic_catalog_csv());
}
}
@@ -0,0 +1,37 @@
//! Local host timing only; these measurements never define guest cycles.
use prometeu_bytecode::Value;
use prometeu_vm::{HostContext, lookup_intrinsic_by_id};
use std::hint::black_box;
use std::time::Instant;
fn main() {
let iterations: u32 =
std::env::args().nth(1).unwrap_or_else(|| "20000".into()).parse().unwrap();
for (id, args) in [
(0x3010, vec![Value::Float(2.)]),
(0x3011, vec![Value::Float(f64::from_bits(0x6974e718d7d7625a))]),
(0x3012, vec![Value::Float(f64::from_bits(0x7fefffffffffffff))]),
(0x3013, vec![Value::Float(1.), Value::Float(3.)]),
(0x1000, vec![Value::Float(1.), Value::Float(2.), Value::Float(3.), Value::Float(4.)]),
(0x1001, vec![Value::Float(1e200), Value::Float(1e200)]),
] {
let m = lookup_intrinsic_by_id(id).unwrap();
let mut ctx = HostContext::new(None);
for _ in 0..100 {
black_box((m.implementation)(black_box(&args), &mut ctx).unwrap());
}
let start = Instant::now();
for _ in 0..iterations {
black_box((m.implementation)(black_box(&args), &mut ctx).unwrap());
}
let elapsed = start.elapsed().as_nanos();
println!(
"{}.{} iterations={} total_ns={} ns_per_call={:.2} virtual_cycles={}",
m.owner,
m.name,
iterations,
elapsed,
elapsed as f64 / f64::from(iterations),
m.cost_cycles
);
}
}
@@ -0,0 +1,91 @@
//! Reproducible bit-level probe for independent tooling; not a cartridge dependency.
//! stdin: intrinsic hex ID followed by f:bits / i:decimal / l:decimal.
//! Arithmetic opcode names ADD/SUB/MUL/DIV execute a validated PBX program.
use prometeu_bytecode::{Value, assemble};
use prometeu_hal::vm_fault::VmFault;
use prometeu_vm::{
HostContext, HostReturn, LogicalFrameEndingReason, NativeInterface, VirtualMachine,
lookup_intrinsic_by_id,
};
use std::io::{self, BufRead};
struct NoNative;
impl NativeInterface for NoNative {
fn syscall(
&mut self,
_: u32,
_: &[Value],
_: &mut HostReturn,
_: &mut HostContext,
) -> Result<(), VmFault> {
panic!("no native call in numeric probe")
}
}
fn text(value: &Value) -> String {
match value {
Value::Float(x) => format!("f:{:016x}", x.to_bits()),
Value::Int32(x) => format!("i:{x}"),
Value::Int64(x) => format!("l:{x}"),
_ => panic!("numeric output"),
}
}
fn main() {
for line in io::stdin().lock().lines() {
let line = line.unwrap();
let mut words = line.split_whitespace();
let op = words.next().unwrap();
let args: Vec<_> = words
.map(|s| {
let (kind, v) = s.split_once(':').unwrap();
match kind {
"f" => Value::Float(f64::from_bits(u64::from_str_radix(v, 16).unwrap())),
"i" => Value::Int32(v.parse().unwrap()),
"l" => Value::Int64(v.parse().unwrap()),
_ => panic!("carrier"),
}
})
.collect();
if !matches!(op, "ADD" | "SUB" | "MUL" | "DIV") {
let id = u32::from_str_radix(op, 16).unwrap();
let m = lookup_intrinsic_by_id(id).unwrap();
match (m.implementation)(&args, &mut HostContext::new(None)) {
Ok(v) => println!("{} {}", text(&v[0]), m.cost_cycles),
Err(prometeu_vm::IntrinsicExecutionError::Numeric(e)) => {
println!("trap:{:x} {}", e.code, m.cost_cycles)
}
Err(e) => panic!("{e:?}"),
}
} else {
let mut source = String::new();
for v in args {
source.push_str(&match v {
Value::Float(x) => format!("PUSH_F64 f64:0x{:016x}\n", x.to_bits()),
Value::Int32(x) => format!("PUSH_I32 {x}\n"),
Value::Int64(x) => format!("PUSH_I64 {x}\n"),
_ => unreachable!(),
});
}
source.push_str(op);
source.push_str("\nHALT");
let bytes = prometeu_test_support::program::TestProgram::single(
assemble(&source).unwrap(),
Default::default(),
0,
8,
)
.serialize();
let mut vm = VirtualMachine::default();
vm.initialize(bytes).unwrap();
vm.prepare_call("0").unwrap();
let r = vm.run_budget(100, &mut NoNative, &mut HostContext::new(None)).unwrap();
match r.reason {
LogicalFrameEndingReason::Halted => {
println!("{} {}", text(&vm.operand_stack_top(1)[0]), r.cycles_used)
}
LogicalFrameEndingReason::Trap(e) => {
println!("trap:{:x} {}", e.code, r.cycles_used)
}
e => panic!("{e:?}"),
}
}
}
}
+85 -4
View File
@@ -206,6 +206,7 @@ pub enum IntrinsicExecutionError {
ArityMismatch { expected: usize, got: usize },
TypeMismatch { index: usize, expected: AbiType },
HardwareUnavailable,
Numeric(crate::numeric::NumericError),
}
#[derive(Debug, Clone, PartialEq, Eq)]
@@ -226,6 +227,9 @@ pub struct IntrinsicMeta {
pub version: u16,
pub arg_layout: &'static [AbiType],
pub ret_layout: &'static [AbiType],
pub parameter_names: &'static [&'static str],
/// Total virtual call cost; math attempts are charged before checks.
pub cost_cycles: u64,
pub deterministic: bool,
pub may_allocate: bool,
pub implementation: IntrinsicImplementation,
@@ -424,7 +428,23 @@ const COLOR_MAGENTA_SLOTS: [BuiltinConstSlotValue; 1] =
const COLOR_TRANSPARENT_SLOTS: [BuiltinConstSlotValue; 1] =
[BuiltinConstSlotValue::Int64(Color::TRANSPARENT.raw() as i64)];
const BUILTIN_CONSTS: [BuiltinConstMeta; 13] = [
const BUILTIN_CONSTS: [BuiltinConstMeta; 15] = [
BuiltinConstMeta {
key: BuiltinConstKey::new("mathf", "pi", 1),
flat_slot_layout: &SINGLE_FLOAT_RET,
flat_slot_width: 1,
materializer: BuiltinConstMaterializer::Direct(&[BuiltinConstSlotValue::Float(
f64::from_bits(crate::numeric::PI_BITS),
)]),
},
BuiltinConstMeta {
key: BuiltinConstKey::new("mathf", "tau", 1),
flat_slot_layout: &SINGLE_FLOAT_RET,
flat_slot_width: 1,
materializer: BuiltinConstMaterializer::Direct(&[BuiltinConstSlotValue::Float(
f64::from_bits(crate::numeric::TAU_BITS),
)]),
},
BuiltinConstMeta {
key: BuiltinConstKey::new("vec2", "zero", 1),
flat_slot_layout: &VEC2_ZERO_LAYOUT,
@@ -491,6 +511,8 @@ const INTRINSICS: [IntrinsicMeta; 21] = [
version: 1,
arg_layout: &VEC2_DOT_ARGS,
ret_layout: &SINGLE_FLOAT_RET,
parameter_names: &["ax", "ay", "bx", "by"],
cost_cycles: 10,
deterministic: true,
may_allocate: false,
implementation: vec2_dot,
@@ -502,6 +524,8 @@ const INTRINSICS: [IntrinsicMeta; 21] = [
version: 1,
arg_layout: &VEC2_LENGTH_ARGS,
ret_layout: &SINGLE_FLOAT_RET,
parameter_names: &["x", "y"],
cost_cycles: 40,
deterministic: true,
may_allocate: false,
implementation: vec2_length,
@@ -513,6 +537,8 @@ const INTRINSICS: [IntrinsicMeta; 21] = [
version: 1,
arg_layout: &INT_RET,
ret_layout: &COLOR_RET,
parameter_names: &["raw"],
cost_cycles: 1,
deterministic: true,
may_allocate: false,
implementation: color_from_raw,
@@ -524,6 +550,8 @@ const INTRINSICS: [IntrinsicMeta; 21] = [
version: 1,
arg_layout: &COLOR_RGB_ARGS,
ret_layout: &COLOR_RET,
parameter_names: &["r", "g", "b"],
cost_cycles: 1,
deterministic: true,
may_allocate: false,
implementation: color_rgb,
@@ -535,6 +563,8 @@ const INTRINSICS: [IntrinsicMeta; 21] = [
version: 1,
arg_layout: &COLOR_RGBA_ARGS,
ret_layout: &COLOR_RET,
parameter_names: &["r", "g", "b", "a"],
cost_cycles: 1,
deterministic: true,
may_allocate: false,
implementation: color_rgba,
@@ -546,6 +576,8 @@ const INTRINSICS: [IntrinsicMeta; 21] = [
version: 1,
arg_layout: &COLOR_HTML_RGBA_ARGS,
ret_layout: &COLOR_RET,
parameter_names: &["value"],
cost_cycles: 1,
deterministic: true,
may_allocate: false,
implementation: color_html_rgba,
@@ -557,6 +589,8 @@ const INTRINSICS: [IntrinsicMeta; 21] = [
version: 1,
arg_layout: &INT_RET,
ret_layout: &COLOR_RET,
parameter_names: &["value"],
cost_cycles: 1,
deterministic: true,
may_allocate: false,
implementation: color_gray_scale,
@@ -568,6 +602,8 @@ const INTRINSICS: [IntrinsicMeta; 21] = [
version: 1,
arg_layout: &COLOR_ARGS,
ret_layout: &INT_RET,
parameter_names: &["color"],
cost_cycles: 1,
deterministic: true,
may_allocate: false,
implementation: color_hex,
@@ -579,6 +615,8 @@ const INTRINSICS: [IntrinsicMeta; 21] = [
version: 1,
arg_layout: &COLOR_ARGS,
ret_layout: &INT_RET,
parameter_names: &["color"],
cost_cycles: 1,
deterministic: true,
may_allocate: false,
implementation: color_alpha,
@@ -590,6 +628,8 @@ const INTRINSICS: [IntrinsicMeta; 21] = [
version: 1,
arg_layout: &NO_ARGS,
ret_layout: &COLOR_RET,
parameter_names: &[],
cost_cycles: 1,
deterministic: true,
may_allocate: false,
implementation: color_black,
@@ -601,6 +641,8 @@ const INTRINSICS: [IntrinsicMeta; 21] = [
version: 1,
arg_layout: &NO_ARGS,
ret_layout: &COLOR_RET,
parameter_names: &[],
cost_cycles: 1,
deterministic: true,
may_allocate: false,
implementation: color_white,
@@ -612,6 +654,8 @@ const INTRINSICS: [IntrinsicMeta; 21] = [
version: 1,
arg_layout: &NO_ARGS,
ret_layout: &COLOR_RET,
parameter_names: &[],
cost_cycles: 1,
deterministic: true,
may_allocate: false,
implementation: color_red,
@@ -623,6 +667,8 @@ const INTRINSICS: [IntrinsicMeta; 21] = [
version: 1,
arg_layout: &NO_ARGS,
ret_layout: &COLOR_RET,
parameter_names: &[],
cost_cycles: 1,
deterministic: true,
may_allocate: false,
implementation: color_green,
@@ -634,6 +680,8 @@ const INTRINSICS: [IntrinsicMeta; 21] = [
version: 1,
arg_layout: &NO_ARGS,
ret_layout: &COLOR_RET,
parameter_names: &[],
cost_cycles: 1,
deterministic: true,
may_allocate: false,
implementation: color_blue,
@@ -645,6 +693,8 @@ const INTRINSICS: [IntrinsicMeta; 21] = [
version: 1,
arg_layout: &NO_ARGS,
ret_layout: &COLOR_RET,
parameter_names: &[],
cost_cycles: 1,
deterministic: true,
may_allocate: false,
implementation: color_yellow,
@@ -656,6 +706,8 @@ const INTRINSICS: [IntrinsicMeta; 21] = [
version: 1,
arg_layout: &NO_ARGS,
ret_layout: &COLOR_RET,
parameter_names: &[],
cost_cycles: 1,
deterministic: true,
may_allocate: false,
implementation: color_orange,
@@ -667,6 +719,8 @@ const INTRINSICS: [IntrinsicMeta; 21] = [
version: 1,
arg_layout: &NO_ARGS,
ret_layout: &COLOR_RET,
parameter_names: &[],
cost_cycles: 1,
deterministic: true,
may_allocate: false,
implementation: color_indigo,
@@ -678,6 +732,8 @@ const INTRINSICS: [IntrinsicMeta; 21] = [
version: 1,
arg_layout: &NO_ARGS,
ret_layout: &COLOR_RET,
parameter_names: &[],
cost_cycles: 1,
deterministic: true,
may_allocate: false,
implementation: color_gray,
@@ -689,6 +745,8 @@ const INTRINSICS: [IntrinsicMeta; 21] = [
version: 1,
arg_layout: &NO_ARGS,
ret_layout: &COLOR_RET,
parameter_names: &[],
cost_cycles: 1,
deterministic: true,
may_allocate: false,
implementation: color_cyan,
@@ -700,6 +758,8 @@ const INTRINSICS: [IntrinsicMeta; 21] = [
version: 1,
arg_layout: &NO_ARGS,
ret_layout: &COLOR_RET,
parameter_names: &[],
cost_cycles: 1,
deterministic: true,
may_allocate: false,
implementation: color_magenta,
@@ -711,6 +771,8 @@ const INTRINSICS: [IntrinsicMeta; 21] = [
version: 1,
arg_layout: &NO_ARGS,
ret_layout: &COLOR_RET,
parameter_names: &[],
cost_cycles: 1,
deterministic: true,
may_allocate: false,
implementation: color_transparent,
@@ -743,6 +805,7 @@ pub fn lookup_intrinsic(owner: &str, name: &str, version: u16) -> Option<&'stati
INTRINSICS
.iter()
.chain(crate::input_intrinsics::INPUT_INTRINSICS.iter())
.chain(crate::math_intrinsics::MATH_INTRINSICS.iter())
.find(|meta| meta.owner == owner && meta.name == name && meta.version == version)
}
@@ -750,6 +813,7 @@ pub fn lookup_intrinsic_by_id(id: u32) -> Option<&'static IntrinsicMeta> {
INTRINSICS
.iter()
.chain(crate::input_intrinsics::INPUT_INTRINSICS.iter())
.chain(crate::math_intrinsics::MATH_INTRINSICS.iter())
.find(|meta| meta.id == id)
}
@@ -841,6 +905,7 @@ fn vec2_dot(
args: &[Value],
_ctx: &mut HostContext<'_>,
) -> Result<Vec<Value>, IntrinsicExecutionError> {
lookup_intrinsic_by_id(0x1000).unwrap().validate_argument_values(args)?;
if args.len() != 4 {
return Err(IntrinsicExecutionError::ArityMismatch { expected: 4, got: args.len() });
}
@@ -848,7 +913,7 @@ fn vec2_dot(
let ay = expect_float_arg(args, 1)?;
let bx = expect_float_arg(args, 2)?;
let by = expect_float_arg(args, 3)?;
Ok(vec![Value::Float((ax * bx) + (ay * by))])
Ok(vec![Value::Float(crate::numeric::dot([ax, ay, bx, by])?)])
}
fn vec2_length(
@@ -858,9 +923,10 @@ fn vec2_length(
if args.len() != 2 {
return Err(IntrinsicExecutionError::ArityMismatch { expected: 2, got: args.len() });
}
lookup_intrinsic_by_id(0x1001).unwrap().validate_argument_values(args)?;
let x = expect_float_arg(args, 0)?;
let y = expect_float_arg(args, 1)?;
Ok(vec![Value::Float((x * x + y * y).sqrt())])
Ok(vec![Value::Float(crate::numeric::length(x, y)?)])
}
fn color_value(color: Color) -> Vec<Value> {
@@ -1041,7 +1107,11 @@ pub(crate) fn metered_lookup_intrinsic(
id: u32,
budget: &mut prometeu_bytecode::load_limits::LoadBudget,
) -> Result<Option<&'static IntrinsicMeta>, prometeu_bytecode::load_limits::LoadFailure> {
for meta in INTRINSICS.iter().chain(crate::input_intrinsics::INPUT_INTRINSICS.iter()) {
for meta in INTRINSICS
.iter()
.chain(crate::input_intrinsics::INPUT_INTRINSICS.iter())
.chain(crate::math_intrinsics::MATH_INTRINSICS.iter())
{
budget.work(1)?;
if meta.id == id {
return Ok(Some(meta));
@@ -1210,3 +1280,14 @@ mod tests {
assert_eq!(pixel.field("color").map(|field| field.start_slot), Some(2));
}
}
/// Runtime-owned catalogue, including input and scalar math.
pub fn intrinsic_catalog() -> impl Iterator<Item = &'static IntrinsicMeta> {
INTRINSICS
.iter()
.chain(crate::input_intrinsics::INPUT_INTRINSICS.iter())
.chain(crate::math_intrinsics::MATH_INTRINSICS.iter())
}
pub fn builtin_constant_catalog() -> impl Iterator<Item = &'static BuiltinConstMeta> {
BUILTIN_CONSTS.iter()
}
+69
View File
@@ -0,0 +1,69 @@
//! Exported handoff artifacts are generated from runtime metadata.
use crate::{AbiType, BuiltinScalarType, builtin_constant_catalog, intrinsic_catalog};
use prometeu_bytecode::Value;
use std::fmt::Write;
fn atom(t: AbiType) -> String {
match t {
AbiType::Scalar(BuiltinScalarType::Int32) => "Int32".into(),
AbiType::Scalar(BuiltinScalarType::Int64) => "Int64".into(),
AbiType::Scalar(BuiltinScalarType::Float) => "Float".into(),
AbiType::Scalar(BuiltinScalarType::Bool) => "Bool".into(),
AbiType::Scalar(BuiltinScalarType::String) => "String".into(),
AbiType::Builtin(k) => format!("builtin:{}", k.name),
AbiType::DynamicTag => "DynamicTag".into(),
AbiType::DynamicPayload => "DynamicPayload".into(),
}
}
pub fn intrinsic_catalog_csv() -> String {
let mut out = String::from(
"final_id_hex,final_id_dec,canonical_name,canonical_version,owner,name,arg_slots,ret_slots,arg_layout,ret_layout,deterministic,may_allocate,parameter_names,cost_cycles\n",
);
let mut entries: Vec<_> = intrinsic_catalog().collect();
entries.sort_by_key(|m| m.id);
for m in entries {
writeln!(
&mut out,
"0x{:04X},{},{}.{},{},{},{},{},{},{},{},{},{},{},{}",
m.id,
m.id,
m.owner,
m.name,
m.version,
m.owner,
m.name,
m.arg_slots(),
m.ret_slots(),
m.arg_layout.iter().copied().map(atom).collect::<Vec<_>>().join("|"),
m.ret_layout.iter().copied().map(atom).collect::<Vec<_>>().join("|"),
m.deterministic,
m.may_allocate,
m.parameter_names.join("|"),
m.cost_cycles
)
.unwrap();
}
out
}
pub fn builtin_constant_catalog_csv() -> String {
let mut out = String::from("target,name,version,slot,carrier,bits_or_value\n");
let mut entries: Vec<_> = builtin_constant_catalog().collect();
entries.sort_by_key(|m| m.key.key());
for m in entries {
for (slot, v) in m.materialize().expect("canonical constant").iter().enumerate() {
let (carrier, value) = match v {
Value::Float(v) => ("Float", format!("0x{:016X}", v.to_bits())),
Value::Int32(v) => ("Int32", v.to_string()),
Value::Int64(v) => ("Int64", v.to_string()),
Value::Boolean(v) => ("Bool", v.to_string()),
_ => unreachable!("canonical constant carrier"),
};
writeln!(
&mut out,
"{},{},{},{},{},{}",
m.key.target, m.key.name, m.key.version, slot, carrier, value
)
.unwrap();
}
}
out
}
@@ -21,6 +21,8 @@ const fn query(
version: 1,
arg_layout: &[],
ret_layout,
parameter_names: &[],
cost_cycles: 1,
deterministic: true,
may_allocate: false,
implementation,
+8 -2
View File
@@ -1,8 +1,13 @@
#[cfg(test)]
extern crate self as prometeu_vm;
mod builtins;
mod catalog;
pub use catalog::{builtin_constant_catalog_csv, intrinsic_catalog_csv};
mod call_frame;
mod input_intrinsics;
mod math_intrinsics;
mod numeric;
pub use numeric::NumericError;
mod local_addressing;
// Keep the verifier internal in production builds, but expose it for integration tests
// so the golden verifier suite can exercise it without widening the public API in releases.
@@ -34,8 +39,9 @@ pub use builtins::{
AbiType, BuiltinConstKey, BuiltinConstMaterializer, BuiltinConstMeta, BuiltinConstSlotValue,
BuiltinFieldMeta, BuiltinLayoutType, BuiltinScalarType, BuiltinTypeKey, BuiltinTypeMeta,
BuiltinTypeShape, BuiltinValueError, IntrinsicExecutionError, IntrinsicImplementation,
IntrinsicKey, IntrinsicMeta, lookup_builtin_constant, lookup_builtin_type, lookup_intrinsic,
lookup_intrinsic_by_id, materialize_builtin_constant,
IntrinsicKey, IntrinsicMeta, builtin_constant_catalog, intrinsic_catalog,
lookup_builtin_constant, lookup_builtin_type, lookup_intrinsic, lookup_intrinsic_by_id,
materialize_builtin_constant,
};
pub use prometeu_hal::{HostContext, HostReturn, NativeInterface, SyscallId};
pub use virtual_machine::{BudgetReport, LogicalFrameEndingReason, VirtualMachine};
@@ -0,0 +1,149 @@
//! Exact scalar identities. Public math overloads are a consumer projection.
use crate::builtins::{AbiType, BuiltinScalarType, IntrinsicExecutionError as E, IntrinsicMeta};
use crate::numeric::{self, NumericError};
use prometeu_bytecode::{TRAP_NUMERIC_DOMAIN, TRAP_NUMERIC_RANGE, Value};
use prometeu_hal::HostContext;
const I32: AbiType = AbiType::Scalar(BuiltinScalarType::Int32);
const I64: AbiType = AbiType::Scalar(BuiltinScalarType::Int64);
const FLOAT: AbiType = AbiType::Scalar(BuiltinScalarType::Float);
const fn entry<const ID: u32>(
owner: &'static str,
name: &'static str,
arg_layout: &'static [AbiType],
ret_layout: &'static [AbiType],
parameter_names: &'static [&'static str],
cost_cycles: u64,
) -> IntrinsicMeta {
IntrinsicMeta {
id: ID,
owner,
name,
version: 1,
arg_layout,
ret_layout,
parameter_names,
cost_cycles,
deterministic: true,
may_allocate: false,
implementation: execute::<ID>,
}
}
pub(crate) const MATH_INTRINSICS: [IntrinsicMeta; 26] = [
entry::<0x3000>("math.i32", "min", &[I32, I32], &[I32], &["a", "b"], 2),
entry::<0x3001>("math.i32", "max", &[I32, I32], &[I32], &["a", "b"], 2),
entry::<0x3002>("math.i32", "clamp", &[I32, I32, I32], &[I32], &["value", "min", "max"], 4),
entry::<0x3003>("math.i32", "abs", &[I32], &[I32], &["value"], 2),
entry::<0x3004>("math.i64", "min", &[I64, I64], &[I64], &["a", "b"], 2),
entry::<0x3005>("math.i64", "max", &[I64, I64], &[I64], &["a", "b"], 2),
entry::<0x3006>("math.i64", "clamp", &[I64, I64, I64], &[I64], &["value", "min", "max"], 4),
entry::<0x3007>("math.i64", "abs", &[I64], &[I64], &["value"], 2),
entry::<0x3008>("mathf", "min", &[FLOAT, FLOAT], &[FLOAT], &["a", "b"], 2),
entry::<0x3009>("mathf", "max", &[FLOAT, FLOAT], &[FLOAT], &["a", "b"], 2),
entry::<0x300a>(
"mathf",
"clamp",
&[FLOAT, FLOAT, FLOAT],
&[FLOAT],
&["value", "min", "max"],
4,
),
entry::<0x300b>("mathf", "abs", &[FLOAT], &[FLOAT], &["value"], 2),
entry::<0x300c>("mathf", "floor", &[FLOAT], &[FLOAT], &["value"], 4),
entry::<0x300d>("mathf", "ceil", &[FLOAT], &[FLOAT], &["value"], 4),
entry::<0x300e>("mathf", "trunc", &[FLOAT], &[FLOAT], &["value"], 4),
entry::<0x300f>("mathf", "round", &[FLOAT], &[FLOAT], &["value"], 4),
entry::<0x3010>("mathf", "sqrt", &[FLOAT], &[FLOAT], &["value"], 16),
entry::<0x3011>("mathf", "sin", &[FLOAT], &[FLOAT], &["angle"], 32),
entry::<0x3012>("mathf", "cos", &[FLOAT], &[FLOAT], &["angle"], 32),
entry::<0x3013>("mathf", "atan2", &[FLOAT, FLOAT], &[FLOAT], &["y", "x"], 48),
entry::<0x3014>("math.i32", "to_i64", &[I32], &[I64], &["value"], 2),
entry::<0x3015>("math.i64", "to_i32", &[I64], &[I32], &["value"], 2),
entry::<0x3016>("math.i32", "to_float", &[I32], &[FLOAT], &["value"], 2),
entry::<0x3017>("math.i64", "to_float", &[I64], &[FLOAT], &["value"], 2),
entry::<0x3018>("mathf", "to_i32", &[FLOAT], &[I32], &["value"], 2),
entry::<0x3019>("mathf", "to_i64", &[FLOAT], &[I64], &["value"], 2),
];
impl From<NumericError> for E {
fn from(error: NumericError) -> Self {
Self::Numeric(error)
}
}
fn integer(args: &[Value], offset: u32, narrow: bool) -> Result<Value, E> {
let mut a = [0i64; 3];
for (i, value) in args.iter().enumerate() {
a[i] = match value {
Value::Int32(v) => i64::from(*v),
Value::Int64(v) => *v,
_ => unreachable!("validated exact integer carrier"),
};
}
let result = match offset {
0 => a[0].min(a[1]),
1 => a[0].max(a[1]),
2 => {
if a[1] > a[2] {
return Err(NumericError::new(TRAP_NUMERIC_DOMAIN).into());
}
a[0].clamp(a[1], a[2])
}
3 => {
if (narrow && a[0] == i64::from(i32::MIN)) || a[0] == i64::MIN {
return Err(NumericError::new(TRAP_NUMERIC_RANGE).into());
}
a[0].abs()
}
_ => unreachable!("private integer operation"),
};
Ok(if narrow { Value::Int32(result as i32) } else { Value::Int64(result) })
}
fn execute<const ID: u32>(args: &[Value], _: &mut HostContext<'_>) -> Result<Vec<Value>, E> {
let meta = crate::lookup_intrinsic_by_id(ID).expect("static scalar identity");
meta.validate_argument_values(args)?;
if ID < 0x3008 {
return Ok(vec![integer(args, (ID - 0x3000) % 4, ID < 0x3004)?]);
}
let mut floats = [0.0; 3];
for (i, value) in args.iter().enumerate() {
if let Value::Float(v) = value {
floats[i] = *v;
}
}
if (0x3008..=0x3013).contains(&ID) || ID >= 0x3018 {
numeric::check_inputs(&floats[..args.len()])?;
}
let x = floats[0];
let value = match ID {
0x3008 => Value::Float(numeric::min(x, floats[1])),
0x3009 => Value::Float(numeric::max(x, floats[1])),
0x300a => Value::Float(numeric::clamp(x, floats[1], floats[2])?),
0x300b => Value::Float(numeric::abs(x)),
0x300c => Value::Float(numeric::floor(x)?),
0x300d => Value::Float(numeric::ceil(x)?),
0x300e => Value::Float(numeric::trunc(x)?),
0x300f => Value::Float(numeric::round(x)?),
0x3010 => Value::Float(numeric::sqrt(x)?),
0x3011 => Value::Float(numeric::sin(x)?),
0x3012 => Value::Float(numeric::cos(x)?),
0x3013 => Value::Float(numeric::atan2(x, floats[1])?),
0x3014 => {
let Value::Int32(v) = args[0] else { unreachable!() };
Value::Int64(i64::from(v))
}
0x3015 => {
let Value::Int64(v) = args[0] else { unreachable!() };
Value::Int32(i32::try_from(v).map_err(|_| NumericError::new(TRAP_NUMERIC_RANGE))?)
}
0x3016 => {
let Value::Int32(v) = args[0] else { unreachable!() };
Value::Float(numeric::from_i64(i64::from(v)))
}
0x3017 => {
let Value::Int64(v) = args[0] else { unreachable!() };
Value::Float(numeric::from_i64(v))
}
0x3018 => Value::Int32(numeric::to_i64(x, 32)? as i32),
0x3019 => Value::Int64(numeric::to_i64(x, 64)?),
_ => unreachable!("static scalar identity"),
};
Ok(vec![value])
}
+324
View File
@@ -0,0 +1,324 @@
//! Canonical binary64 adapter. Host f64 is a bit carrier only; arithmetic and
//! comparisons use SoftF64. Integer conversions and ties-even rounding use bits.
use fpmath::SoftF64 as F;
use prometeu_bytecode::{TRAP_DIV_ZERO, TRAP_NON_FINITE, TRAP_NUMERIC_DOMAIN, TRAP_NUMERIC_RANGE};
pub(crate) const PI_BITS: u64 = 0x4009_21fb_5444_2d18;
pub(crate) const TAU_BITS: u64 = 0x4019_21fb_5444_2d18;
const PI_2_BITS: u64 = 0x3ff9_21fb_5444_2d18;
const SIGN: u64 = 1 << 63;
const MAG: u64 = !SIGN;
const EXP: u64 = 0x7ff0_0000_0000_0000;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct NumericError {
pub code: u32,
pub argument: Option<usize>,
}
impl NumericError {
pub(crate) fn new(code: u32) -> Self {
Self { code, argument: None }
}
}
pub(crate) type Result<T> = std::result::Result<T, NumericError>;
pub(crate) fn finite(x: f64) -> bool {
x.to_bits() & EXP != EXP
}
pub(crate) fn check_inputs(values: &[f64]) -> Result<()> {
for (argument, &value) in values.iter().enumerate() {
if !finite(value) {
return Err(NumericError { code: TRAP_NON_FINITE, argument: Some(argument) });
}
}
Ok(())
}
fn soft(x: f64) -> F {
F::from_bits(x.to_bits())
}
fn output(x: F) -> Result<f64> {
let bits = x.to_bits();
if bits & EXP == EXP {
Err(NumericError::new(TRAP_NUMERIC_RANGE))
} else {
Ok(f64::from_bits(bits))
}
}
pub(crate) fn zero(x: f64) -> bool {
x.to_bits() & MAG == 0
}
pub(crate) fn cmp(a: f64, b: f64) -> std::cmp::Ordering {
// All callers check finitude first. Both zeros compare equal.
soft(a).partial_cmp(&soft(b)).expect("finite binary64 comparison")
}
pub(crate) fn abs(x: f64) -> f64 {
f64::from_bits(x.to_bits() & MAG)
}
pub(crate) fn neg(x: f64) -> Result<f64> {
check_inputs(&[x])?;
Ok(f64::from_bits(x.to_bits() ^ SIGN))
}
pub(crate) fn min(a: f64, b: f64) -> f64 {
if zero(a) && zero(b) {
f64::from_bits(a.to_bits() | b.to_bits())
} else if cmp(a, b).is_gt() {
b
} else {
a
}
}
pub(crate) fn max(a: f64, b: f64) -> f64 {
if zero(a) && zero(b) {
f64::from_bits(a.to_bits() & b.to_bits())
} else if cmp(a, b).is_lt() {
b
} else {
a
}
}
pub(crate) fn clamp(value: f64, lo: f64, hi: f64) -> Result<f64> {
check_inputs(&[value, lo, hi])?;
if cmp(lo, hi).is_gt() {
return Err(NumericError::new(TRAP_NUMERIC_DOMAIN));
}
Ok(min(max(value, lo), hi))
}
pub(crate) fn add(a: f64, b: f64) -> Result<f64> {
check_inputs(&[a, b])?;
output(soft(a) + soft(b))
}
pub(crate) fn sub(a: f64, b: f64) -> Result<f64> {
check_inputs(&[a, b])?;
output(soft(a) - soft(b))
}
pub(crate) fn mul(a: f64, b: f64) -> Result<f64> {
check_inputs(&[a, b])?;
output(soft(a) * soft(b))
}
pub(crate) fn div(a: f64, b: f64) -> Result<f64> {
check_inputs(&[a, b])?;
if zero(b) {
return Err(NumericError::new(TRAP_DIV_ZERO));
}
output(soft(a) / soft(b))
}
pub(crate) fn sqrt(x: f64) -> Result<f64> {
check_inputs(&[x])?;
if !zero(x) && x.to_bits() & SIGN != 0 {
return Err(NumericError::new(TRAP_NUMERIC_DOMAIN));
}
output(fpmath::sqrt(soft(x)))
}
pub(crate) fn sin(x: f64) -> Result<f64> {
check_inputs(&[x])?;
output(fpmath::sin(soft(x)))
}
pub(crate) fn cos(x: f64) -> Result<f64> {
check_inputs(&[x])?;
output(fpmath::cos(soft(x)))
}
pub(crate) fn atan2(y: f64, x: f64) -> Result<f64> {
check_inputs(&[y, x])?;
let sign_y = y.to_bits() & SIGN;
if zero(y) {
if zero(x) {
return Err(NumericError::new(TRAP_NUMERIC_DOMAIN));
}
return Ok(f64::from_bits(sign_y | if x.to_bits() & SIGN != 0 { PI_BITS } else { 0 }));
}
if zero(x) {
return Ok(f64::from_bits(sign_y | PI_2_BITS));
}
output(fpmath::atan2(soft(y), soft(x)))
}
pub(crate) fn floor(x: f64) -> Result<f64> {
check_inputs(&[x])?;
output(fpmath::floor(soft(x)))
}
pub(crate) fn ceil(x: f64) -> Result<f64> {
check_inputs(&[x])?;
output(fpmath::ceil(soft(x)))
}
pub(crate) fn trunc(x: f64) -> Result<f64> {
check_inputs(&[x])?;
output(fpmath::trunc(soft(x)))
}
pub(crate) fn round(x: f64) -> Result<f64> {
check_inputs(&[x])?;
let bits = x.to_bits();
let sign = bits & SIGN;
let magnitude = bits & MAG;
let exponent = ((magnitude >> 52) as i32) - 1023;
let rounded = if exponent >= 52 {
magnitude
} else if exponent < -1 {
0
} else if exponent == -1 {
// Exactly +/-0.5 ties to signed zero, all larger magnitudes to +/-1.
if magnitude == 0x3fe0_0000_0000_0000 { 0 } else { 0x3ff0_0000_0000_0000 }
} else {
let shift = 52 - exponent;
let unit = 1u64 << shift;
let remainder = magnitude & (unit - 1);
let half = unit >> 1;
let integral = magnitude & !(unit - 1);
integral
+ if remainder > half || (remainder == half && integral & unit != 0) { unit } else { 0 }
};
Ok(f64::from_bits(sign | rounded))
}
pub(crate) fn from_i64(value: i64) -> f64 {
let magnitude = value.unsigned_abs();
if magnitude == 0 {
return f64::from_bits(0);
}
let sign = if value < 0 { SIGN } else { 0 };
let mut exponent = 63 - magnitude.leading_zeros();
let mut significand = if exponent <= 52 {
magnitude << (52 - exponent)
} else {
let shift = exponent - 52;
let unit = 1u64 << shift;
let mut sig = magnitude >> shift;
let rem = magnitude & (unit - 1);
if rem > unit / 2 || (rem == unit / 2 && sig & 1 != 0) {
sig += 1;
}
sig
};
if significand == 1u64 << 53 {
significand >>= 1;
exponent += 1;
}
f64::from_bits(sign | (u64::from(exponent + 1023) << 52) | (significand & ((1 << 52) - 1)))
}
pub(crate) fn to_i64(x: f64, width: u32) -> Result<i64> {
check_inputs(&[x])?;
let bits = x.to_bits();
let exponent = ((bits & EXP) >> 52) as i32 - 1023;
if exponent < 0 {
return Ok(0);
}
if exponent > 63 {
return Err(NumericError::new(TRAP_NUMERIC_RANGE));
}
let significand = (bits & ((1 << 52) - 1)) | (1 << 52);
let magnitude = if exponent >= 52 {
significand << (exponent - 52)
} else {
significand >> (52 - exponent)
};
let negative = bits & SIGN != 0;
let limit = 1u64 << (width - 1);
if magnitude > limit || (magnitude == limit && !negative) {
return Err(NumericError::new(TRAP_NUMERIC_RANGE));
}
// unsigned magnitude handles exactly -2^63 without an intermediate overflow.
Ok(if negative { magnitude.wrapping_neg() as i64 } else { magnitude as i64 })
}
pub(crate) fn dot(a: [f64; 4]) -> Result<f64> {
check_inputs(&a)?;
let p1 = mul(a[0], a[2])?;
let p2 = mul(a[1], a[3])?;
add(p1, p2)
}
pub(crate) fn length(x: f64, y: f64) -> Result<f64> {
check_inputs(&[x, y])?;
let ax = abs(x);
let ay = abs(y);
let m = max(ax, ay);
let n = min(ax, ay);
if zero(m) {
return Ok(f64::from_bits(0));
}
let r = div(n, m)?;
let q = mul(r, r)?;
let s = add(f64::from_bits(0x3ff0_0000_0000_0000), q)?;
let t = sqrt(s)?;
mul(m, t)
}
fn promoted(value: &prometeu_bytecode::Value) -> Option<f64> {
use prometeu_bytecode::Value;
match value {
Value::Int32(v) => Some(from_i64(i64::from(*v))),
Value::Int64(v) => Some(from_i64(*v)),
Value::Float(v) => Some(*v),
_ => None,
}
}
pub(crate) fn opcode_binary(
op: prometeu_bytecode::isa::core::CoreOpCode,
a: &prometeu_bytecode::Value,
b: &prometeu_bytecode::Value,
) -> Result<prometeu_bytecode::Value> {
use prometeu_bytecode::isa::core::CoreOpCode as Op;
use prometeu_bytecode::{TRAP_TYPE, Value};
if matches!(a, Value::Float(_)) || matches!(b, Value::Float(_)) {
let (Some(a), Some(b)) = (promoted(a), promoted(b)) else {
return Err(NumericError::new(TRAP_TYPE));
};
return Ok(Value::Float(match op {
Op::Add => add(a, b)?,
Op::Sub => sub(a, b)?,
Op::Mul => mul(a, b)?,
Op::Div => div(a, b)?,
_ => unreachable!(),
}));
}
let (a, b, narrow) = match (a, b) {
(Value::Int32(a), Value::Int32(b)) => (i64::from(*a), i64::from(*b), true),
(Value::Int32(a), Value::Int64(b)) => (i64::from(*a), *b, false),
(Value::Int64(a), Value::Int32(b)) => (*a, i64::from(*b), false),
(Value::Int64(a), Value::Int64(b)) => (*a, *b, false),
_ => return Err(NumericError::new(TRAP_TYPE)),
};
if op == Op::Div && b == 0 {
return Err(NumericError::new(TRAP_DIV_ZERO));
}
if narrow {
let (a, b) = (a as i32, b as i32);
return Ok(Value::Int32(match op {
Op::Add => a.wrapping_add(b),
Op::Sub => a.wrapping_sub(b),
Op::Mul => a.wrapping_mul(b),
Op::Div => a.wrapping_div(b),
_ => unreachable!(),
}));
}
Ok(Value::Int64(match op {
Op::Add => a.wrapping_add(b),
Op::Sub => a.wrapping_sub(b),
Op::Mul => a.wrapping_mul(b),
Op::Div => a.wrapping_div(b),
_ => unreachable!(),
}))
}
pub(crate) fn compare_values(
a: &prometeu_bytecode::Value,
b: &prometeu_bytecode::Value,
) -> Result<Option<std::cmp::Ordering>> {
use prometeu_bytecode::Value;
if matches!(a, Value::Float(_)) || matches!(b, Value::Float(_)) {
let (Some(a), Some(b)) = (promoted(a), promoted(b)) else {
return Ok(None);
};
check_inputs(&[a, b])?;
Ok(Some(cmp(a, b)))
} else {
Ok(a.partial_cmp(b))
}
}
pub(crate) fn equal_values(
a: &prometeu_bytecode::Value,
b: &prometeu_bytecode::Value,
) -> Result<bool> {
use prometeu_bytecode::Value;
if matches!(a, Value::Float(_)) || matches!(b, Value::Float(_)) {
Ok(compare_values(a, b)? == Some(std::cmp::Ordering::Equal))
} else {
Ok(a == b)
}
}
@@ -70,7 +70,7 @@ fn publication_shares_owners_and_preserves_payload_bits_and_names() {
K::Null,
K::String("é猫".into()),
K::String(String::new()),
K::Float64(f64::from_bits(0x7ff8000000000042)),
K::Float64(f64::from_bits(0x0008000000000042)),
K::Float64(-0.0),
];
let bytes = fixture(&[1, 0], 0, &constants, Some(&debug), &[]);
@@ -85,7 +85,7 @@ fn publication_shares_owners_and_preserves_payload_bits_and_names() {
assert!(image.lease_constant(0).is_none());
let Value::Float(nan) = image.constants()[3] else { panic!() };
let Value::Float(zero) = image.constants()[4] else { panic!() };
assert_eq!(nan.to_bits(), 0x7ff8000000000042);
assert_eq!(nan.to_bits(), 0x0008000000000042);
assert_eq!(zero.to_bits(), (-0.0f64).to_bits());
let projection = image.execution.clone();
assert!(Arc::ptr_eq(&projection.rom, &image.execution.rom));
@@ -111,6 +111,13 @@ fn validate_inner(
Op::PushBool if instruction.imm_u8().unwrap() > 1 => {
return Err(fail(R::BooleanImmediate));
}
Op::PushF64 => {
if instruction.imm_f64().unwrap().to_bits() & 0x7ff0_0000_0000_0000
== 0x7ff0_0000_0000_0000
{
return Err(fail(R::NonFiniteValue).at(2, start + pc));
}
}
Op::PushConst => {
let id = instruction.imm_u32().unwrap();
if id as usize >= constants {
@@ -165,7 +172,7 @@ fn validate_inner(
Op::Intrinsic => {
let id = instruction.imm_u32().unwrap();
if crate::builtins::metered_lookup_intrinsic(id, budget)?.is_none() {
return Err(with_id(reference_error(fail(R::NativeId)), id));
return Err(with_id(fail(R::NativeId), id));
}
}
_ => {}
@@ -445,7 +445,11 @@ fn unreachable_function_constant_boolean_and_native_operands_are_checked() {
assert_eq!((e.reason, e.pc, e.referenced_id), (reason, Some(2), Some(id)));
assert_eq!(
e.code,
if operation == Op::Hostcall { C::InvalidCode } else { C::InvalidReference }
if matches!(operation, Op::Hostcall | Op::Intrinsic) {
C::InvalidCode
} else {
C::InvalidReference
}
);
}
let code = [
@@ -7,6 +7,7 @@ use prometeu_bytecode::{HeapRef, Value};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) enum ValueError {
Type,
NonFinite,
InvalidHandle,
NullReference,
Bounds,
+86 -120
View File
@@ -1,3 +1,4 @@
use crate::numeric;
use crate::resource_budget::BudgetVec;
mod callable;
mod collections;
@@ -65,6 +66,12 @@ pub(crate) enum OpError {
Trap(u32, String),
}
impl From<crate::numeric::NumericError> for OpError {
fn from(error: crate::numeric::NumericError) -> Self {
Self::Trap(error.code, format!("Numeric operation failed: {error:?}"))
}
}
impl From<TrapInfo> for LogicalFrameEndingReason {
fn from(info: TrapInfo) -> Self {
LogicalFrameEndingReason::Trap(info)
@@ -276,6 +283,15 @@ impl VirtualMachine {
self.cycles += opcode.cycles();
}
let charged_math = if opcode == OpCode::Intrinsic {
lookup_intrinsic_by_id(instr.imm_u32().unwrap())
.filter(|m| m.owner == "vec2" || m.owner == "mathf" || m.owner.starts_with("math."))
} else {
None
};
if let Some(meta) = charged_math {
self.cycles += meta.cost_cycles;
}
// Execute
match opcode {
OpCode::Nop => {}
@@ -436,117 +452,40 @@ impl VirtualMachine {
{
self.execute_string_add(opcode, start_pc as u32)?;
} else {
self.binary_op(opcode, start_pc as u32, |a, b| match (&a, &b) {
(Value::Int32(a), Value::Int32(b)) => Ok(Value::Int32(a.wrapping_add(*b))),
(Value::Int64(a), Value::Int64(b)) => Ok(Value::Int64(a.wrapping_add(*b))),
(Value::Int32(a), Value::Int64(b)) => {
Ok(Value::Int64((*a as i64).wrapping_add(*b)))
}
(Value::Int64(a), Value::Int32(b)) => {
Ok(Value::Int64(a.wrapping_add(*b as i64)))
}
(Value::Float(a), Value::Float(b)) => Ok(Value::Float(a + b)),
(Value::Int32(a), Value::Float(b)) => Ok(Value::Float(*a as f64 + b)),
(Value::Float(a), Value::Int32(b)) => Ok(Value::Float(a + *b as f64)),
(Value::Int64(a), Value::Float(b)) => Ok(Value::Float(*a as f64 + b)),
(Value::Float(a), Value::Int64(b)) => Ok(Value::Float(a + *b as f64)),
_ => Err(OpError::Trap(TRAP_TYPE, "Invalid types for ADD".into())),
self.binary_op(opcode, start_pc as u32, |a, b| {
numeric::opcode_binary(opcode, &a, &b).map_err(|e| {
if e.code == TRAP_TYPE {
OpError::Trap(
TRAP_TYPE,
format!(
"Invalid types for {}",
format!("{opcode:?}").to_uppercase()
),
)
} else {
OpError::from(e)
}
})
})?;
}
}
OpCode::Sub => self.binary_op(opcode, start_pc as u32, |a, b| match (a, b) {
(Value::Int32(a), Value::Int32(b)) => Ok(Value::Int32(a.wrapping_sub(b))),
(Value::Int64(a), Value::Int64(b)) => Ok(Value::Int64(a.wrapping_sub(b))),
(Value::Int32(a), Value::Int64(b)) => Ok(Value::Int64((a as i64).wrapping_sub(b))),
(Value::Int64(a), Value::Int32(b)) => Ok(Value::Int64(a.wrapping_sub(b as i64))),
(Value::Float(a), Value::Float(b)) => Ok(Value::Float(a - b)),
(Value::Int32(a), Value::Float(b)) => Ok(Value::Float(a as f64 - b)),
(Value::Float(a), Value::Int32(b)) => Ok(Value::Float(a - b as f64)),
(Value::Int64(a), Value::Float(b)) => Ok(Value::Float(a as f64 - b)),
(Value::Float(a), Value::Int64(b)) => Ok(Value::Float(a - b as f64)),
_ => Err(OpError::Trap(TRAP_TYPE, "Invalid types for SUB".into())),
})?,
OpCode::Mul => self.binary_op(opcode, start_pc as u32, |a, b| match (a, b) {
(Value::Int32(a), Value::Int32(b)) => Ok(Value::Int32(a.wrapping_mul(b))),
(Value::Int64(a), Value::Int64(b)) => Ok(Value::Int64(a.wrapping_mul(b))),
(Value::Int32(a), Value::Int64(b)) => Ok(Value::Int64((a as i64).wrapping_mul(b))),
(Value::Int64(a), Value::Int32(b)) => Ok(Value::Int64(a.wrapping_mul(b as i64))),
(Value::Float(a), Value::Float(b)) => Ok(Value::Float(a * b)),
(Value::Int32(a), Value::Float(b)) => Ok(Value::Float(a as f64 * b)),
(Value::Float(a), Value::Int32(b)) => Ok(Value::Float(a * b as f64)),
(Value::Int64(a), Value::Float(b)) => Ok(Value::Float(a as f64 * b)),
(Value::Float(a), Value::Int64(b)) => Ok(Value::Float(a * b as f64)),
_ => Err(OpError::Trap(TRAP_TYPE, "Invalid types for MUL".into())),
})?,
OpCode::Div => self.binary_op(opcode, start_pc as u32, |a, b| match (a, b) {
(Value::Int32(a), Value::Int32(b)) => {
if b == 0 {
return Err(OpError::Trap(
TRAP_DIV_ZERO,
"Integer division by zero".into(),
));
}
Ok(Value::Int32(a.wrapping_div(b)))
}
(Value::Int64(a), Value::Int64(b)) => {
if b == 0 {
return Err(OpError::Trap(
TRAP_DIV_ZERO,
"Integer division by zero".into(),
));
}
Ok(Value::Int64(a.wrapping_div(b)))
}
(Value::Int32(a), Value::Int64(b)) => {
if b == 0 {
return Err(OpError::Trap(
TRAP_DIV_ZERO,
"Integer division by zero".into(),
));
}
Ok(Value::Int64((a as i64).wrapping_div(b)))
}
(Value::Int64(a), Value::Int32(b)) => {
if b == 0 {
return Err(OpError::Trap(
TRAP_DIV_ZERO,
"Integer division by zero".into(),
));
}
Ok(Value::Int64(a.wrapping_div(b as i64)))
}
(Value::Float(a), Value::Float(b)) => {
if b == 0.0 {
return Err(OpError::Trap(TRAP_DIV_ZERO, "Float division by zero".into()));
}
Ok(Value::Float(a / b))
}
(Value::Int32(a), Value::Float(b)) => {
if b == 0.0 {
return Err(OpError::Trap(TRAP_DIV_ZERO, "Float division by zero".into()));
}
Ok(Value::Float(a as f64 / b))
}
(Value::Float(a), Value::Int32(b)) => {
if b == 0 {
return Err(OpError::Trap(TRAP_DIV_ZERO, "Float division by zero".into()));
}
Ok(Value::Float(a / b as f64))
}
(Value::Int64(a), Value::Float(b)) => {
if b == 0.0 {
return Err(OpError::Trap(TRAP_DIV_ZERO, "Float division by zero".into()));
}
Ok(Value::Float(a as f64 / b))
}
(Value::Float(a), Value::Int64(b)) => {
if b == 0 {
return Err(OpError::Trap(TRAP_DIV_ZERO, "Float division by zero".into()));
}
Ok(Value::Float(a / b as f64))
}
_ => Err(OpError::Trap(TRAP_TYPE, "Invalid types for DIV".into())),
})?,
OpCode::Sub | OpCode::Mul | OpCode::Div => {
self.binary_op(opcode, start_pc as u32, |a, b| {
numeric::opcode_binary(opcode, &a, &b).map_err(|e| {
if e.code == TRAP_TYPE {
OpError::Trap(
TRAP_TYPE,
format!(
"Invalid types for {}",
format!("{opcode:?}").to_uppercase()
),
)
} else {
OpError::from(e)
}
})
})?
}
OpCode::Mod => self.binary_op(opcode, start_pc as u32, |a, b| match (a, b) {
(Value::Int32(a), Value::Int32(b)) => {
if b == 0 {
@@ -562,29 +501,33 @@ impl VirtualMachine {
}
_ => Err(OpError::Trap(TRAP_TYPE, "Invalid types for MOD".into())),
})?,
OpCode::Eq => {
self.binary_op(opcode, start_pc as u32, |a, b| Ok(Value::Boolean(a == b)))?
}
OpCode::Neq => {
self.binary_op(opcode, start_pc as u32, |a, b| Ok(Value::Boolean(a != b)))?
}
OpCode::Eq => self.binary_op(opcode, start_pc as u32, |a, b| {
numeric::equal_values(&a, &b).map(Value::Boolean).map_err(OpError::from)
})?,
OpCode::Neq => self.binary_op(opcode, start_pc as u32, |a, b| {
numeric::equal_values(&a, &b).map(|v| Value::Boolean(!v)).map_err(OpError::from)
})?,
OpCode::Lt => self.binary_op(opcode, start_pc as u32, |a, b| {
a.partial_cmp(&b)
numeric::compare_values(&a, &b)
.map_err(OpError::from)?
.map(|o| Value::Boolean(o == std::cmp::Ordering::Less))
.ok_or_else(|| OpError::Trap(TRAP_TYPE, "Invalid types for LT".into()))
})?,
OpCode::Gt => self.binary_op(opcode, start_pc as u32, |a, b| {
a.partial_cmp(&b)
numeric::compare_values(&a, &b)
.map_err(OpError::from)?
.map(|o| Value::Boolean(o == std::cmp::Ordering::Greater))
.ok_or_else(|| OpError::Trap(TRAP_TYPE, "Invalid types for GT".into()))
})?,
OpCode::Lte => self.binary_op(opcode, start_pc as u32, |a, b| {
a.partial_cmp(&b)
numeric::compare_values(&a, &b)
.map_err(OpError::from)?
.map(|o| Value::Boolean(o != std::cmp::Ordering::Greater))
.ok_or_else(|| OpError::Trap(TRAP_TYPE, "Invalid types for LTE".into()))
})?,
OpCode::Gte => self.binary_op(opcode, start_pc as u32, |a, b| {
a.partial_cmp(&b)
numeric::compare_values(&a, &b)
.map_err(OpError::from)?
.map(|o| Value::Boolean(o != std::cmp::Ordering::Less))
.ok_or_else(|| OpError::Trap(TRAP_TYPE, "Invalid types for GTE".into()))
})?,
@@ -657,7 +600,12 @@ impl VirtualMachine {
Value::Int64(a) => {
self.push_trap(Value::Int64(a.wrapping_neg()), opcode, start_pc as u32)?
}
Value::Float(a) => self.push_trap(Value::Float(-a), opcode, start_pc as u32)?,
Value::Float(a) => {
let result = numeric::neg(a).map_err(|e| {
self.trap(e.code, opcode as u16, format!("NEG: {e:?}"), start_pc as u32)
})?;
self.push_trap(Value::Float(result), opcode, start_pc as u32)?;
}
_ => {
return Err(self.trap(
TRAP_TYPE,
@@ -997,6 +945,15 @@ impl VirtualMachine {
),
pc_at_intrinsic,
),
crate::IntrinsicExecutionError::Numeric(error) => self.trap(
error.code,
opcode as u16,
format!(
"Intrinsic {}.{}: {:?}",
intrinsic.owner, intrinsic.name, error
),
pc_at_intrinsic,
),
crate::IntrinsicExecutionError::HardwareUnavailable => self.trap(
TRAP_UNAVAILABLE,
OpCode::Intrinsic as u16,
@@ -1027,6 +984,15 @@ impl VirtualMachine {
),
pc_at_intrinsic,
),
crate::IntrinsicExecutionError::Numeric(error) => self.trap(
error.code,
opcode as u16,
format!(
"Intrinsic {}.{} result: {:?}",
intrinsic.owner, intrinsic.name, error
),
pc_at_intrinsic,
),
crate::IntrinsicExecutionError::HardwareUnavailable => self.trap(
TRAP_UNAVAILABLE,
OpCode::Intrinsic as u16,
@@ -1073,7 +1039,7 @@ impl VirtualMachine {
}
// Control attempts were already charged before validation.
if !charged_control {
if !charged_control && charged_math.is_none() {
self.cycles += opcode.cycles();
}
Ok(())
@@ -34,11 +34,17 @@ impl VirtualMachine {
LogicalFrameEndingReason::Trap(self.program.create_trap(code, opcode, message, pc))
}
pub fn push(&mut self, val: Value) -> Result<(), ResourceFailure> {
let growth = self.operand_stack.prepare_growth(1)?;
let val = self.import_string_value(&val)?;
pub fn push(&mut self, val: Value) -> Result<(), VmFault> {
if matches!(&val,Value::Float(x) if !crate::numeric::finite(*x)) {
return Err(VmFault::Trap(
prometeu_bytecode::TRAP_NON_FINITE,
"Native stack import contains a non-finite Float".into(),
));
}
let growth = self.operand_stack.prepare_growth(1).map_err(VmFault::ResourceLimit)?;
let val = self.import_string_value(&val).map_err(VmFault::ResourceLimit)?;
self.operand_stack.commit_growth(growth);
self.operand_stack.push(val)
self.operand_stack.push(val).map_err(VmFault::ResourceLimit)
}
pub(super) fn push_trap(
@@ -20,6 +20,7 @@ impl VirtualMachine {
pub(super) fn value_error_code(error: ValueError) -> u32 {
match error {
ValueError::Type => TRAP_TYPE,
ValueError::NonFinite => prometeu_bytecode::TRAP_NON_FINITE,
ValueError::InvalidHandle => TRAP_INVALID_HANDLE,
ValueError::NullReference => TRAP_NULL_REFERENCE,
ValueError::Bounds => TRAP_OOB,
@@ -74,6 +75,12 @@ impl VirtualMachine {
if values.len() != slot {
return Err((slot, ValueError::Type));
}
// Validate the complete signature before classifying numeric content.
if let Some(slot) =
values.iter().position(|v| matches!(v,Value::Float(x) if !crate::numeric::finite(*x)))
{
return Err((slot, ValueError::NonFinite));
}
Ok(())
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,434 @@
use prometeu_bytecode::load_limits::{LoadBudget, LoadCode as C, LoadReason as R};
use prometeu_bytecode::{
TRAP_DIV_ZERO, TRAP_NON_FINITE as NON_FINITE, TRAP_NUMERIC_DOMAIN as DOMAIN,
TRAP_NUMERIC_RANGE as RANGE, TRAP_TYPE, Value, assemble,
};
use prometeu_hal::vm_fault::VmFault;
use prometeu_test_support::program::TestProgram;
use prometeu_vm::resource_budget::RuntimeLimits;
use prometeu_vm::{
HostContext, HostReturn, IntrinsicExecutionError as E, LogicalFrameEndingReason as End,
NativeInterface, ValidatedProgramImage, VirtualMachine, VmInitError, lookup_intrinsic_by_id,
materialize_builtin_constant,
};
struct NoNative;
impl NativeInterface for NoNative {
fn syscall(
&mut self,
_: u32,
_: &[Value],
_: &mut HostReturn,
_: &mut HostContext,
) -> Result<(), VmFault> {
panic!("unexpected native call")
}
}
fn call(id: u32, args: &[Value]) -> Result<Value, E> {
let m = lookup_intrinsic_by_id(id).unwrap();
(m.implementation)(args, &mut HostContext::new(None)).map(|mut v| v.remove(0))
}
fn floats(id: u32, xs: &[f64]) -> Result<u64, u32> {
match call(id, &xs.iter().copied().map(Value::Float).collect::<Vec<_>>()) {
Ok(Value::Float(x)) => Ok(x.to_bits()),
Err(E::Numeric(e)) => Err(e.code),
v => panic!("{v:?}"),
}
}
fn vm(source: &str, limits: RuntimeLimits) -> VirtualMachine {
let bytes =
TestProgram::single(assemble(source).unwrap(), Default::default(), 0, 8).serialize();
let image =
ValidatedProgramImage::load(&bytes, &mut LoadBudget::new(Default::default()), 0).unwrap();
let mut vm = VirtualMachine::from_image(image, limits);
vm.prepare_call("0").unwrap();
vm
}
fn run(vm: &mut VirtualMachine, budget: u64) -> prometeu_vm::BudgetReport {
vm.run_budget(budget, &mut NoNative, &mut HostContext::new(None)).unwrap()
}
fn trap(r: &prometeu_vm::BudgetReport) -> &prometeu_bytecode::TrapInfo {
let End::Trap(t) = &r.reason else { panic!("{r:?}") };
t
}
#[test]
fn integer_limits_are_exact_and_abs_does_not_wrap() {
for (base, a, b) in [
(0x3000, Value::Int32(i32::MIN), Value::Int32(i32::MAX)),
(0x3004, Value::Int64(i64::MIN), Value::Int64(i64::MAX)),
] {
assert_eq!(call(base, &[b.clone(), a.clone()]).unwrap(), a);
assert_eq!(call(base + 1, &[a.clone(), b.clone()]).unwrap(), b);
assert!(matches!(call(base+3,&[a.clone()]),Err(E::Numeric(e)) if e.code==RANGE));
assert!(matches!(call(base+2,&[b.clone(),b,a]),Err(E::Numeric(e)) if e.code==DOMAIN));
}
assert_eq!(
call(0x3002, &[Value::Int32(-5), Value::Int32(0), Value::Int32(10)]).unwrap(),
Value::Int32(0)
);
assert!(
matches!(call(0x3002,&[Value::Int32(5),Value::Int32(10),Value::Int32(0)]),Err(E::Numeric(e)) if e.code==DOMAIN)
);
}
#[test]
fn signed_zero_limits_and_rounding_follow_bits() {
for a in [0.0f64, -0.0] {
for b in [0.0f64, -0.0] {
let same = a.to_bits() == b.to_bits();
assert_eq!(
floats(0x3008, &[a, b]),
Ok(if same { a.to_bits() } else { (-0.0f64).to_bits() })
);
assert_eq!(floats(0x3009, &[a, b]), Ok(if same { a.to_bits() } else { 0 }));
}
}
assert_eq!(floats(0x300a, &[-0.0, 0.0, 1.0]), Ok(0));
assert_eq!(floats(0x300b, &[-0.0]), Ok(0));
assert_eq!(floats(0x3010, &[-0.0]), Ok((-0.0f64).to_bits()));
for id in 0x300c..=0x300f {
assert_eq!(floats(id, &[-0.0]), Ok((-0.0f64).to_bits()));
}
for (x, y) in [
(0.5, 0.0f64),
(-0.5, -0.0),
(1.5, 2.0),
(2.5, 2.0),
(3.5, 4.0),
(-2.5, -2.0),
(-3.5, -4.0),
(f64::from_bits(0x3fe0000000000001), 1.0),
(f64::from_bits(0x3fdfffffffffffff), 0.0),
] {
assert_eq!(floats(0x300f, &[x]), Ok(y.to_bits()));
}
assert_eq!(floats(0x300c, &[-2.7]), Ok((-3.0f64).to_bits()));
assert_eq!(floats(0x300d, &[-2.7]), Ok((-2.0f64).to_bits()));
assert_eq!(floats(0x300e, &[-2.7]), Ok((-2.0f64).to_bits()));
}
#[test]
fn atan2_has_explicit_zero_vector_and_signed_axis_contract() {
for y in [0.0, -0.0] {
for x in [0.0, -0.0] {
assert_eq!(floats(0x3013, &[y, x]), Err(DOMAIN));
}
}
for (y, x, bits) in [
(0.0, 1.0, 0),
(-0.0, 1.0, 1 << 63),
(0.0, -1.0, 0x400921fb54442d18),
(-0.0, -1.0, 0xc00921fb54442d18),
(1.0, 0.0, 0x3ff921fb54442d18),
(1.0, -0.0, 0x3ff921fb54442d18),
(-1.0, 0.0, 0xbff921fb54442d18),
(-1.0, -0.0, 0xbff921fb54442d18),
] {
assert_eq!(floats(0x3013, &[y, x]), Ok(bits));
}
assert_eq!(floats(0x3011, &[-0.0]), Ok(1 << 63));
assert_eq!(floats(0x3012, &[-0.0]), Ok(1.0f64.to_bits()));
}
#[test]
fn conversions_check_the_truncated_integer_without_saturating() {
for (x, expected) in [(3.9, 3), (-3.9, -3), (-2147483648.9, i32::MIN)] {
assert_eq!(call(0x3018, &[Value::Float(x)]).unwrap(), Value::Int32(expected));
}
assert!(
matches!(call(0x3018,&[Value::Float(2147483648.0)]),Err(E::Numeric(e)) if e.code==RANGE)
);
let minimum = f64::from_bits(0xc3e0000000000000);
assert_eq!(call(0x3019, &[Value::Float(minimum)]).unwrap(), Value::Int64(i64::MIN));
let Value::Float(wide) = call(0x3017, &[Value::Int64(i64::MAX)]).unwrap() else { panic!() };
assert_eq!(wide.to_bits(), 0x43e0000000000000);
assert!(matches!(call(0x3019,&[Value::Float(wide)]),Err(E::Numeric(e)) if e.code==RANGE));
assert_eq!(
call(0x3019, &[Value::Float(f64::from_bits(0x43dfffffffffffff))]).unwrap(),
Value::Int64(9223372036854774784)
);
assert_eq!(call(0x3014, &[Value::Int32(i32::MIN)]).unwrap(), Value::Int64(i64::from(i32::MIN)));
assert!(matches!(call(0x3015,&[Value::Int64(i64::MAX)]),Err(E::Numeric(e)) if e.code==RANGE));
assert_eq!(call(0x3018, &[Value::Float(-0.0)]).unwrap(), Value::Int32(0));
for (integer, bits) in
[(9007199254740993, 0x4340000000000000), (9007199254740995, 0x4340000000000002)]
{
let Value::Float(v) = call(0x3017, &[Value::Int64(integer)]).unwrap() else { panic!() };
assert_eq!(v.to_bits(), bits);
}
}
#[test]
fn faults_validate_all_types_then_finitude_then_domain() {
assert!(matches!(
call(0x300a, &[Value::Float(f64::NAN), Value::Float(2.), Value::Int32(1)]),
Err(E::TypeMismatch { index: 2, .. })
));
assert_eq!(floats(0x300a, &[f64::NAN, 2., 1.]), Err(NON_FINITE));
assert_eq!(floats(0x300a, &[0., 2., 1.]), Err(DOMAIN));
assert_eq!(floats(0x3010, &[-1.]), Err(DOMAIN));
for x in [f64::NAN, f64::INFINITY, f64::NEG_INFINITY] {
assert_eq!(floats(0x3010, &[x]), Err(NON_FINITE));
}
assert!(matches!(
call(
0x1000,
&[Value::Float(f64::NAN), Value::Float(1.), Value::Float(2.), Value::Int32(3)]
),
Err(E::TypeMismatch { index: 3, .. })
));
}
#[test]
fn vector_sequences_keep_stage_rounding_and_scaled_extremes() {
assert_eq!(floats(0x1001, &[1e200, 0.]), Ok(1e200f64.to_bits()));
assert_eq!(floats(0x1001, &[f64::from_bits(1), 0.]), Ok(1));
assert_eq!(floats(0x1001, &[-0., -0.]), Ok(0));
assert_eq!(floats(0x1001, &[f64::MAX, f64::MAX]), Err(RANGE));
assert_eq!(floats(0x1000, &[f64::MAX, f64::MAX, 2., -2.]), Err(RANGE));
// (1+2^-27)*(1-2^-27) rounds to 1 before subtracting 1.
assert_eq!(
floats(
0x1000,
&[f64::from_bits(0x3ff0000002000000), 1., f64::from_bits(0x3feffffffc000000), -1.]
),
Ok(0)
);
}
#[test]
fn math_attempts_charge_before_failure_and_positive_budget_overshoots() {
for (bits, expected) in [(0x4010000000000000u64, None), (0xbff0000000000000, Some(DOMAIN))] {
let mut v =
vm(&format!("PUSH_F64 f64:0x{bits:016x}\nINTRINSIC 0x3010\nHALT"), Default::default());
assert_eq!(run(&mut v, 1).cycles_used, 2);
let before = v.operand_stack_top(1);
let zero = run(&mut v, 0);
assert_eq!((zero.cycles_used, zero.steps_executed), (0, 0));
assert_eq!(&*before, &*v.operand_stack_top(1));
let attempt = run(&mut v, 1);
assert_eq!(attempt.cycles_used, 16);
if let Some(code) = expected {
assert_eq!((trap(&attempt).code, trap(&attempt).pc), (code, 10));
} else {
assert_eq!(attempt.reason, End::BudgetExhausted);
let Value::Float(x) = v.operand_stack_top(1)[0] else { panic!() };
assert_eq!(x.to_bits(), 2.0f64.to_bits());
assert_eq!(run(&mut v, 1).cycles_used, 1);
}
}
let mut v =
vm("PUSH_I32 1\nSET_GLOBAL 0\nGET_GLOBAL 0\nINTRINSIC 0x3010\nHALT", Default::default());
run(&mut v, 8);
let attempt = run(&mut v, 1);
assert_eq!((attempt.cycles_used, trap(&attempt).code), (16, TRAP_TYPE));
let mut v = vm(
"PUSH_F64 f64:0x4010000000000000\nINTRINSIC 0x3010\nHALT",
RuntimeLimits::default()
.lowered(prometeu_bytecode::RuntimeResource::TemporaryBytes, 0)
.unwrap(),
);
run(&mut v, 1);
let attempt = run(&mut v, 1);
assert_eq!(
(attempt.cycles_used, trap(&attempt).code),
(16, prometeu_bytecode::TRAP_RESOURCE_LIMIT)
);
}
#[test]
fn float_opcodes_preserve_underflow_zero_division_and_numeric_faults() {
for (source, bits) in [
("PUSH_F64 f64:0x0000000000000001\nPUSH_F64 f64:0x3ff0000000000000\nMUL\nHALT", 1),
("PUSH_F64 f64:0x0000000000000001\nPUSH_F64 f64:0x4000000000000000\nDIV\nHALT", 0),
("PUSH_F64 f64:0x8000000000000000\nNEG\nHALT", 0),
(
"PUSH_I64 9007199254740993\nPUSH_F64 f64:0x0000000000000000\nADD\nHALT",
0x4340000000000000,
),
] {
let mut v = vm(source, Default::default());
assert_eq!(run(&mut v, 100).reason, End::Halted);
let Value::Float(x) = v.operand_stack_top(1)[0] else { panic!() };
assert_eq!(x.to_bits(), bits);
}
for (source, code) in [
("PUSH_F64 f64:0x7fefffffffffffff\nPUSH_F64 f64:0x4000000000000000\nMUL\nHALT", RANGE),
(
"PUSH_F64 f64:0x3ff0000000000000\nPUSH_F64 f64:0x8000000000000000\nDIV\nHALT",
TRAP_DIV_ZERO,
),
] {
let mut v = vm(source, Default::default());
assert_eq!(trap(&run(&mut v, 100)).code, code);
}
}
#[test]
fn load_rejects_nonfinite_immediates_and_unknown_intrinsics_even_when_dead() {
for (source, reason) in [
("HALT\nPUSH_F64 f64:0x7ff0000000000000", R::NonFiniteValue),
("HALT\nPUSH_F64 f64:0x7ff8000000000042", R::NonFiniteValue),
("HALT\nINTRINSIC 0xffffffff", R::NativeId),
] {
let bytes =
TestProgram::single(assemble(source).unwrap(), Default::default(), 0, 8).serialize();
let Err(VmInitError::RegistryLoadFailed(e)) =
ValidatedProgramImage::load(&bytes, &mut LoadBudget::new(Default::default()), 0)
else {
panic!()
};
assert_eq!(
(e.code, e.reason, e.function, e.pc),
(C::InvalidCode, reason, Some(0), Some(2))
);
}
}
#[test]
fn native_signature_checks_all_types_before_rejecting_nonfinite() {
use prometeu_bytecode::registry::{NamedType, Signature, TypeId};
let mut program = TestProgram::single(assemble("HALT").unwrap(), Default::default(), 0, 8);
program.functions[0].signature = Signature {
parameters: vec![NamedType { type_id: TypeId(2), name: None }; 2],
results: vec![],
};
let image = ValidatedProgramImage::load(
&program.serialize(),
&mut LoadBudget::new(Default::default()),
0,
)
.unwrap();
let mut v = VirtualMachine::from_image(image, Default::default());
for (args, slot, code) in [
([Value::Float(f64::NAN), Value::Int32(1)], 1, TRAP_TYPE),
([Value::Float(f64::NAN), Value::Float(1.)], 0, NON_FINITE),
] {
assert_eq!(
v.prepare_call_with_args("0", &args),
Err(VmInitError::EntrypointArgumentsInvalid { function: 0, slot, trap_code: code })
);
assert!(v.operand_stack_top(10).is_empty());
}
assert!(matches!(v.push(Value::Float(f64::INFINITY)), Err(VmFault::Trap(NON_FINITE, _))));
assert!(v.operand_stack_top(10).is_empty());
}
#[test]
fn catalog_has_exact_ids_costs_names_and_canonical_constants() {
let costs = [2, 2, 4, 2, 2, 2, 4, 2, 2, 2, 4, 2, 4, 4, 4, 4, 16, 32, 32, 48, 2, 2, 2, 2, 2, 2];
for (offset, cost) in costs.into_iter().enumerate() {
let m = lookup_intrinsic_by_id(0x3000 + offset as u32).unwrap();
assert_eq!((m.version, m.cost_cycles), (1, cost));
assert_eq!(m.parameter_names.len(), m.arg_layout.len());
assert!(m.deterministic && !m.may_allocate);
}
for (id, cost) in [(0x1000, 10), (0x1001, 40), (0x1101, 1), (0x2100, 1)] {
assert_eq!(lookup_intrinsic_by_id(id).unwrap().cost_cycles, cost);
}
for (name, bits) in [("pi", 0x400921fb54442d18), ("tau", 0x401921fb54442d18)] {
let constants = materialize_builtin_constant("mathf", name, 1).unwrap().unwrap();
let Value::Float(x) = constants[0] else { panic!() };
assert_eq!(x.to_bits(), bits);
}
assert_eq!(lookup_intrinsic_by_id(0x3013).unwrap().parameter_names, &["y", "x"]);
}
#[test]
fn exported_artifacts_match_the_single_runtime_catalog() {
assert_eq!(
prometeu_vm::intrinsic_catalog_csv(),
include_str!("../../../../docs/vm-arch/INTRINSICS.csv")
);
assert_eq!(
prometeu_vm::builtin_constant_catalog_csv(),
include_str!("../../../../docs/vm-arch/BUILTIN_CONSTANTS.csv")
);
let mut ids = std::collections::HashSet::new();
let mut keys = std::collections::HashSet::new();
for m in prometeu_vm::intrinsic_catalog() {
assert!(ids.insert(m.id));
assert!(keys.insert(m.key()));
assert_eq!(m.parameter_names.len(), m.arg_slots());
}
}
fn fixture_value(token: &str) -> Value {
let (kind, v) = token.split_once(':').unwrap();
match kind {
"f" => Value::Float(f64::from_bits(u64::from_str_radix(v, 16).unwrap())),
"i" => Value::Int32(v.parse().unwrap()),
"l" => Value::Int64(v.parse().unwrap()),
_ => panic!("numeric fixture"),
}
}
fn value_token(v: &Value) -> String {
match v {
Value::Float(v) => format!("f:{:016x}", v.to_bits()),
Value::Int32(v) => format!("i:{v}"),
Value::Int64(v) => format!("l:{v}"),
_ => panic!("numeric fixture result"),
}
}
fn push_source(v: &Value) -> String {
match v {
Value::Float(v) => format!("PUSH_F64 f64:0x{:016x}\n", v.to_bits()),
Value::Int32(v) => format!("PUSH_I32 {v}\n"),
Value::Int64(v) => format!("PUSH_I64 {v}\n"),
_ => panic!("numeric fixture argument"),
}
}
#[test]
fn mpfr_fixed_corpus_replays_without_a_runtime_or_test_mpfr_dependency() {
for row in include_str!("fixtures/numeric-conformance.tsv").lines() {
let tokens: Vec<_> = row.split_whitespace().collect();
let op = tokens[0];
let expected = tokens[tokens.len() - 2];
let cycles: u64 = tokens[tokens.len() - 1].parse().unwrap();
let args: Vec<_> = tokens[1..tokens.len() - 2].iter().map(|t| fixture_value(t)).collect();
if matches!(op, "ADD" | "SUB" | "MUL" | "DIV") {
let source = args.iter().map(push_source).collect::<String>() + op + "\nHALT";
let mut v = vm(&source, Default::default());
let report = run(&mut v, 100);
assert_eq!(report.cycles_used, cycles, "{row}");
let actual = match report.reason {
End::Halted => value_token(&v.operand_stack_top(1)[0]),
End::Trap(t) => format!("trap:{:x}", t.code),
e => panic!("{row}: {e:?}"),
};
assert_eq!(actual, expected, "{row}");
} else {
let id = u32::from_str_radix(op, 16).unwrap();
let actual = match call(id, &args) {
Ok(v) => value_token(&v),
Err(E::Numeric(e)) => format!("trap:{:x}", e.code),
e => panic!("{e:?}"),
};
assert_eq!(actual, expected, "{row}");
assert_eq!(lookup_intrinsic_by_id(id).unwrap().cost_cycles, cycles);
}
}
}
#[test]
fn every_scalar_and_vector_call_has_the_published_total_execution_cost() {
for m in prometeu_vm::intrinsic_catalog()
.filter(|m| m.owner == "vec2" || m.owner == "mathf" || m.owner.starts_with("math."))
{
let args: Vec<_> = m
.arg_layout
.iter()
.enumerate()
.map(|(i, t)| {
let n = if m.name == "clamp" { [1, 0, 2][i] } else { 1 };
match t {
prometeu_vm::AbiType::Scalar(prometeu_vm::BuiltinScalarType::Int32) => {
Value::Int32(n)
}
prometeu_vm::AbiType::Scalar(prometeu_vm::BuiltinScalarType::Int64) => {
Value::Int64(i64::from(n))
}
_ => Value::Float(f64::from(n)),
}
})
.collect();
let source = args.iter().map(push_source).collect::<String>()
+ &format!("INTRINSIC 0x{:x}\nHALT", m.id);
let mut v = vm(&source, Default::default());
let prefix = run(&mut v, 2 * args.len() as u64);
assert_eq!(prefix.cycles_used, 2 * args.len() as u64);
let attempt = run(&mut v, 1);
assert_eq!(attempt.cycles_used, m.cost_cycles, "{}", m.id);
assert_eq!(attempt.reason, End::BudgetExhausted, "{}", m.id);
}
}
@@ -0,0 +1,211 @@
//! Coverage policy tests drive repository scripts with independently built evidence.
use std::fs;
use std::path::{Path, PathBuf};
use std::process::{Command, Output};
use std::sync::atomic::{AtomicU64, Ordering};
use std::time::{SystemTime, UNIX_EPOCH};
static NEXT_FIXTURE: AtomicU64 = AtomicU64::new(0);
const SOURCE: &str = "crates/console/probe/src/";
const CONFIG: &str = r#"{
"version": 1,
"domains": {
"core": {
"baseline_percent": 80,
"paths": ["crates/console/probe/src/"],
"exclude_paths": ["crates/console/probe/src/bank"]
},
"bank": {
"baseline_percent": 90,
"paths": ["crates/console/probe/src/bank"]
}
}
}"#;
fn repository() -> PathBuf {
Path::new(env!("CARGO_MANIFEST_DIR")).join("../../..").canonicalize().unwrap()
}
struct Fixture(PathBuf);
impl Fixture {
fn new() -> Self {
let nonce = SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_nanos();
let root = std::env::temp_dir().join(format!(
"prometeu-coverage-{}-{nonce}-{}",
std::process::id(),
NEXT_FIXTURE.fetch_add(1, Ordering::Relaxed)
));
fs::create_dir(&root).unwrap();
let this = Self(root);
for name in ["main.rs", "bank.rs", "bank/cache.rs"] {
this.write(&format!("{SOURCE}{name}"), "pub fn value() -> u32 { 1 }\n");
}
this.write("files/config/runtime-edge-coverage-domains.json", CONFIG);
this.report(&[
(format!("{SOURCE}main.rs"), 10, 10),
(format!("./{SOURCE}bank.rs"), 10, 10),
(this.0.join(format!("{SOURCE}bank/cache.rs")).display().to_string(), 10, 10),
]);
this
}
fn write(&self, name: &str, content: &str) {
let path = self.0.join(name);
fs::create_dir_all(path.parent().unwrap()).unwrap();
fs::write(path, content).unwrap();
}
fn report(&self, rows: &[(String, u32, u32)]) {
let records: Vec<_> = rows.iter().map(|(filename, count, covered)| {
format!(r#"{{"filename":"{filename}","summary":{{"lines":{{"count":{count},"covered":{covered}}}}}}}"#)
}).collect();
self.write("report.json", &format!(r#"{{"data":[{{"files":[{}]}}]}}"#, records.join(",")));
}
fn audit(&self, report: bool) -> Output {
let mut cmd = Command::new("python3");
cmd.arg(repository().join("scripts/audit-coverage-domains.py")).arg("--root").arg(&self.0);
if report {
cmd.arg("--report").arg(self.0.join("report.json"));
}
cmd.output().unwrap()
}
fn helper(&self, args: &[&str]) -> Output {
let init =
Command::new("git").args(["init", "--quiet"]).current_dir(&self.0).output().unwrap();
assert!(init.status.success(), "{init:?}");
fs::create_dir_all(self.0.join("scripts")).unwrap();
for name in ["coverage-domain-evidence.sh", "audit-coverage-domains.py"] {
fs::copy(repository().join("scripts").join(name), self.0.join("scripts").join(name))
.unwrap();
}
Command::new("bash")
.arg(self.0.join("scripts/coverage-domain-evidence.sh"))
.args(args)
.current_dir(&self.0)
.output()
.unwrap()
}
}
impl Drop for Fixture {
fn drop(&mut self) {
let _ = fs::remove_dir_all(&self.0);
}
}
fn success(output: Output) {
assert!(
output.status.success(),
"stdout={}\nstderr={}",
String::from_utf8_lossy(&output.stdout),
String::from_utf8_lossy(&output.stderr)
);
}
fn refuses(output: Output, diagnostic: &str) {
assert!(!output.status.success(), "unexpected success: {output:?}");
assert!(String::from_utf8_lossy(&output.stderr).contains(diagnostic), "{output:?}");
}
#[test]
fn repository_sources_have_exactly_one_coverage_owner() {
success(
Command::new("python3")
.arg(repository().join("scripts/audit-coverage-domains.py"))
.arg("--root")
.arg(repository())
.output()
.unwrap(),
);
}
#[test]
fn exclusions_and_absolute_relative_report_names_have_exclusive_ownership() {
let fixture = Fixture::new();
success(fixture.audit(false));
success(fixture.audit(true));
success(fixture.helper(&["--check-all", "report.json"]));
let output = fixture.helper(&["--show-summary-details", "bank", "report.json"]);
assert!(String::from_utf8_lossy(&output.stdout).contains("(20/20)"), "{output:?}");
success(output);
}
#[test]
fn new_source_without_an_owner_is_rejected_even_if_uninstrumented() {
let fixture = Fixture::new();
fixture.write("crates/console/unowned/src/new.rs", "pub fn new() {}\n");
refuses(fixture.audit(false), "expected exactly one domain");
}
#[test]
fn overlapping_domains_are_rejected_before_percentage_comparison() {
let fixture = Fixture::new();
fixture.write(
"files/config/runtime-edge-coverage-domains.json",
&CONFIG.replace(",\n \"exclude_paths\": [\"crates/console/probe/src/bank\"]", ""),
);
refuses(fixture.audit(true), "expected exactly one domain");
refuses(fixture.helper(&["--check", "core", "report.json"]), "expected exactly one domain");
}
#[test]
fn unknown_or_duplicate_report_sources_cannot_add_coverage() {
let fixture = Fixture::new();
fixture.report(&[(format!("{SOURCE}ghost.rs"), 10, 10)]);
refuses(fixture.audit(true), "report source not present");
fixture.report(&[(format!("{SOURCE}main.rs"), 10, 10), (format!("./{SOURCE}main.rs"), 10, 10)]);
refuses(fixture.audit(true), "duplicate source");
}
#[test]
fn missing_empty_or_zero_line_evidence_never_passes_zero_baselines() {
let fixture = Fixture::new();
fixture.write(
"files/config/runtime-edge-coverage-domains.json",
&CONFIG.replace(": 80", ": 0").replace(": 90", ": 0"),
);
fixture.report(&[(format!("{SOURCE}main.rs"), 0, 0), (format!("{SOURCE}bank.rs"), 0, 0)]);
refuses(fixture.helper(&["--check", "core", "report.json"]), "no instrumented lines");
fixture.report(&[]);
refuses(fixture.audit(true), "no instrumented lines");
fixture.report(&[(format!("{SOURCE}main.rs"), 10, 10)]);
refuses(fixture.audit(true), "bank: no instrumented lines");
fs::remove_file(fixture.0.join("report.json")).unwrap();
refuses(fixture.audit(true), "cannot read");
let output = fixture.helper(&["--check", "core", "report.json"]);
assert!(!output.status.success(), "{output:?}");
assert!(
String::from_utf8_lossy(&output.stdout).contains("Coverage report not found"),
"{output:?}"
);
}
#[test]
fn malformed_config_and_impossible_line_counts_fail_with_diagnostics() {
let fixture = Fixture::new();
fixture
.write("files/config/runtime-edge-coverage-domains.json", &CONFIG.replace(": 80", ": NaN"));
refuses(fixture.audit(false), "baseline_percent must be finite");
fixture.write("files/config/runtime-edge-coverage-domains.json", CONFIG);
fixture.report(&[(format!("{SOURCE}main.rs"), 10, 11)]);
refuses(fixture.audit(true), "invalid line counts");
}
#[test]
fn residual_gate_excludes_specialized_domain_and_still_rejects_regression() {
let fixture = Fixture::new();
fixture.report(&[
(format!("{SOURCE}main.rs"), 10, 8),
(format!("{SOURCE}bank.rs"), 10, 0),
(format!("{SOURCE}bank/cache.rs"), 10, 0),
]);
let output = fixture.helper(&[
"--check",
"--show-summary-details",
"--show-matched-files",
"core",
"report.json",
]);
assert!(String::from_utf8_lossy(&output.stdout).contains("(8/10)"), "{output:?}");
assert!(!String::from_utf8_lossy(&output.stdout).contains("bank/cache.rs"), "{output:?}");
success(output);
fixture.report(&[(format!("{SOURCE}main.rs"), 10, 7), (format!("{SOURCE}bank.rs"), 10, 10)]);
let output = fixture.helper(&["--check", "core", "report.json"]);
assert!(!output.status.success(), "{output:?}");
assert!(String::from_utf8_lossy(&output.stdout).contains("below baseline"), "{output:?}");
}
@@ -10,7 +10,11 @@ tags: [tests, coverage, ci, governance]
PROMETEU moved runtime-edge coverage governance away from a single workspace-wide percentage and toward canonical domain gates. That shift mattered not only for policy, but also for how CI logic is expressed and maintained.
The resulting model now treats `system/runtime`, `fs`, `asset/bank`, `firmware`, and `host-dependent` as the operational coverage authorities for runtime-edge changes.
The initial model focused on runtime edges. It now preserves the specialized
system/asset/firmware/host owners and also covers VM, bytecode, residual
HAL/drivers/system sources, tooling and test infrastructure.
The published operational reference is
[Coverage domains](../../../docs/vm-arch/COVERAGE_DOMAINS.md).
## Key Decisions
@@ -36,20 +40,67 @@ The coverage contract evolves with the repository. When CI duplicates the decisi
**Trade-offs:**
The helper must remain readable and stable, because it becomes part of the repository contract rather than a local convenience script.
### Complete and exclusive source ownership
**What:**
Every crate src Rust file has exactly one domain, including sources without
executable LLVM lines. Residual crate owners exclude the existing specialized
prefixes. A shared auditor normalizes report paths and supplies the same
statistics used by evidence display and percentage gates.
**Why:**
Tests can run successfully while the implementation they exercise belongs
to no coverage gate. Moving test files does not repair that omission.
Auditing only report files also misses sources absent from instrumentation.
Separate matching implementations can disagree on absolute/relative paths
or symlink aliases while producing plausible percentages.
**Trade-offs:**
New crates require explicit ownership. Reports with missing domains, duplicate
sources or zero instrumented lines are rejected before threshold comparison.
The current source map assigns 232 files to 15 exclusive owners without
changing the original eight domain baselines.
## Patterns and Algorithms
- Keep the policy in repository files (`Makefile`, coverage scripts, domain baseline config), and keep Jenkins as a thin caller.
- Use domain-scoped baselines as a quantitative gate, but keep mandatory scenarios as the governing behavioral rule.
- Publish operationally useful coverage output that emphasizes gate status first and only exposes deeper evidence on demand.
- Let Cargo discover unit/integration/cross-layer suites in their existing
targets. Their execution contributes coverage to every implementation owner
they exercise; the physical test-file directory is not the ownership map.
- Measure new starting baselines from fresh coverage and preserve existing
ones. Keep precision/bit-level oracles complementary to line coverage.
## Pitfalls
- Treating a global coverage increase as proof that a touched domain is adequately tested.
- Encoding gate math directly in Jenkins and forcing future policy changes to update multiple authorities.
- Letting verbose evidence output bury the actual pass/fail signal in CI logs.
- Allowing an absent or zero-line report to pass a zero baseline.
- Assigning the whole VM to the system integration domain, or counting one
source in both a specialized owner and its enclosing residual crate owner.
- Treating local host measurements as evidence for unexecuted platforms.
## Published Extension and Evidence
The ownership extension derives from accepted DEC-0049 and its completed local
implementation PLN-0180. It preserves the domain-first governance of the
original completed discussion. The
[measured evidence](../../../docs/vm-arch/COVERAGE_DOMAINS_EVIDENCE.json)
records the actual host/configuration, source/report fingerprints and counts.
Local macOS/aarch64 make ci-domains passed 915 tests, with nine existing ignored
tests, formatting, Clippy and all 15 coverage gates. Eight policy regression
tests exercise real repository ownership and independent invalid evidence.
Mathematics and its portable MPFR-generated fixture now exercise vm/core;
bytecode has its own gate. The standalone MPFR qualification remains separate.
This evidence does not claim Linux or Intel Mac coverage execution.
## Takeaways
- Runtime-edge coverage is safer when CI enforces domain ownership instead of trusting a workspace aggregate.
- Scenario-first review and domain baselines complement each other; neither should replace the other.
- Coverage gates that live in repository helpers are easier to evolve, audit, and keep consistent than CI-local logic.
- Audit source ownership and evidence validity before comparing percentages.
A passing percentage is useful only when its denominator has a clear owner.
@@ -0,0 +1,144 @@
---
id: LSN-0062
ticket: gameplay-math-and-numeric-semantics
title: Portable Math Requires a Runtime-Owned Numeric Contract
created: 2026-10-09
tags: [game-readiness]
---
## Context
Gameplay code can be produced on one computer and executed by different hosts.
That portability depends on preserving numeric behavior in the runtime that
executes the cartridge. A frontend-only math implementation would make
different producers responsible for agreeing on details that affect game state.
This lesson derives from accepted decision DEC-0048, implemented through
PLN-0179. The published normative result is
[Gameplay Math and Numeric Semantics](../../../docs/specs/runtime/02d-gameplay-math-and-numeric-semantics.md).
The discussion lifecycle remains in the [index](../../index.ndjson).
The [qualification record](../../../docs/vm-arch/NUMERIC_QUALIFICATION.md)
contains executed evidence, configuration and remaining host comparisons.
## Key Decisions
### Own observable numeric behavior in the VM
**What:** Guest Float operations, conversions and math use the same binary64
software adapter. Runtime metadata owns exact signatures, argument names,
identities, constants, flags and fixed virtual costs. The intended frontend
projection uses math for integers and mathf for Float.
**Why:** Producers select an exact identity and emit a call; the runtime
determines the result. The frontend does not become a second numeric engine.
**Trade-offs:** Software execution costs CPU time. The measured direct-call
costs range from tens of nanoseconds for dot to microseconds for atan2 on the
available machine. Those measurements do not alter guest-visible cycle costs.
Frontend projection and integration remain a separate delivery.
### Separate reproducibility from mathematical accuracy
**What:** Result bits, faults and virtual cycles must agree exactly between
qualified runtime builds. The mathematical reference comparison separately
checks correct rounding or the prescribed strict error bound.
**Why:** Two results can both satisfy a mathematical error bound and still
drive different simulation branches. Approximation quality does not establish
reproducibility.
**Trade-offs:** Backend/dependency changes require a new qualification
baseline. Recognizing the unchanged vec2 v1 identities alone does not qualify
an older runtime for the revised operation sequence.
### Specify composite operations as sequences
**What:** dot rounds and checks two products and their sum separately.
length uses a scaled sequence of division, multiplication, addition and sqrt.
**Why:** Avoiding overflow by scaling improves useful input coverage, while
specifying every step prevents FMA, wider accumulators or library hypot from
silently changing observable bits or faults.
**Trade-offs:** A prescribed sequence need not equal the single correctly
rounded ideal composite function. Intermediate overflow remains observable,
even if a hypothetical wider calculation would cancel it.
## Patterns and Algorithms
Keep f64 as bit transport. SoftF64 delegates arithmetic/comparison to APFloat;
the adapter owns finite admission, signed-zero rules, domain/range faults and
explicit integer conversions. Integer-to-Float conversion rounds significand
bits with ties to even. Float-to-integer conversion truncates the exact
represented value before checking destination bounds.
Validate all declared carriers before all nonfinite parameters, then domain
and result range. Reject invalid Float constants and immediate instructions
at loading, including unreachable code. Native signature import and public
stack import prevent NaN/infinity from entering guest state.
Charge a known mathematical attempt once before validation or scratch
reservation. Failed attempts retain the same cost. Zero budget starts no
instruction; positive budget can admit a complete operation and overshoot.
Keep this independent of actual CPU latency and unchanged unrelated opcode
accounting.
Generate consumer catalogs from runtime descriptors and compare checked-in
exports to that source in tests. Publishing exact parameter order is especially
useful for atan2(y,x), explicit conversions and named-argument lowering.
Use an independent MPFR oracle with exact imports, directed intervals and
adaptive precision. Importing a decimal rendering can test the wrong input.
Binary64 exponent limits and gradual underflow matter as much as precision.
For composite sequences, round each reference step in the same binary64 model.
## Pitfalls
- Upstream round uses ties away from zero; matching a function name did not
make it compatible with the runtime's ties-to-even contract.
- Int64 MAX rounds to +2^63 as Float. Using that rounded value as an inclusive
cast bound would accept an out-of-range conversion; saturating casts would
hide the error.
- Signed zeros affect min/max, rounding, axes and vector results despite
comparing equal numerically.
- A remainder against approximate tau does not provide the required reduction
for every large finite angle.
- Taking abs after an upward-rounded negative subtraction can underestimate
an oracle error bound. Round positive endpoint distances upward instead.
- The existing payload-preservation tests used NaN bit patterns. Finite
subnormal patterns preserve their original bit-transport coverage, while
separate tests assert the new rejection contract.
- An x86_64 oracle process on the same Mac is not x86_64 runtime execution.
Cross-compilation and local debug/release equality also do not replace
empirical comparison between runtime architectures.
## Delivered Evidence and Handoffs
Local macOS/aarch64 dev/release qualification passed 380,946 MPFR cases per
profile with identical corpus bytes. The largest sampled strict error upper
bounds were approximately 0.733 ULP for sin, 0.699 for cos and 0.514 for atan2.
The checked-in 4,747-row fixture runs without MPFR. All 907 workspace tests
passed, with nine existing ignored tests; formatting and Clippy passed.
The 14 numeric contract tests passed in both debug and release.
Sampling plus source/upstream review supports this local baseline without
claiming an exhaustive proof over binary64.
Remaining host validation targets macOS/x86_64 and Linux/x86_64 headless.
Acceptance requires passing the same oracle/contract tests in debug/release
and matching the complete corpus bits, faults and cycles to the published
hash. These runs await available infrastructure; the local delivery did not
execute or certify them.
The frontend handoff is to consume the runtime catalogs, implement namespace
projection and exact overload selection, preserve ordered arguments and calls
with literal inputs, and use canonical constant bits. The published spec
contains consumer/emission examples. No frontend code or frontend integration
tests were implemented in this delivery.
## Takeaways
- Deterministic math is a runtime execution contract, including faults and cost.
- Mathematical accuracy and exact agreement between hosts need separate gates.
- Explicit composite sequences and conversion bounds prevent hidden changes.
- Keep local evidence useful and reproducible while naming unexecuted hosts
and consumer integration precisely.
@@ -171,3 +171,15 @@ Budget admission remains between instructions. Zero executes nothing. A positive
## Typed Callable Costs
Charge each admitted attempt once, including trap: MAKE_CLOSURE 8+C (declared capture-slot sum), CALL_CLOSURE 6, GET_CAPTURE 2+W (selected complete-group width), CALL_TRAIT 6. Direct CALL/RET retain 5/4. No extra callback budget, partial-instruction pause or GC-cycle redesign. Zero budget executes nothing; positive budget may admit an instruction that overshoots. Root-return GC does not grant cycles, advance frames or invoke guest cleanup.
## Mathematical intrinsic attempts
The [numeric contract](02d-gameplay-math-and-numeric-semantics.md) publishes
fixed total call costs: min/max/abs/conversions 2, clamp and rounding 4,
vec2.dot 10, sqrt 16, sin/cos 32, vec2.length 40, atan2 48.
Charge known mathematical attempts before checks and scratch reservations,
including failure, exactly once without an extra generic INTRINSIC cycle.
Zero budget begins no attempt; positive budget admits the complete operation
and retains the existing overshoot rule. Argument-producing bytecode costs
remain additional. Input/color and other intrinsic/opcode costs and accounting
remain unchanged. CPU timings never change guest-visible cycle weights.
@@ -129,3 +129,14 @@ Use a bounded worklist to fixed point, reprocessing widened states; decide state
Builtin IDs, exact slot carriers, nullable defaults and stored layouts are defined in [Program Registry and PBX v1](02c-program-registry-and-pbx-v1.md#values-storage-and-initialization). A fixed list of results does not imply a tuple object or boxing. Parameter names are optional signature metadata; frontend argument reordering must preserve source evaluation order.
## Finite Float and explicit math conversions
Float is binary64 with the VM-owned software semantics in
[Gameplay Math and Numeric Semantics](02d-gameplay-math-and-numeric-semantics.md).
NaN/infinity are rejected at image admission and native import, never stored
as guest numeric defaults. Preserve signed-zero bits and subnormals; numeric
equality treats both zeros equally. Numeric overflow faults by range.
Exact Registry/intrinsic carriers prohibit implicit conversion; math/mathf
supplies explicit conversions with truncation/range and ties-even rules.
Existing arithmetic opcode promotions do not relax typed boundaries.
@@ -194,6 +194,9 @@ Preserve typed reasons and available section/file offset, ID domain/record/membe
| TRAP_INVALID_HANDLE | 0x0000000F | Invalid index, dead slot, stale/invalid generation |
| TRAP_RESOURCE_LIMIT | 0x00000010 | Runtime quota/size overflow/recoverable allocation failure |
| TRAP_UNAVAILABLE | 0x00000011 | Known input query unavailable on the platform |
| TRAP_NUMERIC_DOMAIN | 0x00000012 | Invalid mathematical domain of finite arguments |
| TRAP_NUMERIC_RANGE | 0x00000013 | Finite result/destination outside representable range |
| TRAP_NON_FINITE | 0x00000014 | NaN/infinite input rejected before guest publication |
Keep TrapInfo(code,opcode,pc,message,optional span) and current trap interruption behavior; no guest-catchable exception system. Untyped null to Int32 is TRAP_TYPE, not null dereference. Invalid handles never become false/null and are validated before following them. Preserve existing stack/function/return/intrinsic error categories. No promise to recover process/allocator abort; use fallible new allocation paths rather than operational panics.
@@ -239,3 +242,16 @@ Nested records count fields, methods, parameters/results and implementation Func
Auxiliary state includes capacities of the VM operand stack, CallFrames, globals, handles/free lists, string ledgers and persistent GC structures. The VM owns one context directly; entry preparation allocates no heap execution object. Closure headers and capture payloads remain heap-owned. Call depth and per-frame cap coexist with aggregate session auxiliary cap. Constants are checked at load; runtime excess traps. Growth must not geometrically reserve beyond available quota. Cycle/frame budgets remain separate. Asset and host admission limits are outside these totals.
## Numeric admission
Float64 constant bits must be finite. Reject NaN/infinity using
LOAD_INVALID_FORMAT/NonFiniteValue with Constants section, file offset and
constant index. Reject nonfinite PushF64, even in unreachable declared code,
with LOAD_INVALID_CODE/NonFiniteValue and function/PC/offset context.
Decode/tag/truncation failures preserve structural categories. Unsupported
INTRINSIC identities are LOAD_INVALID_CODE/NativeId with function/PC and ID.
No envelope/version change is introduced. Native signature import validates
complete layouts before checking Float finitude and publishing guest slots.
See [numeric semantics](02d-gameplay-math-and-numeric-semantics.md) for fault
precedence, conversions, catalog metadata and producer examples.
@@ -0,0 +1,307 @@
# Gameplay Math and Numeric Semantics
Domain: VM numeric execution and mathematical intrinsics
Function: normative
Didactic companion: [Portable math requires a runtime-owned numeric contract](../../../discussion/lessons/DSC-0053-gameplay-math-and-numeric-semantics/LSN-0062-portable-math-requires-a-runtime-owned-numeric-contract.md).
## Ownership and reproducibility
The VM owns numeric semantics, implementations, exact intrinsic signatures,
constants and virtual cycle costs. With the same cartridge, numeric contract
and inputs, supported runtime builds MUST produce identical result bits,
faults and cycles. Mathematical error bounds measure deviation from the ideal
function; they are never a tolerance between hosts.
Float is finite IEEE 754 binary64. Its physical f64 carrier transports bits;
guest arithmetic MUST use the canonical software backend. ADD/SUB/MUL/DIV,
conversion to Float and sqrt round correctly to the nearest representable
value, ties to even. Preserve gradual underflow, subnormals and signed zeros.
Underflow to subnormal or signed zero is valid; finite overflow faults.
No fast-math, reassociation or implicit multiply-add fusion is allowed.
The reference uses fpmath exactly 0.1.1 with soft-float and the dependency
resolution in Cargo.lock. The VM adapter supplies the selected rounding,
domains, signed zeros, conversions and fault mapping. Private algorithm
temporaries are not guest instructions; published vector steps below are
canonical binary64 operations.
Existing integer wrapping and arithmetic-opcode promotions remain unchanged:
Int32/Int64 ADD/SUB/MUL/NEG wrap; MIN/-1 returns MIN; MIN%-1 returns zero.
Integer division truncates toward zero and remainder has the dividend sign:
-7/3=-2 and -7%3=-1. Integer division/modulo by zero faults.
Mixed Float opcode operands convert integers through the software conversion
before computing. This does not authorize coercion at Registry or intrinsic
boundaries. Numeric Float comparisons use software conversion/comparison;
+0 and -0 compare equal.
Native acceleration is optional and MUST preserve exact bits, faults and
cycles per operation/host. A runtime recognizing old vec2 IDs is not thereby
qualified for this numeric contract.
## Public surface and exact catalog
The intended consumer surface uses math for Int32/Int64 overloads and mathf
for Float functions. Names identify namespaces, not guest types or receivers.
A frontend resolves overloads at compile time to an exact identity.
Mixed intrinsic carriers require explicit conversion.
[INTRINSICS.csv](../../vm-arch/INTRINSICS.csv) is generated from runtime
metadata: ID, owner/name/version, ordered ABI layout, parameter names,
total call cost and determinism/guest-allocation flags.
[BUILTIN_CONSTANTS.csv](../../vm-arch/BUILTIN_CONSTANTS.csv) publishes constant
slots and Float bits. Consumers MUST use these artifacts rather than duplicate
ID/cost maps. Math functions are pure and allocate no guest objects; runtime
result/scratch reservations remain possible.
All scalar entries below have version 1. vec2.dot/length retain version 1
and existing IDs with the behavior and costs specified here.
| ID | Exact identity | Ordered signature | Call cycles |
| --- | --- | --- | ---: |
| 0x3000 | math.i32.min | (a:Int32,b:Int32)->Int32 | 2 |
| 0x3001 | math.i32.max | (a:Int32,b:Int32)->Int32 | 2 |
| 0x3002 | math.i32.clamp | (value:Int32,min:Int32,max:Int32)->Int32 | 4 |
| 0x3003 | math.i32.abs | (value:Int32)->Int32 | 2 |
| 0x3004 | math.i64.min | (a:Int64,b:Int64)->Int64 | 2 |
| 0x3005 | math.i64.max | (a:Int64,b:Int64)->Int64 | 2 |
| 0x3006 | math.i64.clamp | (value:Int64,min:Int64,max:Int64)->Int64 | 4 |
| 0x3007 | math.i64.abs | (value:Int64)->Int64 | 2 |
| 0x3008 | mathf.min | (a:Float,b:Float)->Float | 2 |
| 0x3009 | mathf.max | (a:Float,b:Float)->Float | 2 |
| 0x300A | mathf.clamp | (value:Float,min:Float,max:Float)->Float | 4 |
| 0x300B | mathf.abs | (value:Float)->Float | 2 |
| 0x300C | mathf.floor | (value:Float)->Float | 4 |
| 0x300D | mathf.ceil | (value:Float)->Float | 4 |
| 0x300E | mathf.trunc | (value:Float)->Float | 4 |
| 0x300F | mathf.round | (value:Float)->Float | 4 |
| 0x3010 | mathf.sqrt | (value:Float)->Float | 16 |
| 0x3011 | mathf.sin | (angle:Float)->Float | 32 |
| 0x3012 | mathf.cos | (angle:Float)->Float | 32 |
| 0x3013 | mathf.atan2 | (y:Float,x:Float)->Float | 48 |
| 0x3014 | math.i32.to_i64 | (value:Int32)->Int64 | 2 |
| 0x3015 | math.i64.to_i32 | (value:Int64)->Int32 | 2 |
| 0x3016 | math.i32.to_float | (value:Int32)->Float | 2 |
| 0x3017 | math.i64.to_float | (value:Int64)->Float | 2 |
| 0x3018 | mathf.to_i32 | (value:Float)->Int32 | 2 |
| 0x3019 | mathf.to_i64 | (value:Float)->Int64 | 2 |
| 0x1000 | vec2.dot | (ax:Float,ay:Float,bx:Float,by:Float)->Float | 10 |
| 0x1001 | vec2.length | (x:Float,y:Float)->Float | 40 |
There are no identity conversions. Public conversions follow the source
carrier: math.to_float(Int32/Int64), math.to_i64(Int32), math.to_i32(Int64),
mathf.to_i32(Float), mathf.to_i64(Float).
## Limits, rounding and conversions
min/max return the numerical limit. Equal nonzero inputs have identical bits.
Equal-sign zeros retain their sign; opposite zeros return -0 for min and +0
for max, in either argument order. Float abs clears the sign bit; integer
abs(MIN) faults NUMERIC_RANGE.
clamp validates all arguments, requires min<=max numerically, then evaluates
min(max(value,min),max) under these zero rules. Opposite zero limits are
numerically equal and valid. Invalid limits fault NUMERIC_DOMAIN; do not
silently swap or correct them.
floor, ceil, trunc and round return Float. For -2.7, the first three yield
-3, -2 and -2. round ties to even: 2.5->2, 3.5->4, -2.5->-2.
Preserve zero input signs; a nonzero input rounding to zero uses its sign.
Float-to-integer conversion checks finitude, truncates toward zero, then
checks the exact truncated value against [-2^31,2^31-1] or [-2^63,2^63-1].
MUST NOT saturate or use Float(Int64 MAX) as an inclusive upper bound.
Int64-to-Int32 requires range. Int32-to-Int64 is exact.
Integer-to-Float uses nearest/ties-to-even; Int64 precision can be lost.
Float -0 converts to integer zero.
| Expression | Result or fault |
| --- | --- |
| mathf.to_i32(3.9) / mathf.to_i32(-3.9) | 3 / -3 |
| mathf.to_i32(-2147483648.9) | Int32 MIN; the truncated value fits |
| mathf.to_i32(2147483648.0) | NUMERIC_RANGE |
| mathf.to_i64(-2^63 as Float) | Int64 MIN |
| mathf.to_i64(+2^63 as Float) | NUMERIC_RANGE |
| math.to_float(Int64 MAX) | Float bits 0x43E0000000000000, equal to +2^63 |
| Convert that Float back to Int64 | NUMERIC_RANGE |
| math.to_float(Int64 9007199254740993) | 9007199254740992, ties-to-even |
## Angles, constants and signed axes
Angles use radians. sin/cos accept every finite binary64 angle, including very
large arguments. Controlled argument reduction is part of the reference;
x%tau alone is insufficient. Functions act on the supplied binary64 value;
sin(pi) is not snapped to zero because binary64 pi approximates π.
| Constant | Binary64 bits |
| --- | --- |
| mathf.pi | 0x400921FB54442D18 |
| mathf.tau | 0x401921FB54442D18 |
| Internal pi/2 for atan2 axes | 0x3FF921FB54442D18 |
pi/tau load through existing constant instructions and their ordinary cost.
They are not intrinsic calls or host-computed literals.
sqrt(-0)=-0, abs(-0)=+0, sin(+/-0)=+/-0 and cos(+/-0)=1.
sqrt of a finite negative nonzero value faults NUMERIC_DOMAIN.
atan2 takes y first, x second. All four signed-zero combinations with
x=y=0 fault NUMERIC_DOMAIN. Other axes are fixed:
| Inputs | Result |
| --- | --- |
| atan2(+0,x>0) / atan2(-0,x>0) | +0 / -0 |
| atan2(+0,x<0) / atan2(-0,x<0) | +pi / -pi |
| atan2(y>0,+/-0) | +pi/2 |
| atan2(y<0,+/-0) | -pi/2 |
## Vector sequences
Validate every carrier and then every Float input before calculating.
dot executes p1=ax*bx, p2=ay*by, result=p1+p2. Every step rounds to binary64
and checks range. Intermediate overflow faults even if the ideal final
expression could cancel. No FMA or wider accumulator is allowed.
length executes this canonical scaled sequence:
ax = abs(x); ay = abs(y)
m = max(ax, ay); n = min(ax, ay)
if m == 0: return +0
r = n / m
q = r * r
s = 1 + q
t = sqrt(s)
return m * t
Each step rounds independently; underflow in r/q is permitted. Final overflow
faults NUMERIC_RANGE. This specifies a sequence, not one rounding of ideal
hypot. Both branches cost 40 cycles.
| Example | Result or fault |
| --- | --- |
| length(1e200,0) | 1e200 without squaring 1e200 |
| length(binary64 bits 0x0000000000000001,0) | bits 0x0000000000000001 |
| length(-0,-0) | +0 |
| length(MAX_FINITE,MAX_FINITE) | NUMERIC_RANGE |
| dot(MAX_FINITE,MAX_FINITE,2,-2) | NUMERIC_RANGE at the first multiplication |
| min(-0,+0) / max(-0,+0) | -0 / +0 |
| clamp(-0,+0,1) | +0 |
| clamp(0,2,1) / atan2(0,0) / abs(Int32 MIN) | NUMERIC_DOMAIN / NUMERIC_DOMAIN / NUMERIC_RANGE |
## Faults, admission and virtual cycles
| Fault | ID | Meaning |
| --- | --- | --- |
| TRAP_NUMERIC_DOMAIN | 0x00000012 | Finite arguments outside the mathematical domain |
| TRAP_NUMERIC_RANGE | 0x00000013 | Finite input whose result/destination cannot be represented |
| TRAP_NON_FINITE | 0x00000014 | NaN or infinite input |
| TRAP_DIV_ZERO | 0x0000000A | Numerical zero divisor, including either signed Float zero |
Use existing TrapInfo interruption and available PC/opcode/source span.
Messages identify operation and argument when applicable. Do not panic Rust,
coerce invalid inputs to zero or add guest-catchable exceptions.
Precedence is structure/height/types, all nonfinite inputs in parameter order,
domain/divisor zero, then range/result. NaN/0 faults NON_FINITE; 1/0 DIV_ZERO.
Native signature import checks all declared layouts before finitude and
refuses invalid values before publishing guest slots. Public native stack
import push returns VmFault::Trap(NON_FINITE) for a nonfinite Float and
VmFault::ResourceLimit for quota refusal. Current HostReturn producers do not
expose a Float result writer.
Loading checks declared instruction ranges, including unreachable code:
- Unknown/unsupported intrinsic: LOAD_INVALID_CODE/NativeId, function/PC and
referenced_id. Runtime TRAP_INVALID_INTRINSIC is a defensive invariant check;
an unknown identity has no mathematical attempt cost.
- NaN/infinite constant: LOAD_INVALID_FORMAT/NonFiniteValue with section,
file offset and constant index.
- NaN/infinite PushF64: LOAD_INVALID_CODE/NonFiniteValue with function/PC and
available offset context.
- Structural decoding/tag/truncation errors retain their categories and
precede classifying the corresponding numerical payload.
No PBX version/encoding change is introduced.
Known mathematical calls admitted by positive budget charge their full cost
once before validation, scratch reservations and execution, including
type/domain/range/nonfinite/resource failures. No generic extra INTRINSIC
cycle or refund. Zero budget does not begin or charge a call; positive budget
admits the complete call and can overshoot. Private steps add no guest costs.
Argument-producing instructions are charged separately. Unrelated
input/color intrinsic costs/accounting and arithmetic opcode costs/accounting
remain unchanged.
## Consumer examples and emission
These examples document the runtime contract for frontend implementers.
Frontend integration is pending: namespace/free-function projection is not
an already-delivered PBS parser/lowering feature. No Math guest type,
receiver, syscall or duplicate numeric backend is required.
| Typed source expression | Required identity/emission | Call cycles |
| --- | --- | ---: |
| math.min(a,b), both Int32 | Push a,b; INTRINSIC 0x3000 | 2 |
| math.clamp(value,min,max), all Int64 | Push value,min,max; INTRINSIC 0x3006 | 4 |
| math.to_float(counter), Int64 | Push counter; INTRINSIC 0x3017 | 2 |
| mathf.to_i32(position), Float | Push position; INTRINSIC 0x3018 | 2 |
| mathf.atan2(y,x), both Float | Push y,x in that order; INTRINSIC 0x3013 | 48 |
| mathf.sin(0.0), Float literal | Load +0; INTRINSIC 0x3011; preserve call | 32 |
| mathf.pi | Existing constant load, canonical bits; no intrinsic | ordinary load cost |
| math.min(a,b), Int32 and Int64 | Require explicit conversion; no exact mixed signature | no call until resolved |
For a Float literal position -3.9, explicit conversion can emit:
PUSH_F64 f64:0xC00F333333333333
INTRINSIC 0x3018
It returns Int32 -3. The constant load costs 2 and the call costs 2.
For direction (y=1,x=0), preserving argument order:
PUSH_F64 f64:0x3FF0000000000000
PUSH_F64 f64:0x0000000000000000
INTRINSIC 0x3013
It returns bits 0x3FF921FB54442D18; the two loads plus call cost 52.
pi can use PUSH_F64 f64:0x400921FB54442D18 or the constant pool.
Mathematical executable expressions MUST retain calls even with literal
arguments in the initial consumer contract. Future folding requires exact
result/fault/cycle equivalence, not host libm evaluation.
## Qualification and evidence
Fundamentals and sqrt require correct rounding; limits/rounding functions
require the exact semantic result. sin/cos/atan2 require absolute error
strictly below 1 ULP of the ideal result of exact binary64 inputs. For normal
ideal results, ULP=2^(floor(log2(abs(result)))-52); for subnormal/zero it is
2^-1074. Exact special cases also preserve documented bits/signs. Vector
accuracy follows the prescribed sequence.
Qualification uses independent MPFR with exact binary64 import, directed
bounds and adaptive precision. Emulate exponent limits and gradual underflow
for reference rounding. MPFR is tooling, never cartridge execution.
Combine critical/random/extreme fixtures with reference source/upstream
audits; sampling alone is not proof over all binary64. Record compiler,
target/profile/features, lockfile/backend revision and catalog snapshot.
Reference changes require requalification, without pinning the entire
workspace's stable toolchain.
Local evidence covers available macOS/aarch64 debug/release. Reproduce the
same portable corpus on macOS/x86_64 and Linux/x86_64 headless when execution
infrastructure becomes available; compare exact bits/faults/cycles in both
profiles. Cross-architecture runs remain pending. Cross-compilation is build
evidence only. Hardware acquisition, frontend integration and new
graphical/audio hosts are not prerequisites for local qualification.
Benchmark real execution separately; never interpret virtual costs as CPU
timings or relax numeric guarantees to improve performance.
Generate/check catalogs:
cargo run -p prometeu-vm --example export_numeric_catalog
cargo run -p prometeu-vm --example export_numeric_catalog -- constants
The independent harness is scripts/qualify-numeric.py and the bit probe is
the numeric_probe example. Portable fixed fixtures reside in
crates/console/prometeu-vm/tests/fixtures/numeric-conformance.tsv.
The versioned [local qualification record](../../vm-arch/NUMERIC_QUALIFICATION.md)
reports the executed configuration, source audit, observed precision and
timings, reproducible commands and pending host comparisons.
@@ -79,17 +79,19 @@ All performance is measured in **PROMETEU cycles**, not in milliseconds.
## 5 Floating Point Precision
To guarantee numerical consistency:
[Numeric execution](02d-gameplay-math-and-numeric-semantics.md) uses finite
binary64 software arithmetic, explicit rounding, signed zeros and subnormals.
Supported hosts MUST agree on result bits, numeric faults and virtual cycles.
The mathematical precision bound for trigonometry is not a tolerance between
hosts. Native acceleration requires exact equivalence to the reference.
- PROMETEU defines explicit mathematical operations
- avoids dependence on specific FPUs
- standardizes `number` behavior
This avoids:
- divergences between architectures
- unpredictable cumulative errors
- subtle differences between platforms
Qualification evidence identifies runtime build/revision, target, profile,
dependency resolution and catalog snapshot. The current independent numeric
delivery qualifies available macOS/aarch64 in debug/release.
Comparative macOS/x86_64 and Linux/x86_64 execution remains pending; recognizing
the same intrinsic IDs or successfully cross-compiling does not certify a
new host. Unavailable hardware does not weaken the contract or require a new
graphical/audio backend for mathematical qualification.
## 6 Cross-Platform Input
+1
View File
@@ -79,6 +79,7 @@ In the current state, no chapter under the active `docs/specs/runtime/` root is
| [`02a-vm-values-and-calling-convention.md`](02a-vm-values-and-calling-convention.md) | VM values and calling convention | normative |
| [`02b-vm-function-values-and-closures.md`](02b-vm-function-values-and-closures.md) | VM closures and function values | normative |
| [`02c-program-registry-and-pbx-v1.md`](02c-program-registry-and-pbx-v1.md) | Registry, typed storage, PBX v1 and quotas | normative |
| [02d-gameplay-math-and-numeric-semantics.md](02d-gameplay-math-and-numeric-semantics.md) | VM math, numeric faults, cycles and consumer examples | normative |
| [`03-memory-stack-heap-and-allocation.md`](03-memory-stack-heap-and-allocation.md) | VM memory model | normative |
| [`04-gfx-peripheral.md`](04-gfx-peripheral.md) | virtual hardware: graphics | normative |
| [`05-audio-peripheral.md`](05-audio-peripheral.md) | virtual hardware: audio | normative |
+17
View File
@@ -0,0 +1,17 @@
target,name,version,slot,carrier,bits_or_value
color,black,1,0,Int64,255
color,blue,1,0,Int64,65535
color,cyan,1,0,Int64,16777215
color,gray,1,0,Int64,2155905279
color,green,1,0,Int64,16711935
color,indigo,1,0,Int64,1258324735
color,magenta,1,0,Int64,4278255615
color,orange,1,0,Int64,4286578943
color,red,1,0,Int64,4278190335
color,transparent,1,0,Int64,0
color,white,1,0,Int64,4294967295
color,yellow,1,0,Int64,4294902015
mathf,pi,1,0,Float,0x400921FB54442D18
mathf,tau,1,0,Float,0x401921FB54442D18
vec2,zero,1,0,Float,0x0000000000000000
vec2,zero,1,1,Float,0x0000000000000000
1 target name version slot carrier bits_or_value
2 color black 1 0 Int64 255
3 color blue 1 0 Int64 65535
4 color cyan 1 0 Int64 16777215
5 color gray 1 0 Int64 2155905279
6 color green 1 0 Int64 16711935
7 color indigo 1 0 Int64 1258324735
8 color magenta 1 0 Int64 4278255615
9 color orange 1 0 Int64 4286578943
10 color red 1 0 Int64 4278190335
11 color transparent 1 0 Int64 0
12 color white 1 0 Int64 4294967295
13 color yellow 1 0 Int64 4294902015
14 mathf pi 1 0 Float 0x400921FB54442D18
15 mathf tau 1 0 Float 0x401921FB54442D18
16 vec2 zero 1 0 Float 0x0000000000000000
17 vec2 zero 1 1 Float 0x0000000000000000
+147
View File
@@ -0,0 +1,147 @@
# Coverage domains
Function: repository coverage ownership and CI operations.
Background lesson: [Domain gates must be owned by the repository](../../discussion/lessons/DSC-0002-runtime-edge-test-plan/LSN-0037-domain-gates-must-be-owned-by-the-repository.md).
Coverage domains assign crate source code to a responsible area. Unit,
integration and cross-layer tests keep their Cargo targets and contribute to
the domains containing the implementation they exercise. Test files do not
need to move into domain directories.
The authorities are
[runtime-edge-coverage-domains.json](../../files/config/runtime-edge-coverage-domains.json),
[the ownership auditor](../../scripts/audit-coverage-domains.py) and
[the evidence/gate helper](../../scripts/coverage-domain-evidence.sh).
The configuration retains its original runtime-edge filename and includes
the core workspace responsibilities as well.
## Ownership
Every Rust file under a repository crate src tree has exactly one owner.
Inclusive paths use repository-relative prefixes; optional exclude_paths
use the same semantics and win within their domain. A file without a domain
or with two domains fails the ownership audit. Sources with no executable
LLVM lines still need an owner.
| Domain | Source responsibility |
| --- | --- |
| system/os | OS facades, process and task services |
| system/runtime | System-side VM lifecycle, scheduling and render integration |
| system/fs | Runtime filesystem and memcard service |
| system/programs | Resident system programs |
| system/core | Remaining system sources, excluding the four specialized owners |
| asset/bank | Existing asset, cartridge and asset-driver prefixes |
| firmware | Firmware state and transitions |
| host-dependent | Desktop host |
| host/headless | Headless host and automation implementation |
| vm/core | VM execution, values, heap, verifier, admission, intrinsics and math |
| bytecode | PBX/Registry encodings, ISA, assembler, decoder and binary admission |
| hal/core | HAL contracts and helpers, excluding existing asset/bank ownership |
| drivers/core | Peripheral/render implementations, excluding the asset driver |
| tooling | CLI and dummy/stress PBX producers |
| dev/test-support | Shared test-program construction and development infrastructure source stubs |
Existing specialized paths and baselines retain their original values.
Residual domains use broad crate source prefixes with explicit exclusions,
so a new module inherits the appropriate owner. A new crate or conflicting
prefix must be assigned before the ownership audit can pass.
## How test suites contribute
VM unit/integration tests, including numeric_contract and the portable
MPFR-generated fixture, exercise vm/core. Bytecode round-trip and Registry
admission tests exercise bytecode; end-to-end loading can also exercise
vm/core. HAL/drivers suites contribute to their corresponding implementation
owners. Headless/CLI integration and development cross-layer suites can
contribute to several domains in one run.
Quality tests remain in prometeu-quality-checks/tests. They enforce the map
and drive the auditor/helper with independent source/report fixtures,
including omitted/overlapping owners, exclusions, absolute/relative filenames,
absent/empty evidence, invalid statistics and percentage regression.
The empty quality/layer library stubs inherit infrastructure ownership;
they do not create separate gates with zero executable lines.
Only crate src paths participate in this domain denominator; integration
test directories, examples, benches, external dependencies and standalone
Python oracle code are outside it. The LLVM instrumentation/report remains
the existing workspace all-features default-profile measurement. Unit tests
colocated in src retain the tool's existing reporting behavior.
The standalone MPFR precision/bit comparison remains complementary numeric
qualification. It is not replaced by line coverage and is not newly required
by make ci-domains. See [numeric qualification](NUMERIC_QUALIFICATION.md).
## Evidence and gate rules
Reports may use absolute or repository-relative source paths. The auditor
normalizes these names before assigning ownership; evidence display and
percentage checks consume its same domain statistics. This prevents path
aliases or separate matching implementations from disagreeing about totals.
The verbose file lists use normalized repository-relative names.
Each report source within scope must exist in the repository and appear once.
Every configured domain must have a positive aggregate instrumented-line
count. Missing reports, unknown sources, duplicate records, invalid counts
and empty domains fail validation. A zero baseline cannot make missing or
empty evidence pass.
The gate compares covered instrumented lines to total instrumented lines,
truncating the percentage downward to two decimals. A domain passes when
this percentage is at least baseline_percent. Counts for functions and
regions remain supporting evidence. Scenario/contract assertions continue
to govern behavior; a percentage does not replace them.
New domains start from a fresh measured baseline, using the same truncation.
Do not lower existing thresholds to hide a failing run. An intentional scope
or baseline revision requires explicit review with measured evidence.
## Commands and CI
List domains, inspect source ownership and validate coverage evidence:
make coverage-domain-list
python3 scripts/audit-coverage-domains.py
make coverage-domain-audit
python3 scripts/audit-coverage-domains.py --report target/llvm-cov/report.json --json
Produce a fresh report and run all gates:
make ci-domains
The existing Jenkins configuration invokes this repository target. Its
coverage-domain-gate step also performs the ownership/evidence audit.
GitHub's workspace-test step discovers the quality regression tests; it
does not separately produce a domain coverage report.
Inspect a domain:
make coverage-domain-evidence DOMAIN=vm/core
scripts/coverage-domain-evidence.sh --check --verbose hal/core
scripts/coverage-domain-evidence.sh --check-all
Dependencies are the existing Rust/LLVM coverage tooling, Bash, Git, jq and rg,
plus Python 3 for the standard-library ownership auditor.
## Published local baseline
The [measured evidence](COVERAGE_DOMAINS_EVIDENCE.json) records configuration,
source/report fingerprints, command/toolchain/host, line totals and gate
results for all 15 domains. The eight earlier domain definitions are
preserved. The seven additional baselines measured on macOS/aarch64 are:
| New domain | Baseline lines |
| --- | ---: |
| vm/core | 89.12% |
| bytecode | 93.23% |
| hal/core | 88.56% |
| drivers/core | 84.51% |
| system/core | 92.71% |
| tooling | 64.75% |
| dev/test-support | 85.96% |
These are observed starting baselines, not uniform target percentages.
Platform-specific compilation and host scenarios can change report totals.
Local evidence does not certify an unexecuted Linux or Intel Mac run; evaluate
those runs using the unchanged repository policy and investigate differences.
+739
View File
@@ -0,0 +1,739 @@
{
"date": "2026-10-09",
"host": "aarch64-apple-darwin",
"scope": "Local workspace coverage domain qualification",
"command": "CARGO_NET_OFFLINE=true make ci-domains",
"rustc": [
"rustc 1.98.1 (48a229cea 2026-09-01)",
"binary: rustc",
"commit-hash: 48a229ceaefd4985c50990b14116b6d856af0985",
"commit-date: 2026-09-01",
"host: aarch64-apple-darwin",
"release: 1.98.1",
"LLVM version: 22.1.8"
],
"cargo_llvm_cov": "cargo-llvm-cov 0.8.5",
"tests": {
"passed": 915,
"failed": 0,
"ignored": 9
},
"policy_tests": {
"passed": 8,
"failed": 0
},
"existing_domains_preserved": [
"system/os",
"system/runtime",
"system/fs",
"system/programs",
"asset/bank",
"firmware",
"host-dependent",
"host/headless"
],
"new_domains": [
"vm/core",
"bytecode",
"hal/core",
"drivers/core",
"system/core",
"tooling",
"dev/test-support"
],
"source_files_before_unmapped": 154,
"source_files_after_unmapped": 0,
"original_config_sha256": "e939bb8e77b42aa3c9862677a849a052a011e27e9394aa641be940e1c0c1a106",
"config_sha256": "209b90dc32148f2ef52a3bab72e8e9df8e3daae78d97f967b891340a0bcad184",
"llvm_report_sha256": "7ce4a8f0602e49d6b8a1d1eb265686f3d80849f91933b73d1943871bcb9953bb",
"ci_log_sha256": "6b0a876011e6c29827ca51465a1f51e392673d2318e44809166898b1f8edd36a",
"audit": {
"source_files": 232,
"domains": {
"system/os": {
"source_files": 19,
"report_files": 10,
"files": [
"crates/console/prometeu-system/src/os/facades/fs.rs",
"crates/console/prometeu-system/src/os/facades/lifecycle.rs",
"crates/console/prometeu-system/src/os/facades/sessions.rs",
"crates/console/prometeu-system/src/os/facades/vm.rs",
"crates/console/prometeu-system/src/os/facades/window.rs",
"crates/console/prometeu-system/src/os/system_os.rs",
"crates/console/prometeu-system/src/services/process/model.rs",
"crates/console/prometeu-system/src/services/process/process_manager.rs",
"crates/console/prometeu-system/src/services/task/model.rs",
"crates/console/prometeu-system/src/services/task/task_manager.rs"
],
"lines_count": 1459,
"lines_covered": 1200,
"functions": {
"count": 224,
"covered": 170
},
"regions": {
"count": 2631,
"covered": 2235
},
"baseline_percent": 77.24,
"line_percent": 82.24,
"gate_passed": true
},
"system/runtime": {
"source_files": 13,
"report_files": 11,
"files": [
"crates/console/prometeu-system/src/services/vm_runtime/dispatch.rs",
"crates/console/prometeu-system/src/services/vm_runtime/frame_scheduler.rs",
"crates/console/prometeu-system/src/services/vm_runtime/lifecycle.rs",
"crates/console/prometeu-system/src/services/vm_runtime/mod.rs",
"crates/console/prometeu-system/src/services/vm_runtime/render_manager.rs",
"crates/console/prometeu-system/src/services/vm_runtime/render_worker.rs",
"crates/console/prometeu-system/src/services/vm_runtime/render_worker_handoff.rs",
"crates/console/prometeu-system/src/services/vm_runtime/render_worker_test_harness.rs",
"crates/console/prometeu-system/src/services/vm_runtime/tests_asset_bank.rs",
"crates/console/prometeu-system/src/services/vm_runtime/tests_fs_memcard.rs",
"crates/console/prometeu-system/src/services/vm_runtime/tick.rs"
],
"lines_count": 3037,
"lines_covered": 2468,
"functions": {
"count": 238,
"covered": 215
},
"regions": {
"count": 5374,
"covered": 4216
},
"baseline_percent": 76.5,
"line_percent": 81.26,
"gate_passed": true
},
"system/fs": {
"source_files": 7,
"report_files": 4,
"files": [
"crates/console/prometeu-system/src/services/fs/fs_backend.rs",
"crates/console/prometeu-system/src/services/fs/fs_error.rs",
"crates/console/prometeu-system/src/services/fs/virtual_fs.rs",
"crates/console/prometeu-system/src/services/memcard.rs"
],
"lines_count": 497,
"lines_covered": 403,
"functions": {
"count": 67,
"covered": 53
},
"regions": {
"count": 896,
"covered": 759
},
"baseline_percent": 76.08,
"line_percent": 81.08,
"gate_passed": true
},
"system/programs": {
"source_files": 3,
"report_files": 1,
"files": [
"crates/console/prometeu-system/src/programs/prometeu_hub/prometeu_hub.rs"
],
"lines_count": 566,
"lines_covered": 555,
"functions": {
"count": 54,
"covered": 52
},
"regions": {
"count": 853,
"covered": 833
},
"baseline_percent": 93.05,
"line_percent": 98.05,
"gate_passed": true
},
"asset/bank": {
"source_files": 5,
"report_files": 4,
"files": [
"crates/console/prometeu-drivers/src/asset.rs",
"crates/console/prometeu-hal/src/asset.rs",
"crates/console/prometeu-hal/src/cartridge.rs",
"crates/console/prometeu-hal/src/cartridge_loader.rs"
],
"lines_count": 2877,
"lines_covered": 2640,
"functions": {
"count": 253,
"covered": 217
},
"regions": {
"count": 4730,
"covered": 4348
},
"baseline_percent": 86.76,
"line_percent": 91.76,
"gate_passed": true
},
"firmware": {
"source_files": 15,
"report_files": 10,
"files": [
"crates/console/prometeu-firmware/src/firmware/firmware.rs",
"crates/console/prometeu-firmware/src/firmware/firmware_step_crash_screen.rs",
"crates/console/prometeu-firmware/src/firmware/firmware_step_game_running.rs",
"crates/console/prometeu-firmware/src/firmware/firmware_step_hub_home.rs",
"crates/console/prometeu-firmware/src/firmware/firmware_step_launch_hub.rs",
"crates/console/prometeu-firmware/src/firmware/firmware_step_load_cartridge.rs",
"crates/console/prometeu-firmware/src/firmware/firmware_step_reset.rs",
"crates/console/prometeu-firmware/src/firmware/firmware_step_shell_running.rs",
"crates/console/prometeu-firmware/src/firmware/firmware_step_splash_screen.rs",
"crates/console/prometeu-firmware/src/firmware/resident_game_termination.rs"
],
"lines_count": 1568,
"lines_covered": 1384,
"functions": {
"count": 105,
"covered": 100
},
"regions": {
"count": 2904,
"covered": 2637
},
"baseline_percent": 83.2,
"line_percent": 88.26,
"gate_passed": true
},
"host-dependent": {
"source_files": 11,
"report_files": 11,
"files": [
"crates/host/prometeu-host-desktop-winit/src/audio.rs",
"crates/host/prometeu-host-desktop-winit/src/cap.rs",
"crates/host/prometeu-host-desktop-winit/src/debugger.rs",
"crates/host/prometeu-host-desktop-winit/src/fs_backend.rs",
"crates/host/prometeu-host-desktop-winit/src/input.rs",
"crates/host/prometeu-host-desktop-winit/src/lib.rs",
"crates/host/prometeu-host-desktop-winit/src/log_sink.rs",
"crates/host/prometeu-host-desktop-winit/src/main.rs",
"crates/host/prometeu-host-desktop-winit/src/runner.rs",
"crates/host/prometeu-host-desktop-winit/src/stats.rs",
"crates/host/prometeu-host-desktop-winit/src/utilities.rs"
],
"lines_count": 1729,
"lines_covered": 779,
"functions": {
"count": 144,
"covered": 77
},
"regions": {
"count": 2678,
"covered": 1172
},
"baseline_percent": 40.05,
"line_percent": 45.05,
"gate_passed": true
},
"host/headless": {
"source_files": 5,
"report_files": 3,
"files": [
"crates/host/prometeu-host-headless/src/automation/mod.rs",
"crates/host/prometeu-host-headless/src/automation/wire.rs",
"crates/host/prometeu-host-headless/src/host.rs"
],
"lines_count": 784,
"lines_covered": 693,
"functions": {
"count": 84,
"covered": 62
},
"regions": {
"count": 1371,
"covered": 1191
},
"baseline_percent": 83.39,
"line_percent": 88.39,
"gate_passed": true
},
"vm/core": {
"source_files": 46,
"report_files": 32,
"files": [
"crates/console/prometeu-vm/src/builtins.rs",
"crates/console/prometeu-vm/src/catalog.rs",
"crates/console/prometeu-vm/src/heap.rs",
"crates/console/prometeu-vm/src/heap/dynamic_box.rs",
"crates/console/prometeu-vm/src/input_intrinsics.rs",
"crates/console/prometeu-vm/src/local_addressing.rs",
"crates/console/prometeu-vm/src/math_intrinsics.rs",
"crates/console/prometeu-vm/src/numeric.rs",
"crates/console/prometeu-vm/src/object.rs",
"crates/console/prometeu-vm/src/program_image.rs",
"crates/console/prometeu-vm/src/registry_verifier.rs",
"crates/console/prometeu-vm/src/registry_verifier/heights.rs",
"crates/console/prometeu-vm/src/registry_verifier/types.rs",
"crates/console/prometeu-vm/src/resource_budget.rs",
"crates/console/prometeu-vm/src/roots.rs",
"crates/console/prometeu-vm/src/string_ledger.rs",
"crates/console/prometeu-vm/src/typed_storage.rs",
"crates/console/prometeu-vm/src/typed_storage/allocation.rs",
"crates/console/prometeu-vm/src/value_contract.rs",
"crates/console/prometeu-vm/src/virtual_machine.rs",
"crates/console/prometeu-vm/src/virtual_machine/callable.rs",
"crates/console/prometeu-vm/src/virtual_machine/collections.rs",
"crates/console/prometeu-vm/src/virtual_machine/control.rs",
"crates/console/prometeu-vm/src/virtual_machine/dynamic.rs",
"crates/console/prometeu-vm/src/virtual_machine/gc.rs",
"crates/console/prometeu-vm/src/virtual_machine/loader.rs",
"crates/console/prometeu-vm/src/virtual_machine/reference.rs",
"crates/console/prometeu-vm/src/virtual_machine/runtime.rs",
"crates/console/prometeu-vm/src/virtual_machine/stack.rs",
"crates/console/prometeu-vm/src/virtual_machine/strings.rs",
"crates/console/prometeu-vm/src/virtual_machine/typed.rs",
"crates/console/prometeu-vm/src/vm_init_error.rs"
],
"lines_count": 8297,
"lines_covered": 7395,
"functions": {
"count": 786,
"covered": 637
},
"regions": {
"count": 15927,
"covered": 14054
},
"baseline_percent": 89.12,
"line_percent": 89.12,
"gate_passed": true
},
"bytecode": {
"source_files": 19,
"report_files": 14,
"files": [
"crates/console/prometeu-bytecode/src/assembler.rs",
"crates/console/prometeu-bytecode/src/decoder.rs",
"crates/console/prometeu-bytecode/src/disassembler.rs",
"crates/console/prometeu-bytecode/src/load_limits.rs",
"crates/console/prometeu-bytecode/src/opcode.rs",
"crates/console/prometeu-bytecode/src/opcode_spec.rs",
"crates/console/prometeu-bytecode/src/program_image.rs",
"crates/console/prometeu-bytecode/src/registry.rs",
"crates/console/prometeu-bytecode/src/registry_codec.rs",
"crates/console/prometeu-bytecode/src/registry_codec/payloads.rs",
"crates/console/prometeu-bytecode/src/registry_codec/writer.rs",
"crates/console/prometeu-bytecode/src/registry_instruction.rs",
"crates/console/prometeu-bytecode/src/resource_failure.rs",
"crates/console/prometeu-bytecode/src/value.rs"
],
"lines_count": 3252,
"lines_covered": 3032,
"functions": {
"count": 289,
"covered": 235
},
"regions": {
"count": 5720,
"covered": 4873
},
"baseline_percent": 93.23,
"line_percent": 93.23,
"gate_passed": true
},
"hal/core": {
"source_files": 55,
"report_files": 26,
"files": [
"crates/console/prometeu-hal/src/button.rs",
"crates/console/prometeu-hal/src/color.rs",
"crates/console/prometeu-hal/src/debugger_protocol.rs",
"crates/console/prometeu-hal/src/glyph_bank.rs",
"crates/console/prometeu-hal/src/host_context.rs",
"crates/console/prometeu-hal/src/host_return.rs",
"crates/console/prometeu-hal/src/log/log_service.rs",
"crates/console/prometeu-hal/src/native_helpers.rs",
"crates/console/prometeu-hal/src/owned_frame.rs",
"crates/console/prometeu-hal/src/platform.rs",
"crates/console/prometeu-hal/src/render_resources.rs",
"crates/console/prometeu-hal/src/render_submission.rs",
"crates/console/prometeu-hal/src/render_worker.rs",
"crates/console/prometeu-hal/src/sample.rs",
"crates/console/prometeu-hal/src/scene_bank.rs",
"crates/console/prometeu-hal/src/scene_layer.rs",
"crates/console/prometeu-hal/src/scene_viewport_cache.rs",
"crates/console/prometeu-hal/src/scene_viewport_resolver.rs",
"crates/console/prometeu-hal/src/sound_bank.rs",
"crates/console/prometeu-hal/src/syscalls.rs",
"crates/console/prometeu-hal/src/syscalls/domains/mod.rs",
"crates/console/prometeu-hal/src/syscalls/registry.rs",
"crates/console/prometeu-hal/src/syscalls/resolver.rs",
"crates/console/prometeu-hal/src/telemetry.rs",
"crates/console/prometeu-hal/src/tilemap.rs",
"crates/console/prometeu-hal/src/value_snapshot.rs"
],
"lines_count": 2326,
"lines_covered": 2060,
"functions": {
"count": 260,
"covered": 223
},
"regions": {
"count": 3297,
"covered": 3001
},
"baseline_percent": 88.56,
"line_percent": 88.56,
"gate_passed": true
},
"drivers/core": {
"source_files": 10,
"report_files": 9,
"files": [
"crates/console/prometeu-drivers/src/audio.rs",
"crates/console/prometeu-drivers/src/frame_composer.rs",
"crates/console/prometeu-drivers/src/gfx.rs",
"crates/console/prometeu-drivers/src/hardware.rs",
"crates/console/prometeu-drivers/src/local_render_backend.rs",
"crates/console/prometeu-drivers/src/memory_banks.rs",
"crates/console/prometeu-drivers/src/pad.rs",
"crates/console/prometeu-drivers/src/test_platform.rs",
"crates/console/prometeu-drivers/src/touch.rs"
],
"lines_count": 2738,
"lines_covered": 2314,
"functions": {
"count": 302,
"covered": 251
},
"regions": {
"count": 3982,
"covered": 3262
},
"baseline_percent": 84.51,
"line_percent": 84.51,
"gate_passed": true
},
"system/core": {
"source_files": 12,
"report_files": 7,
"files": [
"crates/console/prometeu-system/src/crash_report.rs",
"crates/console/prometeu-system/src/crash_report/init_diagnostic.rs",
"crates/console/prometeu-system/src/services/async_work.rs",
"crates/console/prometeu-system/src/services/foreground.rs",
"crates/console/prometeu-system/src/services/game_library.rs",
"crates/console/prometeu-system/src/services/vm_session.rs",
"crates/console/prometeu-system/src/services/windows/window_manager.rs"
],
"lines_count": 1290,
"lines_covered": 1196,
"functions": {
"count": 152,
"covered": 144
},
"regions": {
"count": 2072,
"covered": 1935
},
"baseline_percent": 92.71,
"line_percent": 92.71,
"gate_passed": true
},
"tooling": {
"source_files": 8,
"report_files": 8,
"files": [
"crates/tools/pbxgen-dummy-boy/src/lib.rs",
"crates/tools/pbxgen-dummy-boy/src/main.rs",
"crates/tools/pbxgen-stress/src/lib.rs",
"crates/tools/pbxgen-stress/src/main.rs",
"crates/tools/prometeu-cli/src/bin/prometeu-headless.rs",
"crates/tools/prometeu-cli/src/bin/prometeu-runtime.rs",
"crates/tools/prometeu-cli/src/lib.rs",
"crates/tools/prometeu-cli/src/main.rs"
],
"lines_count": 610,
"lines_covered": 395,
"functions": {
"count": 41,
"covered": 31
},
"regions": {
"count": 945,
"covered": 620
},
"baseline_percent": 64.75,
"line_percent": 64.75,
"gate_passed": true
},
"dev/test-support": {
"source_files": 4,
"report_files": 2,
"files": [
"crates/dev/prometeu-test-support/src/lib.rs",
"crates/dev/prometeu-test-support/src/program.rs"
],
"lines_count": 114,
"lines_covered": 98,
"functions": {
"count": 17,
"covered": 13
},
"regions": {
"count": 130,
"covered": 111
},
"baseline_percent": 85.96,
"line_percent": 85.96,
"gate_passed": true
}
}
},
"source_and_policy_sha256": {
"Cargo.lock": "9d2098de05ba9a1568c49f98eb144c317e62b2da57dcab4a76286d7c26d072cd",
"Cargo.toml": "ac6f69d0bd2ae0c50f0e6123239825eef12d92288625d1ce3eebf71a1d5e8e63",
"Makefile": "fa654f86f1d78f5c6e7916a50c1c82e15a76b28eee0c6ed41da8fa03fbd3db6b",
"crates/console/prometeu-bytecode/src/abi.rs": "b30f684ec084c8f3d971a388e64f1d187610230112aeb46409e2003054e8b455",
"crates/console/prometeu-bytecode/src/assembler.rs": "a687a32a7701602208a28b6e69c4179c54fdcea2d16c0c968d5cbd3a52481715",
"crates/console/prometeu-bytecode/src/decoder.rs": "032e9e7606b68c4d722518e7d4e97eac7fa5feecc78453a41ee8e2e14f8b87d9",
"crates/console/prometeu-bytecode/src/disassembler.rs": "07790f3d023fbe5a57efb2bde9a8a9d4c560b88f10a104c345b8f90bfba02f80",
"crates/console/prometeu-bytecode/src/isa/core.rs": "e5842ac00c1db20fa0e5504e2b10dd01ad86226884f08de50f87f1deefa7223a",
"crates/console/prometeu-bytecode/src/isa/mod.rs": "ed1bb37ae8a434bb93c0f84aef72c69520a147ad040935c3b416c64f73e7f19a",
"crates/console/prometeu-bytecode/src/lib.rs": "d8f58e994fc362fee151f31ecd00c34725a9d09c0699e35e54238844a58e5337",
"crates/console/prometeu-bytecode/src/load_limits.rs": "94a2977adcfb7c12004baeae1ec96525f84d1a7f44d54b973f5b825a76212689",
"crates/console/prometeu-bytecode/src/model.rs": "86884b5fbfa5a520fcea4af6397b210d117a2b0d8ad92d625e6e73c627fdd6e3",
"crates/console/prometeu-bytecode/src/opcode.rs": "eddaffc44562afe78545119e852e2ecc82010efb60a6ae6e39a6c2bc52a0c3da",
"crates/console/prometeu-bytecode/src/opcode_spec.rs": "124ac435f3aa2c428b130c963fb1692c785183fd3b63c1ae5186307a66b1b2b5",
"crates/console/prometeu-bytecode/src/program_image.rs": "ea752b0430963be3d53e41941116a686494dce78644c5a7119e25b6db1b813b2",
"crates/console/prometeu-bytecode/src/registry.rs": "dd727651c05e3d0d012443ed79d92360670d3978bac0a645938d4ae93af4a909",
"crates/console/prometeu-bytecode/src/registry_codec/payloads.rs": "457db2f3470e3c746698c2c73cd2d8387918a01daf64377832b2928fb4f05e1e",
"crates/console/prometeu-bytecode/src/registry_codec/writer.rs": "97a1f19dbc335e86c2d93ca6c5115b4845dc2a23fcf7ef16748a840d03e164b6",
"crates/console/prometeu-bytecode/src/registry_codec.rs": "c9dd8c9e6568b355ac1a172ed92c9bef4d61afb18a5dde95d016c028ad688bd2",
"crates/console/prometeu-bytecode/src/registry_instruction.rs": "48e2d1a25a30bdc4ef4842855fdd0fbc38525257375ba36f489485e88b611004",
"crates/console/prometeu-bytecode/src/resource_failure.rs": "64e63da70bb7be5b4472edbe3e8e66c8b856db6fc41dfa5f2571c3535325c07b",
"crates/console/prometeu-bytecode/src/value.rs": "374d4ea2d7e319cc48d2034553ad3b9866bfce2ff24b4fc0805fa8908f1db314",
"crates/console/prometeu-drivers/src/asset.rs": "fe4e39ef8baacfb25b68cdf8c4149018e90c0845a3e51130992d4f1c0f9fa41e",
"crates/console/prometeu-drivers/src/audio.rs": "abd2ddd615657e33cd15672660d6bdd413ec95b1d1d963d245341d6792ac3c87",
"crates/console/prometeu-drivers/src/frame_composer.rs": "e108a694bc72ea210bc6a668bdc070f88328456f5f90f550f8db88f0096a79d5",
"crates/console/prometeu-drivers/src/gfx.rs": "65f1b54538c69770c8dc03cdd7b066adf8b84c32a1acb91aeb74b6f1b172e922",
"crates/console/prometeu-drivers/src/hardware.rs": "c8861d0d34e82fcfe882b2dc1bc9248c75792a4b85db5a29d15c16344ed17ea0",
"crates/console/prometeu-drivers/src/lib.rs": "971483e396be6c84569f9af1c22a1bae65ec7cf0c994005e05071fa2b1695401",
"crates/console/prometeu-drivers/src/local_render_backend.rs": "2da9d6cf735140b0829363821db40b392c9edc15eefda1ad22a6cb21d3844025",
"crates/console/prometeu-drivers/src/memory_banks.rs": "19a1e6e07db298878018f3aec6ab94c36efda63911d935591a05022fc35d24e0",
"crates/console/prometeu-drivers/src/pad.rs": "615785f3e1f0e889ecc8e6c93607c49f825d1faea761116967a44eb624123950",
"crates/console/prometeu-drivers/src/test_platform.rs": "fb8fa94a438a1fdd4ef25d617bd90a3e5a1a015783185ec0f0bf63cda8f4e4a9",
"crates/console/prometeu-drivers/src/touch.rs": "9de22898effadbbc92bf5a086ab4f4abb2e72ee1b43ed660cd47d64eb5f8460e",
"crates/console/prometeu-firmware/src/firmware/boot_target.rs": "191177c4df78349c57657169a5a901f4e2b039338290302b878b22c8d311444f",
"crates/console/prometeu-firmware/src/firmware/firmware.rs": "fea46ba85b84a79218d1f59dad805d6cd2e2d4c77c9e9fa9e82c9b2716e41812",
"crates/console/prometeu-firmware/src/firmware/firmware_state.rs": "b29deaa2bec0cd8f0f6a776052f1d1d2891a8384811364974f129c55a45e0d3f",
"crates/console/prometeu-firmware/src/firmware/firmware_step_crash_screen.rs": "75ef55d546079df2847c77fe2625f0b99932c8e168f86a0ff0c3fed722495633",
"crates/console/prometeu-firmware/src/firmware/firmware_step_game_running.rs": "fbb42bd99067761b8dced815648299dcc86744463b9c270f04ec445a6552c999",
"crates/console/prometeu-firmware/src/firmware/firmware_step_hub_home.rs": "803356ba6302100eb0e86c4b2396885815f2e333df7396b58bb255d8dc6b5e9a",
"crates/console/prometeu-firmware/src/firmware/firmware_step_launch_hub.rs": "7d8f8ea67e955f175b1fe35ae876927ec606b3b3b5fadfb1209c7d1e81569a54",
"crates/console/prometeu-firmware/src/firmware/firmware_step_load_cartridge.rs": "1da67fb79047a7cd5ea0620e0dde487b2cc82b98fa576f5452d24e6c3d391320",
"crates/console/prometeu-firmware/src/firmware/firmware_step_reset.rs": "202751e9ee21faa27c433c11c2d76d60f3a3105bd92c1000f7b5c09c6c15d2d4",
"crates/console/prometeu-firmware/src/firmware/firmware_step_shell_running.rs": "14e458a34fe4298cbd9d55d7b72c1eda3cba3f7eb882384868be6490cb9a99a0",
"crates/console/prometeu-firmware/src/firmware/firmware_step_splash_screen.rs": "5ca03c2ce8058412130d5b122f74a3e6dc84bbf51c8f189bbba8f4b052530289",
"crates/console/prometeu-firmware/src/firmware/mod.rs": "ac3d54eda8bf688ce9af44a0e3f7a43c369577339a616c1647c2db82779821b1",
"crates/console/prometeu-firmware/src/firmware/prometeu_context.rs": "f8ea0f8864f8c218008906431515b322a794c77d497e4ef0c3551ebdfd8c8f11",
"crates/console/prometeu-firmware/src/firmware/resident_game_termination.rs": "efde0348f0ea4a5adc2a294eed9d3d5cb508b8b824f91767cfe774b673f247f3",
"crates/console/prometeu-firmware/src/lib.rs": "ad384b3d009c25eeb3da25c103c5494a892ca95cbaab67a69cc53e7d60eb4530",
"crates/console/prometeu-hal/src/app_mode.rs": "8e5c54c71622a379f0dd84f8ebdc0beba98dcda481102357a393faa0700c5094",
"crates/console/prometeu-hal/src/asset.rs": "637c0335c22d7f3bfc97b44f4e097f00955748989a0547a5ab216e844d7cc54c",
"crates/console/prometeu-hal/src/asset_bridge.rs": "beb86a087fb8ebdf914749dfd74b4aadd5c3a542fff62369a708823fab9e486e",
"crates/console/prometeu-hal/src/audio_bridge.rs": "561d4f362de164d06e957b50019741e972f135a78dc9d481d7ba13ae20406731",
"crates/console/prometeu-hal/src/button.rs": "2b3ea7c3156a69acfcc9d77b2e3adbfcbdf278d6b24c940c9bb8df9dc96e1eb3",
"crates/console/prometeu-hal/src/cartridge.rs": "d8712df2cea5fa5385ba9eccc95fb2aefae81b5fc4e406ea26b87ff82e5e9cba",
"crates/console/prometeu-hal/src/cartridge_loader.rs": "3ad5c2a8f38656ff025072b2888dee343b11a8bd056a4f7b01e16d814fbcbea5",
"crates/console/prometeu-hal/src/color.rs": "611838e24d02f24afdeb8825d8210d68c38d64758ea77d969c7711315a42cd71",
"crates/console/prometeu-hal/src/composer_status.rs": "ccbc57b5b10ab60d98e135256d0bed2e19af0f8e028864c5de865a9960cf502e",
"crates/console/prometeu-hal/src/debugger_protocol.rs": "249bf096352eceba5e0ed877cf9433a8dba459ca525339a84127d687d653a30d",
"crates/console/prometeu-hal/src/gfx_bridge.rs": "bcf476e77db3f6ef6ebdbc1377ff6af1168d9a129ab764ebaf25406f376e0d31",
"crates/console/prometeu-hal/src/glyph.rs": "ffc77b28a7b46e65d41f89fa1df11120e695423b4ec6ea6092bf7caf5cfac173",
"crates/console/prometeu-hal/src/glyph_bank.rs": "caca493e059f5d22324524131a10f14c07542208d3dee52ccefa354e92eb6fc4",
"crates/console/prometeu-hal/src/host_context.rs": "d934fe6577e58407b1051340e15905d7266c0ed46968037c5e60dc755e54784b",
"crates/console/prometeu-hal/src/host_return.rs": "31229656cc64afe5a56ae58c6240ce43650dbb1a282751aa3dedebd4eff08f1d",
"crates/console/prometeu-hal/src/input_signals.rs": "a95633de4da2c938c0744096b274ffd484b5d1dd0e5c62b4437822141f0c68e1",
"crates/console/prometeu-hal/src/lib.rs": "b6e75bfd9ebdb21db73715db74a5534ecbfb9356dd5443d2c81c2bfe3662cd37",
"crates/console/prometeu-hal/src/log/log_event.rs": "60b1dde0fb782af1bba929400d85907061deadda1b0be3380ae3c7a23f40afe8",
"crates/console/prometeu-hal/src/log/log_level.rs": "12aa77c7bab90ff5f36ca50e9489e3cd53220a271eec66d5bc9972f9e2c28e60",
"crates/console/prometeu-hal/src/log/log_service.rs": "edb9b55a757c577b3f78ef7d611f086cafb3d9bad9263b36bf5c6c0a7e1705f5",
"crates/console/prometeu-hal/src/log/log_source.rs": "74da3e4ed5fd259f29be8c71446098fc735c064ec66b93b25a9df84cd8b7649f",
"crates/console/prometeu-hal/src/log/mod.rs": "2a1001c517f9639c0c565f4355bc1b2bd9e1db793202b4bacefbb6f7f1c94baa",
"crates/console/prometeu-hal/src/native_helpers.rs": "67031964615a4628e9cf906872713093a074f315ef9c6587475af7f59f1b4552",
"crates/console/prometeu-hal/src/native_interface.rs": "ef0094ce650b1913a2b2cce69e80f09334db1cd750a4eaf6ccb571143e4d4ce3",
"crates/console/prometeu-hal/src/owned_frame.rs": "63822a6b81d5be90adf2f26c5cb241636681191e44acca97c7c6253af5146166",
"crates/console/prometeu-hal/src/pad_bridge.rs": "5cdc6a850a948640faa82895c8035711cc1e79e3aa22a84c2ee505caa9f138a3",
"crates/console/prometeu-hal/src/platform.rs": "a5217ac36c254b98f30df9c711dc21b88c6db428f83efbf2f47fd0e758433cce",
"crates/console/prometeu-hal/src/primitives.rs": "1a5151015d157b493fa50dfe735c4409442d93445e5afd3210671915c3bdc1f0",
"crates/console/prometeu-hal/src/render_resources.rs": "6e7d2754ef10474024e3b3384939b8fa7bdcf5830cd3cab43bffbc8e18aa6167",
"crates/console/prometeu-hal/src/render_submission.rs": "534198244dc4c17e1ba111e58e9a2abfe29965eab5e62fffd17c42d4f34b413e",
"crates/console/prometeu-hal/src/render_worker.rs": "7401400e9361777fe9edde41223f458ec1aff8b7e8e7997cd9dd74022494c96c",
"crates/console/prometeu-hal/src/sample.rs": "3857c2275057add3cc843b9b638d006dbe10dbf4023588f1c1d5c59501a8b98d",
"crates/console/prometeu-hal/src/scene_bank.rs": "6ba5e4e577389355f2c8678958d23b1c74d266404959966c777798c14dc59a55",
"crates/console/prometeu-hal/src/scene_layer.rs": "11cbd34788389d959c0d134251ce9c4b2c499a76228052886a149db5c95db504",
"crates/console/prometeu-hal/src/scene_viewport_cache.rs": "b233c337dc1c0ae09c86a9984fd832d4386ca0431b380a369c46d06ccefd6ed2",
"crates/console/prometeu-hal/src/scene_viewport_resolver.rs": "fedd661a45562cc2af3ad213b67ffd204260aa0df52cb4db58108e16fb9f2b0b",
"crates/console/prometeu-hal/src/sound_bank.rs": "43d7b2792c6bd0800dbca3f1b1245218a27e130882c683a9ee19b97ea6b0bf2a",
"crates/console/prometeu-hal/src/sprite.rs": "9d18df0698cc97431f48bbf5a06f223ab51bf1cd721da89a1126f2c8774b83cb",
"crates/console/prometeu-hal/src/syscalls/caps.rs": "e6ff7d4d07c4d532f083c018979fcf002c1c6e65bc30a1412bdc9b78a69c478c",
"crates/console/prometeu-hal/src/syscalls/domains/asset.rs": "6a6b81864c3c1d1916043b232f06e64403c57fec08a640c33749556a8227cd05",
"crates/console/prometeu-hal/src/syscalls/domains/audio.rs": "8c70b4ab89ab635d4267e04bb8c8082de486688c28e980b71bfc5992e5306468",
"crates/console/prometeu-hal/src/syscalls/domains/bank.rs": "582f3b6b7e22ccbb8748b6d11ccc5851ea4ee0a4ee8cf4dc0da10d6e822bd9be",
"crates/console/prometeu-hal/src/syscalls/domains/composer.rs": "11426bb7722700a8655e0b5a496be29662e1be955bc2910a9736dd53f75bab3e",
"crates/console/prometeu-hal/src/syscalls/domains/fs.rs": "6174fe93c421f324cdb51312c05168cc5456a2152ef890d2424d2bd5fcde34ca",
"crates/console/prometeu-hal/src/syscalls/domains/gfx.rs": "ec66207e27ff5d0d79dc81ab52101354190fe0a615bb3ac701d6936ddde5593a",
"crates/console/prometeu-hal/src/syscalls/domains/gfxui.rs": "4a14f4fb82c3d069875e94284e6a2f9a72ad4d86cf899766f9ccb8909bc142cd",
"crates/console/prometeu-hal/src/syscalls/domains/log.rs": "86132ce2391f537026d46f5a85685d451a0d9784d49796284f4c26af76a46687",
"crates/console/prometeu-hal/src/syscalls/domains/mod.rs": "7b0d7f61f632c887fc33b07ab937171a678c49be003aefc84370cda8181f9916",
"crates/console/prometeu-hal/src/syscalls/domains/system.rs": "5f16b5c88a8f8f0360bf200a2d0ecb6d19095c8b70abc7297433560f1945f8e6",
"crates/console/prometeu-hal/src/syscalls/registry.rs": "cd32b541d74ec12a889e8a364ee58f66f182161516600ed79023058d2a63d57f",
"crates/console/prometeu-hal/src/syscalls/resolver.rs": "7def4ef5a99b1ed6007681b3b5e26fb0fde49a485d129f694331c1faac2d4aa6",
"crates/console/prometeu-hal/src/syscalls/tests.rs": "a8fa13655cdb496e1ca4fa88503705e35ed2ba6ee949c2b91c486ceb6a8c4f47",
"crates/console/prometeu-hal/src/syscalls.rs": "b69c64ba04ed4c7b15dbccde75becd10bfb8083deb2d9f14ab319b2da71239fc",
"crates/console/prometeu-hal/src/telemetry.rs": "82ac174e468846ba434cacb88566b0339f86e7e5ca6b38e0451fd5621a369cfc",
"crates/console/prometeu-hal/src/tile.rs": "cd29513a645c79dc4ca1b4a736fe0c54478d189be74b9725e8ea716b632a62b5",
"crates/console/prometeu-hal/src/tilemap.rs": "f6f33923018c23df8e47da413f92f9bc7abbb3aeec57d4942b2acc3a00a07524",
"crates/console/prometeu-hal/src/touch_bridge.rs": "3557d33b137a7e8486ff3c57bf7b9e9c826ffc386397b6b07b039bf9a6c2b82a",
"crates/console/prometeu-hal/src/value_snapshot.rs": "5a618dccf98d14eaa92276191ade8cdf002a042cf3b545db93bbc1df62a21b88",
"crates/console/prometeu-hal/src/vm_fault.rs": "fa101ead0132cb8853237bf993a8a1df0d5b9c71a54d60fa1247369a3d846fbe",
"crates/console/prometeu-system/src/crash_report/init_diagnostic.rs": "5f1cfc093f121a7022e42d60bb6324e34291eb5eb36372401671adeae2eda9e0",
"crates/console/prometeu-system/src/crash_report.rs": "9bc79dd0e3730d1dafc2e729e53d5faf6cb3d351394bfce6e2b32f28b8bf9688",
"crates/console/prometeu-system/src/lib.rs": "b445617822a7d962818d8734d824139e03ad953a78d6d5b9c8415a2f6b5566c5",
"crates/console/prometeu-system/src/os/facades/fs.rs": "00131bfc31d8487c715818cd8cdd2201520a8f862620fc60a7925fa7d7ad75c8",
"crates/console/prometeu-system/src/os/facades/lifecycle.rs": "7b39b32f66fcedb64c2e01fb2fd58df3b79702302eadfc24b6b571ae7851558b",
"crates/console/prometeu-system/src/os/facades/mod.rs": "7a0bdd90a659bc949ec3190ba01bca537ca33aa2db2c7030fd40bf91eefc6fb7",
"crates/console/prometeu-system/src/os/facades/sessions.rs": "25ea3f0cba46c8ffe29dc55751e631f2422958eb30fba7f5f8920c67463df7dd",
"crates/console/prometeu-system/src/os/facades/vm.rs": "5b00eceaeac24f6c59da6904a1b46f19c7d400d771e2da7a632dc88929aea065",
"crates/console/prometeu-system/src/os/facades/window.rs": "e368709796e4c93cbf0c2b923c7a830b0fa81b4f69badbd661633e6f45d96d5a",
"crates/console/prometeu-system/src/os/lifecycle.rs": "038a9bc4401e1daf5b37a05d6e52f0733ab0e465dcb437e63639d7df0a4a5bdf",
"crates/console/prometeu-system/src/os/mod.rs": "e37196ffccf73b5220cf5f365f2d4166e9f14c862b32fd8bfeffbe97a987eea8",
"crates/console/prometeu-system/src/os/system_os.rs": "8c259a14a351e2c74f1a7999415feb2ead2bce8518254be809adc27e55e64afe",
"crates/console/prometeu-system/src/programs/mod.rs": "23c93b1f619f3a87fb06252f69770770eb50a7a22be7216742a2fc6aa281074f",
"crates/console/prometeu-system/src/programs/prometeu_hub/mod.rs": "ae66b3c22606462de491a89bac33425498d23f5111425945bdd480eda587f019",
"crates/console/prometeu-system/src/programs/prometeu_hub/prometeu_hub.rs": "28b33699a7eb8a624c9bde3559fc495ca0f68b5ff6b9557248187dd1ab029e5e",
"crates/console/prometeu-system/src/services/async_work.rs": "7875ae20f64a15868ed7b007b107a4b77d119eede6de2b08a6fcb7473d0dc1b5",
"crates/console/prometeu-system/src/services/foreground.rs": "c84b4cadd4cd039aff7d781bb8ead83c56a8f4311c2c9782f9c11fbf0f325b3c",
"crates/console/prometeu-system/src/services/fs/fs_backend.rs": "1349113b759be203b37dbb3ea1d64cb65357f998d76005aa99ba221a00f5319a",
"crates/console/prometeu-system/src/services/fs/fs_entry.rs": "ac00754669dec364696449b5ca760d69244b9462eba17d317224f7956c82ba20",
"crates/console/prometeu-system/src/services/fs/fs_error.rs": "e955a0bc039e6c073215d843cce44c9ffa6debc3b5107abd1130cd815b7a7513",
"crates/console/prometeu-system/src/services/fs/fs_state.rs": "5fff6bead650036b973f7985db55792e137d4739fad57dd4fd2ba169643ffa6f",
"crates/console/prometeu-system/src/services/fs/mod.rs": "d620eab605f91bd4862e99fac6a490fd2cdb70905a1ec6b439fb98b2eabb2193",
"crates/console/prometeu-system/src/services/fs/virtual_fs.rs": "08660e0eedd64d09c339628327e5d213a38a4d6f2ae2fc86fb0b6034fb3931cb",
"crates/console/prometeu-system/src/services/game_library.rs": "a3bc5aed24b92971f992aeb340e632b80226b9a7c9ae87077801649cc82ff81e",
"crates/console/prometeu-system/src/services/memcard.rs": "bc33f58bf67d6f7b1c39768ad26373ec92362272696fe38c4ecf5756f7c8b5b9",
"crates/console/prometeu-system/src/services/mod.rs": "bb7dc4da3aa2156f2bba871ac7965da224a317aa4f4f00d5cbee478011888eab",
"crates/console/prometeu-system/src/services/process/mod.rs": "d4773e3aebbbc7924d09a6eb6ac70ce86b2dad97a8f05bf959637a6c095dbff8",
"crates/console/prometeu-system/src/services/process/model.rs": "8892a601d817772010a36315cfa2743746523af13389621bfcc661efe96cd5de",
"crates/console/prometeu-system/src/services/process/process_kind.rs": "18a4fdd8481536c78d274949e5b930ddba77a7387070f041df6a9d7f09d63b2d",
"crates/console/prometeu-system/src/services/process/process_manager.rs": "99f4e44b88958c54bbe22a1d34fff91ad49ec669f6259dd6629ef973515cddfc",
"crates/console/prometeu-system/src/services/process/process_state.rs": "18a81d04422eee7fe1be014973d9d670ae24525603d5a16e078b37913026f0de",
"crates/console/prometeu-system/src/services/task/mod.rs": "d8985518d62fad30963de7aa3978ac49caee16f52093685ecdea680c587c78c0",
"crates/console/prometeu-system/src/services/task/model.rs": "fbf8bd6d0ddecc4a63a2cc9b6070a9b9f2f65ec5fafc5689b48ea1a93761dea0",
"crates/console/prometeu-system/src/services/task/task_kind.rs": "dec68edc5c59df946775e212aaa1e49e4c4d6d53bdcc8293da76bb6d77fdb12c",
"crates/console/prometeu-system/src/services/task/task_manager.rs": "635d25e215830096e15b10212df90a3acc196767e02a61e664e62b6fe02b23cf",
"crates/console/prometeu-system/src/services/task/task_state.rs": "818b15ab4ed46571c800ad299ba745204714ac34ed1dcb5a24c72aacecca4f47",
"crates/console/prometeu-system/src/services/vm_runtime/async_render_contract_tests.rs": "45a2393cc98fe015e2e048a1a0ffdd36d52be0172e1cb1fa2cbfd27b5a4d7480",
"crates/console/prometeu-system/src/services/vm_runtime/dispatch.rs": "52f81afd6fa72a0e124f5e73aba8794c6d9e516dd6b6a5a6fee466361a0cb8d8",
"crates/console/prometeu-system/src/services/vm_runtime/frame_scheduler.rs": "651a7ddd184323adf8325359b4de227137206bf00e218ca960bf6634a1a13fd1",
"crates/console/prometeu-system/src/services/vm_runtime/lifecycle.rs": "aaeb68069aeadae20a23637dd0c4a4423acf486e659ea10b191a5ef900dec989",
"crates/console/prometeu-system/src/services/vm_runtime/mod.rs": "63ef828f7b9e9859af86118b1d73753c2cd027277f853185031a62e7676b54b5",
"crates/console/prometeu-system/src/services/vm_runtime/render_manager.rs": "35070768f33d30cbc62be4a009253adcd6b633de068df04bf5eedc0557c3102f",
"crates/console/prometeu-system/src/services/vm_runtime/render_worker.rs": "041f56e178191112ebcbc5cf815f1e20060d71ea2e5171dbd01100650013c145",
"crates/console/prometeu-system/src/services/vm_runtime/render_worker_handoff.rs": "f08b515fc77a6e86132e4df251b0849dec46c1ba72d40b459e703f4d43fc3a1b",
"crates/console/prometeu-system/src/services/vm_runtime/render_worker_test_harness.rs": "74ccb283117632bd83bbb3fa70e5a73db8310a3070874e0e0b6caace65b150ea",
"crates/console/prometeu-system/src/services/vm_runtime/tests.rs": "1a43eeecfad8e6d4e5d1987d911ddcc003a15a88d40349c609577f66200e9186",
"crates/console/prometeu-system/src/services/vm_runtime/tests_asset_bank.rs": "3c833f5d929f4545cdf9a032dc6ffaad029f5dad8a5ef38deda7ab44cf9b7b2c",
"crates/console/prometeu-system/src/services/vm_runtime/tests_fs_memcard.rs": "26c7defd58ff2f6fcf396186bc560aa60c7b288c4e9e8435b7b20dc6d308f808",
"crates/console/prometeu-system/src/services/vm_runtime/tick.rs": "ba9f1d77a4b658a03c3bc1afe96ec1eb448d48cdef079ff33233bfd36d290fa9",
"crates/console/prometeu-system/src/services/vm_session.rs": "d2190c843518761bd40521c6a383af64e6d0f524754fd2fdeb68ae35f929db5a",
"crates/console/prometeu-system/src/services/windows/mod.rs": "5a6cf70f40b00db21396b0aa2c2324c9d47a7b6f4b6fe9bde4c778d487fe2cae",
"crates/console/prometeu-system/src/services/windows/window.rs": "62f78e5ef6e16752cb2b0afbe5dff64b648a77fbcc445c055a018516da0944e6",
"crates/console/prometeu-system/src/services/windows/window_manager.rs": "e52dcf29bfe5994a23461d16a65cdf92e71bcae985b6e81af90ebc1d355360f5",
"crates/console/prometeu-system/src/services/windows/window_owner.rs": "37a4e1999f4c1e639f90bd2bf5c20e99446e0b8c8d75a1055a11b97083e96a3c",
"crates/console/prometeu-vm/src/builtins.rs": "5d5b244ba9b62e4d304c84ab255a682a710b893ee3a0a88c2f1a417928c158df",
"crates/console/prometeu-vm/src/call_frame.rs": "e89e0a549529236358374697fecc2688db3f7ab84644e7cb0226ce80206d4e66",
"crates/console/prometeu-vm/src/catalog.rs": "547aebb0cc72712eb9bca5895d276ebaf5300edcc923a01fb8898090be30b272",
"crates/console/prometeu-vm/src/heap/dynamic_box.rs": "3dae99eba1ca5045fff733f38d80cd4297521d11d0fd1c58d2767e6c5c1286e9",
"crates/console/prometeu-vm/src/heap/dynamic_tests.rs": "bb7e8ed7f33d376e160b3aa7933a53e90d8d601dcde283323cb3e9aff9cf1106",
"crates/console/prometeu-vm/src/heap.rs": "470f0299eade1981a1c9b3543f54c77d2aa54ce539ada554062cfc10236d2a22",
"crates/console/prometeu-vm/src/input_intrinsics.rs": "9cfeaf5c63117adab2fbfa57033d09d5ccf806e865dc3c62726582209c4844ff",
"crates/console/prometeu-vm/src/lib.rs": "fbe80360b30161496ca899ff263d1353cfa86110cd359f003ad80a129885c498",
"crates/console/prometeu-vm/src/local_addressing.rs": "d74965bda1e26a5712257dfc498a3a5a262430464398561923ced9aed3e117c0",
"crates/console/prometeu-vm/src/math_intrinsics.rs": "d83d4cf9cf40d0155bd52a2d2ed5e4312be1a36a9c626cc348c027daf1393475",
"crates/console/prometeu-vm/src/numeric.rs": "9e1eaf35137a89160ae09fe11634645c242f97f332c946bebc0da9fd0b533146",
"crates/console/prometeu-vm/src/object.rs": "ec0deec90720f5cddf748f5c1bc921b8e09e6ccfc5f285891955581297c2efbf",
"crates/console/prometeu-vm/src/program_image/tests.rs": "2c7f6b50d611f995a97cd3993f779ac5c0ae014f9f4108413dde152a4f9bd3c3",
"crates/console/prometeu-vm/src/program_image.rs": "a6bcced8241557586eb7bf5c6922f4222590cc32563032427ae810fd400dd663",
"crates/console/prometeu-vm/src/registry_verifier/heights.rs": "789da044dc5b860027d302d927eb7a460ea1218d0167dffda8c097d9655910f6",
"crates/console/prometeu-vm/src/registry_verifier/tests.rs": "dde3a6a1d06c4402c93b154c4a050880a45363d0493b16af561261c03b0ba1b4",
"crates/console/prometeu-vm/src/registry_verifier/types/tests.rs": "48b5ac47156bbf24988ebc9b3ca8f59df76193231975de6cdb318a682ff68788",
"crates/console/prometeu-vm/src/registry_verifier/types.rs": "4263a498fc44218552d5595f0882772b0bd5bb87ca2da4012b624b5816341f07",
"crates/console/prometeu-vm/src/registry_verifier.rs": "985446f71017625266483be539514f8a74c61ffcf3a21e5676bd67620ae3575f",
"crates/console/prometeu-vm/src/resource_budget.rs": "bab06fb8384410d43f32f4f4d6162351b50fded755794ca69b58ac6d5c921efb",
"crates/console/prometeu-vm/src/roots.rs": "c5a26c3cf9c7655c6d3861c17412d1fa9c7738e16e18079224ad44c954660a2c",
"crates/console/prometeu-vm/src/string_ledger/tests.rs": "4c5b0d68a984f662a7aaec50f5c09075a08b991b182d2dbeb4302ef02baf4fda",
"crates/console/prometeu-vm/src/string_ledger.rs": "a16c944bb119aeb806f5765c450fa56b87c1c38568ed23c4cb0d9ee5f88f0770",
"crates/console/prometeu-vm/src/typed_storage/allocation.rs": "44db682ac5ca42f63552910e9c13ea1e8db1a3bcf1428fd0b9d0c6969bc985a1",
"crates/console/prometeu-vm/src/typed_storage/ownership_tests.rs": "c0b7c152984de0e8a150614e9d3d19ba89994ef0ed84be5345db1f890afeb8de",
"crates/console/prometeu-vm/src/typed_storage/tests.rs": "95d017485f4d62c1ad5196a0ae6dfdb816d673934e06dae5d328102121b21265",
"crates/console/prometeu-vm/src/typed_storage.rs": "81c7e5858fdcb49aab3d6e2be35eae60968951e5c5047a99c471998a30aa8aa8",
"crates/console/prometeu-vm/src/value_contract/reference_tests.rs": "070dc83827cab60e753bcf68d06932d15cfa13ef8f586ce7f7a080ea67e47120",
"crates/console/prometeu-vm/src/value_contract.rs": "134d0a9efca18351236dfbcb343fbeec058e4a6dae7eb8b94f369f0123d6f7da",
"crates/console/prometeu-vm/src/verifier.rs": "73afffa659f46e8f35532aae015769e7eedb4bdbfd1fc9897b42b217d92aa546",
"crates/console/prometeu-vm/src/virtual_machine/callable.rs": "0e6ada8736039157a4bc90a8a70a127f1c61a325fca1b67c3c40b9fb10db5da0",
"crates/console/prometeu-vm/src/virtual_machine/callable_tests.rs": "0dcbd0513dac25fb6577be089f97d84a2c07bcf68c17bf8b4da695d5800648f4",
"crates/console/prometeu-vm/src/virtual_machine/collections.rs": "d83f753801d5f8ac228de96aedb09a200d52937e5f9dd1cc92ddcfcd9e2b10db",
"crates/console/prometeu-vm/src/virtual_machine/collections_tests.rs": "c6e8a3d0a43894f28fab8f5c3705c6030bb11ddbf80761dca44af88f7d127c47",
"crates/console/prometeu-vm/src/virtual_machine/control.rs": "70a769ae28fb985b3db95e635f1f0281f2b162d5a0f2eca39708b5e023538dd6",
"crates/console/prometeu-vm/src/virtual_machine/dynamic.rs": "898cd1bf0d882704451fba240a95eb00fd2d12369436a802d93661d4ed7f960f",
"crates/console/prometeu-vm/src/virtual_machine/gc.rs": "5bb11a32bffa112ffa5ae9e8dbb9204a62db9fd6a9e4662141c1989e9aadbb76",
"crates/console/prometeu-vm/src/virtual_machine/loader.rs": "9f3b87d886562fef2b18625a96e9b1219587232dfd2dc39615ae854b5b91dd1c",
"crates/console/prometeu-vm/src/virtual_machine/reference.rs": "00da14fac117a307ebd030c846932e94acc503fe14b65c1a4613f82e7614718b",
"crates/console/prometeu-vm/src/virtual_machine/runtime.rs": "5547a6b0d7ab0f8c76837f4c281c8577e63d36fce667c90c256bee410b634a58",
"crates/console/prometeu-vm/src/virtual_machine/stack.rs": "778c641b4bb6dd883affaa8567a97effe7b737215654f6af3f928a4d3e05cb03",
"crates/console/prometeu-vm/src/virtual_machine/strings.rs": "82088a668f71089e2ef92c83023891b289881984642ad85a5f9c5f4c9f38e7e9",
"crates/console/prometeu-vm/src/virtual_machine/typed.rs": "06818c09e28c6d3b750fc592b22e3e943098f4448972f2eaab5c0d011d204572",
"crates/console/prometeu-vm/src/virtual_machine/typed_tests.rs": "84dc60e3c8fb25a60c0a22390195494077450ae2cb2172aa920afc2b63e16490",
"crates/console/prometeu-vm/src/virtual_machine.rs": "5a1c2c48871a06ad8bd0dbcd8942e0148f21bc170c6e9677bde70b4cc872f17f",
"crates/console/prometeu-vm/src/vm_init_error.rs": "4704ca4bafe3cd760ab1e8f44d6616f6b377d0a264b65f0c8f6142ea07eec24e",
"crates/dev/prometeu-layer-tests/src/lib.rs": "8d0b20885f32c47e432a459358b6e5c2ab081df7052ebd865c72b74aac19f2b2",
"crates/dev/prometeu-quality-checks/src/lib.rs": "c2ec5b217a7acab47bd6666b9660842231d338b9dec23fc3e38d63afc0075598",
"crates/dev/prometeu-quality-checks/tests/coverage_domains.rs": "81e9b46f5df7b523791c4e6677e3f1aab2d9ecaa5e3fcef9c6cfa1a70245a101",
"crates/dev/prometeu-test-support/src/lib.rs": "79bd4e72e8b7cbebba667ef52b14f227a625ee3f562615056a7229d8ea7c2277",
"crates/dev/prometeu-test-support/src/program.rs": "67677bfa1fa23a51d1cfc29d65b8bf27ecb3812fef51c1ffc1eaaf6bb653cc7f",
"crates/host/prometeu-host-desktop-winit/src/audio.rs": "ef6ab6c6f3b46a3b4f5ae5f6ea05517c4e6c17c23e3f78070c1680bd69dfa712",
"crates/host/prometeu-host-desktop-winit/src/cap.rs": "a4ef27744b7a0f420ac0a9c52ca5ba53dc154afd8db761e210c0575baeeb62f3",
"crates/host/prometeu-host-desktop-winit/src/debugger.rs": "594caf584f86ce97fe855b293a6ea2210e87f620d7bedfe6f5ada6f4a2dd74ab",
"crates/host/prometeu-host-desktop-winit/src/fs_backend.rs": "2c978b2033020681de877edbf32750f3d00ee994905068571e776d3b1254921c",
"crates/host/prometeu-host-desktop-winit/src/input.rs": "bc6bd3a9e5a68ade3380676ae4d9d901cd4dd3bf61ad4b9ee544be12e348956c",
"crates/host/prometeu-host-desktop-winit/src/lib.rs": "a64a3bd8898ad43cb3392055cf1b6db652c94cf1365fbedc43077a97848fd6fe",
"crates/host/prometeu-host-desktop-winit/src/log_sink.rs": "cc6de1c481aa6ad0e004a3d523ab800a9c8df54e3fa4e5d1b22baea077de1bac",
"crates/host/prometeu-host-desktop-winit/src/main.rs": "a10a4475fe3612f32adda03aef0d63a4165f612f7169cb6ef5b8a0afb933a62d",
"crates/host/prometeu-host-desktop-winit/src/runner.rs": "13723f97c39b394485ddc8a8027fd21bf1917cda0674ac924c19fbe845856c91",
"crates/host/prometeu-host-desktop-winit/src/stats.rs": "585970ac2f015b93568eb483d84e9b5c02aca9be9a36eb156205c61b478f8068",
"crates/host/prometeu-host-desktop-winit/src/utilities.rs": "0e46ba6144ea1d9cc3caf5094efbecf5a1a013dcc439b2133dfe47ec9bfbea02",
"crates/host/prometeu-host-headless/src/automation/mod.rs": "8abe9095b1ab4fd1acb2f651e942850f5ed68b717b8b7ae4ae7c87edc22b172f",
"crates/host/prometeu-host-headless/src/automation/wire/fault_tests.rs": "5c877c7a7129bc06803b2a13a0294d2d420c2c772a2cc4fee667af0900a4f879",
"crates/host/prometeu-host-headless/src/automation/wire.rs": "92e80142172b6f687aa95905d6fbe177b1076a4af1d051ace8b8657b28a0408f",
"crates/host/prometeu-host-headless/src/host.rs": "b3912d10e260e78775cab08e32a243fa219436c06071e92045b3abd7858b401a",
"crates/host/prometeu-host-headless/src/lib.rs": "00f5ce05dd9187df96ba22c0d45b9cd694cf0cbfe15e9d56790c6403032a53be",
"crates/tools/pbxgen-dummy-boy/src/lib.rs": "a5db703d805056ce9cd80ded5e2f94677bad8a1496a690e5f4dfdc2ffb10b8ed",
"crates/tools/pbxgen-dummy-boy/src/main.rs": "61cdcef9cf09c8f760b21ca3bbd14b4f7d8cc6440e357cdc911e24ca325cdc11",
"crates/tools/pbxgen-stress/src/lib.rs": "c10d822b780631dc85296d8affe85c1327cf1f79094d48166d251810de34a8c3",
"crates/tools/pbxgen-stress/src/main.rs": "da79e21f7e7ffad01ca1b4e0741196d66d08fa11953236cf7555ae08d264bfab",
"crates/tools/prometeu-cli/src/bin/prometeu-headless.rs": "dc9943719d7ca1c969310fc5f8bfb9bf8b7a0a5ecd0e9e7e245bc26604da7aa6",
"crates/tools/prometeu-cli/src/bin/prometeu-runtime.rs": "a10a4475fe3612f32adda03aef0d63a4165f612f7169cb6ef5b8a0afb933a62d",
"crates/tools/prometeu-cli/src/lib.rs": "d86e7ba2903a1bd464d38c7691f13908f54ad909b6ba5a238767dcf9ddc13230",
"crates/tools/prometeu-cli/src/main.rs": "42827a4599bd0fbc6ceb6d74cb3826e0f86ca2e855e6c1c6d39abc87903edf33",
"files/config/runtime-edge-coverage-domains.json": "209b90dc32148f2ef52a3bab72e8e9df8e3daae78d97f967b891340a0bcad184",
"scripts/audit-coverage-domains.py": "187ce1210a553eb042da8c0cdfbb65a4e9dee9a594e0ef35de1e086168349cda",
"scripts/coverage-domain-evidence.sh": "d32b4c033e6191658e3929ef6c6523fc8d176ab2b3f79db083181b6e43faa944"
},
"limitations": [
"Local macOS/aarch64 only; Linux/Intel host coverage was not executed",
"MPFR remains complementary numeric qualification, not part of the line-coverage gate",
"All crate src files have ownership; sources without executable lines need not appear in LLVM evidence"
],
"ci_domains_exit_code": 0
}
+102 -76
View File
@@ -1,76 +1,102 @@
final_id_hex,final_id_dec,canonical_name,canonical_version,owner,name,arg_slots,ret_slots,arg_layout,ret_layout,deterministic,may_allocate
0x1000,4096,vec2.dot,1,vec2,dot,4,1,Float|Float|Float|Float,Float,true,false
0x1001,4097,vec2.length,1,vec2,length,2,1,Float|Float,Float,true,false
0x1100,4352,color.from_raw,1,color,from_raw,1,1,Int64,builtin:color,true,false
0x1101,4353,color.rgb,1,color,rgb,3,1,Int64|Int64|Int64,builtin:color,true,false
0x1102,4354,color.rgba,1,color,rgba,4,1,Int64|Int64|Int64|Int64,builtin:color,true,false
0x1103,4355,color.html_rgba,1,color,html_rgba,1,1,String,builtin:color,true,false
0x1104,4356,color.gray_scale,1,color,gray_scale,1,1,Int64,builtin:color,true,false
0x1105,4357,color.hex,1,color,hex,1,1,builtin:color,Int64,true,false
0x1106,4358,color.alpha,1,color,alpha,1,1,builtin:color,Int64,true,false
0x1120,4384,color.black,1,color,black,0,1,,builtin:color,true,false
0x1121,4385,color.white,1,color,white,0,1,,builtin:color,true,false
0x1122,4386,color.red,1,color,red,0,1,,builtin:color,true,false
0x1123,4387,color.green,1,color,green,0,1,,builtin:color,true,false
0x1124,4388,color.blue,1,color,blue,0,1,,builtin:color,true,false
0x1125,4389,color.yellow,1,color,yellow,0,1,,builtin:color,true,false
0x1126,4390,color.orange,1,color,orange,0,1,,builtin:color,true,false
0x1127,4391,color.indigo,1,color,indigo,0,1,,builtin:color,true,false
0x1128,4392,color.gray,1,color,gray,0,1,,builtin:color,true,false
0x1129,4393,color.cyan,1,color,cyan,0,1,,builtin:color,true,false
0x112A,4394,color.magenta,1,color,magenta,0,1,,builtin:color,true,false
0x112B,4395,color.transparent,1,color,transparent,0,1,,builtin:color,true,false
0x2100,8448,input.pad.up.pressed,1,input.pad.up,pressed,0,1,,Bool,true,false
0x2101,8449,input.pad.up.released,1,input.pad.up,released,0,1,,Bool,true,false
0x2102,8450,input.pad.up.down,1,input.pad.up,down,0,1,,Bool,true,false
0x2103,8451,input.pad.up.hold,1,input.pad.up,hold,0,1,,Int64,true,false
0x2104,8452,input.pad.down.pressed,1,input.pad.down,pressed,0,1,,Bool,true,false
0x2105,8453,input.pad.down.released,1,input.pad.down,released,0,1,,Bool,true,false
0x2106,8454,input.pad.down.down,1,input.pad.down,down,0,1,,Bool,true,false
0x2107,8455,input.pad.down.hold,1,input.pad.down,hold,0,1,,Int64,true,false
0x2108,8456,input.pad.left.pressed,1,input.pad.left,pressed,0,1,,Bool,true,false
0x2109,8457,input.pad.left.released,1,input.pad.left,released,0,1,,Bool,true,false
0x210A,8458,input.pad.left.down,1,input.pad.left,down,0,1,,Bool,true,false
0x210B,8459,input.pad.left.hold,1,input.pad.left,hold,0,1,,Int64,true,false
0x210C,8460,input.pad.right.pressed,1,input.pad.right,pressed,0,1,,Bool,true,false
0x210D,8461,input.pad.right.released,1,input.pad.right,released,0,1,,Bool,true,false
0x210E,8462,input.pad.right.down,1,input.pad.right,down,0,1,,Bool,true,false
0x210F,8463,input.pad.right.hold,1,input.pad.right,hold,0,1,,Int64,true,false
0x2110,8464,input.pad.a.pressed,1,input.pad.a,pressed,0,1,,Bool,true,false
0x2111,8465,input.pad.a.released,1,input.pad.a,released,0,1,,Bool,true,false
0x2112,8466,input.pad.a.down,1,input.pad.a,down,0,1,,Bool,true,false
0x2113,8467,input.pad.a.hold,1,input.pad.a,hold,0,1,,Int64,true,false
0x2114,8468,input.pad.b.pressed,1,input.pad.b,pressed,0,1,,Bool,true,false
0x2115,8469,input.pad.b.released,1,input.pad.b,released,0,1,,Bool,true,false
0x2116,8470,input.pad.b.down,1,input.pad.b,down,0,1,,Bool,true,false
0x2117,8471,input.pad.b.hold,1,input.pad.b,hold,0,1,,Int64,true,false
0x2118,8472,input.pad.x.pressed,1,input.pad.x,pressed,0,1,,Bool,true,false
0x2119,8473,input.pad.x.released,1,input.pad.x,released,0,1,,Bool,true,false
0x211A,8474,input.pad.x.down,1,input.pad.x,down,0,1,,Bool,true,false
0x211B,8475,input.pad.x.hold,1,input.pad.x,hold,0,1,,Int64,true,false
0x211C,8476,input.pad.y.pressed,1,input.pad.y,pressed,0,1,,Bool,true,false
0x211D,8477,input.pad.y.released,1,input.pad.y,released,0,1,,Bool,true,false
0x211E,8478,input.pad.y.down,1,input.pad.y,down,0,1,,Bool,true,false
0x211F,8479,input.pad.y.hold,1,input.pad.y,hold,0,1,,Int64,true,false
0x2120,8480,input.pad.l.pressed,1,input.pad.l,pressed,0,1,,Bool,true,false
0x2121,8481,input.pad.l.released,1,input.pad.l,released,0,1,,Bool,true,false
0x2122,8482,input.pad.l.down,1,input.pad.l,down,0,1,,Bool,true,false
0x2123,8483,input.pad.l.hold,1,input.pad.l,hold,0,1,,Int64,true,false
0x2124,8484,input.pad.r.pressed,1,input.pad.r,pressed,0,1,,Bool,true,false
0x2125,8485,input.pad.r.released,1,input.pad.r,released,0,1,,Bool,true,false
0x2126,8486,input.pad.r.down,1,input.pad.r,down,0,1,,Bool,true,false
0x2127,8487,input.pad.r.hold,1,input.pad.r,hold,0,1,,Int64,true,false
0x2128,8488,input.pad.start.pressed,1,input.pad.start,pressed,0,1,,Bool,true,false
0x2129,8489,input.pad.start.released,1,input.pad.start,released,0,1,,Bool,true,false
0x212A,8490,input.pad.start.down,1,input.pad.start,down,0,1,,Bool,true,false
0x212B,8491,input.pad.start.hold,1,input.pad.start,hold,0,1,,Int64,true,false
0x212C,8492,input.pad.select.pressed,1,input.pad.select,pressed,0,1,,Bool,true,false
0x212D,8493,input.pad.select.released,1,input.pad.select,released,0,1,,Bool,true,false
0x212E,8494,input.pad.select.down,1,input.pad.select,down,0,1,,Bool,true,false
0x212F,8495,input.pad.select.hold,1,input.pad.select,hold,0,1,,Int64,true,false
0x2130,8496,input.touch.button.pressed,1,input.touch.button,pressed,0,1,,Bool,true,false
0x2131,8497,input.touch.button.released,1,input.touch.button,released,0,1,,Bool,true,false
0x2132,8498,input.touch.button.down,1,input.touch.button,down,0,1,,Bool,true,false
0x2133,8499,input.touch.button.hold,1,input.touch.button,hold,0,1,,Int64,true,false
0x2134,8500,input.touch.x,1,input.touch,x,0,1,,Int64,true,false
0x2135,8501,input.touch.y,1,input.touch,y,0,1,,Int64,true,false
final_id_hex,final_id_dec,canonical_name,canonical_version,owner,name,arg_slots,ret_slots,arg_layout,ret_layout,deterministic,may_allocate,parameter_names,cost_cycles
0x1000,4096,vec2.dot,1,vec2,dot,4,1,Float|Float|Float|Float,Float,true,false,ax|ay|bx|by,10
0x1001,4097,vec2.length,1,vec2,length,2,1,Float|Float,Float,true,false,x|y,40
0x1100,4352,color.from_raw,1,color,from_raw,1,1,Int64,builtin:color,true,false,raw,1
0x1101,4353,color.rgb,1,color,rgb,3,1,Int64|Int64|Int64,builtin:color,true,false,r|g|b,1
0x1102,4354,color.rgba,1,color,rgba,4,1,Int64|Int64|Int64|Int64,builtin:color,true,false,r|g|b|a,1
0x1103,4355,color.html_rgba,1,color,html_rgba,1,1,String,builtin:color,true,false,value,1
0x1104,4356,color.gray_scale,1,color,gray_scale,1,1,Int64,builtin:color,true,false,value,1
0x1105,4357,color.hex,1,color,hex,1,1,builtin:color,Int64,true,false,color,1
0x1106,4358,color.alpha,1,color,alpha,1,1,builtin:color,Int64,true,false,color,1
0x1120,4384,color.black,1,color,black,0,1,,builtin:color,true,false,,1
0x1121,4385,color.white,1,color,white,0,1,,builtin:color,true,false,,1
0x1122,4386,color.red,1,color,red,0,1,,builtin:color,true,false,,1
0x1123,4387,color.green,1,color,green,0,1,,builtin:color,true,false,,1
0x1124,4388,color.blue,1,color,blue,0,1,,builtin:color,true,false,,1
0x1125,4389,color.yellow,1,color,yellow,0,1,,builtin:color,true,false,,1
0x1126,4390,color.orange,1,color,orange,0,1,,builtin:color,true,false,,1
0x1127,4391,color.indigo,1,color,indigo,0,1,,builtin:color,true,false,,1
0x1128,4392,color.gray,1,color,gray,0,1,,builtin:color,true,false,,1
0x1129,4393,color.cyan,1,color,cyan,0,1,,builtin:color,true,false,,1
0x112A,4394,color.magenta,1,color,magenta,0,1,,builtin:color,true,false,,1
0x112B,4395,color.transparent,1,color,transparent,0,1,,builtin:color,true,false,,1
0x2100,8448,input.pad.up.pressed,1,input.pad.up,pressed,0,1,,Bool,true,false,,1
0x2101,8449,input.pad.up.released,1,input.pad.up,released,0,1,,Bool,true,false,,1
0x2102,8450,input.pad.up.down,1,input.pad.up,down,0,1,,Bool,true,false,,1
0x2103,8451,input.pad.up.hold,1,input.pad.up,hold,0,1,,Int64,true,false,,1
0x2104,8452,input.pad.down.pressed,1,input.pad.down,pressed,0,1,,Bool,true,false,,1
0x2105,8453,input.pad.down.released,1,input.pad.down,released,0,1,,Bool,true,false,,1
0x2106,8454,input.pad.down.down,1,input.pad.down,down,0,1,,Bool,true,false,,1
0x2107,8455,input.pad.down.hold,1,input.pad.down,hold,0,1,,Int64,true,false,,1
0x2108,8456,input.pad.left.pressed,1,input.pad.left,pressed,0,1,,Bool,true,false,,1
0x2109,8457,input.pad.left.released,1,input.pad.left,released,0,1,,Bool,true,false,,1
0x210A,8458,input.pad.left.down,1,input.pad.left,down,0,1,,Bool,true,false,,1
0x210B,8459,input.pad.left.hold,1,input.pad.left,hold,0,1,,Int64,true,false,,1
0x210C,8460,input.pad.right.pressed,1,input.pad.right,pressed,0,1,,Bool,true,false,,1
0x210D,8461,input.pad.right.released,1,input.pad.right,released,0,1,,Bool,true,false,,1
0x210E,8462,input.pad.right.down,1,input.pad.right,down,0,1,,Bool,true,false,,1
0x210F,8463,input.pad.right.hold,1,input.pad.right,hold,0,1,,Int64,true,false,,1
0x2110,8464,input.pad.a.pressed,1,input.pad.a,pressed,0,1,,Bool,true,false,,1
0x2111,8465,input.pad.a.released,1,input.pad.a,released,0,1,,Bool,true,false,,1
0x2112,8466,input.pad.a.down,1,input.pad.a,down,0,1,,Bool,true,false,,1
0x2113,8467,input.pad.a.hold,1,input.pad.a,hold,0,1,,Int64,true,false,,1
0x2114,8468,input.pad.b.pressed,1,input.pad.b,pressed,0,1,,Bool,true,false,,1
0x2115,8469,input.pad.b.released,1,input.pad.b,released,0,1,,Bool,true,false,,1
0x2116,8470,input.pad.b.down,1,input.pad.b,down,0,1,,Bool,true,false,,1
0x2117,8471,input.pad.b.hold,1,input.pad.b,hold,0,1,,Int64,true,false,,1
0x2118,8472,input.pad.x.pressed,1,input.pad.x,pressed,0,1,,Bool,true,false,,1
0x2119,8473,input.pad.x.released,1,input.pad.x,released,0,1,,Bool,true,false,,1
0x211A,8474,input.pad.x.down,1,input.pad.x,down,0,1,,Bool,true,false,,1
0x211B,8475,input.pad.x.hold,1,input.pad.x,hold,0,1,,Int64,true,false,,1
0x211C,8476,input.pad.y.pressed,1,input.pad.y,pressed,0,1,,Bool,true,false,,1
0x211D,8477,input.pad.y.released,1,input.pad.y,released,0,1,,Bool,true,false,,1
0x211E,8478,input.pad.y.down,1,input.pad.y,down,0,1,,Bool,true,false,,1
0x211F,8479,input.pad.y.hold,1,input.pad.y,hold,0,1,,Int64,true,false,,1
0x2120,8480,input.pad.l.pressed,1,input.pad.l,pressed,0,1,,Bool,true,false,,1
0x2121,8481,input.pad.l.released,1,input.pad.l,released,0,1,,Bool,true,false,,1
0x2122,8482,input.pad.l.down,1,input.pad.l,down,0,1,,Bool,true,false,,1
0x2123,8483,input.pad.l.hold,1,input.pad.l,hold,0,1,,Int64,true,false,,1
0x2124,8484,input.pad.r.pressed,1,input.pad.r,pressed,0,1,,Bool,true,false,,1
0x2125,8485,input.pad.r.released,1,input.pad.r,released,0,1,,Bool,true,false,,1
0x2126,8486,input.pad.r.down,1,input.pad.r,down,0,1,,Bool,true,false,,1
0x2127,8487,input.pad.r.hold,1,input.pad.r,hold,0,1,,Int64,true,false,,1
0x2128,8488,input.pad.start.pressed,1,input.pad.start,pressed,0,1,,Bool,true,false,,1
0x2129,8489,input.pad.start.released,1,input.pad.start,released,0,1,,Bool,true,false,,1
0x212A,8490,input.pad.start.down,1,input.pad.start,down,0,1,,Bool,true,false,,1
0x212B,8491,input.pad.start.hold,1,input.pad.start,hold,0,1,,Int64,true,false,,1
0x212C,8492,input.pad.select.pressed,1,input.pad.select,pressed,0,1,,Bool,true,false,,1
0x212D,8493,input.pad.select.released,1,input.pad.select,released,0,1,,Bool,true,false,,1
0x212E,8494,input.pad.select.down,1,input.pad.select,down,0,1,,Bool,true,false,,1
0x212F,8495,input.pad.select.hold,1,input.pad.select,hold,0,1,,Int64,true,false,,1
0x2130,8496,input.touch.button.pressed,1,input.touch.button,pressed,0,1,,Bool,true,false,,1
0x2131,8497,input.touch.button.released,1,input.touch.button,released,0,1,,Bool,true,false,,1
0x2132,8498,input.touch.button.down,1,input.touch.button,down,0,1,,Bool,true,false,,1
0x2133,8499,input.touch.button.hold,1,input.touch.button,hold,0,1,,Int64,true,false,,1
0x2134,8500,input.touch.x,1,input.touch,x,0,1,,Int64,true,false,,1
0x2135,8501,input.touch.y,1,input.touch,y,0,1,,Int64,true,false,,1
0x3000,12288,math.i32.min,1,math.i32,min,2,1,Int32|Int32,Int32,true,false,a|b,2
0x3001,12289,math.i32.max,1,math.i32,max,2,1,Int32|Int32,Int32,true,false,a|b,2
0x3002,12290,math.i32.clamp,1,math.i32,clamp,3,1,Int32|Int32|Int32,Int32,true,false,value|min|max,4
0x3003,12291,math.i32.abs,1,math.i32,abs,1,1,Int32,Int32,true,false,value,2
0x3004,12292,math.i64.min,1,math.i64,min,2,1,Int64|Int64,Int64,true,false,a|b,2
0x3005,12293,math.i64.max,1,math.i64,max,2,1,Int64|Int64,Int64,true,false,a|b,2
0x3006,12294,math.i64.clamp,1,math.i64,clamp,3,1,Int64|Int64|Int64,Int64,true,false,value|min|max,4
0x3007,12295,math.i64.abs,1,math.i64,abs,1,1,Int64,Int64,true,false,value,2
0x3008,12296,mathf.min,1,mathf,min,2,1,Float|Float,Float,true,false,a|b,2
0x3009,12297,mathf.max,1,mathf,max,2,1,Float|Float,Float,true,false,a|b,2
0x300A,12298,mathf.clamp,1,mathf,clamp,3,1,Float|Float|Float,Float,true,false,value|min|max,4
0x300B,12299,mathf.abs,1,mathf,abs,1,1,Float,Float,true,false,value,2
0x300C,12300,mathf.floor,1,mathf,floor,1,1,Float,Float,true,false,value,4
0x300D,12301,mathf.ceil,1,mathf,ceil,1,1,Float,Float,true,false,value,4
0x300E,12302,mathf.trunc,1,mathf,trunc,1,1,Float,Float,true,false,value,4
0x300F,12303,mathf.round,1,mathf,round,1,1,Float,Float,true,false,value,4
0x3010,12304,mathf.sqrt,1,mathf,sqrt,1,1,Float,Float,true,false,value,16
0x3011,12305,mathf.sin,1,mathf,sin,1,1,Float,Float,true,false,angle,32
0x3012,12306,mathf.cos,1,mathf,cos,1,1,Float,Float,true,false,angle,32
0x3013,12307,mathf.atan2,1,mathf,atan2,2,1,Float|Float,Float,true,false,y|x,48
0x3014,12308,math.i32.to_i64,1,math.i32,to_i64,1,1,Int32,Int64,true,false,value,2
0x3015,12309,math.i64.to_i32,1,math.i64,to_i32,1,1,Int64,Int32,true,false,value,2
0x3016,12310,math.i32.to_float,1,math.i32,to_float,1,1,Int32,Float,true,false,value,2
0x3017,12311,math.i64.to_float,1,math.i64,to_float,1,1,Int64,Float,true,false,value,2
0x3018,12312,mathf.to_i32,1,mathf,to_i32,1,1,Float,Int32,true,false,value,2
0x3019,12313,mathf.to_i64,1,mathf,to_i64,1,1,Float,Int64,true,false,value,2
1 final_id_hex final_id_dec canonical_name canonical_version owner name arg_slots ret_slots arg_layout ret_layout deterministic may_allocate parameter_names cost_cycles
2 0x1000 4096 vec2.dot 1 vec2 dot 4 1 Float|Float|Float|Float Float true false ax|ay|bx|by 10
3 0x1001 4097 vec2.length 1 vec2 length 2 1 Float|Float Float true false x|y 40
4 0x1100 4352 color.from_raw 1 color from_raw 1 1 Int64 builtin:color true false raw 1
5 0x1101 4353 color.rgb 1 color rgb 3 1 Int64|Int64|Int64 builtin:color true false r|g|b 1
6 0x1102 4354 color.rgba 1 color rgba 4 1 Int64|Int64|Int64|Int64 builtin:color true false r|g|b|a 1
7 0x1103 4355 color.html_rgba 1 color html_rgba 1 1 String builtin:color true false value 1
8 0x1104 4356 color.gray_scale 1 color gray_scale 1 1 Int64 builtin:color true false value 1
9 0x1105 4357 color.hex 1 color hex 1 1 builtin:color Int64 true false color 1
10 0x1106 4358 color.alpha 1 color alpha 1 1 builtin:color Int64 true false color 1
11 0x1120 4384 color.black 1 color black 0 1 builtin:color true false 1
12 0x1121 4385 color.white 1 color white 0 1 builtin:color true false 1
13 0x1122 4386 color.red 1 color red 0 1 builtin:color true false 1
14 0x1123 4387 color.green 1 color green 0 1 builtin:color true false 1
15 0x1124 4388 color.blue 1 color blue 0 1 builtin:color true false 1
16 0x1125 4389 color.yellow 1 color yellow 0 1 builtin:color true false 1
17 0x1126 4390 color.orange 1 color orange 0 1 builtin:color true false 1
18 0x1127 4391 color.indigo 1 color indigo 0 1 builtin:color true false 1
19 0x1128 4392 color.gray 1 color gray 0 1 builtin:color true false 1
20 0x1129 4393 color.cyan 1 color cyan 0 1 builtin:color true false 1
21 0x112A 4394 color.magenta 1 color magenta 0 1 builtin:color true false 1
22 0x112B 4395 color.transparent 1 color transparent 0 1 builtin:color true false 1
23 0x2100 8448 input.pad.up.pressed 1 input.pad.up pressed 0 1 Bool true false 1
24 0x2101 8449 input.pad.up.released 1 input.pad.up released 0 1 Bool true false 1
25 0x2102 8450 input.pad.up.down 1 input.pad.up down 0 1 Bool true false 1
26 0x2103 8451 input.pad.up.hold 1 input.pad.up hold 0 1 Int64 true false 1
27 0x2104 8452 input.pad.down.pressed 1 input.pad.down pressed 0 1 Bool true false 1
28 0x2105 8453 input.pad.down.released 1 input.pad.down released 0 1 Bool true false 1
29 0x2106 8454 input.pad.down.down 1 input.pad.down down 0 1 Bool true false 1
30 0x2107 8455 input.pad.down.hold 1 input.pad.down hold 0 1 Int64 true false 1
31 0x2108 8456 input.pad.left.pressed 1 input.pad.left pressed 0 1 Bool true false 1
32 0x2109 8457 input.pad.left.released 1 input.pad.left released 0 1 Bool true false 1
33 0x210A 8458 input.pad.left.down 1 input.pad.left down 0 1 Bool true false 1
34 0x210B 8459 input.pad.left.hold 1 input.pad.left hold 0 1 Int64 true false 1
35 0x210C 8460 input.pad.right.pressed 1 input.pad.right pressed 0 1 Bool true false 1
36 0x210D 8461 input.pad.right.released 1 input.pad.right released 0 1 Bool true false 1
37 0x210E 8462 input.pad.right.down 1 input.pad.right down 0 1 Bool true false 1
38 0x210F 8463 input.pad.right.hold 1 input.pad.right hold 0 1 Int64 true false 1
39 0x2110 8464 input.pad.a.pressed 1 input.pad.a pressed 0 1 Bool true false 1
40 0x2111 8465 input.pad.a.released 1 input.pad.a released 0 1 Bool true false 1
41 0x2112 8466 input.pad.a.down 1 input.pad.a down 0 1 Bool true false 1
42 0x2113 8467 input.pad.a.hold 1 input.pad.a hold 0 1 Int64 true false 1
43 0x2114 8468 input.pad.b.pressed 1 input.pad.b pressed 0 1 Bool true false 1
44 0x2115 8469 input.pad.b.released 1 input.pad.b released 0 1 Bool true false 1
45 0x2116 8470 input.pad.b.down 1 input.pad.b down 0 1 Bool true false 1
46 0x2117 8471 input.pad.b.hold 1 input.pad.b hold 0 1 Int64 true false 1
47 0x2118 8472 input.pad.x.pressed 1 input.pad.x pressed 0 1 Bool true false 1
48 0x2119 8473 input.pad.x.released 1 input.pad.x released 0 1 Bool true false 1
49 0x211A 8474 input.pad.x.down 1 input.pad.x down 0 1 Bool true false 1
50 0x211B 8475 input.pad.x.hold 1 input.pad.x hold 0 1 Int64 true false 1
51 0x211C 8476 input.pad.y.pressed 1 input.pad.y pressed 0 1 Bool true false 1
52 0x211D 8477 input.pad.y.released 1 input.pad.y released 0 1 Bool true false 1
53 0x211E 8478 input.pad.y.down 1 input.pad.y down 0 1 Bool true false 1
54 0x211F 8479 input.pad.y.hold 1 input.pad.y hold 0 1 Int64 true false 1
55 0x2120 8480 input.pad.l.pressed 1 input.pad.l pressed 0 1 Bool true false 1
56 0x2121 8481 input.pad.l.released 1 input.pad.l released 0 1 Bool true false 1
57 0x2122 8482 input.pad.l.down 1 input.pad.l down 0 1 Bool true false 1
58 0x2123 8483 input.pad.l.hold 1 input.pad.l hold 0 1 Int64 true false 1
59 0x2124 8484 input.pad.r.pressed 1 input.pad.r pressed 0 1 Bool true false 1
60 0x2125 8485 input.pad.r.released 1 input.pad.r released 0 1 Bool true false 1
61 0x2126 8486 input.pad.r.down 1 input.pad.r down 0 1 Bool true false 1
62 0x2127 8487 input.pad.r.hold 1 input.pad.r hold 0 1 Int64 true false 1
63 0x2128 8488 input.pad.start.pressed 1 input.pad.start pressed 0 1 Bool true false 1
64 0x2129 8489 input.pad.start.released 1 input.pad.start released 0 1 Bool true false 1
65 0x212A 8490 input.pad.start.down 1 input.pad.start down 0 1 Bool true false 1
66 0x212B 8491 input.pad.start.hold 1 input.pad.start hold 0 1 Int64 true false 1
67 0x212C 8492 input.pad.select.pressed 1 input.pad.select pressed 0 1 Bool true false 1
68 0x212D 8493 input.pad.select.released 1 input.pad.select released 0 1 Bool true false 1
69 0x212E 8494 input.pad.select.down 1 input.pad.select down 0 1 Bool true false 1
70 0x212F 8495 input.pad.select.hold 1 input.pad.select hold 0 1 Int64 true false 1
71 0x2130 8496 input.touch.button.pressed 1 input.touch.button pressed 0 1 Bool true false 1
72 0x2131 8497 input.touch.button.released 1 input.touch.button released 0 1 Bool true false 1
73 0x2132 8498 input.touch.button.down 1 input.touch.button down 0 1 Bool true false 1
74 0x2133 8499 input.touch.button.hold 1 input.touch.button hold 0 1 Int64 true false 1
75 0x2134 8500 input.touch.x 1 input.touch x 0 1 Int64 true false 1
76 0x2135 8501 input.touch.y 1 input.touch y 0 1 Int64 true false 1
77 0x3000 12288 math.i32.min 1 math.i32 min 2 1 Int32|Int32 Int32 true false a|b 2
78 0x3001 12289 math.i32.max 1 math.i32 max 2 1 Int32|Int32 Int32 true false a|b 2
79 0x3002 12290 math.i32.clamp 1 math.i32 clamp 3 1 Int32|Int32|Int32 Int32 true false value|min|max 4
80 0x3003 12291 math.i32.abs 1 math.i32 abs 1 1 Int32 Int32 true false value 2
81 0x3004 12292 math.i64.min 1 math.i64 min 2 1 Int64|Int64 Int64 true false a|b 2
82 0x3005 12293 math.i64.max 1 math.i64 max 2 1 Int64|Int64 Int64 true false a|b 2
83 0x3006 12294 math.i64.clamp 1 math.i64 clamp 3 1 Int64|Int64|Int64 Int64 true false value|min|max 4
84 0x3007 12295 math.i64.abs 1 math.i64 abs 1 1 Int64 Int64 true false value 2
85 0x3008 12296 mathf.min 1 mathf min 2 1 Float|Float Float true false a|b 2
86 0x3009 12297 mathf.max 1 mathf max 2 1 Float|Float Float true false a|b 2
87 0x300A 12298 mathf.clamp 1 mathf clamp 3 1 Float|Float|Float Float true false value|min|max 4
88 0x300B 12299 mathf.abs 1 mathf abs 1 1 Float Float true false value 2
89 0x300C 12300 mathf.floor 1 mathf floor 1 1 Float Float true false value 4
90 0x300D 12301 mathf.ceil 1 mathf ceil 1 1 Float Float true false value 4
91 0x300E 12302 mathf.trunc 1 mathf trunc 1 1 Float Float true false value 4
92 0x300F 12303 mathf.round 1 mathf round 1 1 Float Float true false value 4
93 0x3010 12304 mathf.sqrt 1 mathf sqrt 1 1 Float Float true false value 16
94 0x3011 12305 mathf.sin 1 mathf sin 1 1 Float Float true false angle 32
95 0x3012 12306 mathf.cos 1 mathf cos 1 1 Float Float true false angle 32
96 0x3013 12307 mathf.atan2 1 mathf atan2 2 1 Float|Float Float true false y|x 48
97 0x3014 12308 math.i32.to_i64 1 math.i32 to_i64 1 1 Int32 Int64 true false value 2
98 0x3015 12309 math.i64.to_i32 1 math.i64 to_i32 1 1 Int64 Int32 true false value 2
99 0x3016 12310 math.i32.to_float 1 math.i32 to_float 1 1 Int32 Float true false value 2
100 0x3017 12311 math.i64.to_float 1 math.i64 to_float 1 1 Int64 Float true false value 2
101 0x3018 12312 mathf.to_i32 1 mathf to_i32 1 1 Float Int32 true false value 2
102 0x3019 12313 mathf.to_i64 1 mathf to_i64 1 1 Float Int64 true false value 2
+13 -3
View File
@@ -98,12 +98,22 @@ Example:
- `canonical_name` is the fully qualified intrinsic identity seen by compiler-side intrinsic pools.
- `arg_slots` and `ret_slots` are the real stack effect contract for verifier/lowering consumers.
- `arg_layout` and `ret_layout` use `|`-separated ABI atoms:
- `int`
- `float`
- `bool`
- `Int32`
- `Int64`
- `Float`
- `Bool`
- `String`
- `builtin:<builtin_name>`
- Rows must remain unique by both `(canonical_name, canonical_version)` and `final_id_hex` / `final_id_dec`.
- Rows must remain deterministically ordered by final ID.
- parameter_names uses ordered | separated names for flattened argument slots.
- cost_cycles is the total call cost; mathematical attempts charge upfront
including failure, with no additional generic INTRINSIC cycle.
- Both [INTRINSICS.csv](INTRINSICS.csv) and
[BUILTIN_CONSTANTS.csv](BUILTIN_CONSTANTS.csv) are generated from runtime
descriptors. Float constants publish bits rather than decimal approximations.
- See [numeric semantics and consumer examples](../specs/runtime/02d-gameplay-math-and-numeric-semantics.md)
for math/mathf, scalar IDs 0x3000–0x3019, numeric traps and the revised vec2 v1 contract.
For exact immediates and stack effects, see `CoreOpCode::spec()` which is the single source of truth used by the decoder, disassembler, and verifier.
+261
View File
@@ -0,0 +1,261 @@
{
"date": "2026-10-09",
"scope": "Local software numeric qualification; no cross-host runtime certification",
"runtime_target": "aarch64-apple-darwin",
"runtime_profiles": [
"dev",
"release"
],
"rustc": [
"rustc 1.98.1 (48a229cea 2026-09-01)",
"binary: rustc",
"commit-hash: 48a229ceaefd4985c50990b14116b6d856af0985",
"commit-date: 2026-09-01",
"host: aarch64-apple-darwin",
"release: 1.98.1",
"LLVM version: 22.1.8"
],
"source_base_commit": "2e041266f1b0caa89ef5c0eaa52d863247079ba7",
"source_state": "Implementation in working tree; fingerprints below identify the qualified files",
"features": {
"fpmath": [
"default (empty)",
"soft-float"
],
"vm": "default; no native numeric acceleration"
},
"resolved_backends": [
{
"name": "fpmath",
"version": "0.1.1",
"source": "registry+https://github.com/rust-lang/crates.io-index",
"checksum": "f617488244e3bd5aa86da93efaf4072579a301832ca5a9c7e3493563b509a43d",
"dependencies": [
"rustc_apfloat"
]
},
{
"name": "rustc_apfloat",
"version": "0.2.3+llvm-462a31f5a5ab",
"source": "registry+https://github.com/rust-lang/crates.io-index",
"checksum": "486c2179b4796f65bfe2ee33679acf0927ac83ecf583ad6c91c3b4570911b9ad",
"dependencies": [
"bitflags 2.10.0",
"smallvec"
]
}
],
"debug": {
"rows": 380946,
"count": 10000,
"seed": 560053,
"corpus_sha256": "51f9361e79b2e648d557d38dad775250ed3c5d57f8ff5f187dc3ee7aab7ddfdb",
"max_error_ulp_upper_bound": {
"3010": 0,
"300c": 0,
"300d": 0,
"300e": 0,
"300f": 0,
"3018": 0,
"3019": 0,
"3011": 0.7327914722897216,
"3012": 0.698851370176746,
"1001": 0,
"1000": 0,
"3013": 0.5139939747008185,
"ADD": 0,
"SUB": 0,
"MUL": 0,
"DIV": 0,
"3017": 0,
"3016": 0
},
"max_mpfr_precision": 160,
"gmpy2": "2.3.0",
"mpfr": "MPFR 4.2.2",
"oracle_architecture": "x86_64",
"probe": "target/debug/examples/numeric_probe",
"cross_host_execution": "pending"
},
"release": {
"rows": 380946,
"count": 10000,
"seed": 560053,
"corpus_sha256": "51f9361e79b2e648d557d38dad775250ed3c5d57f8ff5f187dc3ee7aab7ddfdb",
"max_error_ulp_upper_bound": {
"3010": 0,
"300c": 0,
"300d": 0,
"300e": 0,
"300f": 0,
"3018": 0,
"3019": 0,
"3011": 0.7327914722897216,
"3012": 0.698851370176746,
"1001": 0,
"1000": 0,
"3013": 0.5139939747008185,
"ADD": 0,
"SUB": 0,
"MUL": 0,
"DIV": 0,
"3017": 0,
"3016": 0
},
"max_mpfr_precision": 160,
"gmpy2": "2.3.0",
"mpfr": "MPFR 4.2.2",
"oracle_architecture": "x86_64",
"probe": "target/release/examples/numeric_probe",
"cross_host_execution": "pending"
},
"fixed_corpus": {
"rows": 4747,
"count": 100,
"seed": 560053,
"corpus_sha256": "5536ee18cadaf32e3719b0e8d541dfcf1a84a49ea978a702101547c5ccdee3fe",
"max_error_ulp_upper_bound": {
"3010": 0,
"300c": 0,
"300d": 0,
"300e": 0,
"300f": 0,
"3018": 0,
"3019": 0,
"3011": 0.5183377814123403,
"3012": 0.5331116380110956,
"1001": 0,
"1000": 0,
"3013": 0.4968685838003477,
"ADD": 0,
"SUB": 0,
"MUL": 0,
"DIV": 0,
"3017": 0,
"3016": 0
},
"max_mpfr_precision": 160,
"gmpy2": "2.3.0",
"mpfr": "MPFR 4.2.2",
"oracle_architecture": "x86_64",
"probe": "target/debug/examples/numeric_probe",
"cross_host_execution": "pending"
},
"debug_release_exact_match": true,
"workspace_test_summary": {
"passed": 907,
"failed": 0,
"ignored": 9
},
"checks": {
"workspace_all_targets_all_features": "passed",
"cargo_fmt": "passed",
"workspace_all_features_clippy": "passed",
"numeric_contract_debug_and_release": "passed: 14 tests in each profile"
},
"fingerprints_sha256": {
"Cargo.lock": "9d2098de05ba9a1568c49f98eb144c317e62b2da57dcab4a76286d7c26d072cd",
"crates/console/prometeu-bytecode/src/abi.rs": "b30f684ec084c8f3d971a388e64f1d187610230112aeb46409e2003054e8b455",
"crates/console/prometeu-bytecode/src/assembler.rs": "a687a32a7701602208a28b6e69c4179c54fdcea2d16c0c968d5cbd3a52481715",
"crates/console/prometeu-bytecode/src/decoder.rs": "032e9e7606b68c4d722518e7d4e97eac7fa5feecc78453a41ee8e2e14f8b87d9",
"crates/console/prometeu-bytecode/src/disassembler.rs": "07790f3d023fbe5a57efb2bde9a8a9d4c560b88f10a104c345b8f90bfba02f80",
"crates/console/prometeu-bytecode/src/isa/core.rs": "e5842ac00c1db20fa0e5504e2b10dd01ad86226884f08de50f87f1deefa7223a",
"crates/console/prometeu-bytecode/src/isa/mod.rs": "ed1bb37ae8a434bb93c0f84aef72c69520a147ad040935c3b416c64f73e7f19a",
"crates/console/prometeu-bytecode/src/lib.rs": "d8f58e994fc362fee151f31ecd00c34725a9d09c0699e35e54238844a58e5337",
"crates/console/prometeu-bytecode/src/load_limits.rs": "94a2977adcfb7c12004baeae1ec96525f84d1a7f44d54b973f5b825a76212689",
"crates/console/prometeu-bytecode/src/model.rs": "86884b5fbfa5a520fcea4af6397b210d117a2b0d8ad92d625e6e73c627fdd6e3",
"crates/console/prometeu-bytecode/src/opcode.rs": "eddaffc44562afe78545119e852e2ecc82010efb60a6ae6e39a6c2bc52a0c3da",
"crates/console/prometeu-bytecode/src/opcode_spec.rs": "124ac435f3aa2c428b130c963fb1692c785183fd3b63c1ae5186307a66b1b2b5",
"crates/console/prometeu-bytecode/src/program_image.rs": "ea752b0430963be3d53e41941116a686494dce78644c5a7119e25b6db1b813b2",
"crates/console/prometeu-bytecode/src/registry.rs": "dd727651c05e3d0d012443ed79d92360670d3978bac0a645938d4ae93af4a909",
"crates/console/prometeu-bytecode/src/registry_codec/payloads.rs": "457db2f3470e3c746698c2c73cd2d8387918a01daf64377832b2928fb4f05e1e",
"crates/console/prometeu-bytecode/src/registry_codec/writer.rs": "97a1f19dbc335e86c2d93ca6c5115b4845dc2a23fcf7ef16748a840d03e164b6",
"crates/console/prometeu-bytecode/src/registry_codec.rs": "c9dd8c9e6568b355ac1a172ed92c9bef4d61afb18a5dde95d016c028ad688bd2",
"crates/console/prometeu-bytecode/src/registry_instruction.rs": "48e2d1a25a30bdc4ef4842855fdd0fbc38525257375ba36f489485e88b611004",
"crates/console/prometeu-bytecode/src/resource_failure.rs": "64e63da70bb7be5b4472edbe3e8e66c8b856db6fc41dfa5f2571c3535325c07b",
"crates/console/prometeu-bytecode/src/value.rs": "374d4ea2d7e319cc48d2034553ad3b9866bfce2ff24b4fc0805fa8908f1db314",
"crates/console/prometeu-vm/Cargo.toml": "a41ef0c4007855e5f2c9ba4a33d529dd2d2cd581e53652a67cc6b1902f76512b",
"crates/console/prometeu-vm/examples/export_numeric_catalog.rs": "e6a14b6e93072db573bf32bdcd0858e12180e9a72ceecadda88add97978d5e52",
"crates/console/prometeu-vm/examples/numeric_benchmark.rs": "688200b15be33123f26ee173467ae11c119313ff89c13d69e3bb5e0085f12646",
"crates/console/prometeu-vm/examples/numeric_probe.rs": "eee13ec9e223fc741ad9a3df4e6dc8c7685cb19be7dfabfb7bc3583278a4b744",
"crates/console/prometeu-vm/src/builtins.rs": "5d5b244ba9b62e4d304c84ab255a682a710b893ee3a0a88c2f1a417928c158df",
"crates/console/prometeu-vm/src/call_frame.rs": "e89e0a549529236358374697fecc2688db3f7ab84644e7cb0226ce80206d4e66",
"crates/console/prometeu-vm/src/catalog.rs": "547aebb0cc72712eb9bca5895d276ebaf5300edcc923a01fb8898090be30b272",
"crates/console/prometeu-vm/src/heap/dynamic_box.rs": "3dae99eba1ca5045fff733f38d80cd4297521d11d0fd1c58d2767e6c5c1286e9",
"crates/console/prometeu-vm/src/heap/dynamic_tests.rs": "bb7e8ed7f33d376e160b3aa7933a53e90d8d601dcde283323cb3e9aff9cf1106",
"crates/console/prometeu-vm/src/heap.rs": "470f0299eade1981a1c9b3543f54c77d2aa54ce539ada554062cfc10236d2a22",
"crates/console/prometeu-vm/src/input_intrinsics.rs": "9cfeaf5c63117adab2fbfa57033d09d5ccf806e865dc3c62726582209c4844ff",
"crates/console/prometeu-vm/src/lib.rs": "fbe80360b30161496ca899ff263d1353cfa86110cd359f003ad80a129885c498",
"crates/console/prometeu-vm/src/local_addressing.rs": "d74965bda1e26a5712257dfc498a3a5a262430464398561923ced9aed3e117c0",
"crates/console/prometeu-vm/src/math_intrinsics.rs": "d83d4cf9cf40d0155bd52a2d2ed5e4312be1a36a9c626cc348c027daf1393475",
"crates/console/prometeu-vm/src/numeric.rs": "9e1eaf35137a89160ae09fe11634645c242f97f332c946bebc0da9fd0b533146",
"crates/console/prometeu-vm/src/object.rs": "ec0deec90720f5cddf748f5c1bc921b8e09e6ccfc5f285891955581297c2efbf",
"crates/console/prometeu-vm/src/program_image/tests.rs": "2c7f6b50d611f995a97cd3993f779ac5c0ae014f9f4108413dde152a4f9bd3c3",
"crates/console/prometeu-vm/src/program_image.rs": "a6bcced8241557586eb7bf5c6922f4222590cc32563032427ae810fd400dd663",
"crates/console/prometeu-vm/src/registry_verifier/heights.rs": "789da044dc5b860027d302d927eb7a460ea1218d0167dffda8c097d9655910f6",
"crates/console/prometeu-vm/src/registry_verifier/tests.rs": "dde3a6a1d06c4402c93b154c4a050880a45363d0493b16af561261c03b0ba1b4",
"crates/console/prometeu-vm/src/registry_verifier/types/tests.rs": "48b5ac47156bbf24988ebc9b3ca8f59df76193231975de6cdb318a682ff68788",
"crates/console/prometeu-vm/src/registry_verifier/types.rs": "4263a498fc44218552d5595f0882772b0bd5bb87ca2da4012b624b5816341f07",
"crates/console/prometeu-vm/src/registry_verifier.rs": "985446f71017625266483be539514f8a74c61ffcf3a21e5676bd67620ae3575f",
"crates/console/prometeu-vm/src/resource_budget.rs": "bab06fb8384410d43f32f4f4d6162351b50fded755794ca69b58ac6d5c921efb",
"crates/console/prometeu-vm/src/roots.rs": "c5a26c3cf9c7655c6d3861c17412d1fa9c7738e16e18079224ad44c954660a2c",
"crates/console/prometeu-vm/src/string_ledger/tests.rs": "4c5b0d68a984f662a7aaec50f5c09075a08b991b182d2dbeb4302ef02baf4fda",
"crates/console/prometeu-vm/src/string_ledger.rs": "a16c944bb119aeb806f5765c450fa56b87c1c38568ed23c4cb0d9ee5f88f0770",
"crates/console/prometeu-vm/src/typed_storage/allocation.rs": "44db682ac5ca42f63552910e9c13ea1e8db1a3bcf1428fd0b9d0c6969bc985a1",
"crates/console/prometeu-vm/src/typed_storage/ownership_tests.rs": "c0b7c152984de0e8a150614e9d3d19ba89994ef0ed84be5345db1f890afeb8de",
"crates/console/prometeu-vm/src/typed_storage/tests.rs": "95d017485f4d62c1ad5196a0ae6dfdb816d673934e06dae5d328102121b21265",
"crates/console/prometeu-vm/src/typed_storage.rs": "81c7e5858fdcb49aab3d6e2be35eae60968951e5c5047a99c471998a30aa8aa8",
"crates/console/prometeu-vm/src/value_contract/reference_tests.rs": "070dc83827cab60e753bcf68d06932d15cfa13ef8f586ce7f7a080ea67e47120",
"crates/console/prometeu-vm/src/value_contract.rs": "134d0a9efca18351236dfbcb343fbeec058e4a6dae7eb8b94f369f0123d6f7da",
"crates/console/prometeu-vm/src/verifier.rs": "73afffa659f46e8f35532aae015769e7eedb4bdbfd1fc9897b42b217d92aa546",
"crates/console/prometeu-vm/src/virtual_machine/callable.rs": "0e6ada8736039157a4bc90a8a70a127f1c61a325fca1b67c3c40b9fb10db5da0",
"crates/console/prometeu-vm/src/virtual_machine/callable_tests.rs": "0dcbd0513dac25fb6577be089f97d84a2c07bcf68c17bf8b4da695d5800648f4",
"crates/console/prometeu-vm/src/virtual_machine/collections.rs": "d83f753801d5f8ac228de96aedb09a200d52937e5f9dd1cc92ddcfcd9e2b10db",
"crates/console/prometeu-vm/src/virtual_machine/collections_tests.rs": "c6e8a3d0a43894f28fab8f5c3705c6030bb11ddbf80761dca44af88f7d127c47",
"crates/console/prometeu-vm/src/virtual_machine/control.rs": "70a769ae28fb985b3db95e635f1f0281f2b162d5a0f2eca39708b5e023538dd6",
"crates/console/prometeu-vm/src/virtual_machine/dynamic.rs": "898cd1bf0d882704451fba240a95eb00fd2d12369436a802d93661d4ed7f960f",
"crates/console/prometeu-vm/src/virtual_machine/gc.rs": "5bb11a32bffa112ffa5ae9e8dbb9204a62db9fd6a9e4662141c1989e9aadbb76",
"crates/console/prometeu-vm/src/virtual_machine/loader.rs": "9f3b87d886562fef2b18625a96e9b1219587232dfd2dc39615ae854b5b91dd1c",
"crates/console/prometeu-vm/src/virtual_machine/reference.rs": "00da14fac117a307ebd030c846932e94acc503fe14b65c1a4613f82e7614718b",
"crates/console/prometeu-vm/src/virtual_machine/runtime.rs": "5547a6b0d7ab0f8c76837f4c281c8577e63d36fce667c90c256bee410b634a58",
"crates/console/prometeu-vm/src/virtual_machine/stack.rs": "778c641b4bb6dd883affaa8567a97effe7b737215654f6af3f928a4d3e05cb03",
"crates/console/prometeu-vm/src/virtual_machine/strings.rs": "82088a668f71089e2ef92c83023891b289881984642ad85a5f9c5f4c9f38e7e9",
"crates/console/prometeu-vm/src/virtual_machine/typed.rs": "06818c09e28c6d3b750fc592b22e3e943098f4448972f2eaab5c0d011d204572",
"crates/console/prometeu-vm/src/virtual_machine/typed_tests.rs": "84dc60e3c8fb25a60c0a22390195494077450ae2cb2172aa920afc2b63e16490",
"crates/console/prometeu-vm/src/virtual_machine.rs": "5a1c2c48871a06ad8bd0dbcd8942e0148f21bc170c6e9677bde70b4cc872f17f",
"crates/console/prometeu-vm/src/vm_init_error.rs": "4704ca4bafe3cd760ab1e8f44d6616f6b377d0a264b65f0c8f6142ea07eec24e",
"crates/console/prometeu-vm/tests/fixtures/numeric-conformance.tsv": "5536ee18cadaf32e3719b0e8d541dfcf1a84a49ea978a702101547c5ccdee3fe",
"crates/console/prometeu-vm/tests/numeric_contract.rs": "e200560e6244d39c0edfbf1a794acc89ccfd90312e855ecf78c761e8b9abd642",
"docs/vm-arch/BUILTIN_CONSTANTS.csv": "e407e4718127aa7ef7b1097b5b4b67d86dd979235e73a551a7c36b628cddc039",
"docs/vm-arch/INTRINSICS.csv": "cbf6ec24ab3d2c61bc5a3f5c857f394d4e84491a346003298fd9264ad2b97d8d",
"scripts/numeric-oracle-requirements.txt": "4526004fca0c84f3c74e59eaa4679a09e1ff516f3d0508a63c8451205ff28e02",
"scripts/qualify-numeric.py": "80e3aa2c27f282d8de7c8e251051781d46befac1204a199e58ff2ea3ba84b152"
},
"fpmath_audit_files_sha256": {
"src/lib.rs": "a5e4deee25937410c5db1b59d670a8879a53be7eb741cb4ac0b818bb41b09735",
"src/soft_f64.rs": "30da222738b4d068b23f6bad90248a59a094b79c13fca45f2a20e02f00a13a76",
"src/generic/sqrt.rs": "18afd36432b20e6e6fe69cf3c8d7589f2d9e85d8b6346693ba9256466678d118",
"src/generic/sin_cos.rs": "232424e5434a9861389c460d4845d3a59de23c05fcbd9747cd9d8515d6fd3e5e",
"src/generic/atan.rs": "ce5d10e6162a0db326ca8dde73158c11dbdbcb32f56a703c979874f019966863",
"src/generic/reduce_pi_2.rs": "722be389ab710f9acc59af227e1ef5d6d247be94616e09100500ef1b1e6d695a",
"src/generic/reduce_pi_2_large.rs": "16b70b51f32978ec235e383a099edb78bcbc4af63b9f4cf7ea22bd9044794944"
},
"benchmark": [
"mathf.sqrt iterations=20000 total_ns=2264125 ns_per_call=113.21 virtual_cycles=16",
"mathf.sin iterations=20000 total_ns=17068000 ns_per_call=853.40 virtual_cycles=32",
"mathf.cos iterations=20000 total_ns=18455750 ns_per_call=922.79 virtual_cycles=32",
"mathf.atan2 iterations=20000 total_ns=45482667 ns_per_call=2274.13 virtual_cycles=48",
"vec2.dot iterations=20000 total_ns=1036208 ns_per_call=51.81 virtual_cycles=10",
"vec2.length iterations=20000 total_ns=4970667 ns_per_call=248.53 virtual_cycles=40"
],
"cross_host_pending": [
"macOS/x86_64 debug and release",
"Linux/x86_64 headless debug and release"
],
"limitations": [
"Finite corpus is not an exhaustive proof over all binary64 inputs",
"Oracle x86_64 process does not count as x86_64 runtime execution",
"Scalar/vector probe cycles are catalog costs; interpreter attempt accounting is separately tested",
"Microbenchmark measures direct intrinsic implementations, not full VM throughput"
]
}
+142
View File
@@ -0,0 +1,142 @@
# Software numeric qualification
Date: 2026-10-09. Scope: local macOS/aarch64 qualification.
The normative contract is [Gameplay Math and Numeric Semantics](../specs/runtime/02d-gameplay-math-and-numeric-semantics.md).
The exact configuration, dependency checksums, source/catalog fingerprints,
oracle results and measured timings are in [NUMERIC_QUALIFICATION.json](NUMERIC_QUALIFICATION.json).
## Configuration and source audit
The runtime uses fpmath 0.1.1, feature soft-float, with rustc_apfloat
0.2.3+llvm-462a31f5a5ab resolved in Cargo.lock. Both dev and release probes
ran as aarch64-apple-darwin executables under rustc 1.98.1,
commit 48a229ceaefd4985c50990b14116b6d856af0985, LLVM 22.1.8.
No native numeric acceleration is enabled. Source fingerprints identify
the implementation independently of the pre-change repository commit.
The reviewed paths in the published fpmath source are:
| Path | Finding relevant to the runtime |
| --- | --- |
| src/soft_f64.rs | SoftF64 stores an APFloat Double. Bit import/export does not calculate with native f64. Basic operators delegate to APFloat; comparisons also use that representation. |
| rustc_apfloat src/lib.rs | The default ADD/SUB/MUL/DIV operator implementations select NearestTiesToEven explicitly. |
| src/generic/sqrt.rs | Normalizes subnormals, computes the integer root with an extra bit and constructs the rounded result bits. Zero signs are preserved. The documented upstream error bound is below half an ULP. |
| src/generic/sin_cos.rs; src/generic/reduce_pi_2.rs | Selects small, medium and large argument reduction. Medium reduction uses split constants and additional cancellation correction. |
| src/generic/reduce_pi_2_large.rs | Uses integer/fixed-point chunks and a stored 2/pi expansion derived from the musl/FreeBSD reduction algorithm, rather than a remainder against binary64 tau. |
| src/generic/atan.rs | Generic atan/atan2 calculations use the software scalar implementation. The runtime handles the zero vector and signed axes explicitly before delegation. |
The published [fpmath documentation](https://docs.rs/fpmath/0.1.1/fpmath/)
describes portable soft-float results and error bounds for these functions.
The [versioned source](https://docs.rs/crate/fpmath/0.1.1/source/)
is the audit reference. Upstream claims, source review and independent
testing support the selected reference; this record is not a formal proof
over every binary64 input.
The VM adapter supplies semantics that cannot be taken directly from every
upstream convenience function. In particular, upstream round uses ties away
from zero; runtime mathf.round implements ties to even from bits.
Integer conversions also use bits, avoiding saturation and the rounded
Float representation of Int64 MAX as a range bound. Every public numeric
path validates inputs and maps domains/range to the runtime fault contract.
Float arithmetic, mixed-carrier promotion and comparisons in guest opcodes
use this adapter. Host inspection utilities are outside guest arithmetic.
## Independent oracle and results
The tooling uses gmpy2 2.3.0 and MPFR 4.2.2. Binary64 inputs are imported
through exact rational representations, with explicit preservation of -0.
Directed MPFR bounds start at 160 bits and adapt up to 10,240 bits when
needed. Basic operations, sqrt and integer-to-Float conversions must match
the independently rounded binary64 result, including exponent limits and
gradual underflow. Rounding and Float-to-integer conversions are also checked
against exact integer/rational rules. Vector results match the prescribed
sequence with a binary64 MPFR context at each step.
For sin/cos/atan2 the gate certifies a strict upper error bound below 1 ULP
of the ideal result. Positive endpoint distances are rounded upward before
comparison; taking the absolute value of a negative subtraction rounded
upward would underestimate that bound.
Both profiles passed 380,946 cases with seed 560053 and count 10000.
The corpus combines critical constants, neighboring binades, subnormal
transitions, finite extremes and random finite bit patterns. Arithmetic
opcode rows execute validated bytecode. Scalar/vector rows call the same
runtime implementations directly; their reported cycles come from metadata.
Interpreter accounting is independently exercised by the contract tests
for every scalar/vector identity, refusals, zero budget and overshoot.
| Function | Largest certified error upper bound in the sampled corpus |
| --- | ---: |
| sin | 0.7327914722897216 ULP |
| cos | 0.698851370176746 ULP |
| atan2 | 0.5139939747008185 ULP |
Fundamentals, sqrt, conversions, rounding and vector sequences had no
disagreement with their corresponding exact oracle.
Debug and release corpus bytes were identical, including results/faults
and cycles. SHA-256:
51f9361e79b2e648d557d38dad775250ed3c5d57f8ff5f187dc3ee7aab7ddfdb
The checked-in portable fixture contains 4,747 independently verified rows
(count 100, same seed). It replays without installing MPFR.
Workspace validation passed 907 tests with 9 existing ignored tests,
cargo fmt and workspace Clippy. All 14 numeric contract tests passed in
release as well as debug.
The oracle process runs as x86_64 on the available Mac, while both runtime
executables are aarch64. This is independent oracle execution, not an
x86_64 runtime qualification.
## Indicative local cost
One release microbenchmark called each intrinsic implementation 20,000 times,
after 100 warmup calls, with the inputs in numeric_benchmark.rs.
These timings exclude interpreter dispatch, argument production and frame
scheduling; they are neither worst-case bounds nor virtual cycle calibration.
| Function | Observed ns/call | Fixed virtual call cycles |
| --- | ---: | ---: |
| sqrt | 113.21 | 16 |
| sin, large argument | 853.40 | 32 |
| cos, MAX_FINITE | 922.79 | 32 |
| atan2 | 2274.13 | 48 |
| dot | 51.81 | 10 |
| length | 248.53 | 40 |
## Reproduction and remaining host evidence
Install the independent oracle in an isolated environment:
python3 -m venv /tmp/prometeu-numeric-oracle
/tmp/prometeu-numeric-oracle/bin/python -m pip install -r scripts/numeric-oracle-requirements.txt
Build with the locked dependency resolution and run both profiles:
cargo build --locked -p prometeu-vm --examples
cargo build --locked -p prometeu-vm --examples --release
mkdir -p target/numeric
/tmp/prometeu-numeric-oracle/bin/python scripts/qualify-numeric.py --probe target/debug/examples/numeric_probe --output target/numeric/debug-corpus.tsv --count 10000 > target/numeric/debug-report.json
/tmp/prometeu-numeric-oracle/bin/python scripts/qualify-numeric.py --probe target/release/examples/numeric_probe --output target/numeric/release-corpus.tsv --count 10000 > target/numeric/release-report.json
cmp target/numeric/debug-corpus.tsv target/numeric/release-corpus.tsv
cargo test --locked -p prometeu-vm --test numeric_contract
cargo test --locked -p prometeu-vm --test numeric_contract --release
target/release/examples/numeric_benchmark
Regenerate/check catalog artifacts with export_numeric_catalog. The parity
test compares generated output to both checked-in CSV files. Record
rustc -Vv, target, features, lockfile, source/catalog fingerprints and oracle
versions on every new qualification run.
Runtime execution on macOS/x86_64 and Linux/x86_64 headless remains pending.
When those hosts are available, reproduce this same seed/count in debug and
release, pass the oracle and contract tests, and compare the complete corpus
to the SHA-256 above. Any difference in bits, faults or cycles requires
investigation; meeting the ULP bound alone does not qualify a different result.
Cross-compilation only provides build evidence. A future intentional backend
revision requires a new qualification baseline.
Frontend integration remains pending independently: consume runtime metadata,
project math/mathf namespaces, resolve exact overloads, retain ordered
arguments and preserve calls with literal inputs. The spec supplies examples;
this delivery contains no frontend implementation or frontend integration tests.
@@ -56,6 +56,71 @@
"paths": [
"crates/host/prometeu-host-headless/src/"
]
},
"vm/core": {
"baseline_percent": 89.12,
"paths": [
"crates/console/prometeu-vm/src/"
]
},
"bytecode": {
"baseline_percent": 93.23,
"paths": [
"crates/console/prometeu-bytecode/src/"
]
},
"hal/core": {
"baseline_percent": 88.56,
"paths": [
"crates/console/prometeu-hal/src/"
],
"exclude_paths": [
"crates/console/prometeu-hal/src/asset",
"crates/console/prometeu-hal/src/asset.rs",
"crates/console/prometeu-hal/src/asset_bridge.rs",
"crates/console/prometeu-hal/src/cartridge.rs",
"crates/console/prometeu-hal/src/cartridge_loader.rs"
]
},
"drivers/core": {
"baseline_percent": 84.51,
"paths": [
"crates/console/prometeu-drivers/src/"
],
"exclude_paths": [
"crates/console/prometeu-drivers/src/asset.rs"
]
},
"system/core": {
"baseline_percent": 92.71,
"paths": [
"crates/console/prometeu-system/src/"
],
"exclude_paths": [
"crates/console/prometeu-system/src/os/",
"crates/console/prometeu-system/src/services/process",
"crates/console/prometeu-system/src/services/task",
"crates/console/prometeu-system/src/services/vm_runtime",
"crates/console/prometeu-system/src/services/fs/",
"crates/console/prometeu-system/src/services/memcard.rs",
"crates/console/prometeu-system/src/programs/"
]
},
"tooling": {
"baseline_percent": 64.75,
"paths": [
"crates/tools/prometeu-cli/src/",
"crates/tools/pbxgen-dummy-boy/src/",
"crates/tools/pbxgen-stress/src/"
]
},
"dev/test-support": {
"baseline_percent": 85.96,
"paths": [
"crates/dev/prometeu-test-support/src/",
"crates/dev/prometeu-layer-tests/src/",
"crates/dev/prometeu-quality-checks/src/"
]
}
}
}
+161
View File
@@ -0,0 +1,161 @@
#!/usr/bin/env python3
"""Audit exclusive source ownership and nonempty LLVM coverage domain evidence."""
import argparse
import json
import math
import sys
from pathlib import Path
class AuditError(ValueError):
pass
def load_json(path):
try:
return json.loads(path.read_text())
except (OSError, ValueError) as error:
raise AuditError(f"cannot read {path}: {error}") from error
def matches(name, domain):
return any(name.startswith(p) for p in domain["paths"]) and not any(
name.startswith(p) for p in domain.get("exclude_paths", [])
)
def owners(name, domains):
return [key for key, domain in domains.items() if matches(name, domain)]
def source_name(filename, root):
"""Normalize absolute or remapped relative report paths into repository paths."""
if not isinstance(filename, str):
raise AuditError("report filename must be a string")
path = Path(filename)
if not path.is_absolute():
path = root / path
try:
name = path.resolve().relative_to(root).as_posix()
except ValueError:
return None
parts = Path(name).parts
return name if parts and parts[0] == "crates" and "src" in parts and name.endswith(".rs") else None
def audit(root, config_path, report_path=None):
root = root.resolve()
config = load_json(config_path)
if not isinstance(config, dict) or config.get("version") != 1:
raise AuditError("unsupported coverage configuration version (expected 1)")
domains = config.get("domains")
if not isinstance(domains, dict) or not domains:
raise AuditError("configuration must contain nonempty domains")
sources = sorted(p.relative_to(root).as_posix() for p in (root / "crates").glob("**/src/**/*.rs"))
if not sources:
raise AuditError("no crate src Rust files found")
for key, domain in domains.items():
if not key or not isinstance(domain, dict):
raise AuditError(f"invalid domain {key!r}")
baseline = domain.get("baseline_percent")
if isinstance(baseline, bool) or not isinstance(baseline, (float, int)) or not math.isfinite(baseline) or not 0 <= baseline <= 100:
raise AuditError(f"{key}: baseline_percent must be finite in [0,100]")
paths = domain.get("paths")
exclusions = domain.get("exclude_paths", [])
if not isinstance(paths, list) or not paths or not isinstance(exclusions, list):
raise AuditError(f"{key}: paths must be nonempty and exclude_paths must be a list")
for prefix in paths + exclusions:
if not isinstance(prefix, str) or not prefix.startswith("crates/") or ".." in Path(prefix).parts or not any(s.startswith(prefix) for s in sources):
raise AuditError(f"{key}: prefix does not match crate sources: {prefix!r}")
if any(not any(p.startswith(include) for include in paths) for p in exclusions):
raise AuditError(f"{key}: exclusions must be within inclusive paths")
source_owners = {}
for name in sources:
assigned = owners(name, domains)
if len(assigned) != 1:
raise AuditError(f"{name}: expected exactly one domain, got {assigned}")
source_owners[name] = assigned[0]
result = {
"source_files": len(sources),
"domains": {
key: {"source_files": sum(owner == key for owner in source_owners.values()),
"report_files": 0, "files": [], "lines_count": 0, "lines_covered": 0,
"functions": {"count": 0, "covered": 0},
"regions": {"count": 0, "covered": 0},
"baseline_percent": domain["baseline_percent"]}
for key, domain in domains.items()
},
}
if report_path is None:
return result
report = load_json(report_path)
if not isinstance(report, dict) or not isinstance(report.get("data"), list) or not report["data"]:
raise AuditError("coverage report must contain nonempty data")
seen = set()
for data in report["data"]:
if not isinstance(data, dict) or not isinstance(data.get("files"), list):
raise AuditError("coverage report data must contain files")
for record in data["files"]:
if not isinstance(record, dict):
raise AuditError("coverage report file must be an object")
name = source_name(record.get("filename"), root)
if name is None:
continue
if name not in source_owners:
raise AuditError(f"report source not present in repository: {name}")
if name in seen:
raise AuditError(f"duplicate source in coverage report: {name}")
seen.add(name)
try:
lines = record["summary"]["lines"]
count, covered = lines["count"], lines["covered"]
except (KeyError, TypeError) as error:
raise AuditError(f"{name}: missing line summary") from error
if any(isinstance(v, bool) or not isinstance(v, int) for v in (count, covered)) or not 0 <= covered <= count:
raise AuditError(f"{name}: invalid line counts")
domain = result["domains"][source_owners[name]]
domain["report_files"] += 1
domain["files"].append(name)
domain["lines_count"] += count
domain["lines_covered"] += covered
for metric in ("functions", "regions"):
item = record["summary"].get(metric, {"count": 0, "covered": 0})
if not isinstance(item, dict):
raise AuditError(f"{name}: invalid {metric} summary")
metric_count, metric_covered = item.get("count"), item.get("covered")
if any(isinstance(v, bool) or not isinstance(v, int) for v in (metric_count, metric_covered)) or not 0 <= metric_covered <= metric_count:
raise AuditError(f"{name}: invalid {metric} counts")
domain[metric]["count"] += metric_count
domain[metric]["covered"] += metric_covered
for key, domain in result["domains"].items():
if domain["lines_count"] <= 0:
raise AuditError(f"{key}: no instrumented lines in report")
domain["line_percent"] = (domain["lines_covered"] * 10000 // domain["lines_count"]) / 100
domain["gate_passed"] = domain["line_percent"] >= domain["baseline_percent"]
return result
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--root", type=Path, default=Path(__file__).resolve().parent.parent)
parser.add_argument("--config", type=Path)
parser.add_argument("--report", type=Path)
parser.add_argument("--json", action="store_true")
parser.add_argument("--quiet", action="store_true")
args = parser.parse_args()
try:
result = audit(args.root, args.config or args.root / "files/config/runtime-edge-coverage-domains.json", args.report)
except AuditError as error:
print(f"Coverage domain audit failed: {error}", file=sys.stderr)
return 1
if args.json:
print(json.dumps(result, indent=2))
elif not args.quiet:
print(f"Coverage ownership: {result['source_files']} source files, {len(result['domains'])} exclusive domains")
if args.report:
print("Coverage evidence: all domains contain instrumented lines; no source orphans or duplicates")
return 0
if __name__ == "__main__":
sys.exit(main())
+28 -49
View File
@@ -10,29 +10,14 @@ CYAN=$'\033[36m'
RESET=$'\033[0m'
line_percent() {
jq -r --arg domain "${1}" --arg root "${ROOT}" '
.domains[$domain].paths as $paths
| def matches_domain:
. as $file
| any($paths[]; . as $p | ($file.filename | startswith($root + "/" + $p) or startswith("./" + $p) or startswith($p)));
def pct($covered; $count):
if $count > 0 then (($covered * 10000 / $count | floor) / 100) else 0 end;
reduce (
input.data[]?.files[]?
| select(matches_domain)
) as $file (
{lines: {count: 0, covered: 0}};
.lines.count += ($file.summary.lines.count // 0)
| .lines.covered += ($file.summary.lines.covered // 0)
)
| pct(.lines.covered; .lines.count)
' "${CONFIG_PATH}" "${2}"
jq -r --arg domain "${1}" '.domains[$domain].line_percent' <<< "${AUDIT_RESULT}"
}
usage() {
cat <<'EOF'
Usage:
coverage-domain-evidence.sh --list
coverage-domain-evidence.sh --audit [report.json]
coverage-domain-evidence.sh [--check] [--show-summary-details] [--show-paths] [--show-tracked-files] [--show-matched-files] [--verbose] <domain> [report.json]
coverage-domain-evidence.sh [--show-summary-details] [--show-paths] [--show-tracked-files] [--show-matched-files] [--verbose] --check-all [report.json]
@@ -56,6 +41,11 @@ if [[ "$1" == "--list" ]]; then
exit 0
fi
if [[ "$1" == "--audit" ]]; then
python3 "${ROOT}/scripts/audit-coverage-domains.py" --report "${2:-${DEFAULT_REPORT}}"
exit
fi
CHECK_MODE=0
CHECK_ALL=0
SHOW_PATHS=0
@@ -114,6 +104,7 @@ done
if [[ ${CHECK_ALL} -eq 1 ]]; then
REPORT_PATH="${1:-${DEFAULT_REPORT}}"
python3 "${ROOT}/scripts/audit-coverage-domains.py" --report "${REPORT_PATH}" --quiet
FAIL=0
while IFS= read -r domain; do
@@ -151,17 +142,24 @@ if [[ ${SHOW_PATHS} -eq 1 ]]; then
jq -r --arg domain "${DOMAIN}" '.domains[$domain].paths[]' "${CONFIG_PATH}" | while IFS= read -r prefix; do
echo " - ${prefix}"
done
echo "Excluded repository paths:"
jq -r --arg domain "${DOMAIN}" '.domains[$domain].exclude_paths[]?' "${CONFIG_PATH}" | while IFS= read -r prefix; do
echo " - ${prefix}"
done
echo
fi
if [[ ${SHOW_TRACKED_FILES} -eq 1 ]]; then
echo "Tracked files present in repository:"
while IFS= read -r path; do
(
cd "${ROOT}"
rg --files . | sed 's#^\./##'
) | rg "^${path//\//\\/}" || true
done < <(jq -r --arg domain "${DOMAIN}" '.domains[$domain].paths[]' "${CONFIG_PATH}")
(
cd "${ROOT}"
rg --files crates
) | jq -Rr --arg domain "${DOMAIN}" --slurpfile config "${CONFIG_PATH}" '
$config[0].domains[$domain] as $mapping
| . as $name
| select(any($mapping.paths[]; . as $p | $name | startswith($p))
and (any($mapping.exclude_paths[]?; . as $p | $name | startswith($p)) | not))
'
echo
fi
@@ -174,32 +172,13 @@ if [[ ! -f "${REPORT_PATH}" ]]; then
exit 0
fi
jq -r --arg domain "${DOMAIN}" --arg root "${ROOT}" --argjson baseline "${BASELINE}" --argjson show_matched_files "${SHOW_MATCHED_FILES}" --argjson show_summary_details "${SHOW_SUMMARY_DETAILS}" '
.domains[$domain].paths as $paths
| def matches_domain:
. as $file
| any($paths[]; . as $p | ($file.filename | startswith($root + "/" + $p) or startswith("./" + $p) or startswith($p)));
AUDIT_RESULT="$(python3 "${ROOT}/scripts/audit-coverage-domains.py" --report "${REPORT_PATH}" --json)"
jq -r --arg domain "${DOMAIN}" --argjson show_matched_files "${SHOW_MATCHED_FILES}" --argjson show_summary_details "${SHOW_SUMMARY_DETAILS}" '
def pct($covered; $count):
if $count > 0 then (($covered * 10000 / $count | floor) / 100) else 0 end;
reduce (
input.data[]?.files[]?
| select(matches_domain)
) as $file (
{
files: [],
lines: {count: 0, covered: 0},
functions: {count: 0, covered: 0},
regions: {count: 0, covered: 0}
};
.files += [$file.filename]
| .lines.count += ($file.summary.lines.count // 0)
| .lines.covered += ($file.summary.lines.covered // 0)
| .functions.count += ($file.summary.functions.count // 0)
| .functions.covered += ($file.summary.functions.covered // 0)
| .regions.count += ($file.summary.regions.count // 0)
| .regions.covered += ($file.summary.regions.covered // 0)
)
| . + {line_percent: pct(.lines.covered; .lines.count)}
.domains[$domain]
| . + {lines: {count: .lines_count, covered: .lines_covered}}
| (if $show_summary_details == 1 then "lines: " + (.line_percent | tostring) + "% (" + (.lines.covered|tostring) + "/" + (.lines.count|tostring) + ")" else empty end),
(if $show_summary_details == 1 then " files_in_report: " + (.files | length | tostring) else empty end),
(if $show_summary_details == 1 then
@@ -211,9 +190,9 @@ jq -r --arg domain "${DOMAIN}" --arg root "${ROOT}" --argjson baseline "${BASELI
(if $show_matched_files == 1 then "" else empty end),
(if $show_matched_files == 1 then "Matched report files:" else empty end),
(if $show_matched_files == 1 then (.files[]? | " - " + .) else empty end)
' "${CONFIG_PATH}" "${REPORT_PATH}"
' <<< "${AUDIT_RESULT}"
LINE_PERCENT="$(line_percent "${DOMAIN}" "${REPORT_PATH}")"
LINE_PERCENT="$(line_percent "${DOMAIN}")"
if awk "BEGIN { exit !(${LINE_PERCENT} >= ${BASELINE}) }"; then
GATE_STATUS="${GREEN}PASS${RESET}"
+1
View File
@@ -0,0 +1 @@
gmpy2==2.3.0
+228
View File
@@ -0,0 +1,228 @@
#!/usr/bin/env python3
"""Independent MPFR gate. Requires gmpy2==2.3.0 in tooling, never in the VM.
Build numeric_probe in debug/release, run against each with identical seed/count,
then compare the emitted corpora. Directed MPFR intervals adapt precision until
binary64 rounding and strict trig error classification can be certified.
"""
import argparse
import hashlib
import json
import platform
import random
import struct
import subprocess
from pathlib import Path
import gmpy2 as g
def fbits(value):
return struct.unpack(">Q", struct.pack(">d", value))[0]
def host(bits):
return struct.unpack(">d", struct.pack(">Q", bits))[0]
def exact(bits):
"""Import through the exact rational representation, including subnormals."""
n, d = host(bits).as_integer_ratio()
return g.mpq(n, d)
def evaluate(op, args, precision, rounding):
with g.context(precision=precision, round=rounding):
xs = [g.mpfr("-0") if int(x[2:],16)==1<<63 else g.mpfr(exact(int(x[2:], 16))) for x in args if x.startswith("f:")]
if op == "3010":
return g.sqrt(xs[0])
if op == "3011":
return g.sin(xs[0])
if op == "3012":
return g.cos(xs[0])
if op == "3013":
return g.atan2(xs[0], xs[1])
if op in ("3016", "3017"):
return g.mpfr(int(args[0][2:]))
if op == "ADD":
return xs[0] + xs[1]
if op == "SUB":
return xs[0] - xs[1]
if op == "MUL":
return xs[0] * xs[1]
if op == "DIV":
return xs[0] / xs[1]
raise ValueError(op)
def rounded_bits(value):
# MPFR IEEE context includes gradual underflow and binary64 exponent bounds.
with g.context(g.ieee(64), round=g.RoundToNearest):
rounded = g.mpfr(value)
return fbits(float(rounded))
def certify(op, args, result):
if op in ("300c", "300d", "300e", "300f", "3018", "3019"):
bits = int(args[0][2:], 16)
n, d = host(bits).as_integer_ratio()
integer = abs(n) // d
if op == "300c":
integer = n // d
elif op == "300d":
integer = -((-n) // d)
elif op == "300f":
integer, remainder = divmod(abs(n), d)
if 2*remainder > d or (2*remainder == d and integer % 2):
integer += 1
if n < 0:
integer = -integer
elif n < 0:
integer = -integer
if op in ("3018", "3019"):
width = 32 if op == "3018" else 64
expected = "trap:13" if not -(1 << (width-1)) <= integer < (1 << (width-1)) else ("i:" if width == 32 else "l:")+str(integer)
else:
with g.context(precision=160, round=g.RoundToNearest):
rounded = rounded_bits(g.mpfr(integer))
if integer == 0:
rounded = bits & (1 << 63)
expected = f"f:{rounded:016x}"
if result != expected:
raise AssertionError(f"{op} {args}: {result}, exact {expected}")
return 0.0, 160
if op in ("1000", "1001"):
with g.context(g.ieee(64), round=g.RoundToNearest):
xs = [g.mpfr("-0") if int(x[2:],16)==1<<63 else g.mpfr(exact(int(x[2:],16))) for x in args]
if op == "1000":
p1 = xs[0]*xs[2]
p2 = xs[1]*xs[3]
value = p1+p2
if not g.is_finite(p1) or not g.is_finite(p2):
value = g.mpfr("inf")
else:
m, n = max(abs(xs[0]),abs(xs[1])), min(abs(xs[0]),abs(xs[1]))
if m == 0:
value = g.mpfr(0)
else:
r = n/m
q = r*r
s = g.mpfr(1)+q
t = g.sqrt(s)
value = m*t
expected = "trap:13" if not g.is_finite(value) else f"f:{fbits(float(value)):016x}"
if result != expected:
raise AssertionError(f"{op} {args}: {result}, MPFR sequence {expected}")
return 0.0, 53
trig = op in ("3011", "3012", "3013")
for precision in (160, 320, 640, 1280, 2560, 5120, 10240):
lo = evaluate(op, args, precision, g.RoundDown)
hi = evaluate(op, args, precision, g.RoundUp)
lb, hb = rounded_bits(lo), rounded_bits(hi)
if not trig:
if lo == hi == 0:
lb=hb=rounded_bits(evaluate(op,args,precision,g.RoundToNearest))
if lb != hb:
continue
expected = "trap:13" if lb & 0x7ff0000000000000 == 0x7ff0000000000000 else f"f:{lb:016x}"
if result != expected:
raise AssertionError(f"{op} {args}: {result}, MPFR {expected}")
return 0.0, precision
if not result.startswith("f:"):
raise AssertionError(f"unexpected trig fault: {op} {args}: {result}")
out_bits = int(result[2:], 16)
with g.context(precision=precision, round=g.RoundUp):
out = g.mpfr(exact(out_bits))
# Use a conservative spacing if interval crosses a power of two.
magnitude_lo = min(abs(lo), abs(hi))
if lo <= 0 <= hi:
magnitude_lo = g.mpfr(0)
exponent = max(-1074, int(g.get_exp(magnitude_lo)) - 53) if magnitude_lo else -1074
ulp = g.mul_2exp(g.mpfr(1), exponent)
# Each positive endpoint distance rounds upward. Taking abs after
# an upward-rounded negative subtraction would underestimate it.
error_hi = max(out - lo, hi - out, g.mpfr(0)) / ulp
if error_hi < 1:
return float(error_hi), precision
with g.context(precision=precision, round=g.RoundDown):
error_lo = (lo-out if out < lo else out-hi if out > hi else g.mpfr(0)) / ulp
if error_lo >= 1:
raise AssertionError(f"{op} {args}: {result}, error >= {float(error_lo):.12g} ULP")
raise AssertionError(f"unresolved MPFR interval: {op} {args}")
def corpus(count, seed):
rng = random.Random(seed)
# Both sides of binades, subnormal transitions, pi/2 reductions, huge angles.
critical = [0, 1, 2, 0xfffffffffffff, 0x10000000000000,
0x3fdfffffffffffff, 0x3fe0000000000000, 0x3fe0000000000001,
0x3ff0000000000000, 0x4000000000000000,
0x3ff921fb54442d18, 0x400921fb54442d18,
0x401921fb54442d18, 0x7fefffffffffffff]
critical += [v + delta for v in critical[4:] for delta in (-2, -1, 1, 2)]
critical = [v for v in critical if v & 0x7ff0000000000000 != 0x7ff0000000000000]
bits = critical + [rng.getrandbits(64) & 0x7fefffffffffffff for _ in range(count)]
# Masked samples omit half the exponent binades; add unmasked finite samples.
while len(bits) < 2*count + len(critical):
v = rng.getrandbits(64)
if v & 0x7ff0000000000000 != 0x7ff0000000000000:
bits.append(v)
rows = []
for v in bits:
positive = v & 0x7fffffffffffffff
rows.append(("3010", [f"f:{positive:016x}"]))
for op in ("300c", "300d", "300e", "300f", "3018", "3019"):
rows.append((op, [f"f:{v:016x}"]))
for signed in (positive, positive | (1 << 63)):
rows.append(("3011", [f"f:{signed:016x}"]))
rows.append(("3012", [f"f:{signed:016x}"]))
other = rng.choice(bits)
rows.append(("1001", [f"f:{v:016x}", f"f:{other:016x}"]))
rows.append(("1000", [f"f:{v:016x}", f"f:{other:016x}", f"f:{rng.choice(bits):016x}", f"f:{rng.choice(bits):016x}"]))
if v & 0x7fffffffffffffff or other & 0x7fffffffffffffff:
rows.append(("3013", [f"f:{v:016x}", f"f:{other:016x}"]))
for op in ("ADD", "SUB", "MUL", "DIV"):
if op != "DIV" or other & 0x7fffffffffffffff:
rows.append((op, [f"f:{v:016x}", f"f:{other:016x}"]))
for n in [-(1 << 63), (1 << 63)-1, 0, 1, -1, (1 << 53)-1, (1 << 53)+1] + [rng.randrange(-(1<<63), 1<<63) for _ in range(count)]:
rows.append(("3017", [f"l:{n}"]))
for n in [-(1<<31), (1<<31)-1, 0, 1, -1] + [rng.randrange(-(1<<31), 1<<31) for _ in range(count)]:
rows.append(("3016", [f"i:{n}"]))
return rows
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--probe", required=True)
parser.add_argument("--output", required=True)
parser.add_argument("--count", type=int, default=1000)
parser.add_argument("--seed", type=int, default=560053)
args = parser.parse_args()
rows = corpus(args.count, args.seed)
wire = "".join(" ".join([op] + values) + "\n" for op, values in rows)
process = subprocess.run([args.probe], input=wire, text=True, capture_output=True, check=True)
results = process.stdout.splitlines()
assert len(rows) == len(results)
maxima = {}
max_precision = 0
output = []
for (op, values), line in zip(rows, results):
result, cycles = line.split()
error, precision = certify(op, values, result)
maxima[op] = max(maxima.get(op, 0), error)
max_precision = max(max_precision, precision)
output.append(" ".join([op] + values + [result, cycles]) + "\n")
content = "".join(output).encode()
Path(args.output).parent.mkdir(parents=True, exist_ok=True)
Path(args.output).write_bytes(content)
print(json.dumps({
"rows": len(rows), "count": args.count, "seed": args.seed,
"corpus_sha256": hashlib.sha256(content).hexdigest(),
"max_error_ulp_upper_bound": maxima, "max_mpfr_precision": max_precision,
"gmpy2": g.version(), "mpfr": g.mpfr_version(),
"oracle_architecture": platform.machine(),
"probe": args.probe, "cross_host_execution": "pending",
}, indent=2))
if __name__ == "__main__":
main()