feat(studio): integrate memcard persistence and headless controls
Test / Tests and coverage
Intrepid/Prometeu/Studio/pipeline/pr-master This commit looks good

Persist cartridge identity and slot configuration, add MemcardBoot and the MemcardBuffer SDK, and consume the runtime's negotiated memcard host controls with protected teardown.

Qualify save/reopen and version upgrades through distinct configured runtime processes. Include specs, examples, regression evidence and the consolidated discussion lesson.
This commit is contained in:
2026-10-30 11:01:02 +00:00
parent 3a3417eb44
commit 1d8b8c2101
110 changed files with 6502 additions and 85 deletions
@@ -113,8 +113,8 @@ requires relocating every PUSH_CONST index; changing only the table is invalid.
Roles are None 0, BeforePause 1, BeforeResume 2 and MemcardBoot 3. Nonzero roles
are unique, cannot target entry zero and cannot capture. Pause/resume have empty
signatures; MemcardBoot has `(Int64) -> Int32`. This metadata does not implement
frontend hook selection, mem.bootstrap gating or persistence.
signatures; MemcardBoot has `(Int64) -> Int32`. Frontend-owned role selection and neutral common bootstrap assembly implement
the producer boundary; runtime owns persistence and admission.
Implementations are unique per Struct/Trait pair, complete and ordered. Each
method target has an exact signature with a concrete Struct receiver first,
@@ -286,4 +286,24 @@ Common emission validates unique nonzero roles, empty pause/resume signatures
and capture lists, and final hook FunctionIds other than zero. The ordinary
entry and synthetic Init/Frame assembly keep role None. Calling a hook as an
ordinary function does not request an OS transition. PBS marker syntax belongs
to its frontend; MemcardBoot selection/bootstrap is a separate producer scope.
to its frontend. MemcardBoot uses a typed role and an explicit neutral bootstrap
request, specified below.
## Neutral host bootstrap requests
IRLifecycleFileDeclaration and IRLifecycleDeclaration carry ordered serializable
bootstrapCalls, each ordinary HostCallMetadata (module/name/version/argSlots/retSlots).
Empty requests preserve the existing lifecycle. Aggregation preserves requests
and deduplicates identical boundaries from repeated file contributions. Frontends
MUST request a zero-argument boundary explicitly; the assembler MUST NOT inspect
language syntax/names. It emits CALL_HOST and discards each result after ordered
module/project initialization, before setting the boot guard and invoking Frame.
Requests that require operands from initializer stacks MUST fail validation.
The memcard producer requests mem.bootstrap@1, 0→1. Its role 3 target and callees
are external-entry retention roots. Production project validation requires coherent
slots 1..64, capability memcard, unique role 3 and the boundary before launch.
This is distinct from a direct CALL to the hook. Host storage and headless transport
remain runtime-owned and absent from the common IR. See the PBS
[producer contract](<../compiler-languages/pbs/26. Memcard Bootstrap and SDK Specification.md>).