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
@@ -1,9 +1,11 @@
use prometeu_bytecode::registry::FunctionDecl;
use prometeu_test_support::program::{TestProgram, int64_signature};
use std::fs;
use std::path::Path;
use prometeu_bytecode::SourceSpan;
use prometeu_bytecode::assembler::assemble;
use prometeu_bytecode::model::{BytecodeModule, DebugInfo, Export, FunctionMeta, SyscallDecl};
use prometeu_bytecode::model::{DebugInfo, Export, SyscallDecl};
use prometeu_hal::InputSignals;
use prometeu_hal::app_mode::AppMode;
use prometeu_hal::color::Color;
@@ -487,9 +489,9 @@ fn color_program() -> Vec<u8> {
INTRINSIC 0x210E\n"));
let jump_to_blue = rom.len() + 2;
rom.extend(asm("JMP_IF_FALSE 0"));
rom.extend(asm(&format!("PUSH_I64 {RED}\nHOSTCALL 0\nFRAME_SYNC\nRET\n")));
rom.extend(asm(&format!("PUSH_I64 {RED}\nHOSTCALL 0\nRET\n")));
let blue_at = rom.len() as u32;
rom.extend(asm(&format!("PUSH_I64 {BLUE}\nHOSTCALL 0\nFRAME_SYNC\nRET\n")));
rom.extend(asm(&format!("PUSH_I64 {BLUE}\nHOSTCALL 0\nRET\n")));
rom[jump_to_blue..jump_to_blue + 4].copy_from_slice(&blue_at.to_le_bytes());
module(rom, color_syscalls())
}
@@ -497,20 +499,20 @@ fn color_program() -> Vec<u8> {
fn input_edge_program() -> Vec<u8> {
let mut rom = Vec::new();
let pressed_jump = emit_right_predicate(&mut rom, 0x210C);
rom.extend(asm(&format!("PUSH_I64 {RED}\nHOSTCALL 0\nFRAME_SYNC\nRET\n")));
rom.extend(asm(&format!("PUSH_I64 {RED}\nHOSTCALL 0\nRET\n")));
let released_at = rom.len() as u32;
rom[pressed_jump..pressed_jump + 4].copy_from_slice(&released_at.to_le_bytes());
let released_jump = emit_right_predicate(&mut rom, 0x210D);
rom.extend(asm(&format!("PUSH_I64 {GREEN}\nHOSTCALL 0\nFRAME_SYNC\nRET\n")));
rom.extend(asm(&format!("PUSH_I64 {GREEN}\nHOSTCALL 0\nRET\n")));
let down_at = rom.len() as u32;
rom[released_jump..released_jump + 4].copy_from_slice(&down_at.to_le_bytes());
let down_jump = emit_right_predicate(&mut rom, 0x210E);
rom.extend(asm(&format!("PUSH_I64 {BLUE}\nHOSTCALL 0\nFRAME_SYNC\nRET\n")));
rom.extend(asm(&format!("PUSH_I64 {BLUE}\nHOSTCALL 0\nRET\n")));
let idle_at = rom.len() as u32;
rom[down_jump..down_jump + 4].copy_from_slice(&idle_at.to_le_bytes());
rom.extend(asm(&format!("PUSH_I64 {BLACK}\nHOSTCALL 0\nFRAME_SYNC\nRET\n")));
rom.extend(asm(&format!("PUSH_I64 {BLACK}\nHOSTCALL 0\nRET\n")));
module(rom, gfx_syscalls())
}
@@ -525,20 +527,20 @@ fn emit_right_predicate(rom: &mut Vec<u8>, predicate: u32) -> usize {
fn touch_edge_program() -> Vec<u8> {
let mut rom = Vec::new();
let pressed_jump = emit_touch_predicate(&mut rom, 0x2130);
rom.extend(asm(&format!("PUSH_I64 {RED}\nHOSTCALL 0\nFRAME_SYNC\nRET\n")));
rom.extend(asm(&format!("PUSH_I64 {RED}\nHOSTCALL 0\nRET\n")));
let released_at = rom.len() as u32;
rom[pressed_jump..pressed_jump + 4].copy_from_slice(&released_at.to_le_bytes());
let released_jump = emit_touch_predicate(&mut rom, 0x2131);
rom.extend(asm(&format!("PUSH_I64 {GREEN}\nHOSTCALL 0\nFRAME_SYNC\nRET\n")));
rom.extend(asm(&format!("PUSH_I64 {GREEN}\nHOSTCALL 0\nRET\n")));
let down_at = rom.len() as u32;
rom[released_jump..released_jump + 4].copy_from_slice(&down_at.to_le_bytes());
let down_jump = emit_touch_predicate(&mut rom, 0x2132);
rom.extend(asm(&format!("PUSH_I64 {BLUE}\nHOSTCALL 0\nFRAME_SYNC\nRET\n")));
rom.extend(asm(&format!("PUSH_I64 {BLUE}\nHOSTCALL 0\nRET\n")));
let idle_at = rom.len() as u32;
rom[down_jump..down_jump + 4].copy_from_slice(&idle_at.to_le_bytes());
rom.extend(asm(&format!("PUSH_I64 {BLACK}\nHOSTCALL 0\nFRAME_SYNC\nRET\n")));
rom.extend(asm(&format!("PUSH_I64 {BLACK}\nHOSTCALL 0\nRET\n")));
module(rom, gfx_syscalls())
}
@@ -557,7 +559,7 @@ fn emit_touch_predicate(rom: &mut Vec<u8>, predicate: u32) -> usize {
fn fault_program() -> Vec<u8> {
// `INTRINSIC 0xDEADBEEF` is rejected by the loader as `VerificationFailed`.
// `TRAP` is a legal instruction that becomes `CrashReport::VmTrap` at runtime.
module(asm("TRAP\nFRAME_SYNC\nRET\n"), vec![])
module(asm("TRAP\nRET\n"), vec![])
}
fn delayed_fault_program() -> Vec<u8> {
@@ -567,7 +569,7 @@ fn delayed_fault_program() -> Vec<u8> {
rom.extend(asm("JMP_IF_FALSE 0\nTRAP\n"));
let continue_at = rom.len() as u32;
rom[continue_jump..continue_jump + 4].copy_from_slice(&continue_at.to_le_bytes());
rom.extend(asm(&format!("PUSH_I64 {BLACK}\nHOSTCALL 0\nFRAME_SYNC\nRET\n")));
rom.extend(asm(&format!("PUSH_I64 {BLACK}\nHOSTCALL 0\nRET\n")));
module(rom, gfx_syscalls())
}
@@ -575,7 +577,7 @@ fn multi_tick_program() -> Vec<u8> {
let mut rom = asm("PUSH_I32 30000\nSET_LOCAL 0\n");
let loop_at = rom.len() as u32;
rom.extend(asm("GET_LOCAL 0\nPUSH_I32 1\nSUB\nSET_LOCAL 0\nGET_LOCAL 0\nPUSH_I32 0\nGT\n"));
rom.extend(asm(&format!("JMP_IF_TRUE {loop_at}\nFRAME_SYNC\nRET\n")));
rom.extend(asm(&format!("JMP_IF_TRUE {loop_at}\nRET\n")));
module_with_locals(rom, vec![], 1)
}
@@ -613,16 +615,16 @@ fn module(code: Vec<u8>, syscalls: Vec<SyscallDecl>) -> Vec<u8> {
}
fn module_with_locals(code: Vec<u8>, syscalls: Vec<SyscallDecl>, local_slots: u16) -> Vec<u8> {
BytecodeModule {
version: 0,
TestProgram {
const_pool: vec![],
functions: vec![FunctionMeta {
functions: vec![FunctionDecl {
code_offset: 0,
code_len: code.len() as u32,
param_slots: 0,
local_slots,
return_slots: 0,
local_slots: u32::from(local_slots),
max_stack_slots: 8,
signature: int64_signature(0, 0),
captures: vec![],
name: None,
}],
code,
debug_info: Some(DebugInfo {