# Configuration schemas and transactional reload plan Status: PLANNED feature work. Baseline: `f1f9ba375b22abf1adcc7c550ec21ac20895c0a4`, inspected 2026-11-24. Requirements R-002, R-004, R-009 and R-014 apply. Shared [architecture](../ARCHITECTURE.md) C-02–C-05, C-07 and C-13 governs this plan. ## Existing source and behavioral boundary [Config.hpp](../../../include/Void/Configuration/Config.hpp) implements `Void::Configuration::Config`: string-valued dotted keys, environment allowlists and prefixes, KEY=VALUE/INI/JSON/argument sources, last-writer overlay, sorted keys, subtrees, typed conversion and duration/byte-size handling. Returned string_views borrow the Config's storage. [Bind.hpp](../../../include/Void/Configuration/Bind.hpp) binds reflection aggregates, nested objects, optionals/vectors, defaults, `Key` and `Required` annotations. [Argparse.hpp](../../../include/Void/Configuration/Argparse.hpp) uses the separate `Void::Argparse` namespace, with parser and reflection-generated options; [Argparse.cpp](../../../src/Configuration/Argparse.cpp) implements parsing. [Env.hpp](../../../include/Void/Configuration/Env.hpp) wraps getenv; this plan does not inspect any environment values. [Watch.hpp](../../../include/Void/Configuration/Watch.hpp) provides `ConfigWatch`. Parse/load failure preserves the last configuration, deletion preserves it, and a successful load replaces `m_current` before calling `on_reload` outside its mutex. There is no validation/prepare vote before that publication. Initial load failure leaves an empty configuration without a fallible factory result. A callback rejecting the new config cannot roll publication back transactionally today. [Source tests](../../../tests/standalone/Configuration/Sources.cpp), [typed tests](../../../tests/standalone/Configuration/Typed.cpp), [binding tests](../../../tests/standalone/Configuration/BindAnnotations.cpp), and [watch tests](../../../tests/standalone/Configuration/Watch.cpp) establish existing fixtures. [module.cmake](../../../src/Configuration/module.cmake) declares Functional, System, Data and Time. Graph coverage is partial at declarations in Config, Bind, Argparse, Env and Watch; all reported ranges were read directly. Reflection behavior must be verified with the actual selected compiler, not inferred from graph parsing. ## NEW schema and immutable snapshot API Design sketch, with Result shorthand from Functional and the sole shared options from [Async](Async.md); these names and methods do not yet exist: ```cpp namespace Void::Configuration { struct SourceLocation { SourceId source; std::string key; std::uint32_t line; }; template struct Snapshot { std::uint64_t generation; std::shared_ptr values; std::shared_ptr provenance; }; template Result> validate(const Config&, const Schema&); template class ReloadController { public: Snapshot current() const; Coro::Task> reload(SourceSet, Async::OperationOptions); }; } ``` Schema is Configuration-owned and reuses Data's schema/value machinery. Reflection generates field metadata; explicit schema definitions support cross-field constraints, secret flags, restart-required keys, ranges, deprecations and strict unknown-key policy. Default unknown keys are errors in typed managed configuration; legacy Config retains its permissive string map. Validate a separate default-constructed candidate, collect at most 100 diagnostics, and publish only a complete value. Conversion errors retain source/key/line and machine category; secret values never appear in diagnostics. Default precedence is schema defaults < declared files in order < explicitly selected environment variables < explicit CLI options. Each key retains winning origin and shadowed-origin identifiers without retaining redundant secret values. Missing, empty, null, malformed and removed keys are distinct. Dotted-key escaping/collision rules are specified before adding richer structured values: default reject an ambiguous literal dot versus nested JSON path collision. No fallback from malformed supplied values to defaults. Vectors require contiguous indexes; gaps are validation errors in NEW binding. ## Transaction protocol Reload is serialized per controller and follows read → bounded parse → merge → typed bind → validate → prepare → publish → notify. The transaction has one immutable aggregate generation containing validated settings and prepared per-component resource views. Consumers acquire that aggregate once per operation, so a request cannot mix generations. A NEW prepare-only port can export the retained candidate view to a platform coordinator. For that mode, the platform's single Service/host generation publisher owns commit; the standalone ReloadController must not independently publish the same resource set. 1. Snapshot source bytes and a monotonically increasing source revision. Watch events coalesce; changed content during reading schedules a fresh candidate. Metadata debounce is only a hint. Resolve declared sources, never crawl arbitrary paths or enumerate the entire environment by default. 2. Run pure validators and restart-required checks without registry/publication locks. Rejected fields preserve the active snapshot. A restart-required delta reports a pending restart; it does not partly apply the remaining fields by default. 3. Each registered participant prepares candidate-owned resources without externally visible mutation. `prepare(old, candidate, options)` returns a NEW PreparedChange whose retained immutable view is inserted into the aggregate. Prepare may fail or be cancelled; disposal closes/joins its candidate work. Unregister/close joins participant callbacks before freeing captures. 4. Once every prepare succeeds, check source revision, stop/deadline and the active generation under the short publication guard. Publish one retained aggregate pointer. The pointer swap is the commit point. No fallible user code, allocation, resource creation or callbacks are allowed in commit. An operation that needs independent mutable side-effect commits is not a transactional participant and must be redesigned or marked restart-required. 5. Post-commit notifications are bounded observations outside locks. Callback failure reports a committed generation plus notification error; it does not claim rollback. Old resources remain pinned by old snapshots until their operations drain. A stop racing after commit returns committed-with-stop-observed, not a false rejection. Rollback before commit disposes the candidate in reverse preparation order and leaves the exact old generation active. Reverting after commit is another validated transaction; it may fail and receives its own generation. Persistent config file changes are a separate System durable-replacement operation, not an implied distributed transaction. ## Resource limits and backend choice Native parsing/binding over current Data and standard containers remains the initial implementation; no external configuration framework. General JSON follows Data, while signed release documents remain StrictJson/Update-owned and unchanged (C-07). Default: 1 MiB/source, 8 sources, 4 MiB merged decoded values, 10,000 keys, 4 KiB key, 64 KiB scalar, nesting depth 32, 1,024 vector items, 64 participants and one prepared candidate. All source, merged, provenance and diagnostic buffers count toward the limit. Environment capture uses an allowlist or explicitly requested prefix and the same caps. Keep at most four retained controller generations by default. If consumers still pin four, reject a fifth reload with `retention_limit`; never invalidate a live snapshot. Each participant declares a preparation resource budget; the controller cannot infer memory held by arbitrary callbacks. Default prepare deadline is 5 seconds using Time's injected monotonic clock; owned work still must drain before disposal can complete. Notification queue: 128 generation events with explicit coalesced-generation reporting. No global Runtime is created; synchronous validation is usable without workers and the async reload adapter uses injected Async/System resources. ## Ordered implementation backlog All rows are PLANNED. | ID | Phase / depends on | Intended scope | Acceptance / recommended role | | --- | --- | --- | --- | | M-CONFIGURATION-01 | P0 / baseline | Characterize source precedence, borrowing, initial watch failure, vector gaps and key collisions | Regression fixtures separate permissive legacy behavior from strict NEW behavior / sol_implementer | | M-CONFIGURATION-02 | P1 / M-CONFIGURATION-01; Data schema/error gates | Schema metadata, provenance, bounded parsing and all-or-nothing typed binding | Overflow/unknown/range/cross-field failures contain redacted origins and leave input untouched / sol_implementer | | M-CONFIGURATION-03 | P2 / M-CONFIGURATION-02; Async scope gate | Immutable snapshots, serialized prepare/publish protocol and fallible controller factory | Any prepare failure preserves generation; one pointer swap publishes coherent resources / astra_implementer | | M-CONFIGURATION-04 | P2 / M-CONFIGURATION-03; System joined watcher gate | Coalescing watch adapter, source-revision validation, joined participants | Rapid edit/delete/recreate and slow validator never publish stale or partial candidate / sol_implementer | | M-CONFIGURATION-05 | P3 / M-CONFIGURATION-04 | Runtime/Service integration, retained-resource accounting, migration examples | Old operation sees old settings throughout; new acquisition sees new generation; leaked pins reject reload / astra_implementer | ## Validation, performance and migration CURRENT tests run through the aggregate command `ctest --test-dir /tmp/voidlibrary-discovery-f1f9ba3 --output-on-failure --timeout 60`; not rerun for this documentation change. PROPOSED tests require the NEW controller: participant 2 fails after participant 1 allocates; cancellation immediately before/after swap; concurrent reload ordering; reader pin across replacement; notification throw; unknown key and nested name collision; secret-bearing parse error; byte/key/depth caps; invalid initial config; rollback cleanup that needs asynchronous join. Validate compiled reflection examples and installed isolated Configuration consumers at implementation time. Measure reload p50/p95/p99, reader acquisition cost, parse/validation throughput, allocations, retained-generation RSS/CPU and compile cost under [PERFORMANCE](../PERFORMANCE.md). No benchmark results are asserted. EXISTING `ConfigWatch::json(path, callback)` migrates to a NEW fallible controller factory with schema, participants and explicit executor; callback-only users get a notification adapter, not a veto callback after publication. Retain Config's borrowing and overlay API until a major-release transition; snapshot examples keep the owning Snapshot alive while reading fields. Failures in legacy initial load become explicit errors in the NEW factory. Rollback keeps the previous controller active until the replacement controller validates and starts. See [MIGRATION](../MIGRATION.md), [VALIDATION](../VALIDATION.md), [Runtime](../subsystems/Runtime.md), [Service](Service.md) and [DELIVERY](../DELIVERY.md).