Files
Library/docs/roadmap/platforms/DistributedApplications.md
T

153 lines
12 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# DistributedApplications platform plan — NEW reference compositions
Status: planning only; reference applications below are future artifacts, not runnable
applications in this checkout. All tasks PLANNED. Baseline
`f1f9ba375b22abf1adcc7c550ec21ac20895c0a4`, inspected 2026-11-24.
Authority: [requirements](../REQUIREMENTS.md) R-009–R-016;
[architecture](../ARCHITECTURE.md) C-01–C-14, especially C-12/C-14.
## Baseline and product boundary
Current [Net](../../../include/Void/Net/Http.hpp),
[Security](../../../include/Void/Security/Security.hpp) and
[ShortUrl V1](../../../include/Void/ShortUrl/ShortUrl.hpp) are individual building blocks.
They do not constitute a distributed platform. Source/graph metadata was checked; Net
Http.hpp gaps 112/115 were read directly. There is no distributed launcher, membership
operator, broker, replicated database or acceptance suite claimed at this baseline.
Proposed reference source under `examples/distributed/` and tests under
`tests/integration/distributed/` are NEW; names/targets are assigned only during implementation.
This platform composes [NetworkedApplications](NetworkedApplications.md)'s managed service
and [ReloadableApplications](ReloadableApplications.md)'s optional upgrade discipline with
RPC, Messaging, Discovery, Coordination, Replication and DistributedStorage. It owns startup,
readiness, operator workflows, fault scenarios and reference applications. It does not own
alternative consensus, storage, TLS, task or observability implementations. Linux is the
initial validation host; process/container orchestration is a test/deployment adapter,
not a hidden dependency of embedded libraries.
## Future reference applications and NEW composition API
Choose two bounded first applications: a three-node fixed-membership replicated KV service,
and an at-least-once durable worker queue backed by one replicated group. The KV example
exercises conditional batches, read policies, session dedup, snapshot/restart and backup;
the queue example exercises durable publish/ack, duplicate delivery, poison messages/DLQ
and consumer recovery. A distributed ShortUrl repository is a later optional integration
recipe and must preserve its frozen V1 interface. No arbitrary external service/account or
paid infrastructure is required to run the future loopback tests.
```cpp
// NEW illustrative platform composition; component types remain owner-defined.
struct NodeConfig {
ClusterId cluster; NodeId self; FixedVoterSet voters; BootstrapEndpoints peers;
StorageConfig data; NetServerPolicy transport; ResourceBudget resources;
};
class DistributedHost {
static Result<DistributedHost> compose(NodeConfig, InjectedResources);
Task<Result<Readiness>> start(OperationOptions);
Task<Result<void>> stop(OperationOptions);
};
```
The host retains owned services and borrows injected executor/clock/allocator only through
final join. Async owns operation options and scopes, Runtime owns managed resources, Service
owns lifecycle handles. Embedded applications can construct the same graph with supplied
resources and explicit startup. Configuration is an immutable validated snapshot; changing
voter lists is not hot-reload configuration. Local node identity, data directory, peer trust
mapping and static bootstrap endpoints are explicit. No global singleton starts a cluster.
## Startup, readiness and shutdown algorithm
1. Validate config/schema, fixed group identity, peer identities, directory ownership,
quotas and available backend capabilities. Missing trust material is a startup failure;
credentials are runtime inputs and never checked into examples or printed in diagnostics.
2. Create owned resources, open native Storage and recover protocol/application/snapshot
state. Verify application+dedup+applied index consistency before listeners accept work.
Expose an isolated administrative health interface only under explicit bind/auth policy.
3. Start authenticated peer RPC listener and static Discovery provider. Connect fixed peers;
run the Replication adapter and election. Discovery availability is not a quorum vote.
User listener may bind but rejects calls until the selected service's readiness gate.
4. KV readiness requires an available leader path, current-term committed barrier and local
recoverable application state; leader-only write readiness is distinct from follower
process liveness. Queue readiness additionally requires storage quota and consumer/queue
admission health. A follower can report healthy-but-not-write-ready. Consistent reads
still perform per-operation quorum confirmation; readiness is not a lease.
5. Publish services/endpoint hints after readiness. Start periodic snapshot/observation tasks
through owned scopes; optional coordination-backed Discovery starts only after the
replicated directory is ready and never replaces static Raft membership.
6. Stop external admission and readiness publication, finish or cancel client scopes, drain
mandatory durable actions, stop consumers and peer admission as appropriate, join all
replication/transport/snapshot tasks, then close storage and finally execution resources.
Default grace is 30 seconds; expiry reports incomplete stop while preserving owned state
until join. Do not destroy resources merely to make shutdown appear bounded.
## Operational decisions and failure matrix
Initial profile: three voters, one group/service, one data directory/node, no shared database
file, no automatic member replacement. Use explicit static cluster identity and per-node
authenticated TLS identity. Security authorization separates peer, client and administration
actions; a client cannot issue peer consensus messages. Certificates/trust policy are rotated
with overlapping validated trust generations and connection draining, never disabling checks.
Default platform budgets are the minimum of component limits, plus a host aggregate: 256 MiB
queued/stream payloads, two simultaneous snapshots, 16 active groups and 1,024 external calls.
Account storage caches/indexes separately in RSS; this is not a 256 MiB total-process promise.
| Scenario | Expected service/operational result | Acceptance evidence |
| --- | --- | --- |
| One of three nodes stops | Majority continues after election; no acknowledged state lost | Client history plus durable recovered state |
| Two of three unavailable | No new committed writes or consistent reads; stale reads only by explicit policy | Minority old-leader test |
| Apply committed, response lost | Same identity returns original result | Kill leader at apply/reply boundary |
| Slow/full/failed disk | Admission pressure or group fault; no pre-sync success | Fault port plus real filesystem pressure |
| Corrupt log/snapshot | Quarantine node/group; restore or rebuild under explicit procedure | Mutation/restart test and diagnostics |
| Poison work / worker crash after effect | Retry/DLQ; duplicate side effect possible without application dedup | Worker inbox/outbox demonstration |
| Discovery or metrics unavailable | Static peer transport remains usable; observation failures bounded; no quorum weakening | Disable optional adapters |
| Snapshot load / slow follower | Rate-limited catch-up; bounded queues and readable leader | Long-lag soak and RSS/disk metrics |
| Rolling binary/schema mismatch | Refuse unsupported peer/command; operator halt before unsafe rollout | Mixed-version fixture matrix |
| Loss of quorum disks | Operator recovery into separately identified cluster; no automatic force-new-cluster | Recovery rehearsal and explicit data-loss report |
Metrics: term/role/quorum state, commit/applied lag, sync duration/errors, queue/DLQ depth,
admission rejection, cancellation, snapshot progress and disk headroom. Cap labels at
configured node/group/queue identities; no payloads, raw keys or bearer tokens. A diagnostic
bundle contains version/config fingerprints and sanitized histories, not credentials/data.
SLO profiles are chosen from measured workloads, with separate normal, failover and recovery
latency. Benchmark absence cannot be reported as a production reliability claim.
## Ordered platform backlog
| ID | Phase / dependencies | Scope and acceptance | Recommended role |
| --- | --- | --- | --- |
| P-DISTRIBUTED-01 | P0; baseline | Define future examples, deterministic failure histories and readiness states; no runnable artifact claim | astra_implementer |
| P-DISTRIBUTED-02 | P1; P-DISTRIBUTED-01, Runtime/Service/Async contracts | NEW host graph specification and fake component lifecycle tests; injected resources outlive join | astra_implementer |
| P-DISTRIBUTED-03 | P3; P-DISTRIBUTED-02, NetworkedApplications gate, RPC/Discovery | Single-node reference composition and authenticated peer fixture; bounded startup/rollback/shutdown | sol_implementer |
| P-DISTRIBUTED-04 | P4; P-DISTRIBUTED-03, Coordination/Replication/DistributedStorage single-group gates | Three-node KV reference and linearizability/crash histories; quorum reads and durable replies | astra_implementer |
| P-DISTRIBUTED-05 | P4; P-DISTRIBUTED-04, Messaging replicated queue gate | Worker queue reference, inbox/outbox and DLQ operations; at-least-once failure matrix passes | sol_implementer |
| P-DISTRIBUTED-06 | P4; P-DISTRIBUTED-04, snapshot/recovery gates | Backup/restore, trust rotation, mixed-version rollout and chaos tooling; restore rehearsals retain identities correctly | astra_implementer |
| P-DISTRIBUTED-07 | P4 later; P-DISTRIBUTED-06, DistributedStorage routing/movement gates | Range movement operations and optional replicated directory; ownership/freeze/crash evidence before scale claims | astra_implementer |
## Evidence, migration and release gate
CURRENT evidence is the root-recorded baseline build/tests in [VALIDATION](../VALIDATION.md),
not distributed feature evidence. No builds, benchmarks, fault tests or deployments ran
for this document. PROPOSED tests first run deterministic adapters, then three independent
processes with isolated ports/directories, controlled packet faults and kill/restart points.
Test harnesses collect complete operation histories including unknown outcomes, seeds and
fault timelines; acceptance checks linearizability, dedup, applied positions, durable replies,
resource bounds and shutdown. No future launcher command is advertised as presently usable.
Build/consumer gates follow [BUILD-AND-DISTRIBUTION](../BUILD-AND-DISTRIBUTION.md).
Use [PERFORMANCE](../PERFORMANCE.md) to record p50/p95/p99, throughput, allocations, peak
RSS/CPU, disk amplification/recovery, network traffic and build cost. Compare one/three/five
node profiles only after corresponding membership configurations are supported and verified.
Durability tests follow [SQLite's crash fault methodology](https://sqlite.org/atomiccommit.html#_testing_atomic_commit_behavior);
consensus safety follows the selected [Raft protocol](https://raft.github.io/raft.pdf), with
application-specific integration evidence still mandatory.
Rollout first verifies every node can read existing log/snapshot/application formats, then
deploys readers, then enables new commands only after all voters advertise support. Rollback
stops new command admission and requires old readers for everything already durable. Plugin
reload does not unload an in-use state-machine implementation: pin through active apply and
snapshot work, and migrate state only at a recoverable checkpoint. Majority-loss restoration,
voter changes and data-destructive repair are operator-authorized procedures, never automated
startup fallbacks. See [MIGRATION](../MIGRATION.md), [DELIVERY](../DELIVERY.md) and
[DEPENDENCIES](../DEPENDENCIES.md). A fresh independent integrated review and full affected
behavior checks precede any merge/release recommendation; documentation completion is not release.