Skip to content

Commit df6eac2

Browse files
committed
docs(architecture): specify registration race and failure tests
Define the non-throwing publication sequence, shutdown linearization and regression matrix required before implementation of atomic configuration registration.
1 parent dda0fc7 commit df6eac2

1 file changed

Lines changed: 34 additions & 3 deletions

File tree

‎docs/adr/0010-atomic-configuration-registration.md‎

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ The future registration operation will accept a complete prepared set and an
2727
explicit registration-options object. It will:
2828

2929
1. validate the entire batch before publication;
30-
2. build all new strategies and registration metadata while holding the
31-
registry write lock (or before taking it when no live state is inspected);
32-
3. check `m_shutdown` before preparation and again before publication;
30+
2. build all new strategies and candidate registry/ID-map snapshots before
31+
mutating live state;
32+
3. check `m_shutdown` before preparation and again under the registry write
33+
lock before publication;
3334
4. publish one immutable strategy-list snapshot with one release-store;
3435
5. return a stable mapping from each configuration `id` to its runtime index.
3536

@@ -47,6 +48,21 @@ registry after the existing strategies. The returned ID/index mapping is the
4748
only supported way for a configuration caller to address a logger; vector
4849
order and backend type are not inferred from the ID.
4950

51+
All potentially throwing validation, allocation, strategy construction, and
52+
ID-map work must finish before mutating `m_loggers`. Under its write lock, the
53+
implementation prepares a complete candidate list and immutable snapshot,
54+
then uses non-throwing swaps for the mutable registry and ID map before the
55+
single release-store of the snapshot. No failure may leave the mutable registry
56+
and published snapshot describing different batches. An empty batch is a
57+
successful no-op with an empty returned mapping.
58+
59+
Shutdown and batch registration must share a linearization boundary. The
60+
future `shutdown()` path must set `m_shutdown` and capture the registry under
61+
the same write lock used by registration. If shutdown wins, registration
62+
fails without publishing. If registration wins, shutdown sees and shuts down
63+
the entire appended batch. The existing fast-path `m_shutdown` check remains
64+
an early exit, not the sole race guard.
65+
5066
### Ownership boundary
5167

5268
The recommended implementation changes `LoggerStrategy`'s internal owners to
@@ -83,6 +99,21 @@ existing `Logger::shutdown()` and strategy lifetime rules.
8399
- Configuration IDs require a small registry-side metadata map; they are not
84100
retrofitted onto legacy unnamed registrations.
85101

102+
## Regression matrix for implementation
103+
104+
| Case | Required result |
105+
| --- | --- |
106+
| Two-entry batch succeeds | One snapshot publication; both IDs map to consecutive runtime indices after existing strategies. |
107+
| Invalid second entry or duplicate ID | No new strategy or ID is visible; existing registry and caller output remain unchanged. |
108+
| Repeated batch | Duplicate configured IDs fail; no implicit replacement or idempotent success. |
109+
| Legacy `add_logger()` before and after a batch | Existing API remains valid; unnamed indices remain stable and configured ID mapping remains unambiguous. |
110+
| Prepared set destroyed after registration | Backend and formatter remain alive through registry ownership. |
111+
| `single_mode` option and enabled state | Targeted/general routing and default enabled state match ordinary strategy behavior. |
112+
| Concurrent dispatch during registration | Each dispatch sees either the old or complete new snapshot, never a partial batch. |
113+
| Registration versus shutdown | Exactly one wins the registry lock; no published backend escapes shutdown. |
114+
| Factory/formatter failure before registration | No registration call or live mutation occurs. |
115+
| C++11/C++17 and feature-disabled builds | Public `add_logger()` remains source-compatible; registration uses no newer language features or optional parser dependency. |
116+
86117
## Alternatives considered
87118

88119
### Move prepared pointers into `unique_ptr`

0 commit comments

Comments
 (0)