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,288 @@
|
||||
# Architecture and shared contracts
|
||||
|
||||
Status: target design for planning; NEW contracts below are not existing library APIs.
|
||||
Source baseline: `f1f9ba375b22abf1adcc7c550ec21ac20895c0a4`.
|
||||
|
||||
## Existing architecture
|
||||
|
||||
[CMakeLists.txt](../../CMakeLists.txt) discovers module declarations and supports
|
||||
`VOID_ENABLED_MODULES` with transitive internal dependencies. Public CMake targets use
|
||||
`Void::<Module>`. The repository has 26 public feature modules and the supporting
|
||||
LogState target. Existing namespaces do not always match CMake module names; migration
|
||||
must preserve or explicitly adapt those differences.
|
||||
|
||||
Current integrations already include coroutine tasks, a manual executor, a future-based
|
||||
thread pool, reflection serialization, scoped service registries, pinned plugin
|
||||
generations, signed update verification, and durable version activation. Their existence
|
||||
does not establish a unified execution or lifetime contract. Individual plans record
|
||||
their inspected source and exact compatibility obligations.
|
||||
|
||||
## C-01 — Layering and package independence
|
||||
|
||||
The target dependency direction is foundations → execution/I/O and system facilities →
|
||||
complete functional modules → platform compositions. This is a target, not a claim that
|
||||
today's declarations already satisfy it.
|
||||
|
||||
Foundation: Core, Functional, Memory, Containers, Algorithms, Math, Text, Unicode, Time,
|
||||
Binary, and Data. These may depend on lower foundation components and the standard
|
||||
library; none requires Runtime, Net, a database, crypto, a logging backend, or a worker
|
||||
thread. Unicode data tables are versioned build inputs, not a runtime external engine.
|
||||
|
||||
Core cannot import Math merely to implement UUID generation in the target graph. Keep
|
||||
UUID representation in Core; use standard entropy/injected generation without importing
|
||||
the broader Math module. Functional formatting bridges must not produce a Core↔Functional
|
||||
cycle. Unicode integration into Text is optional; Unicode may reuse byte/text primitives
|
||||
without Text depending back on Unicode.
|
||||
|
||||
Math's scalar checked arithmetic uses standard-library storage and imports neither
|
||||
Containers nor Algorithms. Algorithms may use that narrow numeric interface and standard
|
||||
scratch containers; Containers/Text provide adapters above Algorithms. Algorithms never
|
||||
imports Containers or Text. Allocator-aware Containers build on Memory, not vice versa.
|
||||
|
||||
Public headers compile independently with their declared dependencies. Build selection,
|
||||
installed component selection, static linkage, and shared linkage all receive consumer
|
||||
checks. Optional capabilities live in adapters or higher-level modules. A merged
|
||||
kitchen-sink test executable is insufficient evidence of independence.
|
||||
|
||||
## C-02 — Errors and compatibility
|
||||
|
||||
Use the existing `Void::Result::Result<T>`/`std::expected` conventions as the starting
|
||||
point for fallible operations. `Result<T>` in designs is shorthand, not a claim that a
|
||||
new top-level alias exists. Functional owns shared error-category and conversion design.
|
||||
Domain errors retain machine-readable classifications and contextual causes.
|
||||
|
||||
Operational failures, cancellation, timeout, overload, unsupported capabilities, and
|
||||
corruption are distinguishable. Exception-based existing APIs get explicit adapters;
|
||||
there is no universal silent conversion of programmer errors into success or empty
|
||||
values. No exception crosses a C ABI boundary. Existing exception/future semantics stay
|
||||
documented until their specific major-release migration is implemented.
|
||||
|
||||
## C-03 — Task ownership and operation completion
|
||||
|
||||
Async owns structured task scopes, executor contracts, and operation completion.
|
||||
Each admitted operation has an owner until exactly one terminal result is delivered
|
||||
and all backend access to its buffers/state has ceased. Scheduler queues must not
|
||||
outlive borrowed coroutine frames. Detached work requires an explicit lifetime and
|
||||
error sink; ordinary scope destruction requests stop and joins owned work.
|
||||
|
||||
The initial shared operation options use `std::stop_token` and an optional absolute
|
||||
`std::chrono::steady_clock::time_point` deadline. Async owns their NEW public type;
|
||||
IO, Net, RPC, and higher modules reference it instead of declaring competing types.
|
||||
Time owns the injected clock contract. Deadlines include admission and all operation
|
||||
phases unless an API explicitly documents a distinct phase budget.
|
||||
|
||||
Cancellation is cooperative, never forceful interruption of arbitrary application code.
|
||||
It cannot undo a write or commit already performed. A cancellation request racing with
|
||||
completion produces one documented terminal outcome and still performs resource cleanup.
|
||||
Single-delivery arbitration does not choose the domain outcome: stop/expiry records intent,
|
||||
while the owning operation classifies its result from backend and persistence evidence.
|
||||
Known commitment returns its receipt even if stop was requested first; uncertain effects
|
||||
return the domain's explicit unknown-outcome error. Cancellation/timeout alone is valid
|
||||
only where the domain can establish that classification, including any partial effects.
|
||||
The sole result is delivered after required backend access ends; a caller's deadline does
|
||||
not permit discarding late commit evidence or freeing still-owned resources.
|
||||
Event subscriptions define whether already-admitted callbacks drain; unsubscribe alone
|
||||
must not be presented as a guarantee that all captured state is no longer in use.
|
||||
|
||||
## C-04 — Execution, clocks, and runtime injection
|
||||
|
||||
Async defines execution; Time defines clocks; Memory defines allocator facilities.
|
||||
Runtime composes those contracts and cannot become their dependency. Applications may
|
||||
inject an executor, clock, allocator/resource budget, and observation hooks. Dependencies
|
||||
borrowed by a context must outlive its final shutdown; managed Runtime retains its owned
|
||||
resources through that boundary.
|
||||
|
||||
Embedded mode uses application-supplied resources. Managed mode creates resources only
|
||||
on explicit startup and stops admission before draining/cancelling and joining. Ordinary
|
||||
module constructors do not silently start a global runtime. Process-wide LogState is a
|
||||
documented logging compatibility bridge, not the owner of execution services.
|
||||
|
||||
Monotonic clocks govern elapsed time, retries, and deadlines. Civil clocks and time zones
|
||||
govern calendar schedules. Tests inject clocks and control task progress. Persistent job
|
||||
identities use scheduled occurrence identifiers, not the current wall clock alone.
|
||||
|
||||
## C-05 — Bounds, admission, and memory
|
||||
|
||||
Each complete module specifies finite default limits for queues, concurrency, input
|
||||
size, buffers, recursion, retained history, and pending output where applicable. Defaults
|
||||
are concrete in its area plan and configurable. New APIs use an explicit unbounded
|
||||
policy when needed; zero must not acquire undocumented unlimited semantics.
|
||||
|
||||
Admission reports overload instead of silently allocating without bound. Async waiting
|
||||
for capacity is explicit and cancellable; blocking admission is an opt-in that cannot
|
||||
block the same executor needed to release capacity. Logging defines its own loss policy
|
||||
and observable counters. In-flight work and batches count toward bounds, not only queue
|
||||
slots. Memory/allocator hooks target owned allocations and documented lifetime domains.
|
||||
|
||||
## C-06 — Native I/O and network interoperability
|
||||
|
||||
IO owns the platform operation backend and byte-stream contracts. Initial Linux sockets
|
||||
use nonblocking descriptors with level-triggered epoll; filesystem operations use bounded
|
||||
blocking workers. Optional io_uring comes later behind capability detection and conformance
|
||||
tests. Backend selection/fallback happens before submission; a potentially effective write
|
||||
is not blindly replayed on another backend.
|
||||
|
||||
Network and protocol APIs remain Void-owned. Preserve existing Boost-based paths during
|
||||
migration; new native runtime/protocol paths need interoperability and fuzz evidence before
|
||||
replacement. Net owns network protocol state and connection reuse; IO owns descriptor,
|
||||
buffer, cancellation, partial-transfer, and completion rules. RPC uses Net/IO and serialization
|
||||
without depending on Coordination or a platform.
|
||||
|
||||
TLS clients verify trust chains and expected peer identity by default, with explicit trust
|
||||
configuration. SNI is not hostname verification. HTTP redirect rules strip origin-sensitive
|
||||
credentials on cross-origin transitions and define method/body behavior. Total deadlines
|
||||
include DNS, connect, proxy negotiation, TLS, request, and response. OpenSSL remains the
|
||||
initial TLS implementation. See the [OpenSSL client guide](https://docs.openssl.org/3.5/man7/ossl-guide-tls-client-block/).
|
||||
|
||||
## C-07 — Data and signed-document boundaries
|
||||
|
||||
Data owns general structured values, parsing policies, reflection serialization, and
|
||||
schema/version evolution; Binary owns byte encoding/decoding. General JSON adds exact
|
||||
signed/unsigned integer representation and checked numeric conversion without routing
|
||||
all values through double. Limits and duplicate-key policies are explicit.
|
||||
|
||||
Preserve StrictJson's separate restricted representation and acceptance rules. Existing
|
||||
Update envelope parsing uses general Json, not StrictJson, and must retain its own
|
||||
versioned compatibility profile. General JSON improvements must not silently broaden
|
||||
either protected profile. The target Update contract verifies signatures over exact
|
||||
provided payload bytes before payload schema parsing or readable-document comparison;
|
||||
reserialization cannot substitute for those bytes. The current schema-3 path parses the
|
||||
payload for readable-document comparison before signature verification, so this ordering
|
||||
is an explicit hardening task in [Update](modules/Update.md), not completed behavior.
|
||||
Existing signed documents remain regression fixtures.
|
||||
|
||||
## C-08 — Original storage and SQLite
|
||||
|
||||
Storage is an original implementation. Sqlite remains a first-class integration with
|
||||
SQLite itself. Neither is a compatibility facade over the other. Original Storage makes
|
||||
no SQL or SQLite file-format promise.
|
||||
|
||||
The selected initial layout is an append-only checksummed WAL, an ordered in-memory index,
|
||||
and immutable sorted checkpoint/table files; the Storage plan specifies the format and
|
||||
manifest protocol. Begin with one serialized writer, atomic batches, consistent snapshots,
|
||||
and ordered iteration. Incremental bounded compaction follows the durable core. Readers
|
||||
pin versions; reclamation waits for pins and observes configured retention budgets.
|
||||
|
||||
Atomic batches are not a claim of arbitrary read-modify-write transaction isolation.
|
||||
Conditional updates evaluate version/value preconditions atomically with the batch in
|
||||
writer order. A conflict reports failure without partial mutation. Richer transactions
|
||||
and document/index layers require separate documented isolation contracts.
|
||||
|
||||
Durable success follows successful persistence of all recovery dependencies. Weaker
|
||||
durability is an explicit policy. Errors and lost replies may leave an unknown commit
|
||||
outcome, so retries require operation identity or inspection. Failed sync, disk full,
|
||||
short writes, corruption, and recovery interruption are first-class outcomes.
|
||||
See [SQLite's crash-testing methodology](https://sqlite.org/atomiccommit.html#_testing_atomic_commit_behavior).
|
||||
|
||||
## C-09 — Services, plugins, and ABI
|
||||
|
||||
Service owns registry access and lifecycle contracts; Plugin owns library generations
|
||||
and module hosting. Acquired service handles retain provider ownership throughout calls
|
||||
and replacement. Snapshot lifecycle operations and invoke user callbacks outside registry
|
||||
locks. Dependency ordering, failed-start rollback, and shutdown are deterministic.
|
||||
|
||||
The plugin host composes validation → activation → readiness → publication and, where
|
||||
state transfer requires it, quiescence → checkpoint → candidate restore. Failed candidates
|
||||
preserve the active generation. Existing callers keep their generation pin. Safe unloading
|
||||
requires both generation references and owned asynchronous activity to end.
|
||||
|
||||
The NEW stable C interface uses fixed-width fields, structure sizes/versions, opaque
|
||||
handles, function tables, status codes, byte spans, and explicit release functions.
|
||||
Allocate and release through the same owner. No STL objects, C++ exceptions, or implicit
|
||||
RTTI contract crosses that boundary. Existing C++ descriptors remain same-toolchain
|
||||
interfaces; a C ABI does not make existing C++ objects cross-toolchain compatible.
|
||||
ShortUrl V1 remains frozen as documented in [its contract](../short-url.md).
|
||||
|
||||
## C-10 — Workflow state and updates
|
||||
|
||||
Fsm owns state execution and supervision; Scheduler owns calendar/delayed job admission
|
||||
and persistence. Checkpoints capture application state at documented boundaries, not
|
||||
coroutine frames. Concurrent child scopes must be cancelled/joined when a parent or race
|
||||
finishes. Faulted is a terminal state throughout supervision APIs.
|
||||
|
||||
Update owns signed release selection and durable version activation. Preserve the existing
|
||||
distinction between reversible candidate activation and the durable healthy commit marker
|
||||
in [VersionStore](../../include/Void/Update/VersionStore.hpp). Cleanup failure after that
|
||||
commit cannot be reported as though rollback were still the correct action. Plugin and
|
||||
platform plans coordinate with that boundary rather than inventing another commit point.
|
||||
|
||||
## C-11 — Logging and observability
|
||||
|
||||
Log owns delivery and sinks; Observability owns metrics/traces/context interfaces and
|
||||
export adapters. Foundation and execution modules depend on lightweight optional hooks,
|
||||
not on a concrete exporter or managed runtime. Avoid Log↔Observability and Async↔Log
|
||||
cycles. Preserve process-wide facade state across shared-library boundaries.
|
||||
|
||||
User sinks/callbacks execute outside shared configuration locks. Queue, in-flight batch,
|
||||
flush, loss, and sink-failure semantics are bounded and measurable. Context propagation
|
||||
snapshots values at admission; pointers to transient thread-local state cannot escape.
|
||||
Metrics labels and retained trace data also have cardinality and resource limits.
|
||||
|
||||
## C-12 — Distributed ownership and consistency
|
||||
|
||||
Coordination owns a deterministic Raft protocol core with injected clock, transport,
|
||||
and stable-storage ports. It emits actions; its core does not import RPC, Discovery,
|
||||
DistributedStorage, or platform orchestration. Replication owns the adapters connecting
|
||||
Coordination, transport, and Storage. Discovery starts with static/local providers;
|
||||
coordination-backed discovery is a higher-layer adapter, avoiding a bootstrap cycle.
|
||||
|
||||
Initial replicated groups have fixed membership, one leader, majority commit, and a
|
||||
crash-failure model. Persist protocol state before replies that depend on it. Apply only
|
||||
committed commands in deterministic order. Store application mutations, deduplication
|
||||
records, and the applied-log position in one recoverable Storage batch. Snapshot metadata
|
||||
identifies the included log position and format version.
|
||||
|
||||
Initial consistent reads use quorum-confirmed leadership/read-index behavior; explicitly
|
||||
stale reads have a separate API policy. An isolated old leader must not acknowledge new
|
||||
commits or advertise linearizable local reads. No cross-shard transactions or global
|
||||
exactly-once side-effect guarantee is implied. Later membership changes use a separately
|
||||
tested protocol; sharding follows single-group correctness. See the
|
||||
[Raft extended paper](https://raft.github.io/raft.pdf).
|
||||
|
||||
Messaging begins with explicit at-least-once delivery and acknowledgement, bounded retries,
|
||||
and application deduplication. Replication does not turn an external side effect into an
|
||||
exactly-once transaction. Durable jobs follow the same acknowledgement/unknown-outcome rules.
|
||||
|
||||
## C-13 — Public evolution and integration
|
||||
|
||||
Each area distinguishes EXISTING names from NEW proposed interfaces, names its owner,
|
||||
lists downstream users, and supplies migration examples. Shared contracts in this file
|
||||
are authoritative; area plans reference contract IDs and do not redefine their meaning.
|
||||
Changes to shared contracts update the [decision ledger](../agent-workflow/DECISIONS.md)
|
||||
and all affected area plans before parallel implementation.
|
||||
|
||||
Implementation task identifiers use `M-<MODULE>-NN`, `S-<SUBSYSTEM>-NN`,
|
||||
`P-<PLATFORM>-NN`, or `X-<AREA>-NN`. They are planned feature work, distinct from the
|
||||
`T-DOC-*` tasks that author these documents. New source paths and commands are marked
|
||||
PROPOSED until they exist. Readiness means passing the gate for that phase, not all
|
||||
long-term distributed or portability promises.
|
||||
|
||||
## C-14 — Reference compositions
|
||||
|
||||
NetworkedApplications composes runtime, protocols, storage, configuration, security,
|
||||
observability, and shutdown. ReloadableApplications composes services, plugin generations,
|
||||
FSM supervision, update activation, and observability. DistributedApplications composes
|
||||
transport, replicated state, membership/routing operations, metrics, and recovery tools.
|
||||
Platforms reuse modules; they do not own alternate implementations of shared primitives.
|
||||
Their documents specify future reference applications and acceptance scenarios only.
|
||||
|
||||
## Contract owners
|
||||
|
||||
| Shared responsibility | Authoritative area |
|
||||
| --- | --- |
|
||||
| Result/error adaptation | Functional |
|
||||
| Clocks/calendar | Time |
|
||||
| Allocation facilities | Memory |
|
||||
| Executor, operation options, structured task scope | Async |
|
||||
| Descriptor/stream/backend lifetime | IO |
|
||||
| Managed composition | Runtime |
|
||||
| General values/schema and binary representation | Data and Binary, respectively |
|
||||
| Atomic storage/recovery format | Storage |
|
||||
| Registry ownership and dynamic loading | Service and Plugin, respectively |
|
||||
| Workflow state and job scheduling | Fsm and Scheduler, respectively |
|
||||
| Delivery and telemetry model | Log and Observability, respectively |
|
||||
| Consensus core and application replication adapters | Coordination and Replication, respectively |
|
||||
|
||||
Package edges, phase dependencies, and validation gates are expanded in
|
||||
[DEPENDENCIES.md](DEPENDENCIES.md), [DELIVERY.md](DELIVERY.md), and
|
||||
[VALIDATION.md](VALIDATION.md).
|
||||
Reference in new issue
Block a user