193 lines
14 KiB
Markdown
193 lines
14 KiB
Markdown
# Update — verified releases and recoverable activation
|
||
|
||
Status: plan; all feature tasks PLANNED. Baseline `f1f9ba375b22abf1adcc7c550ec21ac20895c0a4`.
|
||
R-010/R-015 and [C-02–C-07/C-09/C-10](../ARCHITECTURE.md) govern this module.
|
||
|
||
## Existing source and protected behavior
|
||
|
||
[Feed.hpp](../../../include/Void/Update/Feed.hpp) defines `Void::Update::Feed`, `Release`,
|
||
`VerificationPolicy`, `VerifiedFeed`, `VerifiedEnvelope`, component catalog/release types,
|
||
verification/parsing functions and selection. Defaults cap envelopes at 5 MiB, payloads at
|
||
4 MiB and releases at 10,000; replay floor and injected current time are already policy
|
||
inputs. [Feed.cpp](../../../src/Update/Feed.cpp) verifies Ed25519 signatures over decoded
|
||
payload bytes and retains those bytes as `signedPayload`. Component-set validation and
|
||
greatest-compatible-version selection are existing capabilities.
|
||
|
||
Important baseline distinction: Feed.cpp includes general `Void::Json` from
|
||
[Json.hpp](../../../include/Void/Data/Json.hpp), not
|
||
[StrictJson.hpp](../../../include/Void/Data/StrictJson.hpp). The latter has a separate
|
||
restricted representation/profile. Schema-3 readable-document equality currently parses
|
||
the signed payload before the signature call; `verifyFeedEnvelope` parses the feed schema
|
||
after `verifyEnvelope`. The target verify-before-schema rule is therefore an explicit
|
||
hardening task, not a claim that every current envelope path already follows that order.
|
||
Do not broaden StrictJson or silently change legacy accepted documents when modernizing Data.
|
||
|
||
[VersionStore.hpp](../../../include/Void/Update/VersionStore.hpp) and
|
||
[VersionStore.cpp](../../../src/Update/VersionStore.cpp) implement prepare/publish/activate,
|
||
commit/rollback/reconcile, external lifecycle health recording and retention. Candidate
|
||
activation is reversible until a durable healthy-history marker newer than the activation
|
||
journal baseline commits it. `commit` rechecks marker evidence after an apparent write/sync
|
||
failure. After that point journal cleanup is idempotent maintenance; `rollback` finalizes a
|
||
committed candidate instead of undoing it. Preserve these exact semantics.
|
||
|
||
[Update tests](../../../tests/standalone/Update/Update.cpp) cover signatures/replay/selection,
|
||
readable envelopes, component sets, idempotent commit, durable marker reconciliation,
|
||
external lifecycle recording, health-order/prune behavior and unsafe filesystem layouts.
|
||
[module.cmake](../../../src/Update/module.cmake) depends on Crypto, Data, Functional, System
|
||
and Text. The module is not currently a complete transport/download/orchestrator service.
|
||
|
||
## Chosen composition and NEW interfaces
|
||
|
||
Keep native release-selection/workflow logic and existing cryptographic implementations
|
||
from [Crypto](Crypto.md)/[Security](Security.md). OpenSSL/libsodium remain the initial
|
||
primitives; Update does not write its own signature algorithm. Net handles transport,
|
||
Archive handles bounded package extraction, Plugin/Service handle live candidate lifetimes,
|
||
and VersionStore owns durable activation. Runtime/Fsm adapters are optional composition
|
||
layers, so parsing and store operations remain usable in an embedded application.
|
||
|
||
NEW illustrative Update-owned orchestration API:
|
||
|
||
```cpp
|
||
enum class InstallState {
|
||
Verified, Downloading, Staged, Published, Activated, HealthyCommitted,
|
||
CleanupPending, RolledBack, RecoveryRequired
|
||
};
|
||
struct InstallReceipt { InstallId id; InstallState state; ReleaseIdentity release; };
|
||
struct InstallOptions; // admission limits plus Async operation options
|
||
class InstallSession; // owns candidate, staging, callbacks and progress
|
||
Result<InstallSession> plan_install(VerifiedSelection, InstallOptions);
|
||
// async run/stop/status adapters use Async-owned task/operation contracts
|
||
```
|
||
|
||
All names in this sketch beyond existing types are NEW, including VerifiedSelection and
|
||
ReleaseIdentity. VerifiedSelection retains the original verified envelope bytes, signer
|
||
identity, selected component dependency set, artifact digest/size and policy decision.
|
||
It cannot be constructed from an arbitrary caller string pretending to be verified. The
|
||
public unsigned parsers remain clearly named structural tools and never confer trust.
|
||
|
||
## Verification, selection and installation dataflow
|
||
|
||
1. Snapshot explicit trust keys, channel/platform/ABI constraints, clock and policy at
|
||
admission. Fetch within Net's total deadline and bounded response size. Outer envelope
|
||
parsing is bounded and only extracts schema/key/encoded payload/signature; decode exactly
|
||
once, retain the decoded bytes, and verify their signature before payload schema parsing
|
||
or readable-document comparison. No reserialization or whitespace normalization is
|
||
substituted for those signed bytes.
|
||
2. Select the Data-owned versioned parsing policy for that envelope schema. Pin the accepted
|
||
legacy behavior with golden signed fixtures; general JSON improvements cannot silently
|
||
enlarge it. StrictJson's numeric/duplicate/depth rules remain unchanged. New strict-profile
|
||
schemas must explicitly declare their representation and compatibility in M-UPDATE-02;
|
||
migration of legacy documents requires a separate schema version if the existing corpus
|
||
cannot be preserved. This gate cannot be bypassed by switching parser aliases globally.
|
||
3. Validate expiry, monotonic feed sequence, platform/toolchain/ABI and component dependency
|
||
closure before downloading artifacts. Persist a high-water sequence per configured feed
|
||
identity/channel using atomic file replacement and directory sync before accepting a
|
||
lower sequence on any later restart. Key rotation does not reset that floor. Valid but
|
||
unusable releases may advance the verified-feed floor; retain their signed metadata so
|
||
the same verified selection can resume. Explicit rollback to an already known healthy
|
||
local version is a separate operator action, not acceptance of a replayed feed.
|
||
4. Stream artifacts to an exclusive staging area while checking actual size and incremental
|
||
digest. Require exact final size/digest. A resumable download is accepted only after a
|
||
server identity/validator match and final whole-artifact digest verification; default is
|
||
restart into a new temporary file. Redirects follow Net's credential/origin policy.
|
||
5. Extract using [Archive](Archive.md)'s safe staging workflow and validate the release
|
||
manifest/ABI/component inventory. Publishing immutable version directories is distinct
|
||
from activation. Do not substitute a tar filename for authenticated artifact identity.
|
||
6. An explicit lifecycle owner activates the candidate, waits for bounded readiness/health,
|
||
then calls the existing VersionStore commit path (internal activation) or `recordHealthy`
|
||
(external activation). These modes remain separate; external health recording cannot
|
||
implicitly commit an internal activation journal. [ReloadableApplications](../platforms/ReloadableApplications.md)
|
||
owns generation publication and quiescence; acquired old handles keep their pins.
|
||
7. Report HealthyCommitted only after the durable marker. Cleanup/prune failures become
|
||
CleanupPending with diagnostics and retry state, never an invitation to rollback.
|
||
|
||
TLS trust-chain and peer-host checks remain enabled in transport. SNI alone does not verify
|
||
the expected peer, as the [OpenSSL 3.5 client guide](https://docs.openssl.org/3.5/man7/ossl-guide-tls-client-block/)
|
||
explains. Network trust does not replace signed release verification. Diagnostics/progress
|
||
must omit keys, authorization headers and artifact contents.
|
||
|
||
## Failure, cancellation and recovery semantics
|
||
|
||
Before activation, failure leaves the active version unchanged and cleans only owned staging.
|
||
During reversible activation, readiness failure requests stop, joins candidate work, then
|
||
rolls back through VersionStore. Cancellation after the durable healthy marker reports the
|
||
committed state and stops only optional cleanup. A lost acknowledgement or failed sync can
|
||
be Unknown; run `reconcile` and inspect durable health/journal evidence before choosing the
|
||
next action. A caller must not convert every error into a rollback command.
|
||
|
||
One coordinator per store serializes workflow transitions; filesystem mutation still uses
|
||
VersionStore's locking. Network work and user health/lifecycle callbacks execute outside
|
||
store/configuration locks. Progress subscriptions snapshot owning events; unsubscribe stops
|
||
future admissions and has a separate drain boundary. Shutdown rejects new sessions, cancels
|
||
downloads, joins extraction/candidate work and reconciles any transition already entered.
|
||
No forced plugin unload or asynchronous use of destroyed staging paths is allowed.
|
||
|
||
Restart reads the operation journal, immutable publication identity, activation journal and
|
||
healthy history. A journal is versioned/checksummed and written before its dependent side
|
||
effect where compensation requires it; it references existing VersionStore evidence instead
|
||
of declaring another activation commit point. Unknown or mismatched records stop automation
|
||
with RecoveryRequired. Corrupt metadata is not discarded to make an update appear successful.
|
||
Retain active, pending candidate, previous candidate and pinned plugin generations; retention
|
||
must respect both durable store protection and external live-generation pins.
|
||
|
||
Trust changes are explicit configuration operations: bootstrap keys come from the application,
|
||
rotation requires an authenticated old-trust transition or an operator-approved replacement,
|
||
and removal/revocation invalidates future selections without rewriting historical signed bytes.
|
||
Expiry is a civil-time policy with an injected clock; time rollback cannot lower the stored
|
||
sequence floor. Update does not invent a network time authority.
|
||
|
||
## Defaults and operation budgets
|
||
|
||
Keep existing envelope/payload/release limits. NEW defaults: one active install per store,
|
||
eight queued selections, two concurrent artifact downloads, 512 MiB per compressed artifact,
|
||
2 GiB staging quota, 32 components and 256 dependency edges per transaction. Package
|
||
extraction retains Archive's absolute limits and additionally obeys the session quota.
|
||
Reserve disk headroom for candidate plus previous healthy content before admission; do not
|
||
delete the rollback version to make an unverified candidate fit.
|
||
|
||
The default install deadline is ten minutes including admission, download and activation,
|
||
with a 30-second readiness phase bounded by the remaining total time. Use a one-second
|
||
health probe interval and require three consecutive ready responses in the reference
|
||
workflow; applications can replace that health policy explicitly. Health callbacks are
|
||
cooperative owned work, not forcefully killed code. Retain two previous healthy versions
|
||
by default, subject to pins and space diagnostics; bounded cleanup batches process at most
|
||
16 publications per pass. A pin preventing cleanup reports pressure rather than being broken.
|
||
|
||
## Ordered implementation tasks
|
||
|
||
| ID | Phase / dependencies | Scope and acceptance | Recommended role |
|
||
| --- | --- | --- | --- |
|
||
| M-UPDATE-01 | P0; current signed/store tests | Freeze exact-byte and durable-marker fixtures, including schema-3 verification order and cleanup failure; record baseline general-vs-strict parser boundary. | astra_implementer |
|
||
| M-UPDATE-02 | P1; M-UPDATE-01, Data profile owner, Crypto contract | Verify-before-payload-parse, pinned schema policy and durable replay floor; invalid signatures never trigger payload schema processing and legacy fixtures retain defined behavior. | astra_implementer |
|
||
| M-UPDATE-03 | P2; M-UPDATE-02, Net streaming/deadlines, Archive staging | Bounded download/verify/extract/publication session and resumability; wrong size/digest/path never reaches activation. | astra_implementer |
|
||
| M-UPDATE-04 | P2; M-UPDATE-03, Plugin/Service/Fsm lifecycle | Readiness, internal/external lifecycle adapters and operation journal; exactly one activation owner and no second commit marker. | astra_implementer |
|
||
| M-UPDATE-05 | P3; M-UPDATE-04, Runtime/Observability | Managed shutdown, retained-generation-aware pruning, trust operations and recovery status; committed cleanup failure is visible but not rollback-safe. | sol_implementer |
|
||
| M-UPDATE-06 | P3; M-UPDATE-05, Testing fault harness | Crash/race matrix and installed reference workflow; repeated reconcile is idempotent at every transition. | astra_implementer |
|
||
|
||
P4 rollout coordination uses [DistributedApplications](../platforms/DistributedApplications.md)
|
||
policy above Update; a fleet controller cannot override a host's exact-byte verification,
|
||
generation ownership or healthy commit semantics.
|
||
|
||
## Validation and migration
|
||
|
||
CURRENT TEMPLATE, with source-verified filters:
|
||
`<existing-build>/tests/VoidTests --filter '^(update_feed_.*|component_feed_.*|readable_component_.*|version_store_.*)$'`.
|
||
The actual baseline and unrun checks are in [validation](../VALIDATION.md). PROPOSED after
|
||
M-UPDATE-02–06: mutate signed bytes while preserving equivalent JSON, invalid signature with
|
||
malformed payload, duplicate/oversized/deep fields under each declared profile, schema-3
|
||
mirror mismatch, replay after restart/key rotation, download redirect/partial/hash failure,
|
||
disk full, callback reentry, activation-time cancellation and crash at every health/journal
|
||
sync. Inject cleanup failure after commit and assert that rollback preserves the candidate.
|
||
|
||
Use [performance](../PERFORMANCE.md) for verify/select latency, streaming throughput, activation
|
||
p50/p95/p99, peak RSS/CPU/staging space and build cost; use common sample/confidence rules.
|
||
Report retained generations and failed installs, not only successful fast paths.
|
||
|
||
[Migration](../MIGRATION.md) preserves existing verification and VersionStore interfaces via
|
||
adapters. Store-journal upgrades are versioned and recover old records before admitting new
|
||
work; backup old metadata without erasing commit evidence. Unknown newer schemas are rejected.
|
||
Roll back candidate code only before its healthy commit, or perform a new explicit activation
|
||
of a known healthy version afterward. No automatic schema/data downgrade is implied.
|
||
Graph coverage was checked; partial Feed declarations/definitions and adjacent Json ranges
|
||
were read directly. These planned changes have not been built, fuzzed or crash-tested.
|