319 lines
26 KiB
Markdown
319 lines
26 KiB
Markdown
# S-IO-03 — Bounded positional file workers, sync, active cancel, safe shutdown core, epoll D1 fixes
|
||
|
||
Task ID: S-IO-03
|
||
Role: opus-implementer
|
||
Status: READY
|
||
|
||
## 1. Context and baseline
|
||
- Wave 11 package step B2 (critical path). Repo VoidLibrary, branch `feat/roadmap-p2-wave11`.
|
||
You work in an isolated git worktree of the HEAD given in your prompt; cwd = worktree root.
|
||
Never read the user's untracked files (`.env`, `WG.conf`, `keys`, `jev_token`) in the main checkout.
|
||
- Baseline: full suite at `38436b1` = 1,484 tests, 1,480 passed, 4 skipped, 0 failed.
|
||
- Observed source (cite-checked by planner and two PREFLIGHT reviews):
|
||
- `include/Void/IO/Driver.hpp:59-105`: `Driver` (non-movable; `create(executor, BackendOptions,
|
||
clock, pmr resource)`, `poll_once(max_wait)`, `wake`, `request_stop`, `shutdown_and_join`), no
|
||
thread, no run loop, no file API. `~Driver` at `src/IO/EpollDriver.cpp:1737-1742` and
|
||
`~EpollBackend` at `:953-963` both call `shutdown_and_join()` and ignore the result.
|
||
- `include/Void/IO/Types.hpp`: `IoErrorCode` (incl. root-added `sync_failed = 12` → `ErrorKind::io`),
|
||
`IoLimits{max_descriptors 4096, max_operations 8192, ..., file_workers 4, max_file_queue 256}`
|
||
(:100-110), `validate_limits` ignores file fields (:112-124), `BackendOptions`, `DriverTelemetry`.
|
||
- `include/Void/IO/Detail/Backend.hpp`: `DriverBackend` virtual interface; streams hold `weak_ptr`
|
||
to the backend (:85-125); stop forwarders lock briefly (:279-285).
|
||
- Epoll defects D1 (all CONFIRMED): (a) `complete_op_and_collect_tickets` releases the backend ref
|
||
unconditionally (`EpollDriver.cpp:448`) though `retire_op_locked` is idempotent (:391-394);
|
||
(b) cancel path (:1332-1351) doesn't skip retired ops (mock does, :770-781) — stop after the
|
||
start-of-turn drain (:1053) while `drive_read/write` completes the op double-releases at the
|
||
end-of-turn drain (:1173); (c) `::read`/`::send`/`::write` at :1466/:1549/:1560 run outside `mu_`
|
||
without `in_execution` (mock-only, :653-671); (d) cross-thread `shutdown_and_join` (:1179-1238)
|
||
completes ops mid-syscall and closes fds (:1221→:363) while a poller holds the integer (:1151).
|
||
- `poll_once` early-returns once stopping (`:1056-1059`); mock `poll_once` ignores `max_wait`
|
||
(:739-741); `IoErrorCode::busy` already means "concurrent op not allowed" (:533-540).
|
||
- Consumers of `Driver`: IPC (`src/IPC/Session.cpp:1118-1129` bounded poll loop ignoring result),
|
||
SystemAsync, CryptoAsync, Storage, ConfigurationAsync, Runtime tests.
|
||
- Requirements: roadmap row S-IO-03 ("Bounded positional file workers, serialization, sync and
|
||
active-cancel handling | Short writes preserve progress; active timeout retains buffers; sync
|
||
success/failure after stop remains authoritative in the sole result"); `docs/roadmap/subsystems/IO.md`
|
||
(updated in `7f95f89`); contracts C-03..C-06; decisions D-038, D-040.
|
||
- MANDATORY design sources (read fully): `docs/agent-workflow/tasks/W11-PLAN-OUTPUT.md` §S-IO-03,
|
||
`W11-PLAN-REV1-OUTPUT.md` F1, F2, F9, F11, F13 and P3 (D1 seam), and `W11-CONTRACT-R2.md` N3, N4,
|
||
P3-5, P3-9. Precedence: R2 > REV1 > PLAN. This spec restates the mandatory points.
|
||
|
||
## 2. Objective and deliverables
|
||
1. NEW `include/Void/IO/File.hpp`: `FileOpenOptions`, `SyncMode`, `FileSyscallResult`,
|
||
`FileSyscalls` (injectable shim with `native()`), move-only `File`, `read_exact_at`, `write_all_at`.
|
||
2. EDIT `include/Void/IO/Driver.hpp`: `open_file`, `adopt_file_fd`, `start_file_workers`,
|
||
`run_file_work`, NEW free `is_io_worker_thread()`; `~Driver` becomes the only blocking teardown;
|
||
public inline shutdown wrappers `begin_shutdown()`, `shutdown(Async::OperationOptions)`,
|
||
`quiescent()`, `shutdown_complete()` (moved from S-IO-04 by D-042 so B2 can test its primitive).
|
||
3. EDIT `include/Void/IO/Types.hpp`: append `BackendOptions::file_syscalls{nullptr}` (borrowed),
|
||
`BackendOptions::before_file_worker_start{}`, `DriverTelemetry::{queued_file_requests,
|
||
active_file_requests, file_workers_running, duplicate_completions_ignored}`, NEW
|
||
`DriverShutdownReport`; `validate_limits` rejects `max_file_queue == 0`.
|
||
4. EDIT `include/Void/IO/Detail/Backend.hpp`: file-submit virtuals + shutdown primitives
|
||
(`begin_shutdown`, `advance_shutdown`, `shutdown_complete`, `quiescent`, `teardown_blocking`).
|
||
5. EDIT `src/IO/EpollDriver.cpp`: D1 fixes, poll-owner exclusion, file completion lane, bounded
|
||
shutdown core, F2 wake/close rules; NEW private `src/IO/FileWorkers.{hpp,cpp}`.
|
||
6. NEW `tests/standalone/IO/IoFile.cpp`.
|
||
|
||
## 3. Scope and non-goals
|
||
In: the above, for both mock and epoll backends (file pool shared via the base backend).
|
||
Out: `Driver::run` and `Pump.hpp`/`pump_until` (S-IO-04, step A4); Net
|
||
adapter; io_uring; Runtime; any build-file edit; `Threads::Threads` (D-W11-08: IO already uses
|
||
pthread calls without it; IOOnly consumer disables Threads lookup).
|
||
|
||
## 4. Files to inspect
|
||
`include/Void/IO/{Types,Driver,Stream}.hpp`, `include/Void/IO/Detail/Backend.hpp`,
|
||
`src/IO/EpollDriver.cpp` (all), `include/Void/Async/{Operation,Executor,TaskScope}.hpp`,
|
||
`include/Void/Async/Detail/Types.hpp`, `tests/standalone/IO/IoDriver.cpp`,
|
||
`tests/package/InstalledComponents.cmake:74-80` (IOOnly flags), `src/IPC/Session.cpp:1118-1129`,
|
||
and the three design documents in §1.
|
||
|
||
## 5. Write ownership and coordination
|
||
Write scope: `include/Void/IO/File.hpp` (NEW), `include/Void/IO/Driver.hpp`, `include/Void/IO/Types.hpp`,
|
||
`include/Void/IO/Detail/Backend.hpp`, `src/IO/EpollDriver.cpp`, `src/IO/FileWorkers.hpp` (NEW),
|
||
`src/IO/FileWorkers.cpp` (NEW), `tests/standalone/IO/IoFile.cpp` (NEW).
|
||
Forbidden: all other paths, including `src/IO/module.cmake`, Async headers, Runtime, SystemAsync,
|
||
IPC, tests other than `IoFile.cpp`, build files, docs. Other workers may run concurrently in other
|
||
worktrees on Async files. No git commit/branch/stash/reset.
|
||
|
||
## 6. Implementation or investigation approach
|
||
Order: (1) D1 fixes + regression test first; (2) poll-owner exclusion; (3) file pool + File API;
|
||
(4) bounded shutdown core + teardown; (5) remaining tests; (6) downstream builds.
|
||
MANDATORY invariants:
|
||
- D1: release the backend ref only if this call retired the op; cancel/expire paths skip retired
|
||
ops; epoll marks an op `in_execution` under `mu_` before its syscall and shutdown/cancel never
|
||
completes an op that is in execution (it records stop intent; the syscall's real result settles
|
||
it). NEW `duplicate_completions_ignored` counts suppressed double retirements.
|
||
- Poll owner: a dedicated `std::mutex poll_mu_`; `poll_once` first checks the thread-local
|
||
polling marker (reentrant call → `busy`), then `try_lock`; failure → `IoErrorCode::busy`
|
||
without touching any fd. Every turn drains cancels, control messages and file completions
|
||
BEFORE any stop-flag early return. While stopping (not yet shut down) a turn with no work waits
|
||
in `epoll_wait` up to `max_wait` (no spin). After shutdown completes `poll_once` returns 0
|
||
without touching any fd.
|
||
- File workers (F1): a worker performs exactly one syscall (native or the injected shim — the
|
||
single documented exception allowed to run on workers; it must not call Driver/Executor/File
|
||
APIs), then pushes `{request, result}` onto the shared completion queue under the pool mutex and
|
||
wakes. Resume tickets are produced only by a poll turn via the existing
|
||
`complete_op_and_collect_tickets` path. `run_file_work(n)` runs syscalls on the caller and only
|
||
queues results. Workers hold `shared_ptr<detail::FileWorkerShared>`, never the backend.
|
||
Thread-local `tl_io_worker_owner` set on workers; `is_io_worker_thread()` reads it.
|
||
- Admission: closed driver / stopped / expired → rejected before queueing; `max_file_queue` bounds
|
||
queued requests, `max_operations` bounds queued+active; either → `overloaded`; zero-length →
|
||
`{0,false}` without a syscall; offset+length overflow → `invalid_argument`. Files count against
|
||
`max_descriptors`.
|
||
- Ordering: writes and syncs on one file run in admission order, one active at a time; reads may
|
||
run concurrently. One syscall per request; EINTR retried; short transfer returns actual bytes;
|
||
0-byte read of nonzero length = EOF.
|
||
- Queued stop/expiry: removed, completes `cancelled`/`timeout`; writes/syncs carry
|
||
`DomainOutcomeKind::not_committed`. Expiry checked by the driver clock in `poll_once` and again at
|
||
worker dequeue.
|
||
- Active stop/expiry: intent only; span/lease and telemetry retained; result = the syscall's actual
|
||
outcome. Sync success after stop = success; sync failure → `sync_failed` + native errno +
|
||
`DomainOutcomeKind::unknown`.
|
||
- `start_file_workers()` explicit, once; the `before_file_worker_start(index)` hook error or a
|
||
caught `std::system_error` joins already-started workers, returns `os_error` (system code when
|
||
present), and allows retry.
|
||
- File fd state (N4/F13): `detail::FileState` shared-owned, `enum {open, closing, closed}` under
|
||
the pool mutex; handle drop / in-flight / `close_pending` transitions under that mutex; exactly
|
||
one close enqueued (preallocated node inside `FileState`, reserved capacity bounded by
|
||
`max_descriptors`); close executes on a worker or in `run_file_work`. `~File` wakes only via a
|
||
weak→strong backend lock or the worker condvar, never a raw waker. Teardown closes remaining file
|
||
fds after joining workers and marks them `closed`; afterwards File ops return `closed` without a
|
||
syscall, `~File` does nothing, `close_and_join` returns success. `File::close_and_join(options)`
|
||
is always admitted; deadline/stop expiry → `incomplete_shutdown`, File stays valid with fd and
|
||
buffers retained; close syscall failure → `os_error`, fd treated as closed.
|
||
- Shutdown core (F9/N3): backend `begin_shutdown()` (idempotent: sets the stopping flag, closes
|
||
admission, cancels queued, stops active); `advance_shutdown(deadline, stop)` waits in ≤1 ms real
|
||
slices re-reading the injected clock, releases `poll_mu_` between slices, runs its own turns only
|
||
while holding poll ownership, wakes the current poller, returns the current
|
||
`DriverShutdownReport` with `complete=false` on deadline or stop (not an error), returns
|
||
`Async::make_async_error(AdmissionError::self_join)`-equivalent error if called on this backend's
|
||
worker or inside its poll turn; dispatches resume tickets only after releasing poll ownership
|
||
(P3-9). On completion: workers joined, op/descriptor fds closed, `wake_closed_` set (release).
|
||
1.x `shutdown_and_join()` = `advance_shutdown(nullopt, {})` mapped to `Result<void>`.
|
||
- F2: epoll fd and eventfd close only in `~EpollBackend`; `wake()` returns early if
|
||
`wake_closed_` (acquire).
|
||
- F1 teardown: `~EpollBackend`/`~MockBackend`/`~FileWorkers` never block; `~FileWorkers` finding
|
||
a joinable thread prints a one-line stderr diagnostic and `std::terminate`s. `Driver::~Driver`
|
||
calls `backend_->teardown_blocking()` (begin + advance to completion). `~Driver` on a file-worker
|
||
thread or inside a poll turn of that backend → stderr diagnostic + `std::terminate`.
|
||
|
||
|
||
### Amendments from W11-SPEC-REVIEW-1 (MANDATORY; override earlier text where they differ)
|
||
Source: `docs/agent-workflow/tasks/W11-SPEC-REVIEW-1-OUTPUT.md` S1–S9 + P3 (decision D-042).
|
||
- S1 ownership handoff: before each slice `advance_shutdown` sets atomic `shutdown_waiting_` and
|
||
calls `wake()`. While it is set, `poll_once` on any other thread returns `busy` before `try_lock`,
|
||
touching no fd and not incrementing `turns`. It is cleared once `advance_shutdown` holds
|
||
`poll_mu_`. Between slices, after `advance_shutdown` releases `poll_mu_`, other pollers may run turns.
|
||
- S2 shutdown order (replaces the order implied above): (1) `begin_shutdown()` — `advance_shutdown`
|
||
calls it itself; (2) wait until no queued or active file request and no op `in_execution`;
|
||
(3) under `poll_mu_`, final drain of cancels, controls, file completions and close waiters;
|
||
(4) join workers; (5) still under `poll_mu_`, close remaining file fds (mark `closed`, complete
|
||
pending `close_and_join` waiters with success), then close op/descriptor fds; (6) set `shut_down_`
|
||
(release), then `wake_closed_`; (7) release `poll_mu_`, then dispatch tickets. `self_join` misuse
|
||
(`Async::make_async_error(Async::AdmissionError::self_join)`) is detected before any state change.
|
||
`begin_shutdown` only records intent and wakes the poller; it never completes or dispatches.
|
||
Document: the executor must outlive the Driver; an owned executor must not be joined before
|
||
Driver teardown (P3-9).
|
||
- S3 (replaces "Expiry checked ... again at worker dequeue"): expiry is checked with the driver
|
||
clock in `poll_once`; the epoll wait bound includes the earliest queued-file deadline. At dequeue a
|
||
worker checks, under the pool mutex and WITHOUT calling the clock, the request's stop flag and the
|
||
expired mark set by the last turn; such a request completes `cancelled`/`timeout` with no syscall.
|
||
- S4 observable contract: queued stop → `IoErrorCode::cancelled`, queued expiry →
|
||
`IoErrorCode::timeout` (kIoErrorDomain), zero shim calls, unchanged file bytes; sync failure →
|
||
`IoErrorCode::sync_failed` with `system_code() == std::error_code{errno, std::generic_category()}`.
|
||
Internally settle with `try_commit_error(err, not_committed|unknown)`; tests do not assert the
|
||
outcome kind. Retirement uses a retire-once path equivalent to `complete_op_and_collect_tickets`,
|
||
generalized for `OperationState<void>` and the file outcome kinds.
|
||
- S5 slots: a File occupies a `DescriptorSlot`, counts in `active_descriptors_`, bounded by
|
||
`max_descriptors`; `File::id()` is that slot's `DescriptorId`. The slot has `fd = -1` and a
|
||
file-kind flag; socket paths (interest updates, `close_fd` controls, stale-event checks, shutdown
|
||
sweep) skip it. The file fd lives only in `FileState`.
|
||
- S6 lifetimes: `FileState` holds `shared_ptr<detail::FileWorkerShared>` and `weak_ptr<DriverBackend>`,
|
||
never raw pool/backend pointers. The raw-context waker is called only by workers, which are joined
|
||
before the backend is destroyed.
|
||
- S7 stop flag: `request_stop()` == `begin_shutdown()`, with idempotence on a separate
|
||
`shutdown_begun_` flag. On mock, requests held by a token never block `advance_shutdown`;
|
||
`finish_*` still completes them, and `teardown_blocking` completes any still held with
|
||
`IoErrorCode::closed`.
|
||
- S8 D1 counter: increment `duplicate_completions_ignored` each time a cancel, expiry or shutdown
|
||
path meets an already-retired op and skips it. Retired ops are not purged from the cancel queue
|
||
early. A turn's first `clock_.now()` comes after the start-of-turn cancel/control/file drain; the
|
||
queued-file expiry scan reads the clock only when queued file requests have deadlines.
|
||
- S9 (D-042): B2 owns and tests the public wrappers `begin_shutdown`, `shutdown(options)`,
|
||
`quiescent`, `shutdown_complete` (inline in `Driver.hpp`). A4 adds only `run()`, `Pump.hpp`,
|
||
SystemAsync conformance and its tests.
|
||
- P3 clarifications: busy only if the polling marker equals THIS backend (save/restore it for nested
|
||
turns of other drivers); mock `poll_once` still ignores `max_wait`; the only worker-side Driver call
|
||
is detected (`shutdown_and_join`/`shutdown` → `self_join`); closed → `closed`, stop → `cancelled`,
|
||
expired → `timeout` (as `submit_io`); `offset > OFF_MAX` or `offset+len > OFF_MAX` →
|
||
`invalid_argument`; file requests count in the shared `active_operations_` until poll-turn
|
||
retirement; reads are unordered relative to writes; a second `start_file_workers` →
|
||
`invalid_argument`, `file_workers == 0` → success with no threads, after shutdown begins →
|
||
`closed`, `run_file_work` while workers run → `busy`; `close_and_join` waits for (does not cancel)
|
||
the file's queued/active requests, success invalidates the File, after an expired call the File is
|
||
`valid()` but closing (new ops → `closed`, a repeat call waits); document the difference from
|
||
`ByteStream::close_and_join`; `read_exact_at`/`write_all_at` mirror `Stream.hpp` composed transfers
|
||
with the offset advancing and one deadline, a 0-byte pwrite with bytes remaining is an error (no
|
||
loop); open flags: RDWR/WRONLY/RDONLY, neither read nor write → `invalid_argument`, `truncate`
|
||
requires write, `exclusive` requires create, always `O_CLOEXEC`, runs on the caller's thread;
|
||
`adopt_file_fd` takes ownership only on success; the injected shim must outlive Driver teardown.
|
||
- Test file includes: `IoFile.cpp` may include only Void/{IO, Async, Time, Memory, Functional, Core,
|
||
Testing} headers (otherwise it is silently skipped); write a local temp-dir helper.
|
||
|
||
## 7. Interfaces and data contracts
|
||
```cpp
|
||
namespace Void::IO { // File.hpp (NEW)
|
||
struct FileOpenOptions { bool read{true}, write{false}, create{false}, truncate{false}, exclusive{false};
|
||
std::uint32_t mode{0600}; };
|
||
enum class SyncMode : std::uint8_t { data, full };
|
||
struct FileSyscallResult { std::int64_t value{0}; int error{0}; };
|
||
class FileSyscalls { public: virtual ~FileSyscalls() = default;
|
||
[[nodiscard]] virtual FileSyscallResult pread(int, std::span<std::byte>, std::uint64_t) noexcept;
|
||
[[nodiscard]] virtual FileSyscallResult pwrite(int, std::span<const std::byte>, std::uint64_t) noexcept;
|
||
[[nodiscard]] virtual FileSyscallResult sync(int, SyncMode) noexcept;
|
||
[[nodiscard]] virtual FileSyscallResult close(int) noexcept;
|
||
[[nodiscard]] static FileSyscalls& native() noexcept; };
|
||
class File { public: File() noexcept; File(File&&) noexcept; File& operator=(File&&) noexcept; ~File();
|
||
[[nodiscard]] bool valid() const noexcept; [[nodiscard]] DescriptorId id() const noexcept;
|
||
[[nodiscard]] Coro::Task<Void::Result::Result<Transfer>> read_at(std::uint64_t, std::span<std::byte>, Async::OperationOptions = {});
|
||
[[nodiscard]] Coro::Task<Void::Result::Result<Transfer>> write_at(std::uint64_t, std::span<const std::byte>, Async::OperationOptions = {});
|
||
[[nodiscard]] Coro::Task<Void::Result::Result<Transfer>> read_at_owned(std::uint64_t, BufferLease&, Async::OperationOptions = {});
|
||
[[nodiscard]] Coro::Task<Void::Result::Result<Transfer>> write_at_owned(std::uint64_t, const BufferLease&, Async::OperationOptions = {});
|
||
[[nodiscard]] Coro::Task<Void::Result::Result<void>> sync(SyncMode = SyncMode::full, Async::OperationOptions = {});
|
||
[[nodiscard]] Coro::Task<Void::Result::Result<void>> close_and_join(Async::OperationOptions = {}); };
|
||
[[nodiscard]] Coro::Task<std::expected<std::size_t, ComposedTransferError>> read_exact_at(File&, std::uint64_t, std::span<std::byte>, Async::OperationOptions = {});
|
||
[[nodiscard]] Coro::Task<std::expected<std::size_t, ComposedTransferError>> write_all_at(File&, std::uint64_t, std::span<const std::byte>, Async::OperationOptions = {});
|
||
}
|
||
// Driver.hpp additions
|
||
[[nodiscard]] Void::Result::Result<File> Driver::open_file(const std::filesystem::path&, FileOpenOptions = {});
|
||
[[nodiscard]] Void::Result::Result<File> Driver::adopt_file_fd(int fd);
|
||
[[nodiscard]] Void::Result::Result<void> Driver::start_file_workers();
|
||
[[nodiscard]] Void::Result::Result<std::size_t> Driver::run_file_work(std::size_t max_requests = 1);
|
||
[[nodiscard]] bool Void::IO::is_io_worker_thread() noexcept;
|
||
void Driver::begin_shutdown() noexcept; // -> backend_->begin_shutdown()
|
||
[[nodiscard]] Void::Result::Result<DriverShutdownReport> Driver::shutdown(Async::OperationOptions); // -> advance_shutdown(o.deadline, o.stop)
|
||
[[nodiscard]] bool Driver::quiescent() const noexcept;
|
||
[[nodiscard]] bool Driver::shutdown_complete() const noexcept;
|
||
// Types.hpp additions
|
||
struct DriverShutdownReport { bool complete{false}; std::size_t pending_operations{0},
|
||
active_file_requests{0}, open_descriptors{0}, retained_buffer_bytes{0}; };
|
||
// BackendOptions (append): FileSyscalls* file_syscalls{nullptr};
|
||
// std::function<Void::Result::Result<void>(std::size_t)> before_file_worker_start{};
|
||
// DriverTelemetry (append): queued_file_requests, active_file_requests, file_workers_running,
|
||
// duplicate_completions_ignored (std::size_t / std::uint64_t as fits existing fields)
|
||
// detail::DriverBackend (append, pure virtual or with base impl):
|
||
virtual void begin_shutdown() noexcept;
|
||
[[nodiscard]] virtual Void::Result::Result<DriverShutdownReport> advance_shutdown(
|
||
std::optional<Void::Time::MonotonicClock::time_point> deadline, std::stop_token stop);
|
||
[[nodiscard]] virtual bool shutdown_complete() const noexcept;
|
||
[[nodiscard]] virtual bool quiescent() const noexcept;
|
||
virtual void teardown_blocking() noexcept;
|
||
```
|
||
`ComposedTransferError`, `Transfer`, `DescriptorId`, `BufferLease` are existing IO types — reuse.
|
||
Use existing namespace aliases/spellings for `Coro::Task` and `Void::Result::Result` as in `Stream.hpp`.
|
||
Unchanged 1.x: every existing `Driver`/`ByteStream`/`BufferLease` signature and the IoDriver tests.
|
||
|
||
## 8. Dependencies and integration
|
||
Upstream: S-IO-01/02 (done), root prep `7f95f89` (`sync_failed`). Downstream: S-IO-04 (A4) adds
|
||
public wrappers over your backend primitives (gate G4); S-RUNTIME-02 (B3) uses
|
||
`start_file_workers`, `is_io_worker_thread`. Keep §7 exactly. Root integrates and commits.
|
||
|
||
## 9. Edge cases security and performance
|
||
fd reuse after close during concurrent poll; buffer retention on active timeout; `open_file` uses
|
||
`O_CLOEXEC` with ordinary `open(2)` path semantics (no new symlink policy); EINTR; ENOSPC/EIO surfaced as `os_error`; partial start; teardown with
|
||
stalled worker (shim gated by a latch); no busy loops; no allocation in `~File`; TSan-clean.
|
||
|
||
## 10. Acceptance criteria
|
||
`IoFile.cpp` (isolated temp dir per test, no fixed paths): `io_file_native_roundtrip_isolated_tmpdir`,
|
||
`io_file_short_write_preserves_progress_write_all_at`, `io_file_writes_syncs_serialized_admission_order`,
|
||
`io_file_reads_concurrent_explicit_offsets`, `io_file_queue_and_ops_quota_overloaded`,
|
||
`io_file_queued_cancel_not_committed_zero_effects`, `io_file_queued_deadline_expires_once_manual_clock_poll`,
|
||
`io_file_active_timeout_retains_buffer_until_syscall_returns`, `io_file_sync_success_after_stop_is_success`,
|
||
`io_file_sync_failure_after_stop_sync_failed_unknown_errno`, `io_file_manual_stepping_without_workers`,
|
||
`io_file_shutdown_joins_stalled_worker_then_delivers`, `io_file_shutdown_from_worker_self_join`,
|
||
`io_file_workers_partial_start_failure_joins_started`, `io_file_drop_with_inflight_defers_close_until_drained`,
|
||
`io_file_close_and_join_expiry_incomplete_retains_then_completes`, `io_file_ops_after_teardown_closed_no_syscall`,
|
||
`io_driver_destroyed_from_coroutine_resumed_after_poll_dispatch_same_thread`,
|
||
`io_worker_thread_marker_only_on_file_workers`, `io_concurrent_poll_once_second_caller_busy_no_fd_touch_tsan`,
|
||
`io_epoll_shutdown_concurrent_with_poller_no_uaf_tsan`, `io_stop_after_completion_releases_backend_ref_once`,
|
||
`io_epoll_stop_requested_at_deadline_scan_completes_once` (D1 seam: clock armed after submission,
|
||
asserts single delivery and `duplicate_completions_ignored >= 1`), `io_file_eintr_retried_via_shim`,
|
||
`io_file_zero_length_overflow_and_zero_queue_limit`, `io_file_counts_against_max_descriptors`,
|
||
`io_file_workers_second_start_invalid`, `io_poll_once_after_shutdown_returns_zero`,
|
||
`io_poll_once_reentrant_inline_resume_busy`, `io_shutdown_bounded_deadline_incomplete_then_complete`,
|
||
`io_shutdown_stop_token_returns_incomplete_report`, `io_request_stop_then_shutdown_cancels_queued_files`,
|
||
`io_mock_held_request_does_not_block_teardown`. All pass; existing `IoDriver` tests
|
||
pass unchanged; downstream suites pass unfiltered; `-Werror`, TSan 0 races, ASan+UBSan 0 errors.
|
||
|
||
## 11. Verification commands and evidence
|
||
Cwd = worktree root; run `dev` with the sandbox disabled. Confirm new suites appear in output.
|
||
```sh
|
||
dev cpp-gcc -c bash -lc 'cmake -S . -B /tmp/void-w11-io3 -G Ninja -DVOID_ENABLED_MODULES="IO;Testing" -DVOID_WARNINGS_AS_ERRORS=ON && cmake --build /tmp/void-w11-io3 --parallel 8 && /tmp/void-w11-io3/tests/VoidTests --filter "^(IoFile|IoDriver)\." && ctest --test-dir /tmp/void-w11-io3 --output-on-failure --timeout 60'
|
||
dev cpp-gcc -c bash -lc 'cmake -S . -B /tmp/void-w11-io3-tsan -G Ninja -DCMAKE_BUILD_TYPE=Debug -DVOID_ENABLED_MODULES="IO;Testing" -DVOID_ENABLE_TSAN=ON -DVOID_WARNINGS_AS_ERRORS=ON && cmake --build /tmp/void-w11-io3-tsan --parallel 8 && /tmp/void-w11-io3-tsan/tests/VoidTests --filter "^(IoFile|IoDriver)\."'
|
||
dev cpp-gcc -c bash -lc 'cmake -S . -B /tmp/void-w11-io3-asan -G Ninja -DCMAKE_BUILD_TYPE=Debug -DVOID_ENABLED_MODULES="IO;Testing" -DVOID_ENABLE_ASAN=ON -DVOID_ENABLE_UBSAN=ON -DVOID_WARNINGS_AS_ERRORS=ON && cmake --build /tmp/void-w11-io3-asan --parallel 8 && /tmp/void-w11-io3-asan/tests/VoidTests --filter "^(IoFile|IoDriver)\."'
|
||
dev cpp-gcc -c bash -lc 'cmake -S . -B /tmp/void-w11-io3-users -G Ninja -DVOID_ENABLED_MODULES="IO;IPC;SystemAsync;Storage;CryptoAsync;Runtime;ConfigurationAsync;Testing" -DVOID_WARNINGS_AS_ERRORS=ON && cmake --build /tmp/void-w11-io3-users --parallel 8 && /tmp/void-w11-io3-users/tests/VoidTests && ctest --test-dir /tmp/void-w11-io3-users --output-on-failure --timeout 180'
|
||
```
|
||
Warnings check (VOID_WARNINGS_AS_ERRORS does not reach VoidTests TUs, X-QA-01):
|
||
```sh
|
||
dev cpp-gcc -c bash -lc 'g++ -std=c++26 -freflection -fsyntax-only -Iinclude -Wall -Wextra -Wpedantic -Werror -Wno-missing-field-initializers tests/standalone/IO/IoFile.cpp && for h in File Driver Types; do echo "#include <Void/IO/$h.hpp>" | g++ -std=c++26 -freflection -x c++ -fsyntax-only -Iinclude -Wall -Wextra -Wpedantic -Werror -Wno-missing-field-initializers - || exit 1; done'
|
||
```
|
||
CryptoAsync may need `-p openssl` on the `dev` line (`dev cpp-gcc -p openssl -c ...`); report the
|
||
exact command used.
|
||
|
||
## 12. Constraints and stop conditions
|
||
No edits outside write scope; no weakened assertions; no disabled warnings; no Threads link. Stop
|
||
and report BLOCKED if: a forbidden file must change; a downstream suite fails for reasons rooted in
|
||
the new blocking `shutdown_and_join` semantics that need a consumer edit; any D1 fix cannot be made
|
||
without changing a public 1.x signature; or two repair attempts at the same failing check fail.
|
||
|
||
## 13. Authorization and decisions
|
||
Root decisions D-034, D-038, D-040 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 (esp. any choice the
|
||
design docs left to you); evidence per acceptance criterion; commands with cwd/results (test counts,
|
||
TSan/ASan); checks not run; residual risks; integration notes (worktree path, primitives A4 should
|
||
wrap). Do not spawn children.
|