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
@@ -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!(