258 lines
18 KiB
Markdown
258 lines
18 KiB
Markdown
# Reloadable applications reference-platform specification
|
||
|
||
Status: PLANNED platform and future runnable-host specification. No host, executable,
|
||
deployment configuration or feature code is implemented by this document. Baseline:
|
||
`f1f9ba375b22abf1adcc7c550ec21ac20895c0a4`, inspected 2026-11-24.
|
||
Requirements R-004, R-009, R-010 and R-013–R-016 apply.
|
||
[Architecture](../ARCHITECTURE.md) C-03–C-05, C-07, C-09, C-10, C-11 and C-14
|
||
defines the platform contract.
|
||
|
||
## Source baseline and composition boundary
|
||
|
||
Existing [PluginManager](../../../include/Void/Plugin/Manager.hpp) supports pinned
|
||
generations, transactional candidate validation and immutable-path replacement.
|
||
[Module.hpp](../../../include/Void/Plugin/Module.hpp) supplies C++ module descriptors
|
||
and lifecycle hooks; it is not a stable C-only interface.
|
||
[PluginServiceBinding](../../../include/Void/Service/PluginService.hpp) pins providers;
|
||
[ServiceRegistry](../../../include/Void/Service/Registry.hpp) still has borrowed require
|
||
and lock-held lifecycle gaps. [Fsm Machine](../../../include/Void/Fsm/Machine.hpp)
|
||
already serializes named application state but needs boundary/quiescence guarantees.
|
||
[Configuration Watch](../../../include/Void/Configuration/Watch.hpp) preserves parse
|
||
failures but publishes before its observer callback, so it is not a platform transaction.
|
||
|
||
[VersionStore.hpp](../../../include/Void/Update/VersionStore.hpp) explicitly separates
|
||
reversible activate/rollback from durable commit: the durable healthy-history event is
|
||
the commit marker, and later journal cleanup can fail after commitment. This boundary
|
||
must remain authoritative. Source paths were coverage-checked, with partial Plugin,
|
||
Service and Configuration declarations directly read. Existing
|
||
[reload-under-load](../../../tests/standalone/Plugin/HotReloadUnderLoad.cpp),
|
||
[replacement](../../../tests/standalone/Plugin/Manager.cpp),
|
||
[Fsm serialization](../../../tests/standalone/Fsm/Serialize.cpp), and
|
||
[configuration watch](../../../tests/standalone/Configuration/Watch.cpp) fixtures cover
|
||
ingredients; they do not prove a runnable reload platform exists.
|
||
|
||
The platform composes [Runtime](../subsystems/Runtime.md),
|
||
[Async](../modules/Async.md), [IO](../subsystems/IO.md),
|
||
[Service](../modules/Service.md), [Plugin](../modules/Plugin.md),
|
||
[Fsm](../modules/Fsm.md), [Configuration](../modules/Configuration.md),
|
||
[Update](../modules/Update.md), [Security](../modules/Security.md),
|
||
[Log](../modules/Log.md) and [Observability](../subsystems/Observability.md).
|
||
It owns ordering, host policy and operator experience, not alternate implementations
|
||
of their shared primitives. Optional process workers use [IPC](../subsystems/IPC.md).
|
||
Distributed membership/consensus is not a prerequisite for local reload.
|
||
|
||
## Future reference host and user journeys
|
||
|
||
NEW proposed application root: `examples/reloadable-host/`; NEW proposed target and
|
||
installed executable: `void-reloadable-host`. These are specification names only.
|
||
The host starts from an explicit trusted release directory/config path, validates a
|
||
release, creates Runtime resources, starts required services, restores boundary state,
|
||
then admits application calls. It never watches arbitrary directories or loads an
|
||
unverified library solely because its mtime changed.
|
||
|
||
The reference workload is a counter/workflow provider. Version A serves acquire/read/
|
||
increment and a cancellable delayed operation; version B changes internal layout and
|
||
migrates a versioned checkpoint while preserving durable counter operations. It exposes
|
||
both a same-toolchain C++ fixture and a separate stable C-table fixture. A client holds
|
||
an old read handle across replacement, while a delayed callback proves activity pinning.
|
||
Stateful increments use operation IDs and one authoritative state owner; the example
|
||
does not promise duplicate-free external effects from checkpointing alone.
|
||
|
||
Future local operator commands are inspect, validate-candidate, reload, health, drain,
|
||
shutdown and recover. They run through an authenticated local IPC control endpoint;
|
||
network exposure is disabled by default. Inspect reports active release/publication
|
||
epoch, readiness, retained generations, async pins, quiescence phase and last error
|
||
category without secrets. Reload returns a transaction ID and a phase-aware outcome.
|
||
Remote request cancellation can stop preparation but cannot undo publication or a
|
||
durable healthy commit. A lost reply is inspected by transaction ID before retry.
|
||
|
||
Future CLI examples below are PROPOSED syntax, not available commands:
|
||
|
||
```text
|
||
void-reloadable-host --release-root <owned-directory> --config <validated-file>
|
||
void-reloadable-host ctl inspect --endpoint <local-socket>
|
||
void-reloadable-host ctl reload --candidate <immutable-release-id> --deadline 30s
|
||
void-reloadable-host ctl recover --release-root <owned-directory>
|
||
```
|
||
|
||
Angle-bracket arguments denote application inputs in proposed documentation, not
|
||
unresolved implementation choices. Build/install/run prerequisites and target selection
|
||
will be added only when the reference target exists, following
|
||
[BUILD-AND-DISTRIBUTION](../BUILD-AND-DISTRIBUTION.md).
|
||
|
||
## NEW host generation and interfaces
|
||
|
||
Illustrative composition types, not library declarations:
|
||
|
||
```cpp
|
||
struct HostGeneration { // NEW platform-owned aggregate
|
||
ReleaseId release;
|
||
PublicationEpoch epoch;
|
||
ValidatedConfigurationView configuration;
|
||
ServiceRegistrySnapshot providers;
|
||
WorkflowCheckpointMetadata workflow;
|
||
std::vector<PluginGenerationLease> plugins;
|
||
};
|
||
// prepare_reload(candidate, Async::OperationOptions) -> Task<Result<PreparedReload>>;
|
||
// publish(PreparedReload&&, ExpectedEpoch) -> Result<PublicationEpoch>;
|
||
// inspect(transaction_id) -> ReloadOutcome; // includes durable commit state
|
||
```
|
||
|
||
Shared types belong to their module plans. HostGeneration is retained behind a single
|
||
publication pointer; its providers/configuration/plugin identities describe one epoch.
|
||
The Service-owned publication primitive is the publication authority for the host:
|
||
store HostGeneration/config views as part of that immutable registry generation and
|
||
derive manager/host acquisition from it. Do not separately swap PluginManager current,
|
||
Configuration current and the service table and call that atomic. Configuration exports
|
||
a prepared immutable view to this coordinator; its standalone controller is not another
|
||
publisher for the same host generation. A request captures one generation at admission.
|
||
|
||
Initial host supports one reload transaction at a time and one application process.
|
||
Required dependencies form a DAG; optional dependencies have explicit absence behavior.
|
||
ActivationPolicy Reloadable uses the protocol below; RestartRequired performs a supervised
|
||
stop/start with persisted application checkpoint; InstallerRequired returns an operator
|
||
action without executing a privileged installer. No mode silently escalates permissions.
|
||
|
||
## Candidate-to-commit dataflow
|
||
|
||
1. **Discover/verify.** Resolve an immutable release ID under the owned release root.
|
||
Update/Security verify the signed manifest and exact signed payload bytes before
|
||
parsing its schema. Validate path containment, hashes, ABI/application contracts,
|
||
dependency versions and retained-resource budgets. Existing StrictJson and frozen
|
||
ShortUrl V1 fixtures remain unchanged. A file watch only suggests a validation job.
|
||
2. **Prepare privately.** Create candidate module instances and configuration/resource
|
||
views in a private Service snapshot. No candidate accepts user requests or publishes
|
||
external writes. Validate startup/readiness prerequisites before interrupting the old
|
||
application. A module that cannot stage reversibly requires restart policy.
|
||
3. **Quiesce stateful owners.** Stop old-generation mutation admission, await admitted
|
||
writes and child scopes, and ask Fsm to checkpoint at a declared state boundary.
|
||
Existing read handles can remain valid if the provider declares snapshot-safe reads;
|
||
other old-handle calls return quiescing rather than entering a second writer. Stop
|
||
and join race losers, subscriptions and generation-owned activities as specified by
|
||
Async/Fsm/Plugin. A deadline retains ownership and fails the candidate safely.
|
||
4. **Restore/readiness.** Candidate validates checkpoint schema into private state,
|
||
prepares compatible persistent views, activates staged resources and reports readiness.
|
||
Readiness includes dependency health and a bounded synthetic operation; it is not
|
||
merely a successful factory call. Do not perform an irreversible persistent format
|
||
migration inside a reversible reload. Such a release requires an explicit migration
|
||
gate with separate backup/rollback policy.
|
||
5. **Activate reversibly and publish.** Persist the bounded versioned application
|
||
checkpoint to an immutable file using System's NEW durable replacement protocol,
|
||
with release/schema identity and checksum; sync its recovery dependencies before
|
||
recording its reference. Today's non-fsync `atomic_write` is insufficient. Call
|
||
VersionStore activation for the verified candidate to record the durable reversible
|
||
activation journal. Then publish one
|
||
preallocated host/Service generation after rechecking expected epoch. No fallible
|
||
plugin code or user callback runs under the publication guard. A failure before
|
||
publication rolls back VersionStore activation, disposes/joins the candidate and
|
||
resumes the old owner. Failed rollback/resume is degraded recovery, not success.
|
||
6. **Health window.** Observe required services and bounded synthetic checks for a default
|
||
10-second window. During this reversible window, admit snapshot-safe reads only;
|
||
queue no unbounded writes. Mutation requests receive retryable not-ready/quiescing.
|
||
This preserves the old checkpoint as a valid rollback continuation. A release that
|
||
requires writable probation needs a separately proven compatible shared-state protocol
|
||
before enabling it. On failure, republish the retained old generation, roll back the
|
||
reversible activation and resume old mutation admission after validation.
|
||
7. **Commit and reopen writes.** Commit through VersionStore's durable healthy event.
|
||
Once commitment is known durable, enable candidate mutations and retire old owners.
|
||
Failure/lost acknowledgement is resolved by VersionStore reconciliation/inspection
|
||
before choosing rollback. Cleanup failure after the healthy marker reports
|
||
committed-with-cleanup-error; never roll back as though the commit had not occurred.
|
||
8. **Reclaim.** Drain old external generation references and async activity pins. Run
|
||
deactivate/destruction/release outside locks and after plugin stacks return, then
|
||
unmap only if unload conformance is enabled. Retain stuck generations and refuse
|
||
further reload when budgets saturate. Process shutdown is a separate explicit choice.
|
||
|
||
This selected initial health policy trades brief write unavailability for deterministic
|
||
rollback. The platform does not claim zero write downtime. Read continuity and delayed
|
||
old-handle completion are measured independently.
|
||
|
||
## Failure matrix and recovery
|
||
|
||
| Failure point | Active ownership / required outcome |
|
||
| --- | --- |
|
||
| Manifest/ABI/dependency/config rejection | Old generation unchanged; candidate never activated publicly |
|
||
| Quiescence timeout | Old/candidate owners retained; resume old admission only after confirming safe ownership; report phase |
|
||
| Restore/readiness failure | Dispose and join candidate; restore old mutation gate; no new publication |
|
||
| Activation journal written, crash before registry swap | On startup VersionStore reconcile chooses prior healthy release; no in-memory generation survives crash |
|
||
| Published during reversible read-only health window, crash | Reconcile uncommitted activation to prior healthy release/checkpoint |
|
||
| Health failure before healthy marker | Publish retained old state and roll back activation; no new writes admitted |
|
||
| Commit acknowledgement lost | Inspect/reconcile durable healthy event; classify unknown until resolved |
|
||
| Healthy marker durable, cleanup fails | Candidate remains committed; retry cleanup; preserve marker and report cleanup error |
|
||
| Old plugin activity never ends | Keep mapping/owner; report retained pins; reject reload beyond retention cap |
|
||
|
||
On first bootstrap with no prior healthy release, failed candidate health leaves
|
||
admission closed, joins the candidate and enters diagnostic/not-ready mode. Recovery
|
||
never invents a previous release or labels an unvalidated candidate healthy.
|
||
|
||
Host transaction metadata persists release/transaction identity, activation phase and
|
||
checkpoint reference through Update-owned durable facilities. It never introduces a
|
||
second independent commit marker that can disagree with VersionStore. Crash recovery
|
||
validates checkpoint/release compatibility before opening listeners. Candidate checkpoints
|
||
are versioned and bounded; credentials/configuration secrets are not dumped into them by
|
||
default. Recovery failure starts diagnostic/not-ready mode without user mutation admission.
|
||
|
||
## Limits, security and performance
|
||
|
||
Platform defaults: 64 modules, 256 services, four retained generations/module, one reload
|
||
transaction, 4 MiB checkpoint/module, 32 MiB aggregate checkpoint bytes, 64 MiB total
|
||
candidate images and 256 MiB owned runtime dynamic budget. All candidate/retired resources
|
||
share global permits as well as local module caps. Image bytes, stacks/kernel buffers,
|
||
external application state and RSS are reported separately. Control endpoint defaults
|
||
to 16 sessions, 64 KiB requests and 32 in-flight operations; reload admission rejects a
|
||
second transaction with busy. Phase limits fit a default 30-second total Async deadline;
|
||
cleanup retains resources beyond expiry when safety requires it.
|
||
|
||
Native module compositions are selected; preserve current OpenSSL/libsodium primitives
|
||
through Security/Update and existing same-toolchain plugin support. Stable C ABI is an
|
||
opt-in separate path. A native plugin is trusted code; signatures establish authorized
|
||
origin, not memory isolation. Optional isolated workers use IPC/System with explicit
|
||
restart/effect semantics and narrower exposed capabilities. Diagnostics use bounded,
|
||
redacted logs/metrics with transaction correlation, not unbounded plugin names as labels.
|
||
|
||
Measure reload/ready/quiescence/commit p50/p95/p99, read throughput during replacement,
|
||
write-unavailable duration, allocations, retained pins, peak RSS/CPU and complete host
|
||
build cost under [PERFORMANCE](../PERFORMANCE.md). Test slow callbacks and memory pressure;
|
||
do not infer platform latency from an uncontended PluginManager test. No host benchmarks
|
||
or deployment checks ran for this plan.
|
||
|
||
## Ordered implementation backlog
|
||
|
||
All rows are PLANNED; none authorizes building the host in this documentation task.
|
||
|
||
| ID | Phase / depends on | Intended scope | Acceptance / recommended role |
|
||
| --- | --- | --- | --- |
|
||
| P-RELOADABLE-01 | P0 / current Plugin/Service/Fsm/Update source | Freeze source-based fixture matrix, release/health/rollback state diagram and isolated-consumer baseline | Existing C++ versus NEW C ABI and Update commit boundary are independently testable / astra_planner |
|
||
| P-RELOADABLE-02 | P2 / P-RELOADABLE-01; Async/IO/Runtime, Service owning snapshots and Configuration prepare gates | Host-generation composition and lifecycle coordinator with fake modules | Failed prepare publishes nothing; readers acquire one coherent epoch; no user callback under locks / astra_implementer |
|
||
| P-RELOADABLE-03 | P3 / P-RELOADABLE-02; Plugin C ABI/activity pins and Fsm checkpoint gates | Future reference host, counter/workflow A/B fixtures and local IPC controls | C++/C fixture migration, old read handle and delayed operation survive replacement without unmap / sol_implementer |
|
||
| P-RELOADABLE-04 | P3 / P-RELOADABLE-03; Update durable activation/reconciliation gate | Signed candidate lifecycle, reversible read-only health window, healthy commit and crash recovery | Crash matrix obeys one durable commit marker; precommit health failure loses no admitted writes / astra_implementer |
|
||
| P-RELOADABLE-05 | P3 / P-RELOADABLE-04; validation/profile harness | Failure injection, sustained reload/load, retained-resource limits, runbook and package examples | Uncooperative plugin remains pinned; budget saturation rejects reload; measured downtime/RSS reported / astra_implementer |
|
||
| P-RELOADABLE-06 | P4 / P-RELOADABLE-05; IPC worker-isolation gate | Optional supervised out-of-process provider composition | Worker crash yields explicit unknown effects and restart policy; no claim of distributed/exactly-once reload / astra_implementer |
|
||
|
||
## Validation and migration evidence gates
|
||
|
||
CURRENT ingredient tests can be invoked with
|
||
`ctest --test-dir /tmp/voidlibrary-discovery-f1f9ba3 --output-on-failure --timeout 60`;
|
||
not rerun here. The inherited build/test observations in [VALIDATION](../VALIDATION.md)
|
||
are not host acceptance evidence. PROPOSED checks require the future application and
|
||
fixtures: continuous readers and operations during A→B, cancelled delayed callbacks,
|
||
writer quiescence, failed schema/ABI/readiness, lost commit acknowledgement, killed host
|
||
at each matrix boundary, failed journal cleanup after commit, invalid config during
|
||
reload, stuck generation pins, endpoint authorization and repeated shutdown under load.
|
||
Persist expected counter operation IDs and compare recovery state after every crash.
|
||
|
||
Proposed build template, only after the NEW target is implemented and configured with
|
||
its dependencies: `cmake --build <configured-build-dir> --target void-reloadable-host`.
|
||
This is not a current command result. Add isolated package/ABI consumers and documented
|
||
manual recovery drills under [BUILD-AND-DISTRIBUTION](../BUILD-AND-DISTRIBUTION.md).
|
||
|
||
Migration initially wraps existing PluginManager and IModule without changing their
|
||
symbols; explicit host staging is opt-in. Legacy plugins lacking async pin/quiescence
|
||
evidence remain restart-required with dlclose disabled. Persistent state upgrades keep
|
||
old readers/checkpoints until verified; incompatible destructive migrations require a
|
||
separate release plan. Preserve [ShortUrl V1](../../short-url.md), exact signed payload
|
||
bytes and Update healthy markers throughout. Rollback after committed new writes is
|
||
another compatible release/recovery action, never an automatic pointer reversal.
|
||
See [MIGRATION](../MIGRATION.md), [DEPENDENCIES](../DEPENDENCIES.md),
|
||
[DELIVERY](../DELIVERY.md), and [DOCUMENTATION](../DOCUMENTATION.md).
|