Practical guide
Preserve compatible state across reload
Design package state so transactional reload can validate a replacement VM and retain only version-compatible host-owned settings.
Procedure
- Keep durable settings in the manifest-declared settings schema instead of hidden globals.
- Declare a settings schema version and provide defaults for every field.
- Implement validate, initialize, suspend, and shutdown callbacks with bounded work and no owner mutation.
- Request reload through the compiled recovery action at a frame boundary.
- If validation fails, inspect diagnostics while the prior VM and composition graph remain active.
Example
function validate_package()
assert(package_info.id == "worldforge.resource-counts")
assert(type(settings.enabled) == "boolean")
end
function initialize_package()
initialized = true
end
function suspend_package()
assert(initialized)
end
function shutdown_package()
initialized = false
end
Constraints and recovery
- Lua globals belong to one VM generation and are not a persistence format.
- The host rejects stale-generation actions after a successful reload.
- A failed candidate never replaces the live VM, provider graph, or compatible settings.
Related symbols
lifecycle.validatelifecycle.initializelifecycle.suspendlifecycle.shutdownui.action.packages.reloaderror.package-reload