feat(compiler): port runtime catalogs and enforce target ABI (AGD77)
Import both runtime catalogs and provenance, port all intrinsic metadata and exact constants, and validate target signatures and carriers through the common pipeline. Package matching compiler/SDK resources and add active parity plus production runtime conformance checks. Validation: 420 compiler/PBS tests passed, with 12 existing skips; provider export, runtime execution and installed catalog checks passed. The pre-existing Gfx.clear typed-metadata failure remains active and assigned to AGD78 under the explicitly accepted scope revision recorded in LSN-0080.
This commit is contained in:
@@ -6,7 +6,7 @@ it does not implement a Java approximation of runtime admission.
|
||||
From the Studio root:
|
||||
|
||||
```sh
|
||||
./gradlew :prometeu-compiler:prometeu-build-pipeline:test --tests '*LinkedRegistryTest' --tests '*PbxRegistryConformanceTest' --tests '*TypedCommonPipelineTest'
|
||||
./gradlew :prometeu-compiler:prometeu-build-pipeline:test --tests '*LinkedRegistryTest' --tests '*PbxRegistryConformanceTest' --tests '*TypedCommonPipelineTest' --tests '*RuntimeCatalogPipelineTest'
|
||||
python3 tools/pbx-conformance/run.py --runtime ../runtime
|
||||
```
|
||||
|
||||
@@ -45,3 +45,20 @@ remove the exception once the schema is corrected.
|
||||
|
||||
This corpus qualifies common backend production, not PBS lowering, lifecycle
|
||||
selection, memcard persistence or installed-runtime deployment.
|
||||
|
||||
## Runtime catalog consumer fixtures
|
||||
|
||||
The catalog corpus adds common-IR Random calls with an aliased handle, a discarded
|
||||
first result, mixed next/nextf/range calls and a subsequent next. The VM checks the
|
||||
independent seed-42 handoff vector and identical charged work before/after
|
||||
optimization. Constants are compared slot-by-slot against runtime materialization,
|
||||
including exact Float bits and both slots of `vec2.zero`. Pool deduplication may
|
||||
share a value but cannot omit a group component.
|
||||
|
||||
A known zero-argument touch query loads and traps `TRAP_UNAVAILABLE` without a
|
||||
hardware context. A removed endpoint ID is rejected even after an unreachable
|
||||
HALT. `color.html_rgba` executes with a String value and rejects a proven null
|
||||
at load time, matching the runtime verifier's stricter rule despite the
|
||||
dispatcher's nullable String carrier. These are distinct outcomes. Run the separate provider-export check with
|
||||
`python3 tools/runtime-catalog/verify.py --runtime ../runtime` to compare the
|
||||
selected source revision, imported CSV bytes and exporter output as well.
|
||||
|
||||
@@ -36,6 +36,7 @@ impl NativeInterface for NoNative {
|
||||
|
||||
fn main() {
|
||||
let root = std::path::PathBuf::from(std::env::args().nth(1).expect("fixture directory"));
|
||||
verify_catalog_fixtures(&root);
|
||||
for name in [
|
||||
"minimal",
|
||||
"jump-end",
|
||||
@@ -257,6 +258,58 @@ fn main() {
|
||||
);
|
||||
}
|
||||
|
||||
fn verify_catalog_fixtures(root: &std::path::Path) {
|
||||
use prometeu_vm::LogicalFrameEndingReason as End;
|
||||
let mut random_cycles = None;
|
||||
for name in ["catalog-random-off", "catalog-random-on", "catalog-constants", "catalog-vec2-zero", "catalog-input", "catalog-string"] {
|
||||
let bytes = std::fs::read(root.join(format!("{name}.pbx"))).unwrap();
|
||||
let image = ValidatedProgramImage::load(&bytes, &mut LoadBudget::new(LoadLimits::default()), caps::NONE)
|
||||
.unwrap_or_else(|error| panic!("{name}: {error:?}"));
|
||||
println!("LOAD PASS {name}");
|
||||
let mut vm = VirtualMachine::from_image(image, Default::default());
|
||||
vm.prepare_boot_call().unwrap();
|
||||
let report = vm.run_budget(10000, &mut NoNative, &mut HostContext::new(None)).unwrap();
|
||||
if name == "catalog-input" {
|
||||
assert!(matches!(report.reason, End::Trap(ref trap) if trap.code == prometeu_bytecode::TRAP_UNAVAILABLE));
|
||||
println!("EXEC PASS {name}: TRAP_UNAVAILABLE (known query, no hardware)");
|
||||
continue;
|
||||
}
|
||||
assert!(matches!(report.reason, End::Halted | End::EndOfRom), "{name}: {report:?}");
|
||||
if name.starts_with("catalog-random-") {
|
||||
// Independent seed-42 vector and unit-range consumption from the provider handoff/tests.
|
||||
assert_eq!(vm.operand_stack_top(3), vec![
|
||||
Value::Int64(0xF9090E529A7DAE00u64 as i64), Value::Int64(-7),
|
||||
Value::Float(f64::from_bits(0x3FB304AA46C98538)),
|
||||
], "{name}: aliasing, discarded first next, mixed operations and exact order");
|
||||
if let Some(cycles) = random_cycles { assert_eq!(report.cycles_used, cycles, "optimization changed charged work"); }
|
||||
random_cycles = Some(report.cycles_used);
|
||||
} else if name == "catalog-vec2-zero" {
|
||||
assert_eq!(vm.operand_stack_top(2), vec![Value::Float(0.0), Value::Float(0.0)]);
|
||||
} else if name == "catalog-string" {
|
||||
assert_eq!(vm.operand_stack_top(1), vec![Value::Int64(0xAABBCCDD)]);
|
||||
} else {
|
||||
let mut constants: Vec<_> = prometeu_vm::builtin_constant_catalog().collect();
|
||||
constants.sort_by_key(|constant| constant.key.key());
|
||||
let mut expected = Vec::new();
|
||||
for constant in constants { expected.extend(constant.materialize().unwrap()); }
|
||||
expected.reverse();
|
||||
let actual = vm.operand_stack_top(expected.len());
|
||||
assert_eq!(actual.len(), 16);
|
||||
for (actual, expected) in actual.iter().zip(expected.iter()) {
|
||||
match (actual, expected) {
|
||||
(Value::Float(a), Value::Float(b)) => assert_eq!(a.to_bits(), b.to_bits()),
|
||||
_ => assert_eq!(actual, expected),
|
||||
}
|
||||
}
|
||||
}
|
||||
println!("EXEC PASS {name}: {} cycles, {} steps", report.cycles_used, report.steps_executed);
|
||||
}
|
||||
let removed = std::fs::read(root.join("catalog-removed.pbx")).unwrap();
|
||||
reject(root, "catalog-removed", &removed, LoadLimits::default());
|
||||
let null_string = std::fs::read(root.join("catalog-null-string.pbx")).unwrap();
|
||||
reject(root, "catalog-null-string", &null_string, LoadLimits::default());
|
||||
}
|
||||
|
||||
fn reject(root: &std::path::Path, name: &str, bytes: &[u8], limits: LoadLimits) {
|
||||
let error =
|
||||
ValidatedProgramImage::load(bytes, &mut LoadBudget::new(limits), caps::NONE).unwrap_err();
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
"""Explicit provider check; ordinary Studio compilation does not invoke this tool."""
|
||||
import argparse
|
||||
import hashlib
|
||||
import pathlib
|
||||
import platform
|
||||
import subprocess
|
||||
import tempfile
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--runtime", type=pathlib.Path, required=True)
|
||||
args = parser.parse_args()
|
||||
studio = pathlib.Path(__file__).resolve().parents[2]
|
||||
mirror = studio / "docs/vm-arch"
|
||||
properties = dict(line.split("=", 1) for line in
|
||||
(mirror / "runtime-catalog.properties").read_text().splitlines() if line)
|
||||
runtime = args.runtime.resolve(strict=True)
|
||||
revision = subprocess.check_output(["git", "-C", str(runtime), "rev-parse", "HEAD"], text=True).strip()
|
||||
if revision != properties["runtime.revision"]:
|
||||
raise SystemExit(f"Expected selected provider {properties['runtime.revision']}, found {revision}; "
|
||||
"this is an evidence-target mismatch, not a runtime compatibility verdict")
|
||||
# Evidence must correspond to committed source, not just two matching local copies.
|
||||
dirty = subprocess.check_output(["git", "-C", str(runtime), "status", "--porcelain"], text=True)
|
||||
if dirty:
|
||||
raise SystemExit("Provider checkout is dirty; verify the selected revision in a clean checkout")
|
||||
for name in ("INTRINSICS.csv", "BUILTIN_CONSTANTS.csv"):
|
||||
committed = subprocess.check_output(["git", "-C", str(runtime), "show", f"{revision}:docs/vm-arch/{name}"])
|
||||
if committed != (runtime / "docs/vm-arch" / name).read_bytes() or committed != (mirror / name).read_bytes():
|
||||
raise SystemExit(f"Provider/mirror bytes differ: {name}")
|
||||
digest = hashlib.sha256(committed).hexdigest()
|
||||
if digest != properties[name + ".sha256"]:
|
||||
raise SystemExit(f"Provenance hash mismatch: {name}")
|
||||
print(f"MATCH {name} sha256={digest}", flush=True)
|
||||
print(f"Provider {revision}; {platform.platform()}; Cargo test profile, default features", flush=True)
|
||||
with tempfile.TemporaryDirectory(prefix="studio-catalog-provider-") as target:
|
||||
subprocess.run(["cargo", "test", "--locked", "--offline", "--target-dir", target,
|
||||
"-p", "prometeu-vm", "--test", "numeric_contract",
|
||||
"exported_artifacts_match_the_single_runtime_catalog", "--", "--exact"],
|
||||
cwd=runtime, check=True)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user