5.9 KiB
Published Entrypoint, Synthetic Wrapper, and FRAME_RET Ownership Decision
Status: Accepted
Date: 2026-03-22
Related Agenda: docs/compiler/pbs/agendas/19.3. Published Entrypoint, Synthetic Wrapper, and FRAME_RET Ownership Agenda.md
Context
After closing globals and lifecycle semantics, PBS v1 still needed a precise publication contract for executable boot.
The remaining problem was no longer how initialization behaves in userland. It was how that behavior is published into the artifact and consumed by backend stages and runtime.
The open points were:
- whether the published entrypoint is still the user
frame()callable, - whether a synthetic wrapper becomes the true physical entrypoint,
- where
FRAME_RETmust live once lifecycle bootstrap exists, - whether
FrontendSpeccontinues to hold authority over entrypoint identity, - and whether
manifest.jsonremains part of entrypoint authority.
Important fixed inputs already existed:
[Frame]identifies the userland logical frame root,- module init and project init are already defined in lifecycle terms,
- boot is one-shot and fail-fast,
- and general backend specs already converge on entrypoint function index
0.
Decision
PBS adopts the following publication and ownership policy for executable boot in v1:
- The compiler publishes a synthetic wrapper as the physical executable entrypoint.
- The userland callable marked with
[Frame]remains the logical frame root of user code. - The synthetic wrapper is therefore the physical root, while
[Frame]remains the logical root. - The wrapper must contain:
- one-shot boot orchestration,
- the required init execution exactly once,
- invocation of the userland
[Frame]callable, - and the final
FRAME_RET.
FRAME_RETno longer belongs at the end of the userlandframe()body.FRAME_RETbelongs to the published wrapper.- The published wrapper must occupy physical entrypoint index
0.
Entrypoint Authority
PBS adopts the following authority model:
FrontendSpecno longer holds authority to decide which callable is the published entrypoint for PBS.- Entrypoint authority is owned exclusively by the PBS compiler.
- Source-derived lifecycle semantics determine the logical frame root.
- The compiler then publishes the physical wrapper that realizes that lifecycle contract.
- Backend handoff must therefore preserve the compiler-selected published wrapper as the effective entrypoint identity.
Manifest and Runtime Protocol
PBS adopts the following target protocol direction:
entrypointmust stop being part of the finalmanifest.jsoncontract.- Runtime boot must not depend on nominal entrypoint resolution from the manifest.
- Runtime boot must treat physical entrypoint index
0as protocol. - The compiler guarantees that the published wrapper occupies that index.
- Any temporary compatibility line with manifest-declared nominal entrypoint is transitional only and is not the target contract.
Exports Boundary
PBS adopts the following boundary for nominal exports:
- Nominal function exports may continue to exist in the emitted artifact.
- Those exports are no longer authoritative for loader or boot.
- Boot depends exclusively on the published physical entrypoint at index
0. - Nominal exports remain useful only for tooling, debug, introspection, and related non-boot concerns.
Rationale
This decision keeps logical user semantics and physical boot publication clearly separated.
That matters because:
- the user
frame()callable should remain the semantic root of frame logic, - the one-shot bootstrap sequence must still execute before normal frame work,
FRAME_RETshould mark the true end of the logical published frame,- and the compiler must be the single authority that turns source lifecycle into executable publication.
The decision also deliberately removes duplicated authority:
- not
FrontendSpec, - not manifest nominal metadata,
- and not PBX nominal exports are allowed to compete with the compiler-selected physical wrapper as boot authority.
Invariants
[Frame]remains the userland logical frame root.- The published wrapper remains the physical executable root.
FRAME_RETbelongs to the published wrapper.- Physical entrypoint index
0belongs to that wrapper. - Nominal exports are not boot authority.
- Entrypoint authority for PBS belongs to the compiler, not to
FrontendSpecor manifest metadata.
Explicit Non-Decisions
- This decision does not define the final IR encoding of the wrapper body.
- This decision does not define the detailed lowering mechanics of globals and lifecycle into IR.
- This decision does not define the runtime-side migration implementation plan in detail.
- This decision does not define the final diagnostics catalog for backend/runtime structural failures.
Spec Impact
This decision should feed at least:
docs/compiler/pbs/specs/9. Dynamic Semantics Specification.mddocs/compiler/pbs/specs/13. Lowering IRBackend Specification.mddocs/compiler/pbs/specs/7. Cartridge Manifest and Runtime Capabilities Specification.mddocs/compiler/general/specs/15. Bytecode and PBX Mapping Specification.mddocs/compiler/general/specs/20. IRBackend to IRVM Lowering Specification.md
It also requires explicit cross-domain propagation to:
../runtime/docs/runtime/agendas/025-cartridge-manifest-entrypoint-removal-and-runtime-protocol.md
Validation Notes
At minimum, validation for this decision should include:
- emitted artifact evidence that the published wrapper occupies function index
0; - conformance evidence that the userland
[Frame]callable is invoked by that wrapper rather than being published directly; - evidence that
FRAME_RETis emitted in the wrapper path; - evidence that nominal exports, when present, do not participate in boot authority;
- integration evidence that runtime boot aligns with the fixed physical entrypoint protocol.