docs(wave11): S-IO-04 and combined S-RUNTIME-02/03 specs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7c1fd3cac1
commit
09789ae141
2 files changed
+358
No files matched your search
@@ -0,0 +1,134 @@
|
||||
# S-IO-04 — Embedded pumping (`Driver::run`, `pump_until`), joined-shutdown conformance
|
||||
|
||||
Task ID: S-IO-04
|
||||
Role: sonnet-implementer
|
||||
Status: READY
|
||||
|
||||
## 1. Context and baseline
|
||||
- Wave 11 package step A4 (gate G4: S-IO-03 committed). Repo VoidLibrary, branch
|
||||
`feat/roadmap-p2-wave11`. Isolated worktree; first fast-forward it to the HEAD stated in your prompt.
|
||||
- Baseline: full suite at `38436b1` = 1,484 tests (1,480 ✔, 4 ⊘); the branch adds RetryState, TimerQueue,
|
||||
retry_async and S-IO-03 (IoFile 33 tests).
|
||||
- Observed source after S-IO-03 (see `docs/agent-workflow/tasks/S-IO-03.md` and its implementer notes):
|
||||
- `include/Void/IO/Driver.hpp`: `poll_once(max_wait)` returns `IoErrorCode::busy` for three causes
|
||||
(reentrant call on this backend, concurrent poller, shutdown taking over poll ownership) without
|
||||
touching fds; after shutdown completes it returns 0 immediately. Public inline wrappers
|
||||
`begin_shutdown()`, `shutdown(Async::OperationOptions)` → `DriverShutdownReport`, `quiescent()`,
|
||||
`shutdown_complete()`; `request_stop()` == `begin_shutdown()`. Shutdown dispatches resume tickets on the
|
||||
thread that called `shutdown()`, after releasing poll ownership; the executor must outlive the Driver.
|
||||
- Mock backend: `poll_once` ignores `max_wait` (never blocks); requests held by a `MockController`
|
||||
token keep `pending_operations > 0` even when the report says `complete == true`.
|
||||
- `include/Void/Async/Timer.hpp`: `TimerQueue::{poll_expired, wait_duration(max_wait), next_deadline}`.
|
||||
- `include/Void/Async/TaskScope.hpp`: `join_pumping` drains the executor but never polls IO.
|
||||
- SystemAsync `ProcessManager` borrows a `Driver` (`include/Void/System/AsyncProcess.hpp`,
|
||||
`src/SystemAsync/AsyncProcess.cpp`). Net does not use IO (Net adapter deferred, D-W11-07).
|
||||
- Requirements: roadmap row S-IO-04 ("Embedded pumping, joined shutdown, SystemAsync conformance (Net
|
||||
adapter deferred) | Shutdown during pending socket/file work retains resources; no IO→Runtime/Net
|
||||
dependency"); C-03..C-06; decisions D-038, D-040 (N3 loop rules), D-042 (S9 split).
|
||||
|
||||
## 2. Objective and deliverables
|
||||
1. EDIT `include/Void/IO/Driver.hpp`: NEW inline `Driver::run(std::stop_token, std::chrono::nanoseconds max_wait = 5ms)`.
|
||||
2. NEW `include/Void/IO/Pump.hpp`: `PumpOptions`, `pump_until`.
|
||||
3. NEW tests `tests/standalone/IO/IoShutdown.cpp`, `tests/standalone/IO/IoPump.cpp`,
|
||||
`tests/standalone/SystemAsync/SystemAsyncShutdown.cpp`.
|
||||
|
||||
## 3. Scope and non-goals
|
||||
Out: any change to `src/IO/*`, `include/Void/IO/{Types,File}.hpp`, `include/Void/IO/Detail/*`, Async
|
||||
headers, SystemAsync sources, Runtime, Net adapter, build files. If a defect in the S-IO-03 primitives is
|
||||
found, STOP and report it with a reproducer (root owns the fix).
|
||||
|
||||
## 4. Files to inspect
|
||||
`include/Void/IO/{Driver,Types,File,Stream}.hpp`, `include/Void/IO/Detail/Backend.hpp` (read-only),
|
||||
`include/Void/Async/{Timer,Executor,TaskScope}.hpp`, `include/Void/System/AsyncProcess.hpp`,
|
||||
`tests/standalone/IO/{IoDriver,IoFile}.cpp`, `tests/standalone/SystemAsync/*.cpp`,
|
||||
`docs/agent-workflow/tasks/W11-CONTRACT-R2.md` N3, `W11-PLAN-OUTPUT.md` §S-IO-04.
|
||||
|
||||
## 5. Write ownership and coordination
|
||||
Write scope: `include/Void/IO/Driver.hpp` (only the NEW `run` declaration/definition), `include/Void/IO/Pump.hpp` (NEW),
|
||||
`tests/standalone/IO/IoShutdown.cpp` (NEW), `tests/standalone/IO/IoPump.cpp` (NEW),
|
||||
`tests/standalone/SystemAsync/SystemAsyncShutdown.cpp` (NEW).
|
||||
Forbidden: every other path. Other implementers work concurrently in other worktrees (Async EventBus/
|
||||
Observable; Runtime). No git operations except the authorized fast-forward.
|
||||
|
||||
## 6. Implementation or investigation approach
|
||||
MANDATORY:
|
||||
- `run(stop, max_wait)`: loop until `stop.stop_requested()` or `shutdown_complete()`; each iteration calls
|
||||
`poll_once(max_wait)`; on `busy` wait up to `max_wait` in ≤1 ms stop-aware slices and retry; on a mock
|
||||
backend (or any turn that did no work and returned immediately) wait up to `max_wait` stop-aware so the
|
||||
loop never busy-spins; propagate any other error; return the accumulated work count. Never closes,
|
||||
frees or joins anything.
|
||||
- `pump_until(driver, manual, done, options)`: loop: `done()` → return count; `options.operation.stop`
|
||||
requested → `cancelled`; `options.operation.deadline` reached per `driver.clock()` → `timeout`;
|
||||
`max_turns` exceeded → `IoErrorCode::exhausted`; otherwise one turn = `poll_once(wait)` with
|
||||
`wait = timers ? timers->wait_duration(max_wait) : max_wait` (0 when work is runnable), then
|
||||
`timers->poll_expired()` if set, then drain `manual`; `busy` handled as in `run`; exits when
|
||||
`shutdown_complete()` and `done()` still false → returns the current count (caller decides). Never frees
|
||||
work; all waits re-read the injected clock.
|
||||
- Shutdown conformance tests use the public S-IO-03 API only: an expired `shutdown(options)` returns
|
||||
`complete=false` and retains fds/buffers/workers; a repeat call completes after release; concurrent
|
||||
`run()` loop + `shutdown()` is TSan-clean and the run loop exits on `shutdown_complete()`.
|
||||
- Layering: no `Void/Runtime`, `Void/Net`, `Void/System` include in `include/Void/IO` or `src/IO`
|
||||
(SystemAsync test lives under `tests/standalone/SystemAsync/`).
|
||||
|
||||
## 7. Interfaces and data contracts
|
||||
```cpp
|
||||
namespace Void::IO {
|
||||
// Driver.hpp (NEW member, inline)
|
||||
[[nodiscard]] Void::Result::Result<std::size_t> Driver::run(std::stop_token stop,
|
||||
std::chrono::nanoseconds max_wait = std::chrono::milliseconds{5});
|
||||
// Pump.hpp (NEW)
|
||||
struct PumpOptions { std::chrono::nanoseconds max_wait{0}; std::size_t max_turns{1u << 20};
|
||||
Async::OperationOptions operation{}; Async::TimerQueue* timers{nullptr}; };
|
||||
template <class Done> requires std::predicate<Done&>
|
||||
[[nodiscard]] Void::Result::Result<std::size_t> pump_until(Driver&, Async::ManualExecutor&, Done&& done,
|
||||
PumpOptions = {});
|
||||
}
|
||||
```
|
||||
Errors: `IoErrorCode::{cancelled, timeout, exhausted}` via `make_io_error`; `busy` is never returned by
|
||||
`run`/`pump_until`. Unchanged: every existing Driver member.
|
||||
|
||||
## 8. Dependencies and integration
|
||||
Upstream: S-IO-03, M-TIME-03 (TimerQueue). Downstream: S-RUNTIME-03 `shutdown_pumping` uses `pump_until`
|
||||
(gate G5); the Runtime reactor follows the same `busy`/mock wait rules. Root integrates and commits.
|
||||
|
||||
## 9. Edge cases security and performance
|
||||
Spurious `busy` during shutdown handoff; mock never blocks; `max_wait == 0`; stop already requested;
|
||||
deadline already expired; timers with nothing due; `done()` true initially; executor work that posts more
|
||||
work; no allocation per turn; no busy loops (assert bounded iteration counts with a fake/injected clock).
|
||||
|
||||
## 10. Acceptance criteria
|
||||
- `IoShutdown.cpp`: `io_shutdown_expired_budget_incomplete_retains_stalled_file_worker`,
|
||||
`io_shutdown_pending_socket_read_retains_buffer_until_delivery`, `io_shutdown_repeated_idempotent_after_complete`,
|
||||
`io_shutdown_concurrent_with_run_loop_tsan`, `io_run_stops_on_token_and_on_shutdown`,
|
||||
`io_begin_shutdown_rejects_new_admission`, `io_run_busy_and_mock_wait_does_not_spin`.
|
||||
- `IoPump.cpp`: `io_pump_until_scope_join_mock`, `io_pump_until_deadline_injected_clock`,
|
||||
`io_pump_until_max_turns_exhausted`, `io_pump_until_drives_timer_queue`, `io_pump_until_stop_cancelled`,
|
||||
`io_pump_until_exits_after_shutdown_complete`.
|
||||
- `SystemAsyncShutdown.cpp`: `systemasync_driver_shutdown_pending_pipe_read_retains_and_delivers_once`.
|
||||
- Existing `IoDriver`, `IoFile`, `SystemAsync` tests pass; TSan 0 races; ASan+UBSan 0 errors; `-Werror`
|
||||
syntax checks clean; layering `rg` empty; `git diff --stat -- src/IO/module.cmake` empty.
|
||||
- Test caveats: keep each test well under 1,000 assertions (X-QA-02; count in loops, assert once) and keep
|
||||
each test declaration on ONE line (X-QA-03).
|
||||
|
||||
## 11. Verification commands and evidence
|
||||
Cwd = worktree root; `dev` with the sandbox disabled. Confirm new suites appear in the output.
|
||||
```sh
|
||||
dev cpp-gcc -c bash -lc 'cmake -S . -B /tmp/void-w11-io4 -G Ninja -DVOID_ENABLED_MODULES="IO;SystemAsync;Testing" -DVOID_WARNINGS_AS_ERRORS=ON && cmake --build /tmp/void-w11-io4 --parallel 8 && /tmp/void-w11-io4/tests/VoidTests --filter "^(IoShutdown|IoPump|IoFile|IoDriver|SystemAsyncShutdown|SystemAsync)\." && ctest --test-dir /tmp/void-w11-io4 --output-on-failure --timeout 120'
|
||||
dev cpp-gcc -c bash -lc 'cmake -S . -B /tmp/void-w11-io4-tsan -G Ninja -DCMAKE_BUILD_TYPE=Debug -DVOID_ENABLED_MODULES="IO;SystemAsync;Testing" -DVOID_ENABLE_TSAN=ON && cmake --build /tmp/void-w11-io4-tsan --parallel 8 && /tmp/void-w11-io4-tsan/tests/VoidTests --filter "^(IoShutdown|IoPump|SystemAsyncShutdown|IoFile)\."'
|
||||
dev cpp-gcc -c bash -lc 'cmake -S . -B /tmp/void-w11-io4-asan -G Ninja -DCMAKE_BUILD_TYPE=Debug -DVOID_ENABLED_MODULES="IO;SystemAsync;Testing" -DVOID_ENABLE_ASAN=ON -DVOID_ENABLE_UBSAN=ON && cmake --build /tmp/void-w11-io4-asan --parallel 8 && /tmp/void-w11-io4-asan/tests/VoidTests --filter "^(IoShutdown|IoPump|SystemAsyncShutdown)\."'
|
||||
dev cpp-gcc -c bash -lc 'for f in IO/IoShutdown IO/IoPump SystemAsync/SystemAsyncShutdown; do g++ -std=c++26 -freflection -fsyntax-only -Iinclude -Wall -Wextra -Wpedantic -Werror -Wno-missing-field-initializers tests/standalone/$f.cpp || exit 1; done'
|
||||
rg -n "Void/(Runtime|Net|System)/" include/Void/IO src/IO # expect no output
|
||||
```
|
||||
|
||||
## 12. Constraints and stop conditions
|
||||
No edits outside write scope; no weakened assertions. Stop and report BLOCKED with a reproducer if an
|
||||
S-IO-03 primitive misbehaves (deadlock, spin, wrong report), if SystemAsync needs a source change, or two
|
||||
repair attempts at one check fail.
|
||||
|
||||
## 13. Authorization and decisions
|
||||
Root decisions D-034, D-038, D-040, D-042 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; checks not run; residual risks; worktree path. Do not spawn children.
|
||||
Reference in new issue
Block a user