Keep PBX at v0 and simplify Jenkins quality gate
Intrepid/Prometeu/Runtime/pipeline/pr-master There was a failure building this commit
Intrepid/Prometeu/Runtime/pipeline/pr-master There was a failure building this commit
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
//! Shared PBX v1 resource limits and structured validation failures.
|
||||
//! Shared PBX v0 resource limits and structured validation failures.
|
||||
//! Counters are deterministic; a failed reservation never changes usage.
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fmt;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! Strict PBX v1 envelope and Registry sections. No legacy fallback.
|
||||
//! Strict PBX v0 envelope and Registry sections. No legacy fallback.
|
||||
//! Envelope parsing is structural only: non-Registry sections and instructions
|
||||
//! must be validated by their consumers before an executable image is published.
|
||||
use crate::load_limits::{
|
||||
@@ -32,7 +32,7 @@ impl<'a> PbxEnvelope<'a> {
|
||||
if &bytes[..4] != b"PBX\0" {
|
||||
return Err(E::new(C::InvalidFormat, R::Magic));
|
||||
}
|
||||
if bytes[4..6] != [1, 0] {
|
||||
if bytes[4..6] != [0, 0] {
|
||||
return Err(E::new(C::UnsupportedFormat, R::Version));
|
||||
}
|
||||
if bytes[6] != 0 {
|
||||
@@ -314,14 +314,14 @@ impl<'a, 'b> Reader<'a, 'b> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Raw section input for a v1 envelope writer. Non-Registry section bytes must
|
||||
/// Raw section input for a v0 envelope writer. Non-Registry section bytes must
|
||||
/// come from their own validated writers; this API never invents defaults.
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct SectionData<'a> {
|
||||
pub kind: u32,
|
||||
pub bytes: &'a [u8],
|
||||
}
|
||||
/// Assemble strict v1 sections. The output buffer is charged to temporary load storage.
|
||||
/// Assemble strict v0 sections. The output buffer is charged to temporary load storage.
|
||||
pub fn encode_envelope(sections: &[SectionData<'_>], b: &mut LoadBudget) -> Result<Vec<u8>, E> {
|
||||
b.transaction(|b| {
|
||||
let mut by_kind = [None; 9];
|
||||
@@ -349,7 +349,7 @@ pub fn encode_envelope(sections: &[SectionData<'_>], b: &mut LoadBudget) -> Resu
|
||||
b.work(total)?;
|
||||
let mut out = b.vector(total, Q::TemporaryBytes)?;
|
||||
out.extend_from_slice(b"PBX\0");
|
||||
out.extend_from_slice(&[1, 0, 0, 0]);
|
||||
out.extend_from_slice(&[0, 0, 0, 0]);
|
||||
out.extend_from_slice(&(count as u32).to_le_bytes());
|
||||
out.extend_from_slice(&[0; 20]);
|
||||
let mut offset = directory_end;
|
||||
|
||||
@@ -6,7 +6,7 @@ use crate::load_limits::IdDomain;
|
||||
use crate::model::{ConstantPoolEntry, DebugInfo, Export, SyscallDecl};
|
||||
use std::cmp::Ordering;
|
||||
|
||||
/// Owned, bounded PBX v1 tables for the executable loader. This is not an
|
||||
/// Owned, bounded PBX v0 tables for the executable loader. This is not an
|
||||
/// executable image: bindings and instruction/type verification are still due.
|
||||
#[derive(Debug)]
|
||||
pub struct OwnedPbx {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//! Producer-side serialization of a complete typed module. This writer emits
|
||||
//! only v1; executable consumers still need bindings and code verification.
|
||||
//! only v0; executable consumers still need bindings and code verification.
|
||||
use super::*;
|
||||
use crate::load_limits::IdDomain;
|
||||
use crate::model::{ConstantPoolEntry, DebugInfo, Export, SyscallDecl};
|
||||
|
||||
+3
-3
@@ -172,7 +172,7 @@ fn hex(s: &str) -> Vec<u8> {
|
||||
// syscalls=168/4, types=172/10, implementations=182/4, captures=186/8. Total=194.
|
||||
fn minimal_bytes() -> Vec<u8> {
|
||||
hex("
|
||||
50 42 58 00 01 00 00 00 08 00 00 00
|
||||
50 42 58 00 00 00 00 00 08 00 00 00
|
||||
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
||||
00 00 00 00 80 00 00 00 04 00 00 00
|
||||
01 00 00 00 84 00 00 00 1e 00 00 00
|
||||
@@ -241,7 +241,7 @@ fn writer_matches_independent_minimal_envelope() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn owned_v1_decoder_accepts_independent_bytes_without_publishing_an_image() {
|
||||
fn owned_v0_decoder_accepts_independent_bytes_without_publishing_an_image() {
|
||||
let mut b = budget();
|
||||
let owned = OwnedPbx::parse(&minimal_bytes(), &mut b).unwrap();
|
||||
assert_eq!(owned.registry.declarations(), minimal_registry().declarations());
|
||||
@@ -536,7 +536,7 @@ fn every_truncated_envelope_is_rejected_without_panic() {
|
||||
fn envelope_mutations_have_typed_reasons() {
|
||||
for (offset, value, code, reason) in [
|
||||
(0, 0, LoadCode::InvalidFormat, LoadReason::Magic),
|
||||
(4, 0, LoadCode::UnsupportedFormat, LoadReason::Version),
|
||||
(4, 1, LoadCode::UnsupportedFormat, LoadReason::Version),
|
||||
(6, 1, LoadCode::InvalidFormat, LoadReason::Endianness),
|
||||
(7, 1, LoadCode::InvalidFormat, LoadReason::Reserved),
|
||||
(31, 1, LoadCode::InvalidFormat, LoadReason::Reserved),
|
||||
@@ -1,4 +1,4 @@
|
||||
//! PBX v1 publication: immutable metadata and shared payload, after bindings
|
||||
//! PBX v0 publication: immutable metadata and shared payload, after bindings
|
||||
//! and bounded whole-program verification. No public unchecked constructor.
|
||||
use crate::string_identity_index::Identity;
|
||||
use crate::{LoaderPatchError, VmInitError};
|
||||
|
||||
@@ -2485,7 +2485,7 @@ mod tests {
|
||||
let mut vm = VirtualMachine::default();
|
||||
let mut header = vec![0u8; 32];
|
||||
header[0..4].copy_from_slice(&prometeu_bytecode::PBX_MAGIC);
|
||||
header[4..6].copy_from_slice(&0u16.to_le_bytes()); // retired version
|
||||
header[4..6].copy_from_slice(&1u16.to_le_bytes()); // unsupported version
|
||||
|
||||
let res = vm.initialize(header);
|
||||
assert!(
|
||||
@@ -2494,11 +2494,11 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_loader_hardening_malformed_pbx_v1() {
|
||||
fn test_loader_hardening_malformed_pbx_v0() {
|
||||
let mut vm = VirtualMachine::default();
|
||||
let mut header = vec![0u8; 32];
|
||||
header[0..4].copy_from_slice(&prometeu_bytecode::PBX_MAGIC);
|
||||
header[4..6].copy_from_slice(&1u16.to_le_bytes());
|
||||
header[4..6].copy_from_slice(&0u16.to_le_bytes());
|
||||
header[8..12].copy_from_slice(&1u32.to_le_bytes()); // missing directory
|
||||
|
||||
let res = vm.initialize(header);
|
||||
|
||||
@@ -9,7 +9,7 @@ use prometeu_vm::{
|
||||
// Independent executable oracle: 32-byte header, eight directory entries,
|
||||
// payload at 128, one Bool import, one zero-slot HALT function; total 194.
|
||||
fn minimal() -> Vec<u8> {
|
||||
"50 42 58 00 01 00 00 00 08 00 00 00
|
||||
"50 42 58 00 00 00 00 00 08 00 00 00
|
||||
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
||||
00 00 00 00 80 00 00 00 04 00 00 00
|
||||
01 00 00 00 84 00 00 00 1e 00 00 00
|
||||
@@ -46,7 +46,7 @@ impl NativeInterface for Native {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn independent_v1_bytes_load_publish_and_execute_through_the_public_sealed_boundary() {
|
||||
fn independent_v0_bytes_load_publish_and_execute_through_the_public_sealed_boundary() {
|
||||
let bytes = minimal();
|
||||
assert_eq!(bytes.len(), 194);
|
||||
let mut load = LoadBudget::new(Default::default());
|
||||
@@ -64,7 +64,7 @@ fn independent_v1_bytes_load_publish_and_execute_through_the_public_sealed_bound
|
||||
#[test]
|
||||
fn single_violation_oracles_reject_before_image_publication_with_typed_context() {
|
||||
for (offset, replacement, code, reason, pc) in [
|
||||
(4, 0, LoadCode::UnsupportedFormat, LoadReason::Version, None),
|
||||
(4, 1, LoadCode::UnsupportedFormat, LoadReason::Version, None),
|
||||
(178, 0, LoadCode::UnsupportedFormat, LoadReason::Builtin, None),
|
||||
(162, 0xff, LoadCode::InvalidCode, LoadReason::UnknownOpcode, Some(0)),
|
||||
(162, 0x11, LoadCode::InvalidCode, LoadReason::StackUnderflow, Some(0)),
|
||||
|
||||
@@ -108,7 +108,7 @@ pub fn build_program() -> Vec<u8> {
|
||||
],
|
||||
}
|
||||
.serialize(&mut LoadBudget::new(Default::default()))
|
||||
.expect("bounded v1 program")
|
||||
.expect("bounded v0 program")
|
||||
}
|
||||
|
||||
pub fn manifest_json() -> Vec<u8> {
|
||||
|
||||
@@ -114,7 +114,7 @@ pub fn generate() -> Result<()> {
|
||||
syscalls: &syscalls,
|
||||
}
|
||||
.serialize(&mut LoadBudget::new(Default::default()))
|
||||
.expect("bounded v1 program");
|
||||
.expect("bounded v0 program");
|
||||
|
||||
let mut out_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||
out_dir.pop(); // pbxgen-stress
|
||||
|
||||
Reference in New Issue
Block a user