feat(vm)!: implement typed callables and single-context execution
Intrepid/Prometeu/Runtime/pipeline/pr-master This commit looks good

Add structural Fn signatures, typed capture environments, indirect calls and Trait dispatch while preserving logical parameter and result groups, ownership and budgets.

Remove guest coroutine execution and legacy loading. Activate bounded sealed PBX v1 with mandatory capture metadata, preserve frame continuations and root return results, and migrate producers and shipped cartridges.

Publish coordinated specs, handoffs and the completed runtime lesson. Validation: 880 workspace tests passed, 9 existing tests ignored; both cartridges completed six production-host frames.
This commit is contained in:
2026-10-09 05:47:24 +01:00
parent 86bade3e1f
commit ec84a6bba5
96 changed files with 3656 additions and 6075 deletions
@@ -51,11 +51,8 @@ fn new_attempt_costs_budget_and_transactional_refusal() {
let (vm, result) = attempt("ARRAY_NEW 12", std::slice::from_ref(&length), limits, cost);
trap(result, fault);
assert_eq!(vm.operand_stack.as_slice(), &[length]);
assert_eq!(
vm.budget.used(RuntimeResource::GuestBytes),
size_of::<crate::heap::StoredObject>() as u64
);
assert_eq!(vm.budget.used(RuntimeResource::HandleSlots), 1);
assert_eq!(vm.budget.used(RuntimeResource::GuestBytes), 0);
assert_eq!(vm.budget.used(RuntimeResource::HandleSlots), 0);
}
let mut vm = vm("PUSH_I64 10\nARRAY_NEW 12\nHALT", RuntimeLimits::default());
vm.step(&mut Native, &mut HostContext::new(None)).unwrap();
@@ -208,6 +205,9 @@ fn provisional_allocation_and_handle_refusals_publish_nothing() {
v.step(&mut Native, &mut HostContext::new(None)).unwrap();
// Test-only accounting state: lower the resource ceiling to current usage
// after boot, without changing any production constructor/check.
if quota == RuntimeResource::TemporaryBytes {
v.heap.allocate_object(crate::object::ObjectKind::Bytes, &[]).unwrap();
}
let current = v.budget.used(quota);
v.budget.test_lower_limit(quota, current);
let guest = v.budget.used(RuntimeResource::GuestBytes);
@@ -234,7 +234,7 @@ fn provisional_allocation_and_handle_refusals_publish_nothing() {
);
assert_eq!(v.budget.used(RuntimeResource::GuestBytes), guest);
assert_eq!(v.operand_stack.as_slice(), &[Value::Int64(10)]);
assert_eq!(v.heap.len(), 1);
assert_eq!(v.heap.len(), 0);
}
#[test]
fn rooted_native_owners_boxes_traits_and_cycles_survive_then_reclaim_at_real_safepoints() {
@@ -268,7 +268,7 @@ fn rooted_native_owners_boxes_traits_and_cycles_survive_then_reclaim_at_real_saf
LogicalFrameEndingReason::FrameSync
);
assert!(!v.heap.is_valid(node));
assert_eq!(v.heap.len(), 1);
assert_eq!(v.heap.len(), 0);
assert_eq!(v.budget.used(RuntimeResource::StringBytes), 0);
assert_eq!(v.budget.used(RuntimeResource::StringAllocations), 0);
assert_eq!(v.heap.concrete_type(node, &registry), Err(ValueError::InvalidHandle));
@@ -399,23 +399,18 @@ fn malformed_trait_and_dynamic_stores_reject_the_whole_group() {
}
#[test]
fn legacy_verifier_rejects_every_collection_even_when_unreachable() {
fn typed_loader_rejects_out_of_registry_collections_even_when_unreachable() {
for text in [
"STRUCT_NEW 9",
"STRUCT_GET type=9, field=0",
"STRUCT_SET type=9, field=0",
"ARRAY_NEW 11",
"ARRAY_LEN 11",
"ARRAY_GET 11",
"ARRAY_SET 11",
"STRUCT_NEW 99",
"STRUCT_GET type=99,field=0",
"STRUCT_SET type=99,field=0",
"ARRAY_NEW 99",
"ARRAY_LEN 99",
"ARRAY_GET 99",
"ARRAY_SET 99",
] {
let code = assemble(&format!("HALT\n{text}")).unwrap();
let f =
prometeu_bytecode::FunctionMeta { code_len: code.len() as u32, ..Default::default() };
assert!(matches!(
crate::verifier::Verifier::verify(&code, &[f]),
Err(crate::verifier::VerifierError::RegistryRequired { pc: 2, .. })
));
assert!(support::load(&code).is_err());
}
}
#[test]