45. Replacing a procedure body while it runs
Note: This feature is planned and not available in
coax0. The syntax shown follows the Coax specification and may change before it's built. This is roadmap R26.
Nothing in coax0, metaverse/ or the iOS app reloads code today (chapter 19). R26 is the smallest useful experiment: on a restricted Mac host, replace the bodies of procedures whose exports, calling conventions, semantic profiles and layout fingerprints have not changed. It needs R1's interface identities and a defined quiet point in the host's lifecycle. It doesn't need plugins, self-hosting or owning containers. It has to show value before general state migration (chapter 46) is built.
What this chapter will cover
- What may change in a replacement and what must not.
- The safe point at which a replacement is admitted.
- The cases that are refused, and why refusing them is part of the feature.
- Measuring edit-to-visible-result on a real change.
Outline
- The resident host. Persistent storage and platform resources stay in the host, which is never reloaded. The iOS app's
host.calready owns the buffers Coax draws into. - Unchanged interfaces. A candidate library must match the running one's exports, calling conventions, semantic profiles and layout fingerprints.
- The safe point. Replacement happens only at an established quiet point, with no old frame on any stack.
- Refusals. A changed layout or export, an escaped callback or code pointer, an outstanding old frame and unsupported worker activity are each refused with a reason.
- Keeping the old table. The old callable table stays in place until the candidate validates and publishes.
- Measure it. Edit a controller or world procedure, and measure the time from saving the file to the changed result on screen.
- What stays out. Signed iOS builds don't load code. Replacement runs on a Mac.
The consumer and the gate
The consumer is a real controller or world change in a Metaverse realm on a Mac. The gate:
- Each refused case has a fixture that is refused with its reason.
- The old table survives a failed candidate.
- The measured edit-to-visible-result time is published, and it decides whether R27 goes ahead.
Done when
- R26 has shipped with the gate above.
- The chapter shows the refusal fixtures and the latency measurement as exact transcripts.
- The chapter's examples run under
check-examples.sh.
Dependencies
- R1 interface and layout identities.
- Chapter 19 for the hot-reload requirements and chapter 18 for versioned interfaces.