5.1 KiB
PR-6 — PBX Declared Syscalls Section (Load-Time Resolution Integration)
Briefing
Chapter 16 requires that cartridges declare required syscalls using canonical identities (module, name, version) and that these be resolved at load time before the VM begins execution.
Until now, resolution has existed only as an API (PR5.3.2). The PBX on-disk format currently does not carry declared syscalls, and the loader cannot enforce load-time resolution deterministically.
This PR introduces a minimal, production-grade PBX section for declared syscalls only and integrates it into the PBX load sequence.
Scope note (important):
- PBX contains program + syscall metadata only.
- Assets (
asset_table,preload, etc.) are explicitly out of scope for this PR and will be handled later viaasset.pa.
After this PR:
program.pbxcontains aSYSC(declared syscalls) section.- The PBX loader parses
SYSCand resolves identities at load time. - Load fails deterministically if resolution fails.
- The VM continues to execute
SYSCALL <id>only.
No backward compatibility. No fallback to external manifests in production.
Target
- Define a minimal PBX section for declared syscalls.
- Extend the PBX parser/loader to read this section.
- Integrate
resolve_program_syscalls()into PBX load. - Enforce load-time failure on unknown or unauthorized syscalls.
- Keep VM runtime strictly numeric.
PBX Section Format (Authoritative for This PR)
Add a new PBX chunk:
- Chunk ID:
SYSC
Binary layout:
u32 count
repeat count times:
u16 module_len
[module_len bytes UTF-8]
u16 name_len
[name_len bytes UTF-8]
u16 version
Rules:
- UTF-8 strings only.
- No string table in this PR (keep it minimal).
- This section is REQUIRED for PBX v0 after this PR.
- If absent → load error.
- Duplicate
(module,name,version)entries → load error.
Out of scope: Any asset-related metadata. Do not add ASSET_TABLE, PRELOAD, or anything similar to PBX in this PR.
Load Sequence (After PR-6)
-
Parse PBX header and TOC.
-
Parse
SYSCsection intoVec<SyscallIdentity>. -
Call:
resolve_program_syscalls(&declared, vm.capabilities) -
If resolution fails → abort load deterministically.
-
Store resolved syscalls inside VM (or a
LoadedProgramstruct). -
Start VM execution.
No runtime name resolution allowed.
Work Items
1) PBX Parser / Loader Extension
- Add support for
SYSCchunk in the PBX parser/loader. - Return
declared_syscalls: Vec<SyscallIdentity>as part ofProgramImage(or equivalent). - If
SYSCis missing → return load error.
2) Load-Time Resolver Integration
-
In the PBX load path:
- Parse declared syscalls.
- Resolve using
prometeu_hal::syscalls::resolve_program_syscalls. - Enforce capability checks at load time.
- If resolution fails → load fails (no runtime fallback).
-
Do NOT modify VM execution core beyond storing the resolved mapping.
3) VM State Storage
- Add or finalize storage for resolved syscalls (if not already present).
- VM must NOT use canonical strings at runtime.
- VM runtime continues to execute only numeric IDs.
4) Error Handling
PBX load must fail deterministically if:
- Unknown
(module,name,version). - Capability mismatch.
- Duplicate identities in
SYSC. SYSCchunk is missing.- Malformed
SYSCpayload (lengths/UTF-8).
Errors must be explicit and deterministic.
Acceptance Checklist
- PBX format supports
SYSCchunk. - Loader parses declared syscalls from PBX.
- Resolver runs during PBX load (before VM execution).
- Load fails on unknown syscall.
- Load fails on capability violation.
- Load fails when
SYSCchunk is missing. - No runtime name resolution exists.
cargo testpasses.
Tests
Add tests covering:
- Valid PBX with one syscall identity → loads successfully.
- PBX with unknown syscall identity → load error.
- PBX with capability violation → load error.
- PBX without
SYSCsection → load error. - PBX with duplicate identity entries → load error.
- PBX with malformed
SYSCpayload (bad lengths/invalid UTF-8) → load error.
Tests must construct minimal synthetic PBX images in-memory.
Do NOT rely on external files.
Junie Instructions
You MAY:
- Extend PBX parser/loader to support
SYSC. - Integrate the resolver into the PBX load path.
- Add deterministic tests for load-time resolution.
You MUST NOT:
- Add backward compatibility paths.
- Add fallback to JSON manifests.
- Add any asset-table or preload metadata to PBX.
- Change VM runtime dispatch logic.
- Modify syscall numeric IDs.
If PBX container format details (header/TOC/chunk reading) are unclear:
- STOP.
- Ask for clarification before inventing new unrelated chunk structures.
No assumptions beyond the SYSC layout defined above.
Definition of Done
After this PR:
- Syscall resolution is fully load-time for PBX.
- PBX is authoritative for declared syscalls.
- VM executes only numeric syscalls.
- No legacy or dev fallback exists in the production load path.
- No asset responsibilities are added to PBX.