2.9 KiB
2.9 KiB
Runtime Values, Identity, and Memory Boundaries
Original Problem
PBS needed a consistent user-visible runtime model for:
- which values carry identity,
- which values are copied payload,
- where ownership changes at host boundaries,
- what the collector is allowed to assume,
- and which cost facts matter semantically.
Without that closure, later lowering and diagnostics would have to guess whether a construct implied allocation, aliasing, retention, or host-owned state.
Consolidated Decision
PBS keeps the runtime model intentionally small and explicit.
The stable rules are:
- Scalars are copied values without user-visible identity.
- Structs are identity-bearing reference values.
- Services are canonical singleton identity-bearing values.
- Host-backed resources are identity-bearing on the PBS side even when authority remains host-owned.
optional,result, and tuples are carriers; they do not create identity of their own.- Contract values do not create a second identity separate from the underlying value.
- Host interaction is stack-only across the boundary.
- The GC and reachability model must preserve identity-bearing values and retained callback contexts.
- Cost visibility is semantic only where it changes reasoning:
- allocation-bearing versus non-allocation-bearing,
- retention-bearing versus non-retention-bearing,
- copy versus aliasing,
- host-boundary crossing,
- and trap possibility.
Final Model
The runtime contract is qualitative, not byte-accounting-driven.
PBS does not promise:
- exact byte counts,
- one exact heap layout,
- or one exact collector schedule.
It does promise the semantic facts that maintenance tooling and humans need:
- whether aliasing is preserved,
- whether retention exists,
- whether a construct may allocate,
- and whether a boundary crossing is happening.
Practical Consequences
bind(context, fn_name)is the main retention-bearing primitive in the current surface.- Carrier constructs are not allocation-bearing by themselves.
- Host memory authority remains on the host side even when PBS models the value as identity-bearing.
- Lifetime-control surfaces beyond the current line remain future-profile work, not silently implied support.
Common Pitfalls
- Treating carriers like
optionalorresultas if they created fresh identity. - Assuming stack-only host crossing means host ownership disappears.
- Confusing qualitative cost guarantees with exact runtime budgeting.
- Treating future lifetime-control or concurrency surfaces as part of
core-v1by implication.
Source Decisions
Value Representation and Identity Decision.mdHost Memory Boundary Decision.mdGC and Reachability Decision.mdAllocation and Cost Visibility Decision.mdLifetime Control and Future Profiles Decision.mdDynamic Semantics - Execution Model Decision.mdDynamic Semantics - Branch Selection Decision.mdDynamic Semantics - Effect Surfaces Decision.md