Skip to content

Internals Runtime

Stefan Crkvenjakov edited this page Oct 7, 2026 · 1 revision

Runtime internals

Framework Internals · Developer guide

RuntimeLoader obtains active InstalledPackage models and RuntimeCreator creates an IRuntime state object for each executable package. RuntimeOrchestrator indexes runtimes by package name, installs its runPackage callback on the executor, validates all entry points/version bounds/manifest dependency targets, and performs a graph cycle check before running package code.

RuntimeExecutor's run() loads main.php through ObjectHandler, activates package context, injects shared/passable registries and dispatcher, then calls prepareAPI() and executeAPI(). Initialization assigns API metadata and resets flags/waits. prepareAPI invokes environmentSetup(), captures state, resolves waits, calls setup(), captures again, and resolves waits again. main execution installs the VFS context responder, calls main(), captures state, registers passable/router output, then recursively executes links.

The linker creates new Runtime state for each linked component using the same package, root and dispatcher. This keeps child flags/waits separate. Links are checked through realpath for package-root containment; an active path stack detects link recursion. After a child returns, context and injection are restored to the parent. Nested dependency execution uses local API/runtime variables so executor state is not overwritten accidentally.

Orchestrator package states change to RUNNING before dependencies, EXECUTED after executor success, STOPPED on Throwable; stack cleanup happens in finally. Already loaded packages are skipped. Missing, disabled, incompatible or circular targets fail before/while scheduling rather than retrying PACKAGE_MAX_LOAD_TRY times. RuntimeFlagHandler accepts only native ERuntimeFlags and deduplicates by case name.

The legacy phased executor methods setRuntime()/initRuntime()/setupEnvironment()/setup()/execute() remain public, alongside run()/prepareAPI()/executeAPI(). Normal bootstrap uses the latter flow. Capability interfaces describe router/controller/linker roles, but actual executor enforcement is stronger for linkers and routers than for the descriptive access/controller/command flags.

Component reference

Clone this wiki locally