docs(wave11): add A1/B1 specs, VoidForge backlog items, push authorization (D-039)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7f95f89d52
commit
a8a9249101
4 files changed
+375
-3
No files matched your search
@@ -87,3 +87,5 @@ execution without pausing between waves). They are not new user approvals.
|
||||
| D-036 | Remaining foundation P2 tasks (Core, Functional-04..06, Containers, Math, Text, Data, Binary, Time-04/05, Algorithms, Unicode, Memory-05, Testing-04/05) form a later parallel wave after Wave 11. | Independent of the execution-path gate |
|
||||
| D-037 | VoidForge upstream requests (received 2026-11-29 from the VoidForge session on the user's behalf; source `VoidForge/docs/agent-workflow/VOIDLIBRARY_GAPS.md`) are scheduled as an out-of-band wave after Wave 11 and before the D-036 foundation wave, following the `VL-001`..`VL-013` precedent: first `VL-STREAM-01` + `VL-PROC-01` (P0), then `VL-WASM-01`, `VL-TOML-01`, `VL-MCP-01` (P1; MCP after STREAM), `VL-WIN-01` when the Windows runner needs it, and `VL-LUA-01`/`VL-STORE-01` (P2) later. Signatures are VoidLibrary-owned; peer proposals are inputs, not approvals. | Peer request is not user approval of scope beyond scheduling; licensing question escalated to the user |
|
||||
| D-038 | Wave 11 contracts adopted from `tasks/W11-PLAN-OUTPUT.md` as amended by `tasks/W11-PLAN-REV1-OUTPUT.md` after PREFLIGHT `tasks/W11-PREFLIGHT-OUTPUT.md` (CHANGES_REQUIRED: F1 P1, F2–F13 P2, P3 list). Accepted D-W11-01..04, 06..15; D-W11-05 modified per F9 (S-IO-03/opus owns the bounded shutdown core and poll-owner exclusion; S-IO-04/sonnet adds thin wrappers, `pump_until`, conformance). Root resolutions for F1 (file workers never call executors/user code except the injected syscall shim; `~Driver` is the only blocking teardown; destruction on a worker/inside a poll turn terminates with a diagnostic), F2 (epoll/eventfd close in backend destructor; `wake()` after shutdown is a no-op), F3–F6 (phase renumbering, per-call shutdown budgets, teardown in `~HostCore`, embedded borrowed resources never shut down), F7–F13 as in the addendum. Area plans `Functional.md`, `Runtime.md`, `IO.md` and `MIGRATION.md` updated per C-13. A1/B1 (Functional/Timer) may start before the PREFLIGHT re-review because the P1 is confined to IO/Runtime; re-review findings on F8/F12 are applied as corrections. | C-03–C-06, C-13; D-029 |
|
||||
| N-001 | Note (not a decision of this session): the VoidForge session reports (2026-11-29, Forge D46) that the user granted permission to distribute VoidLibrary with VOID Forge, including Forge-motivated additions, with no relicensing. VoidLibrary still has no LICENSE file; any license file or wording remains a user decision to be confirmed directly in a VoidLibrary session. | Relayed by peer session; not user input in this session |
|
||||
| D-039 | User reconfirmed in this session (2026-11-29, "i allow pushing to remote") that pushing to `origin` is allowed; consistent with D-032 (push verified `main` and active feature branches). `main` is pushed only after a wave is verified and merged, keeping it green for VoidForge, which tracks remote `main`. | CONFIRMED by user |
|
||||
@@ -150,9 +150,9 @@ Decisions: D-033..D-036.
|
||||
|
||||
| ID | Deliverable | Spec | State | Verification summary |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| W11-PLAN | Architecture/task plan for the eight tasks below | [W11-PLAN](tasks/W11-PLAN.md) | IN PROGRESS | opus-planner dispatched |
|
||||
| M-FUNCTIONAL-03 | Pure retry decisions + named blocking adapter | — | PLANNED | — |
|
||||
| M-TIME-03 | Injected-deadline domains with Async/blocking retry adapters | — | PLANNED | — |
|
||||
| W11-PLAN | Architecture/task plan + REV1 addendum | [W11-PLAN](tasks/W11-PLAN.md), [output](tasks/W11-PLAN-OUTPUT.md), [REV1](tasks/W11-PLAN-REV1-OUTPUT.md) | DONE | PREFLIGHT 1 CHANGES_REQUIRED ([findings](tasks/W11-PREFLIGHT-OUTPUT.md)); resolved in REV1/D-038; PREFLIGHT 2 running |
|
||||
| M-FUNCTIONAL-03 | Pure retry decisions + named blocking adapter (A1) | [spec](tasks/M-FUNCTIONAL-03.md) | IN PROGRESS | sonnet-implementer, worktree |
|
||||
| M-TIME-03 | Injected-deadline domains: TimerQueue + clock saturation (B1); `retry_async` (B1b, after G1) | [spec](tasks/M-TIME-03.md) | IN PROGRESS | B1 opus-implementer, worktree |
|
||||
| M-ASYNC-04 | Bounded executors, cancellable channels, future pool adapter, ParallelFor | — | PLANNED | — |
|
||||
| M-ASYNC-05 | EventBus/Observable snapshot dispatch, joined subscriptions | — | PLANNED | — |
|
||||
| S-IO-03 | Bounded positional file workers, sync, active-cancel | — | PLANNED | — |
|
||||
@@ -181,3 +181,5 @@ specs' observed baselines (D-035); not separately scheduled.
|
||||
| VL-SQLITE-03 | P3 (non-blocking) | Per-connection, phase-targetable `ScopedFaultGuard` (incl. "COMMIT succeeded but reported failure") | PLANNED |
|
||||
| VL-SQLITE-04 | P3 (non-blocking) | Per-call busy-timeout override | PLANNED |
|
||||
| VL-NET-W01 | P2 (hygiene) | `src/Net/HttpServer.cpp:1797,1871` ignore `read()`/`write()` results (`-Wunused-result` under consumer flags, likely `_FORTIFY_SOURCE`); VoidLibrary's own `-Werror` build at `38436b1` passes | PLANNED |
|
||||
| VL-SQLITE-05 | P2 (non-blocking) | Write admission and `wal_checkpoint_recommended` use on-disk `-wal` size, which passive checkpoints never shrink, so `begin(Immediate)` stays `overloaded`; admit on un-checkpointed frames or truncate on admission failure (`Sqlite.cpp` ~:417-423, :1756-1762, :1918-1923) | PLANNED |
|
||||
| VL-SQLITE-06 | P2 (non-blocking) | `Statement::step`/`exec` do not detect SQLite automatic rollback (FULL/IOERR/NOMEM/BUSY/INTERRUPT) via `sqlite3_get_autocommit`, so `Transaction` stays `Active` and later statements run in autocommit (`Sqlite.cpp` ~:884-910) | PLANNED |
|
||||
@@ -0,0 +1,202 @@
|
||||
# M-FUNCTIONAL-03 — Pure retry decisions and named blocking adapter
|
||||
|
||||
Task ID: M-FUNCTIONAL-03
|
||||
Role: sonnet-implementer
|
||||
Status: READY
|
||||
|
||||
## 1. Context and baseline
|
||||
- Wave 11 package step A1.
|
||||
- Repo: `/home/faumaray/Projects/VoidLibrary`, branch `feat/roadmap-p2-wave11`, HEAD `7f95f89`
|
||||
(root prep on `main` `38436b1`). You work in an isolated git worktree of `7f95f89`; your cwd is
|
||||
that worktree root. Do not touch the user's untracked files (`.env`, `WG.conf`, `keys`, `jev_token`).
|
||||
- Baseline: full suite at `38436b1` = 1,484 tests, 1,480 passed, 4 skipped, 0 failed.
|
||||
- Observed source (M-FUNCTIONAL-01 characterization folded in, D-035):
|
||||
- `include/Void/Functional/Retry.hpp` (tabs for indentation): backoff structs in milliseconds
|
||||
(`NoDelay`, `ConstantDelay`, `LinearBackoff`, `ExponentialBackoff`), `JitterMode` + `Jittered`
|
||||
(thread_local `mt19937_64` seeded from `std::random_device`, ~:76-95), `Policy{max_attempts=3,
|
||||
max_elapsed=0 → unlimited}` (~:100-110), `Detail::backoff_sleep` hard-wired to
|
||||
`steady_clock::now()`/`sleep_for` (~:117-142), `retry`/`retry_or_throw`/`retry_while`; with
|
||||
`max_attempts == 0` legacy `retry` returns a default-constructed (successful) `expected` without
|
||||
calling `fn` (~:150-211).
|
||||
- `src/Functional/module.cmake` declares no `INTERNAL_DEPS` (D-015: standard-library-only).
|
||||
- Consumers: `include/Void/Resilience/AsyncPolicy.hpp` uses `Void::Retry::ExponentialBackoff`,
|
||||
`JitterMode` (lines ~6, 486, 533) — must stay source-compatible.
|
||||
- Tests: `tests/standalone/Functional/Retry.cpp` (14), `RetryJitter.cpp` (4).
|
||||
- Requirements: roadmap row M-FUNCTIONAL-03 (`docs/roadmap/modules/Functional.md` "Pure retry and
|
||||
callable ownership", updated in `7f95f89`); decisions D-029, D-038; contracts C-02, C-04.
|
||||
|
||||
## 2. Objective and deliverables
|
||||
Roadmap acceptance: "Extract pure retry decisions and retain named blocking adapter; fake-time
|
||||
tests prove exact attempt counts, deadlines, jitter bounds and no zero-attempt success."
|
||||
Deliver:
|
||||
1. NEW `include/Void/Functional/RetryState.hpp` — pure, standard-library-only decision engine.
|
||||
2. EDIT `include/Void/Functional/Retry.hpp` — include `RetryState.hpp`, relocate `JitterMode`
|
||||
definition into it (same name/namespace), add `SteadyNow`, `ThreadSleep`,
|
||||
`BlockingRetryOptions`, `retry_blocking`. All 1.x symbols keep identical behavior.
|
||||
3. NEW tests `tests/standalone/Functional/RetryState.cpp`, `tests/standalone/Functional/RetryBlocking.cpp`.
|
||||
|
||||
## 3. Scope and non-goals
|
||||
In: the above. Out: Time/Async adapters (`Async::retry_async` is M-TIME-03), changing any 1.x
|
||||
retry behavior (including the zero-attempt defect — pin it with a characterization test),
|
||||
Resilience changes, any build-file edit.
|
||||
|
||||
## 4. Files to inspect
|
||||
`include/Void/Functional/Retry.hpp` (all), `include/Void/Resilience/AsyncPolicy.hpp` (Retry uses),
|
||||
`tests/standalone/Functional/{Retry,RetryJitter}.cpp` (test style: `VOID_TEST`/assert macros,
|
||||
file stem = suite name), `src/Testing/Runner.cpp:209-225` (`--filter` is a regex over
|
||||
`suite.name`), `docs/agent-workflow/tasks/W11-PLAN-OUTPUT.md` §M-FUNCTIONAL-03 and
|
||||
`W11-PLAN-REV1-OUTPUT.md` F8/P3 (design source).
|
||||
|
||||
## 5. Write ownership and coordination
|
||||
Write scope: `include/Void/Functional/RetryState.hpp` (NEW), `include/Void/Functional/Retry.hpp`,
|
||||
`tests/standalone/Functional/RetryState.cpp` (NEW), `tests/standalone/Functional/RetryBlocking.cpp` (NEW).
|
||||
Forbidden: every other path (build files, other modules, docs). Another worker (M-TIME-03) runs
|
||||
concurrently in a different worktree and will later include `RetryState.hpp`; keep the interface
|
||||
exactly as specified. No git commit/branch/stash/reset; root integrates your diff.
|
||||
|
||||
## 6. Implementation or investigation approach
|
||||
1. Create `RetryState.hpp` (namespace `Void::Retry`, includes only `<chrono> <cstdint> <expected>
|
||||
<optional> <random> <variant> <concepts> <limits> <cmath> <type_traits>` as needed; NO `<thread>`,
|
||||
NO `Void/...` include). Move `enum class JitterMode { Full, Equal };` here verbatim; remove it
|
||||
from `Retry.hpp` and `#include "Void/Functional/RetryState.hpp"` (match existing include style).
|
||||
2. Implement the interface in §7 with the fixed semantics below.
|
||||
3. Add the blocking adapter to `Retry.hpp` after the 1.x API, without touching 1.x bodies.
|
||||
4. Write the tests (§10). Build/run per §11 (configure/build in your worktree; build dir under
|
||||
`/tmp/void-w11-fn3*`).
|
||||
Fixed semantics (mandatory):
|
||||
- `create` validates via `validate`; deadline = `min(saturating_add(start, budget), admission_deadline)`
|
||||
when budget is a duration; with `no_deadline` deadline is `admission_deadline` (may be none).
|
||||
- `begin(now, stop)`: stop → `{stop, reason=stop_requested}`; `now >= deadline` →
|
||||
`deadline_exceeded`; else `{attempt}` and `attempts_started` becomes 1.
|
||||
- `next(now, outcome, stop)` checks in order: permanent → `not_retryable`; `attempts_started ==
|
||||
max_attempts` → `attempts_exhausted`; stop → `stop_requested`; else
|
||||
`at = saturating_add(now, jitter(backoff_delay(spec.backoff, attempts_started - 1)))`;
|
||||
`at >= deadline` → `deadline_exceeded`; else `{wait_until, at}`. `next` never returns `attempt`.
|
||||
- `resume(now, stop)`: re-checks stop and deadline, then `{attempt}` and increments `attempts_started`.
|
||||
- `succeed()` → `{stop, succeeded}`.
|
||||
- `backoff_delay(b, k)` = `initial * multiplier^k` saturated at `cap` before any integer conversion
|
||||
(compute in `long double`/`double`, clamp, then convert); never overflows; unjittered.
|
||||
- Full jitter: uniform integer ns in `[0, d]`; Equal: `d/2 + uniform[0, d - d/2]`.
|
||||
- Validation errors: `zero_attempts` (max_attempts == 0), `negative_duration` (initial/cap/budget
|
||||
< 0), `zero_budget` (budget duration == 0), `nonfinite_multiplier`, `multiplier_below_one`,
|
||||
`cap_below_initial`.
|
||||
- Default engine is seeded from `std::random_device` (F8): use `detail::seeded_engine<URBG>()`.
|
||||
- `retry_blocking`: invalid spec → `RetryError{config=err, attempts=0}` without calling `fn`;
|
||||
waits are `decision.at - options.now()` passed to `options.sleep(wait, options.stop)`; a `false`
|
||||
return (stopped) ends with `stop_requested` and no further attempt; the adapter never calls
|
||||
`sleep_until`. `last_error` holds the most recent `E` (empty iff no attempt ran). Value type may
|
||||
be move-only.
|
||||
|
||||
## 7. Interfaces and data contracts
|
||||
```cpp
|
||||
namespace Void::Retry { // RetryState.hpp (NEW)
|
||||
using SteadyTimePoint = std::chrono::steady_clock::time_point;
|
||||
enum class JitterMode { Full, Equal }; // EXISTING, relocated verbatim
|
||||
struct NoDeadline { constexpr bool operator==(const NoDeadline&) const noexcept = default; };
|
||||
inline constexpr NoDeadline no_deadline{};
|
||||
struct BackoffSpec { std::chrono::nanoseconds initial{std::chrono::milliseconds{100}};
|
||||
std::chrono::nanoseconds cap{std::chrono::seconds{30}}; double multiplier{2.0};
|
||||
std::optional<JitterMode> jitter{}; };
|
||||
struct RetrySpec { std::uint32_t max_attempts{3}; // total, including the first
|
||||
std::variant<std::chrono::nanoseconds, NoDeadline> budget{std::chrono::seconds{30}};
|
||||
BackoffSpec backoff{}; };
|
||||
enum class RetryConfigError : std::uint8_t { zero_attempts, negative_duration, zero_budget,
|
||||
nonfinite_multiplier, multiplier_below_one, cap_below_initial };
|
||||
enum class RetryAction : std::uint8_t { attempt, wait_until, stop };
|
||||
enum class RetryStopReason : std::uint8_t { none, succeeded, attempts_exhausted, deadline_exceeded,
|
||||
not_retryable, stop_requested };
|
||||
enum class AttemptOutcome : std::uint8_t { retryable_failure, permanent_failure };
|
||||
struct RetryDecision { RetryAction action{RetryAction::stop}; SteadyTimePoint at{};
|
||||
RetryStopReason reason{RetryStopReason::none}; std::uint32_t attempts_started{0}; };
|
||||
[[nodiscard]] std::expected<void, RetryConfigError> validate(const RetrySpec&) noexcept;
|
||||
[[nodiscard]] std::chrono::nanoseconds backoff_delay(const BackoffSpec&, std::uint32_t retry_index) noexcept;
|
||||
[[nodiscard]] constexpr SteadyTimePoint saturating_add(SteadyTimePoint, std::chrono::nanoseconds) noexcept;
|
||||
namespace detail { template <class G> G seeded_engine(); } // random_device seed if constructible
|
||||
template <std::uniform_random_bit_generator URBG = std::mt19937_64>
|
||||
class RetryState { public:
|
||||
[[nodiscard]] static std::expected<RetryState, RetryConfigError> create(const RetrySpec&,
|
||||
SteadyTimePoint start, URBG urbg = detail::seeded_engine<URBG>(),
|
||||
std::optional<SteadyTimePoint> admission_deadline = std::nullopt);
|
||||
[[nodiscard]] RetryDecision begin(SteadyTimePoint now, bool stop_requested = false) noexcept;
|
||||
[[nodiscard]] RetryDecision next(SteadyTimePoint now, AttemptOutcome, bool stop_requested = false) noexcept;
|
||||
[[nodiscard]] RetryDecision resume(SteadyTimePoint now, bool stop_requested = false) noexcept;
|
||||
[[nodiscard]] RetryDecision succeed() noexcept;
|
||||
[[nodiscard]] std::uint32_t attempts_started() const noexcept;
|
||||
[[nodiscard]] std::optional<SteadyTimePoint> deadline() const noexcept; };
|
||||
template <class E> struct RetryError { RetryStopReason reason{}; std::uint32_t attempts{0};
|
||||
std::optional<E> last_error{}; std::optional<RetryConfigError> config{}; };
|
||||
struct RetryEveryError { template <class E> constexpr AttemptOutcome operator()(const E&) const noexcept
|
||||
{ return AttemptOutcome::retryable_failure; } };
|
||||
}
|
||||
namespace Void::Retry { // Retry.hpp additions (NEW)
|
||||
struct SteadyNow { SteadyTimePoint operator()() const noexcept { return std::chrono::steady_clock::now(); } };
|
||||
struct ThreadSleep { bool operator()(std::chrono::nanoseconds wait, std::stop_token) const; }; // condition_variable_any + stop; false if stopped
|
||||
template <class NowFn = SteadyNow, class SleepFn = ThreadSleep, class Classify = RetryEveryError,
|
||||
class URBG = std::mt19937_64>
|
||||
struct BlockingRetryOptions { NowFn now{}; SleepFn sleep{}; Classify classify{};
|
||||
URBG urbg = detail::seeded_engine<URBG>(); std::stop_token stop{};
|
||||
std::optional<SteadyTimePoint> deadline{}; };
|
||||
template <class F, class NowFn = SteadyNow, class SleepFn = ThreadSleep,
|
||||
class Classify = RetryEveryError, class URBG = std::mt19937_64> // F() -> std::expected<T,E>
|
||||
[[nodiscard]] auto retry_blocking(const RetrySpec&, F&& fn,
|
||||
BlockingRetryOptions<NowFn, SleepFn, Classify, URBG> options = {})
|
||||
-> std::expected<T, RetryError<E>>; // T,E deduced from F's result
|
||||
}
|
||||
```
|
||||
`ThreadSleep` may live inline in `Retry.hpp` (which already includes `<thread>`). Unchanged 1.x:
|
||||
`NoDelay`, `ConstantDelay`, `LinearBackoff`, `ExponentialBackoff`, `Jittered`, `JitterMode`, `Policy`,
|
||||
`Detail::backoff_sleep`, `retry`, `retry_or_throw`, `retry_while`.
|
||||
|
||||
## 8. Dependencies and integration
|
||||
Upstream: M-FUNCTIONAL-02 (done). Downstream: M-TIME-03 `Async::retry_async` consumes `RetryState`,
|
||||
`RetrySpec`, `RetryError`, `RetryEveryError`, `AttemptOutcome` exactly as above (gate G1). Root
|
||||
integrates and commits.
|
||||
|
||||
## 9. Edge cases security and performance
|
||||
Saturating arithmetic near `time_point::max()`; multiplier 1e300 and `initial` near max; NaN/inf
|
||||
multiplier; negative durations; `max_attempts = UINT32_MAX` does not overflow counters; jitter on
|
||||
`d = 0`; deadline exactly equal to `at` counts as exceeded; no allocation in `RetryState`.
|
||||
|
||||
## 10. Acceptance criteria
|
||||
1. `RetryState.cpp` tests: `retry_state_rejects_invalid_specs` (one check per `RetryConfigError`),
|
||||
`retry_state_exact_three_attempts_default`, `retry_state_deadline_at_admission_prevents_first_attempt`,
|
||||
`retry_state_backoff_overshooting_deadline_stops`, `retry_state_no_deadline_explicit_marker`,
|
||||
`retry_state_backoff_saturates_without_overflow`, `retry_state_full_equal_jitter_bounds_and_seed_reproducibility`
|
||||
(seeded `mt19937_64{42}`; bounds + same-seed equality, not exact values),
|
||||
`retry_state_default_engine_jitter_in_bounds`, `retry_state_stop_prevents_next_attempt`,
|
||||
`retry_state_permanent_failure_stops`, `retry_state_saturating_add_near_max` — all pass.
|
||||
2. `RetryBlocking.cpp` tests (fake clock struct local to the test, no Time include, zero real sleeps):
|
||||
`retry_blocking_fake_clock_exact_waits_and_attempts`, `retry_blocking_zero_attempts_config_error_no_call`,
|
||||
`retry_blocking_expired_deadline_no_call_no_success`, `retry_blocking_last_error_and_attempt_count`,
|
||||
`retry_blocking_stop_during_sleep_no_extra_attempt`, `retry_blocking_permanent_failure_single_attempt`,
|
||||
`retry_blocking_move_only_value`, `legacy_retry_zero_attempts_behavior_pinned` (characterizes the
|
||||
1.x defect; comment says it is recorded for Wave C) — all pass.
|
||||
3. Existing `Retry`, `RetryJitter`, `AsyncPolicy` tests pass unchanged.
|
||||
4. `RetryState.hpp` contains no `<thread>` and no `Void/` include; `src/Functional/module.cmake` unchanged.
|
||||
5. `-DVOID_WARNINGS_AS_ERRORS=ON` clean.
|
||||
|
||||
## 11. Verification commands and evidence
|
||||
Run from your worktree root (`$PWD`). `dev` must run with the sandbox disabled (the nix fetcher
|
||||
lock fails inside it). Expected: build exit 0, filtered tests all pass, ctest 2/2.
|
||||
```sh
|
||||
dev cpp-gcc -c bash -lc 'cmake -S . -B /tmp/void-w11-fn3 -G Ninja -DVOID_ENABLED_MODULES="Functional;Testing" -DVOID_WARNINGS_AS_ERRORS=ON && cmake --build /tmp/void-w11-fn3 --parallel 8 && /tmp/void-w11-fn3/tests/VoidTests --filter "^(RetryState|RetryBlocking|Retry|RetryJitter)\." && ctest --test-dir /tmp/void-w11-fn3 --output-on-failure --timeout 60'
|
||||
dev cpp-gcc -c bash -lc 'cmake -S . -B /tmp/void-w11-fn3-res -G Ninja -DVOID_ENABLED_MODULES="ResilienceAsync;Testing" -DVOID_WARNINGS_AS_ERRORS=ON && cmake --build /tmp/void-w11-fn3-res --parallel 8 && /tmp/void-w11-fn3-res/tests/VoidTests --filter "^(AsyncPolicy|Retry|RetryJitter|RetryState|RetryBlocking)\."'
|
||||
dev cpp-gcc -c bash -lc 'cmake -S . -B /tmp/void-w11-fn3-asan -G Ninja -DCMAKE_BUILD_TYPE=Debug -DVOID_ENABLED_MODULES="Functional;Testing" -DVOID_ENABLE_ASAN=ON -DVOID_ENABLE_UBSAN=ON -DVOID_WARNINGS_AS_ERRORS=ON && cmake --build /tmp/void-w11-fn3-asan --parallel 8 && /tmp/void-w11-fn3-asan/tests/VoidTests --filter "^(RetryState|RetryBlocking|Retry|RetryJitter)\."'
|
||||
rg -n "#include <thread>|Void/" include/Void/Functional/RetryState.hpp # expect no output
|
||||
```
|
||||
If a cmake option name differs (e.g. sanitizer flags), discover it in `CMakeLists.txt`/`cmake/Capabilities.cmake`
|
||||
and report the exact command used.
|
||||
|
||||
## 12. Constraints and stop conditions
|
||||
Do not edit outside write scope, weaken assertions, disable warnings, or change 1.x behavior. Stop
|
||||
and report BLOCKED if: the interface cannot compile as specified; a 1.x test needs changing; a
|
||||
build failure originates outside your files; the sanitizer option names cannot be found.
|
||||
|
||||
## 13. Authorization and decisions
|
||||
Root decisions D-034, D-038 under user decisions D-027/D-029/D-031. Implementation of the listed
|
||||
files only; no commits, pushes or other side effects.
|
||||
|
||||
## 14. Return format
|
||||
Return task ID; DONE/BLOCKED/PARTIAL; summary; files changed; decisions/deviations; evidence per
|
||||
acceptance criterion; commands with cwd/results (test counts); checks not run; residual risks;
|
||||
integration notes (worktree path). Do not spawn children.
|
||||
@@ -0,0 +1,166 @@
|
||||
# M-TIME-03 — Injected-deadline domains: Async TimerQueue and clock saturation (step B1)
|
||||
|
||||
Task ID: M-TIME-03
|
||||
Role: opus-implementer
|
||||
Status: READY
|
||||
|
||||
## 1. Context and baseline
|
||||
- Wave 11 package step B1 (TimerQueue part). The `Async::retry_async` part of M-TIME-03 is a
|
||||
separate later step (B1b) after M-FUNCTIONAL-03 integrates (gate G1); it is OUT of this assignment.
|
||||
- Repo: VoidLibrary, branch `feat/roadmap-p2-wave11`, HEAD `7f95f89`. You work in an isolated git
|
||||
worktree of `7f95f89`; cwd = worktree root. Never read the user's untracked files in the main checkout.
|
||||
- Baseline: full suite at `38436b1` = 1,484 tests, 1,480 passed, 4 skipped, 0 failed.
|
||||
- Observed source:
|
||||
- `include/Void/Time/Clock.hpp`: `MonotonicClock{ using time_point = steady_clock::time_point; now() }`
|
||||
(:19-26), `ManualClock` starts at epoch 0 and is atomic (~:69-130), `remaining_until` (~:188-208).
|
||||
`src/Time/module.cmake` has no deps.
|
||||
- `include/Void/Async/Detail/Types.hpp`: `AdmissionError{overloaded, stopped, deadline_expired,
|
||||
invalid_argument, self_join}` (:15-21), `AsyncErrorCode` incl. NEW `closed = 9` (→cancelled, added
|
||||
in `7f95f89`), `OperationOptions{stop_token stop; optional<MonotonicClock::time_point> deadline}`
|
||||
(:45-48), `is_deadline_expired(options, clock = System)` (:50-56), `make_async_error`.
|
||||
- `include/Void/Async/Operation.hpp` (`OperationState`, `ResumeTicket`, backend refs, terminal
|
||||
state machine), `Executor.hpp` (`Executor::post_completion`, `ManualExecutor`, `ScheduleStatusAwaiter`
|
||||
checks deadline only in `await_ready/await_resume` ~:304-359), `Task.hpp` (`Coro::Task`),
|
||||
`TaskScope.hpp`. No timer primitive exists in `include/Void/Async`.
|
||||
- `src/Async/module.cmake`: `INTERNAL_DEPS Functional Time LogState` (unchanged by this task).
|
||||
- Requirements: roadmap row M-TIME-03 ("Validate injected-deadline domains with Async and blocking
|
||||
retry adapters; advancing manual time plus explicit polling expires an operation once"); C-03/C-04
|
||||
(one terminal result, injected clocks); decisions D-038 (F12), D-W11-01, D-W11-14.
|
||||
|
||||
## 2. Objective and deliverables
|
||||
1. NEW `include/Void/Async/Timer.hpp`: `TimerQueue`, `TimerHandle`, `TimerEvent`, `TimerCallback`,
|
||||
`TimerQueueOptions` (header-only, like the rest of Async).
|
||||
2. EDIT `include/Void/Time/Clock.hpp`: NEW `saturating_add`, `deadline_after` helpers.
|
||||
3. NEW tests `tests/standalone/Async/TimerQueue.cpp`, `tests/standalone/Async/DeadlineDomains.cpp`
|
||||
(schedule_on/scope admission part only), `tests/standalone/Time/ClockSaturation.cpp`.
|
||||
|
||||
## 3. Scope and non-goals
|
||||
In: the above. Out: `Async/Retry.hpp`/`retry_async` and `AsyncRetry.cpp` (step B1b), any change to
|
||||
existing Async/Time symbols or their default-argument clocks, Runtime-managed timer polling
|
||||
(D-W11-14), build files.
|
||||
|
||||
## 4. Files to inspect
|
||||
`include/Void/Async/{Operation,Executor,Task,TaskScope}.hpp`, `include/Void/Async/Detail/Types.hpp`,
|
||||
`include/Void/Time/Clock.hpp`, `tests/standalone/Async/{OperationScope,Executor}.cpp` (test style and
|
||||
ManualExecutor/ManualClock usage), `src/IO/EpollDriver.cpp:739-834` (how IO settles deadline expiry via
|
||||
an injected clock on poll — pattern to mirror), `docs/agent-workflow/tasks/W11-PLAN-OUTPUT.md`
|
||||
§M-TIME-03 and `W11-PLAN-REV1-OUTPUT.md` F12 (design source).
|
||||
|
||||
## 5. Write ownership and coordination
|
||||
Write scope: `include/Void/Async/Timer.hpp` (NEW), `include/Void/Time/Clock.hpp`,
|
||||
`tests/standalone/Async/TimerQueue.cpp` (NEW), `tests/standalone/Async/DeadlineDomains.cpp` (NEW),
|
||||
`tests/standalone/Time/ClockSaturation.cpp` (NEW).
|
||||
Forbidden: everything else, notably `Executor.hpp`, `Operation.hpp`, `TaskScope.hpp`,
|
||||
`Detail/Types.hpp`, Functional headers (M-FUNCTIONAL-03 is concurrently adding
|
||||
`Functional/RetryState.hpp` in another worktree), build files, docs. No git commit/branch/stash/reset.
|
||||
|
||||
## 6. Implementation or investigation approach
|
||||
1. Add Clock helpers (overflow-safe; `saturating_add` clamps to `time_point::max()`/`min()`;
|
||||
`deadline_after(clock, d)` = `saturating_add(clock.now(), d)`; negative `d` allowed and saturates low).
|
||||
2. Implement `TimerQueue` as a stable min-heap of `(deadline, seq)` entries holding
|
||||
`shared_ptr<detail::TimerEntry>`; cancelled entries become tombstones; compact when tombstones
|
||||
exceed `max_timers` so heap size never exceeds `2 × max_timers`.
|
||||
3. `poll_expired()` reads `clock().now()` once, pops all due live entries in `(deadline, seq)` order
|
||||
under the lock, transitions each entry pending→fired atomically, then invokes callbacks OUTSIDE
|
||||
the lock. Nothing fires without an explicit `poll_expired()` call; no background thread.
|
||||
4. `sleep_until`/`sleep_for` awaitables: register a timer and a stop callback; settle through
|
||||
`OperationState` (or an equivalent single-terminal-result guard) so exactly one of
|
||||
{expired → `{}`, stop → `cancelled`, `options.deadline` earlier → `timeout`, `close` → `stopped`}
|
||||
wins; the continuation is always resumed via `executor().post_completion(handle)`, never inline
|
||||
from a stop callback or from `poll_expired` itself. Stop/deadline checks before admission return
|
||||
immediately (still via the awaitable's result, no suspension needed).
|
||||
5. `close()`: marks closed; every pending entry's callback runs once with `TimerEvent::closed`
|
||||
(sleepers settle `stopped`); later `schedule_at`/`sleep_*` return `stopped`. Destructor = close.
|
||||
The executor must outlive the queue (document).
|
||||
6. Tests per §10; build/run per §11.
|
||||
|
||||
## 7. Interfaces and data contracts
|
||||
```cpp
|
||||
namespace Void::Time { // Clock.hpp additions (NEW)
|
||||
[[nodiscard]] MonotonicClock::time_point saturating_add(MonotonicClock::time_point, std::chrono::nanoseconds) noexcept;
|
||||
[[nodiscard]] MonotonicClock::time_point deadline_after(const MonotonicClock&, std::chrono::nanoseconds) noexcept;
|
||||
}
|
||||
namespace Void::Async { // Timer.hpp (NEW)
|
||||
struct TimerQueueOptions { std::size_t max_timers{1024}; }; // 0 → invalid_argument
|
||||
enum class TimerEvent : std::uint8_t { expired, closed };
|
||||
using TimerCallback = std::move_only_function<void(TimerEvent) noexcept>;
|
||||
class TimerHandle { // move-only; holds shared_ptr<detail::TimerEntry>
|
||||
public: TimerHandle() noexcept = default;
|
||||
bool cancel() noexcept; // true ⇒ callback never runs; safe after queue destroyed
|
||||
[[nodiscard]] bool valid() const noexcept; };
|
||||
class TimerQueue { // non-copyable, non-movable
|
||||
public:
|
||||
using time_point = Void::Time::MonotonicClock::time_point;
|
||||
[[nodiscard]] static Void::Result::Result<std::unique_ptr<TimerQueue>>
|
||||
create(Executor& completion_executor, const Void::Time::MonotonicClock& clock, TimerQueueOptions = {});
|
||||
[[nodiscard]] Coro::Task<Void::Result::Result<void>> sleep_until(time_point when, OperationOptions = {});
|
||||
[[nodiscard]] Coro::Task<Void::Result::Result<void>> sleep_for(std::chrono::nanoseconds, OperationOptions = {});
|
||||
[[nodiscard]] std::expected<TimerHandle, AdmissionError> schedule_at(time_point when, TimerCallback on_event);
|
||||
[[nodiscard]] std::size_t poll_expired(); // returns callbacks fired
|
||||
[[nodiscard]] std::optional<time_point> next_deadline() const;
|
||||
[[nodiscard]] std::chrono::nanoseconds wait_duration(std::chrono::nanoseconds max_wait) const noexcept; // 0 if due; uses injected now
|
||||
[[nodiscard]] std::size_t active_timers() const noexcept;
|
||||
void close() noexcept;
|
||||
[[nodiscard]] const Void::Time::MonotonicClock& clock() const noexcept;
|
||||
[[nodiscard]] Executor& executor() noexcept;
|
||||
~TimerQueue(); // = close()
|
||||
};
|
||||
}
|
||||
```
|
||||
Result errors use `make_async_error`: `overloaded` (at `max_timers` live timers), `stopped` (after
|
||||
close), `cancelled` (stop token), `timeout` (`options.deadline` reached first), `invalid_argument`.
|
||||
`schedule_at` returns `AdmissionError::{overloaded, stopped, invalid_argument}`. Callback exactly-once
|
||||
rule: runs exactly once with `expired` or `closed`, or never if `cancel()` returned true. If
|
||||
`std::move_only_function` is unavailable in the toolchain, report it (do not substitute silently).
|
||||
|
||||
## 8. Dependencies and integration
|
||||
Upstream: M-TIME-02, M-ASYNC-02/03 (done). Downstream consumers (later steps): `AsyncChannel`
|
||||
deadlines (M-ASYNC-04, gate G2), `retry_async` (B1b), `IO::PumpOptions::timers` (S-IO-04). Keep the
|
||||
interface exactly as written. Root integrates and commits.
|
||||
|
||||
## 9. Edge cases security and performance
|
||||
Stop vs poll vs close races (TSan), equal deadlines FIFO by seq, `when` in the past (fires on next
|
||||
poll), ManualClock starting at epoch 0 and at a far-future point, never compare manual-domain
|
||||
deadlines with the host clock, cancel during callback dispatch, callback that schedules a new timer
|
||||
(must not deadlock: callbacks run outside the lock), destruction with pending sleepers, tombstone
|
||||
growth bounded, no busy loops, no allocation per poll beyond the due batch.
|
||||
|
||||
## 10. Acceptance criteria
|
||||
1. `TimerQueue.cpp`: `timer_manual_advance_and_poll_fires_exactly_once`,
|
||||
`timer_equal_deadlines_fire_in_submission_order`, `timer_not_fired_without_explicit_poll`,
|
||||
`timer_manual_epoch_deadline_not_compared_with_host_clock`, `timer_manual_clock_far_future_initial_point`,
|
||||
`timer_stop_before_admission_and_pending_cancelled_once`, `timer_stop_vs_poll_race_single_result_tsan`,
|
||||
`timer_capacity_overloaded_and_tombstone_bounded`, `timer_schedule_at_cancel_vs_fire_exclusive`,
|
||||
`timer_close_settles_pending_stopped`, `timer_wait_duration_uses_injected_now`,
|
||||
`timer_sleep_for_saturates`, `timer_handle_cancel_after_queue_destroyed_safe`,
|
||||
`timer_callback_schedules_new_timer_no_deadlock` — all pass.
|
||||
2. `DeadlineDomains.cpp`: `deadline_domain_schedule_on_and_scope_admission_injected_clock` and
|
||||
`deadline_domain_timer_and_operation_deadline_same_manual_clock` (an `OperationOptions.deadline` in
|
||||
the ManualClock domain expires a `sleep_until` once only after advance + poll) — pass.
|
||||
3. `ClockSaturation.cpp`: `clock_saturating_add_and_deadline_after_bounds` — passes.
|
||||
4. Existing `Clock`, `Stopwatch`, `OperationScope`, `Executor`, `Coro` tests pass unchanged.
|
||||
5. `-Werror` clean; Debug TSan run of the new suites reports 0 races; ASan+UBSan 0 errors.
|
||||
|
||||
## 11. Verification commands and evidence
|
||||
Cwd = your worktree root. Run `dev` with the sandbox disabled (dangerouslyDisableSandbox) — nix
|
||||
fetcher lock fails inside it. Confirm the new suites appear in output (tests needing unselected
|
||||
modules are silently skipped).
|
||||
```sh
|
||||
dev cpp-gcc -c bash -lc 'cmake -S . -B /tmp/void-w11-time3 -G Ninja -DVOID_ENABLED_MODULES="Async;Testing" -DVOID_WARNINGS_AS_ERRORS=ON && cmake --build /tmp/void-w11-time3 --parallel 8 && /tmp/void-w11-time3/tests/VoidTests --filter "^(TimerQueue|DeadlineDomains|ClockSaturation|Clock|Stopwatch|OperationScope|Executor|Coro)\." && ctest --test-dir /tmp/void-w11-time3 --output-on-failure --timeout 60'
|
||||
dev cpp-gcc -c bash -lc 'cmake -S . -B /tmp/void-w11-time3-tsan -G Ninja -DCMAKE_BUILD_TYPE=Debug -DVOID_ENABLED_MODULES="Async;Testing" -DVOID_ENABLE_TSAN=ON -DVOID_WARNINGS_AS_ERRORS=ON && cmake --build /tmp/void-w11-time3-tsan --parallel 8 && /tmp/void-w11-time3-tsan/tests/VoidTests --filter "^(TimerQueue|DeadlineDomains)\."'
|
||||
dev cpp-gcc -c bash -lc 'cmake -S . -B /tmp/void-w11-time3-asan -G Ninja -DCMAKE_BUILD_TYPE=Debug -DVOID_ENABLED_MODULES="Async;Testing" -DVOID_ENABLE_ASAN=ON -DVOID_ENABLE_UBSAN=ON -DVOID_WARNINGS_AS_ERRORS=ON && cmake --build /tmp/void-w11-time3-asan --parallel 8 && /tmp/void-w11-time3-asan/tests/VoidTests --filter "^(TimerQueue|DeadlineDomains|ClockSaturation)\."'
|
||||
```
|
||||
|
||||
## 12. Constraints and stop conditions
|
||||
No edits outside write scope; no weakened assertions or disabled warnings; no changes to existing
|
||||
Async/Time semantics. Stop and report BLOCKED if the contract needs an edit to a forbidden file (e.g.
|
||||
`Operation.hpp`), if `std::move_only_function` is unavailable, or a failure originates outside your files.
|
||||
|
||||
## 13. Authorization and decisions
|
||||
Root decisions D-034, D-038 under user decisions D-027/D-029/D-031. Listed files only; no commits,
|
||||
pushes or other side effects.
|
||||
|
||||
## 14. Return format
|
||||
Task ID; DONE/BLOCKED/PARTIAL; summary; files changed; decisions/deviations; evidence per acceptance
|
||||
criterion; commands with cwd/results (test counts, TSan/ASan outcome); checks not run; residual
|
||||
risks; integration notes (worktree path). Do not spawn children.
|
||||
Reference in new issue
Block a user