feat(pbs): add explicit guest lifecycle hooks

This commit is contained in:
2026-10-28 09:12:48 +00:00
parent eb7d6a2398
commit 9504f4694a
41 changed files with 1209 additions and 24 deletions
@@ -229,7 +229,7 @@ For executable PBS frontends, PBS lowering MUST emit a typed `IRLifecycleDeclara
At frontend `IRBackend` emission time:
1. PBS MUST retain marker admission for `[Init]`, `[Frame]`, and `InitAllowed`,
1. PBS MUST retain marker admission for `[Init]`, `[Frame]`, `[BeforePause]`, `[BeforeResume]`, and `InitAllowed`,
2. PBS MUST emit typed references for:
- file-init fragments that include global materialization and non-project `[Init]`,
- the optional project-init callable, which is the `[Init]` colocated with `[Frame]`,
@@ -262,3 +262,20 @@ See [PBS generic contracts](../../../compiler/pbs/specs/generic-contracts.md).
Instantiate structs, free functions and owner-bound implementations within PBS before publishing executable descriptors. Registry receives concrete fields, signatures, bodies, capture groups and targets. Specialized free-function references use existing empty-environment Closure values; Fn remains structural. Preserve receiver identity, implementation zero, singletons, rooting, GC, ownership, evaluation/fault order and quotas. No generic Dynamic/boxing ABI, opcode, descriptor category or runtime instantiation engine is introduced.
See [Concrete generic structs and free functions](../../../compiler/pbs/specs/generic-structs-and-free-functions.md).
## Lowering optional runtime hook roles
Map BEFORE_PAUSE/BEFORE_RESUME to `IRRegistry.Role.BEFORE_PAUSE` (1) /
`BEFORE_RESUME` (2) in typed FunctionMetadata. Preserve the declaration/callable
identity, empty signature and capture list; no hidden receiver or parameter is
introduced. INIT/FRAME and ordinary functions retain role None (0). Function
names/exports/manifests are not role binding mechanisms. No MemcardBoot role is
inferred or emitted by these markers.
Each role target and its dependencies are externally entered retention roots,
even without source callers. Merge, lifecycle assembly, linking and optimization
MUST preserve bodies and metadata. Common code consumes neutral typed roles,
never PBS ASTs/names. The ordinary assembled entry remains physical FunctionId
zero; hook targets are nonzero after deterministic linking. Common Registry/PBX
validation and production runtime admission remain mandatory defenses.