Files
Library/docs/roadmap/DEPENDENCIES.md
T

152 lines
9.2 KiB
Markdown

# Dependencies, contracts, and integration order
Status: target dependency design; current build metadata and future architecture are
separated below. Read [ARCHITECTURE.md](ARCHITECTURE.md) for contract definitions.
## Current declared build edges
These edges come from `src/<Module>/module.cmake` at `f1f9ba3`. They are not a complete
header-use graph: undeclared includes and optional bridges must be audited separately.
| Module | Declared internal dependencies | External/platform dependencies |
| --- | --- | --- |
| Core, Functional, Containers, Math, Text, Time, Resilience, LogState | None | None |
| Binary | Functional | None |
| Data | Time | None |
| Async | LogState | None |
| System | Functional, LogState | Threads |
| Configuration | Functional, System, Data, Time | None |
| Log | Functional, Configuration; optional Stacktrace | None |
| Stacktrace | Functional, LogState | Boost.Stacktrace; platform dl/options |
| Plugin | Functional, System, Data | UNIX dl |
| Service | Functional, Log | None |
| Fsm | Async, Data, Functional, Log, Service | None |
| Net | Functional, Text | Boost headers/Asio/Beast/URL, OpenSSL, Threads |
| Crypto | Functional | OpenSSL.Crypto |
| Security | Functional | libsodium |
| Archive | Functional | LibArchive |
| Sqlite | Functional | SQLite C API |
| Update | Crypto, Data, Functional, System, Text | None |
| ShortUrl | Service | None |
| Testing | LogState; optional Stacktrace, Log, Async, Configuration, Text | None |
| TestingMock | Testing, Functional | None |
The [module helper](../../cmake/Module.cmake) controls target construction/export, and
[package config](../../cmake/VoidConfig.cmake.in) resolves requested components.
`INTERNAL_DEPS`, public includes, exported target edges, and installed headers must agree.
## Target package rules
1. A foundation package resolves only its lower foundation dependencies and standard
library requirements. No concrete runtime, network, telemetry exporter, crypto,
storage engine, or logging sink enters that closure accidentally.
2. Async never depends on a concrete Log backend or managed Runtime. IO depends on Async;
Runtime composes them. System may use IO, but IO cannot call back into System for its
platform operations. Backend primitives live inside IO.
3. Service's registry core does not depend on Plugin. The existing plugin-service bridge
becomes an explicit higher-level integration; retaining a compatibility include must
not silently add Plugin to every Service consumer.
4. Log's configuration adapter is an optional integration above Log and Configuration.
Base Log delivery cannot require the entire configuration/system stack just to emit.
5. Observation hooks are lightweight contracts. Exporters and network exporters are
separate adapter targets; Net cannot depend on an exporter that depends on Net.
6. Storage core handles bytes and durable versions. Structured document/index adapters
add Data above it. Sqlite is independent; neither engine is the other's prerequisite.
7. Coordination is a deterministic core with abstract ports. Replication owns transport
and Storage adapters. Discovery can bootstrap from static peers without querying a
consensus group that itself needs discovery to start.
Exact adapter target names are NEW and are specified by the owning area plan. Their
direction and ownership are fixed here. No compatibility wrapper may conceal a reverse
dependency; installed consumer tests exercise each bridge explicitly.
## Area dependency map
The following are implementation prerequisites, not a promise that every listed
prerequisite must be a public link dependency of every API.
| Area | Prerequisites and owned integration boundary |
| --- | --- |
| Core, Functional | Foundation layering/error contracts; resolve representation bridges without a cycle |
| Memory | Core and standard PMR; raw allocation facilities precede allocator-aware containers |
| Math | Core and standard-library storage; scalar checked arithmetic precedes Algorithms; no Containers/Algorithms imports or dependency back from Core UUID representation |
| Algorithms | Core and narrow Math checked arithmetic; optional Functional/Memory adapters; standard-library scratch storage, never Containers or Text |
| Containers | Core; Memory before allocator-aware types; graph convenience adapters may depend on Algorithms, never the reverse |
| Text, Unicode | Text byte utilities first; Unicode tables/algorithms above them; optional Text adapters |
| Time | Core/error conventions; clock interface before timers and scheduler |
| Binary, Data | Binary bounds/encoding first; Data composes codecs, text and time where required |
| Async | Error, clock, memory and resource contracts; lifetime model before IO/FSM upgrades |
| IO, System, IPC | Async/byte streams → IO backends → System workflows/IPC framing |
| Configuration | Data, Text, Time; watching/reload adapters additionally use System/Async |
| Log, Stacktrace, Observability | Independent hook contracts; Async for queued delivery; exporters above protocols |
| Crypto, Security, Archive | Functional/error/byte interfaces; retained backend feature checks |
| Net, RPC | IO/Async, Binary/Text, TLS backend → Net transports → RPC framing/schema |
| Sqlite, Storage | Error/byte contracts; Storage additionally IO and memory; independently tested durability |
| Service, Plugin, Fsm | Owning service handles → module host and FSM supervision; Async joins before safe unload |
| Scheduler, Messaging | Async/Time; optional Storage persistence; network/replication adapters later |
| Update, ShortUrl | Existing trust/ABI contracts; higher integration with Net/Plugin/Storage stays optional |
| Discovery | Static/local provider first; RPC health/registration; replicated provider in a higher adapter |
| Coordination | Deterministic core and stable-storage/clock/transport ports; simulation harness |
| Replication | Coordination + Storage + RPC adapters; atomic applied-state and dedup contract |
| DistributedStorage | Proven single-group Replication; routing/reconfiguration before sharding/rebalance |
| Testing, TestingMock | Minimal framework can validate foundations; fault/property extensions grow alongside modules |
| NetworkedApplications | Runtime, Net, chosen Storage/Sqlite, Configuration, Security, Observability |
| ReloadableApplications | Runtime, Service, Plugin, Fsm, Update, Configuration, Observability |
| DistributedApplications | RPC, Messaging, Discovery, Coordination, Replication, DistributedStorage, operations |
## Critical path and parallel work
```mermaid
flowchart TD
B[Baseline and package audit] --> C[Shared contracts and foundation]
C --> A[Async ownership and clocks]
A --> I[Native IO and bounded streams]
C --> D[Data and binary contracts]
I --> N[Network transport and streaming]
I --> S[Original storage durability]
D --> S
A --> L[Service and plugin lifecycle]
L --> H[Reloadable platform]
N --> P[Networked platform]
S --> P
N --> R[RPC and discovery adapters]
S --> M[Durable local messaging]
R --> X[Replication adapters]
S --> X
Q[Deterministic coordination core] --> X
X --> Z[Distributed storage and platform]
```
The diagram shows integration gates; it does not prevent building a deterministic
coordination simulator while independent module work continues. Single-node deliverables
must not wait for distributed completion. Foundation improvements continue across phases.
## Contract freeze and ownership
| Gate | Required agreement before parallel dependents |
| --- | --- |
| G-ERROR | Functional error classification/conversion and allocator ownership |
| G-EXEC | Async scope/operation/executor API and Time clock/deadline behavior |
| G-IO | Stream buffer lifetime, partial results, cancellation/completion and admission |
| G-DATA | Numeric values, codec bounds, schema versioning, strict signed-data compatibility |
| G-STORE | Commit/unknown outcome, format/recovery, snapshots, preconditions and retention |
| G-HOST | Service pinning, lifecycle callbacks, C ABI and safe generation retirement |
| G-REPL | Stable protocol state, committed/applied position, deduplication and snapshot atomicity |
Area plans may refine interfaces owned by their area; cross-area meaning changes require
an updated decision and reconciliation before dispatch. Shared build declarations,
generated Unicode tables, disk/wire formats, exported ABI headers, and schemas each have
one writer per implementation wave. Source-disjoint tasks may still share ports, storage
directories, global log state, or clocks; tests isolate those resources.
## Integration checks
- Compile public headers and link installed consumers against the smallest supported
component closure, including deliberate absence of unrelated external dependencies.
- Compare exported target dependencies to source includes and implementation use.
- Exercise adapter packages separately from core packages in shared and static builds.
- Check each feature task's prerequisite IDs and cross-plan links before execution;
no implementation task is READY with an unresolved required contract.
- Re-run affected cross-module scenarios after ownership, wire/disk format, error, or
lifetime changes. See [VALIDATION.md](VALIDATION.md) for the evidence matrix.