docs: add expansion roadmap and workflow baseline
This commit is contained in:
1 parent
f1f9ba375b
commit
faa8a5198d
65 files changed
+9292
No files matched your search
@@ -0,0 +1,244 @@
|
||||
# NetworkedApplications — bounded reference services and operations
|
||||
|
||||
Status: NEW platform composition plan; all tasks PLANNED. Baseline
|
||||
`f1f9ba375b22abf1adcc7c550ec21ac20895c0a4`. This document specifies future reference
|
||||
applications only; it creates no server, deployment, open port or runnable command.
|
||||
R-003/R-007/R-009/R-010/R-012 and [C-01–C-08/C-11/C-14](../ARCHITECTURE.md) apply.
|
||||
|
||||
## Existing pieces and composition boundary
|
||||
|
||||
The inspected repository already contains [Sqlite](../../../include/Void/Sqlite/Sqlite.hpp)
|
||||
RAII operations, [Log](../../../include/Void/Log/Log.hpp) facade/sinks,
|
||||
[Archive](../../../include/Void/Archive/Archive.hpp) extraction and
|
||||
[Update VersionStore](../../../include/Void/Update/VersionStore.hpp) activation primitives.
|
||||
They do not by themselves establish the startup, request ownership, durability or shutdown
|
||||
contract of a complete service. Their existing tests remain module evidence, not an
|
||||
end-to-end platform acceptance result. Native Storage and Observability are NEW designs.
|
||||
|
||||
The platform composes [Runtime](../subsystems/Runtime.md), [Async](../modules/Async.md),
|
||||
[IO](../subsystems/IO.md), [Net](../modules/Net.md), [Configuration](../modules/Configuration.md),
|
||||
[Service](../modules/Service.md), [Security](../modules/Security.md),
|
||||
[Storage](../subsystems/Storage.md), [Sqlite](../modules/Sqlite.md),
|
||||
[Log](../modules/Log.md) and [Observability](../subsystems/Observability.md).
|
||||
It owns wiring, reference domain workflows, lifecycle policy and operational acceptance.
|
||||
It does not own a second executor, HTTP parser, TLS engine, database, logger or error type.
|
||||
Optional RPC/jobs use their existing plan owners, and no foundation imports this platform.
|
||||
|
||||
Choose Void-owned native protocol/IO paths when their conformance gates pass. Preserve
|
||||
the existing Boost-based paths behind documented adapters during migration; do not replace
|
||||
them merely to declare the platform native. IO owns level-triggered epoll/nonblocking sockets
|
||||
and bounded file workers under C-06, Net owns protocol/session reuse, and OpenSSL supplies
|
||||
TLS. Verify both trust and peer identity for outbound clients; SNI is a distinct setting.
|
||||
[OpenSSL's client guide](https://docs.openssl.org/3.5/man7/ossl-guide-tls-client-block/)
|
||||
is the primary TLS implementation reference.
|
||||
|
||||
## Reference applications and NEW composition surface
|
||||
|
||||
PROPOSED source locations are `examples/platforms/networked-kv/`,
|
||||
`examples/platforms/networked-client/` and later `examples/platforms/networked-jobs/`.
|
||||
These are NEW paths, not existing examples to run. Build them as installed-package consumers
|
||||
so accidental whole-repository linkage cannot hide missing dependencies. The reference
|
||||
service first uses a native Storage backend; a separate SQLite profile exercises first-class
|
||||
SQL integration with its own schema/migrations. Both implement only the explicitly common
|
||||
reference-domain contract; they are not interchangeable engine/file-format facades.
|
||||
|
||||
NEW illustrative platform-owned API, subject to module-owned type definitions:
|
||||
|
||||
```cpp
|
||||
struct NetworkedConfig; // validated listener/domain/limit configuration
|
||||
struct ApplicationResources; // owning/borrowed handles to module-owned resources
|
||||
class NetworkedApplication {
|
||||
public:
|
||||
static Result<NetworkedApplication> create(ApplicationResources, NetworkedConfig);
|
||||
Result<void> start();
|
||||
Result<HealthSnapshot> health() const;
|
||||
// stop/join use Async's operation options and completion contract
|
||||
};
|
||||
```
|
||||
|
||||
`Result` is C-02 shorthand; HealthSnapshot and the composition wrapper are NEW platform
|
||||
types. Resources do not define competing executor/clock/memory/telemetry interfaces. Embedded
|
||||
mode borrows application-supplied module resources through final join. Managed mode explicitly
|
||||
starts Runtime, which owns them through shutdown. Construction alone opens no listeners or
|
||||
workers. The reference client uses Net sessions, total deadlines and checked responses;
|
||||
it never blindly retries a mutating request on a new connection.
|
||||
|
||||
## Initial HTTP key-value workflow
|
||||
|
||||
HTTP/1.1 is the first protocol profile. The service has the following NEW application
|
||||
endpoints; Net remains responsible for parsing and framing.
|
||||
|
||||
| Endpoint | Contract and storage effect |
|
||||
| --- | --- |
|
||||
| `GET /v1/kv/{key}` | Canonical base64url key, bounded owning value response and opaque version ETag; 404 only for an absent key in the captured snapshot. |
|
||||
| `PUT /v1/kv/{key}` | Raw value body, required idempotency ID and explicit absent/version precondition; atomically store value/new version and request outcome. |
|
||||
| `DELETE /v1/kv/{key}` | Required version precondition/idempotency ID; atomically tombstone/remove plus record outcome. |
|
||||
| `GET /v1/scan` | Bounded page within a retained snapshot; opaque expiring cursor, no leaking raw database sequence/file offsets. |
|
||||
| `GET /v1/operations/{id}` | Auth-scoped known outcome or explicit Unknown; absence/expired retention is never proof that a write did not commit. |
|
||||
| `/live`, `/ready`, `/metrics` | Separate administrative listener; lifecycle status and bounded telemetry, no data mutation or credential dump. |
|
||||
|
||||
Request flow is accept → protocol bounds → deadline/admission → authentication/authorization
|
||||
→ decode/validate → domain operation → durable backend result → response encoding/write.
|
||||
Each request owns a task scope, context snapshot, body buffers and storage handles until
|
||||
exactly one completion and final backend access. Buffer ownership extends past socket close
|
||||
if a write is still completing; disconnect does not roll back an already committed mutation.
|
||||
|
||||
Native Storage uses one conditional batch for the business key/version plus a reserved
|
||||
application namespace containing idempotency record/result. SQLite uses one explicit
|
||||
transaction and unique request-id constraint plus version-checked update; affected-row
|
||||
count and stored outcome are checked before commit. No operation spans both backends in
|
||||
one atomic promise. Domain adapters expose Conflict, NotFound, Overloaded, Unavailable and
|
||||
UnknownCommit separately, preserving backend causes in bounded internal diagnostics.
|
||||
|
||||
Idempotency IDs are scoped to authenticated principal and operation type. Persist a digest
|
||||
of canonical operation/key/precondition/body with the outcome; the same ID with different
|
||||
inputs is Conflict. Retain records for at least 24 hours, with a default 100,000-record/
|
||||
256 MiB budget; when full of unexpired records, reject new mutations instead of evicting
|
||||
live deduplication promises. After the advertised retention window, clients must inspect
|
||||
business state or obtain a new explicit decision, not retry an old ID as though dedup were
|
||||
permanent. GC runs in bounded backend transactions/batches. Persist enough time/high-water
|
||||
metadata that backward clock changes cannot shorten the advertised retention horizon.
|
||||
|
||||
Durable success is returned only after the chosen backend's durable commit succeeds. If
|
||||
commit succeeded but the socket write fails, a retry with the same ID retrieves the stored
|
||||
outcome. A backend Unknown makes readiness reflect recovery state and returns a structured
|
||||
503 with operation ID/outcome=unknown when a reply is possible. A canceled pre-admission
|
||||
request has no effect; cancellation after submission must retain outcome uncertainty.
|
||||
Do not classify a transport timeout as a safe reason to create a new ID and replay the write.
|
||||
|
||||
## Startup, configuration and shutdown
|
||||
|
||||
Startup is a dependency-ordered transaction:
|
||||
|
||||
1. Validate configuration and capabilities, select embedded/managed resource ownership,
|
||||
install bounded early diagnostics, load trust/auth policy and reserve budgets.
|
||||
2. Open the selected database, recover/reconcile it, and validate schema/format compatibility.
|
||||
Required migrations run only under their explicit migration gate; never expose readiness
|
||||
while silently upgrading a store of unknown provenance.
|
||||
3. Register service/domain handlers and telemetry, then start protocol listeners. Default
|
||||
reference data listener is `127.0.0.1:8080`, admin is `127.0.0.1:9090`; tests use assigned
|
||||
ephemeral loopback ports. Binding external interfaces requires explicit application
|
||||
configuration with TLS and authentication policy.
|
||||
4. Publish readiness only after storage, handler dependencies and mandatory resources are
|
||||
healthy. On failure, close listeners/registrations and unwind started resources in reverse
|
||||
dependency order, preserving the original failure and cleanup diagnostics.
|
||||
|
||||
Configuration reload parses a complete candidate, validates limits/paths/certificates,
|
||||
then atomically publishes an immutable configuration generation. In-flight requests keep
|
||||
their old generation. Level/telemetry policy and new-connection TLS material can change
|
||||
live; backend selection, database path and persistent schema require a restart/migration
|
||||
workflow. Do not partly install a configuration whose second listener fails to bind.
|
||||
Hot code replacement follows [ReloadableApplications](ReloadableApplications.md), not an
|
||||
uncoordinated callback swap in this platform.
|
||||
|
||||
Shutdown first marks unready and closes new admission/keepalive reuse, then drains requests
|
||||
for 20 seconds, requests cooperative stop, and joins them within a default 30-second total
|
||||
shutdown budget where supported. Storage operations that already crossed a commit boundary
|
||||
finish/report their outcome. If arbitrary application code does not cooperate, an external
|
||||
process supervisor may terminate the service; the library does not forcibly destroy its
|
||||
objects and claim clean shutdown. After tasks join: flush/checkpoint as configured, close
|
||||
database handles, flush telemetry/logging, stop IO/executors and release resources. Never
|
||||
destroy the logger/exporter first while tasks still hold callbacks into it.
|
||||
A timed-out telemetry flush retains its backend ownership and execution dependencies;
|
||||
Runtime reports shutdown_incomplete until those calls quiesce and can be joined. The
|
||||
platform must not treat the flush timeout as permission to stop their IO/workers.
|
||||
|
||||
## Admission, security and operation budgets
|
||||
|
||||
These are NEW reference-profile defaults, not universal module defaults. Apply the smaller
|
||||
of platform and module limits; reject contradictory configurations at startup.
|
||||
|
||||
| Resource | Default |
|
||||
| --- | --- |
|
||||
| Connections | 1,024 total; 128 per authenticated principal/source admission bucket, with bounded bucket registry. |
|
||||
| Requests | 256 active, 512 waiting; four pipelined requests/connection; overload returns 503 or closes before body admission. |
|
||||
| Input/output | 16 KiB headers, 64 header fields, 64 KiB mutation body, 1 MiB output page; 64 MiB total admitted request/response buffers including sends in flight. |
|
||||
| Time | Five-second total request deadline, two-second header deadline, 30-second keepalive idle timeout; retries consume the original total budget. |
|
||||
| Scans | 64 retained cursor snapshots, 30-second idle lease, 1,024 rows/page; expiry explicitly ends the cursor instead of switching snapshots silently. |
|
||||
| Control plane | Four admin requests concurrently, 64 KiB admin response, separate admission reserve so data overload cannot starve health. |
|
||||
|
||||
Rate-limit registry cardinality is bounded at 4,096 buckets with conservative shared overflow
|
||||
limits, preventing attacker-created IP/identity labels from exhausting memory. Use a caller-
|
||||
approved authentication adapter; the reference profile uses explicit static test identities
|
||||
on loopback and a configured verified credential mechanism for external deployment. Production
|
||||
secrets stay in runtime secret/config facilities and never appear in examples, metrics or logs.
|
||||
Map authorization to key namespaces before storage access, including scans and operation-status
|
||||
lookups. Admin endpoints expose aggregate health only and bind separately by default.
|
||||
|
||||
Malformed framing, conflicting lengths, oversized bodies, slow readers and connection churn
|
||||
are Net conformance cases plus platform resource tests. Optional compression cannot expand
|
||||
past the same body cap. TLS configuration is replaced only for new handshakes; active sessions
|
||||
retain their state through completion. Outbound redirects cannot forward origin-sensitive
|
||||
credentials cross-origin. Untrusted trace headers supply context, never user identity.
|
||||
|
||||
## Operational workflows and later capabilities
|
||||
|
||||
Health reports separate process liveness, readiness and degraded optional exporters. Database
|
||||
RecoveryRequired, mandatory auth failure or exhausted durable-write capacity makes the service
|
||||
unready for mutations; a telemetry outage alone does not. Metrics use bounded route/status/
|
||||
backend labels and include admission rejection, active requests, total owned bytes, commit
|
||||
latency, Unknown outcomes, oldest snapshot and exporter loss. Request IDs belong in bounded
|
||||
logs/traces, not metric labels.
|
||||
|
||||
Backup is an authenticated operator workflow using the selected backend's consistent backup
|
||||
API. Verify a restore into a separate directory and run read-only domain checks before any
|
||||
traffic switch. Do not copy an open SQLite main file alone or a moving native table set.
|
||||
Upgrades validate module/package versions and persistence compatibility; [Update](../modules/Update.md)
|
||||
can stage signed application artifacts, while application schema changes remain separately
|
||||
gated. A committed data migration is not undone by choosing the previous executable.
|
||||
|
||||
The later job reference composes [Scheduler](../subsystems/Scheduler.md) and
|
||||
[Messaging](../subsystems/Messaging.md) for durable admission, retries and acknowledgements.
|
||||
It demonstrates an outbox/deduplication workflow with at-least-once external delivery, not
|
||||
exactly-once effects. The RPC profile reuses [RPC](../subsystems/RPC.md) serialization and
|
||||
transport contracts. P4 service discovery/replication integrate through
|
||||
[DistributedApplications](DistributedApplications.md); this initial single-node platform
|
||||
makes no minority-write, leader-election or cross-shard consistency promise.
|
||||
|
||||
## Ordered platform tasks
|
||||
|
||||
| ID | Phase / dependencies | Scope and acceptance | Recommended role |
|
||||
| --- | --- | --- | --- |
|
||||
| P-NETWORKED-01 | P0; shared contracts and module plans | Freeze reference-domain operations, limits, error mapping and startup/shutdown DAG; backend-specific guarantees are explicit. | astra_implementer |
|
||||
| P-NETWORKED-02 | P2; P-NETWORKED-01, Runtime/Async/IO/Net lifecycle gates | Embedded/managed composition skeleton and installed-package consumer; no hidden workers before start, failed startup unwinds ownership. | astra_implementer |
|
||||
| P-NETWORKED-03 | P3; P-NETWORKED-02, Storage durable batches/snapshots, Security, Configuration | Native durable KV service and client, idempotency/version/scan workflows; lost replies never cause partial or duplicate mutations inside retention. | astra_implementer |
|
||||
| P-NETWORKED-04 | P3; P-NETWORKED-02, Sqlite checked transaction/migration gates | Independent SQLite service profile with schema/backup workflow; shared domain tests pass without claiming identical engine semantics. | sol_implementer |
|
||||
| P-NETWORKED-05 | P3; P-NETWORKED-03/04, Log/Observability, Update recovery | Operational health, graceful shutdown, config generations, backup/restore and signed-code-upgrade scenario; cleanup failure and schema rollback limits stay visible. | astra_implementer |
|
||||
| P-NETWORKED-06 | P3; P-NETWORKED-05, Testing fault/performance harness | Protocol interoperability, overload/crash matrix and workload baselines; bounded memory and durable-ack invariants hold with slow clients/storage/exporters. | astra_implementer |
|
||||
| P-NETWORKED-07 | P3; P-NETWORKED-05, Scheduler/Messaging/RPC capability gates | Job and RPC reference compositions; retries, cancellation and duplicate delivery match their module contracts. | sol_implementer |
|
||||
| P-NETWORKED-08 | P4; P-NETWORKED-06/07, distributed platform gates | Add discovery/replicated domain adapters through owners; partition behavior is tested before an availability/consistency claim. | astra_implementer |
|
||||
|
||||
## Acceptance scenarios, commands and migration
|
||||
|
||||
CURRENT: aggregate module build/tests exist, as recorded in [validation](../VALIDATION.md).
|
||||
No reference-server executable or platform-specific CTest entry is claimed. PROPOSED command
|
||||
templates after P-NETWORKED-02 registers the consumers and P-NETWORKED-06 adds the test label:
|
||||
`cmake --build <configured-build> --target <registered-reference-target>` and
|
||||
`ctest --test-dir <configured-build> -L networked-platform --output-on-failure`.
|
||||
Target/label registration is implementation work; these commands were not run.
|
||||
|
||||
Acceptance exercises both embedded and managed modes: start/fail-start/restart, parallel
|
||||
conditional writes, duplicate ID with same/different body, disk full and failed sync,
|
||||
response loss after commit, cursor expiry under compaction, slow header/body/response,
|
||||
wrong-host/untrusted TLS, authenticated namespace isolation, config reload races, telemetry
|
||||
failure, signal-triggered shutdown and restore of a consistent backup. Use private local
|
||||
fixtures, assigned ports and disposable directories; no public endpoint or production data
|
||||
is required. Check durable receipts against recovered backend contents after forced process
|
||||
termination. SQLite and native Storage get separate evidence records.
|
||||
|
||||
[Performance](../PERFORMANCE.md) governs warmup, repetitions, confidence intervals and
|
||||
regression thresholds. Measure cold/warm TLS, keepalive, tiny/large values, mixed reads/writes,
|
||||
scans and overload, retaining per-request p50/p95/p99 plus throughput, rejection/timeouts,
|
||||
allocations, total peak RSS/CPU (all workers), storage amplification and installed build cost.
|
||||
Drive independent client arrival schedules so queueing latency is not hidden. Hard budgets
|
||||
are correctness gates; only measured workload baselines can set later numerical latency SLOs.
|
||||
|
||||
[Migration](../MIGRATION.md) versions HTTP/domain schemas separately from package/storage
|
||||
formats. Additive response fields remain ignorable; required semantic changes use a new
|
||||
endpoint version. Backend migration exports a consistent logical snapshot into a new store,
|
||||
checks key/value/version/dedup invariants, then changes routing under a controlled write pause.
|
||||
Rollback to an old store after new writes requires reconciliation; switching a config string
|
||||
is not sufficient. [Documentation](../DOCUMENTATION.md) owns operator/client walkthroughs and
|
||||
[delivery](../DELIVERY.md) owns evidence gates. Cited existing component headers have graph
|
||||
coverage checks and source verification; all platform APIs, applications and end-to-end
|
||||
validation here are future work.
|
||||
Reference in new issue
Block a user