Files
faumarayandClaude Opus 5.5 7f95f89d52 chore(wave11): plan execution-path backfill, reserve error codes, update area plans
- Audit roadmap vs TASKS (D-033); scope Wave 11 to M-FUNCTIONAL-03, M-TIME-03,
  M-ASYNC-04/05, S-IO-03/04, S-RUNTIME-02/03 (D-034..D-036)
- Schedule VoidForge upstream requests after Wave 11 (D-037)
- Persist planner output, PREFLIGHT findings and contract addendum (D-038)
- Add AsyncErrorCode::closed, IoErrorCode::sync_failed,
  RuntimeErrorCode::{self_join, shutdown_incomplete}
- Update Functional/IO/Runtime area plans and MIGRATION per C-13

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 18:31:14 +03:00

29 KiB
Raw Permalink Blame History

W11-PLAN-REV1 contract addendum (opus-planner, 2026-11-29)

Verbatim agent return. Advisory input; root dispositions are recorded in DECISIONS.md.

W11-PLAN-REV1: contract addendum (deltas only)

Status: DONE. I accepted every root resolution, with three clarifications recorded at the end:

  • F5: the off-owner signal adapter should close its fd. That matches 1.x and avoids a descriptor leak.
  • F1(a): the injected FileSyscalls shim is the one exception to "workers never run user code".
  • Observable: queuing nested updates for copyable types is a 1.x ordering change that MIGRATION must record.

Nothing was written to the repository. The reviewer's findings aren't persisted separately: W11-PREFLIGHT.md is the review brief. I worked from your F1–F13 and P3 summary. Gates G1–G5 stay; G6 is new; the B2 and A4 file sets change (table at the end).


F1 (P1) S-IO-03 teardown thread rule (owner B2)

Invariants

  • (a) A file worker performs one syscall (native or FileSyscalls shim) and nothing else. It then pushes {request, result} onto FileWorkerShared::completions under the shared mutex and calls the waker.
    • Resume tickets are produced only by a poll turn, which drains completions through the existing complete_op_and_collect_tickets / dispatch_tickets path.
    • run_file_work() executes one syscall on the caller's thread and only queues its result.
  • (b) Workers hold only std::shared_ptr<detail::FileWorkerShared> (queues, mutex/condvar, completion queue, and a waker given as function pointer plus context). They never hold shared_ptr<DriverBackend>.
    • The waker's raw backend pointer stays valid because workers are joined before the backend can be destroyed: Driver::~Driver and shutdown_and_join both join first.
  • (c) ~EpollBackend, ~MockBackend and ~FileWorkers never block. ~FileWorkers finding a joinable thread prints a diagnostic to stderr and calls std::terminate.
    • Today ~EpollBackend blocks (EpollDriver.cpp:953-955 calls shutdown_and_join); that call is removed.
    • Driver::~Driver (:1737-1742) becomes the blocking teardown: backend_->teardown_blocking().
  • (d) Two thread-local markers detect misuse:
    • tl_io_worker_owner (a non-null pool pointer on worker threads)
    • tl_polling_backend (set while a thread runs that backend's poll_once turn) ~Driver with either marker matching prints a one-line stderr diagnostic and calls std::terminate.
  • NEW, declared in Driver.hpp and defined in FileWorkers.cpp:
    [[nodiscard]] bool Void::IO::is_io_worker_thread() noexcept;  // true on any Driver's file-worker thread
    

(e) Tests (IoFile.cpp)

  • io_driver_destroyed_from_coroutine_resumed_after_poll_dispatch_same_thread: with ManualExecutor, poll_once dispatches a ticket and exec.drain() on the same thread resumes a coroutine that resets the unique_ptr<Driver>. Teardown must complete with no terminate.
  • io_worker_thread_marker_only_on_file_workers: a gated shim records is_io_worker_thread() as true inside pread; it is false on the main thread, inside the poll turn and inside executor drain. The terminate path is documented only; no death test, because the Runner has no fork-based death support (src/Testing/Subprocess.cpp:142 only execs helpers).

F2 epoll/eventfd lifetime (B2)

  • The epoll fd and eventfd still close in ~EpollBackend, as in 1.x (:956-963).
  • Shutdown closes only operation and descriptor fds, and only after it holds poll ownership.
  • wake() loads std::atomic<bool> wake_closed_ (acquire) and returns if set. It is set (release) when shutdown completes.
  • Lock vs atomic: atomic is enough, and TSan-clean. wake_fd_ is written only in the constructor (:1255-1265) and in ~EpollBackend.
    • All wake() callers hold a shared owner: Driver::backend_, the CancelForwarder weak→lock at :589-596, and StreamState::lock_backend at Backend.hpp:89-96.
    • Workers are joined first.
    • So the destructor's write happens after every wake() call, through the shared_ptr control block's acq_rel ordering.
  • poll_once checks shut_down_ (acquire) on entry and returns 0 before touching any fd. That keeps the 1.x return value (:1057-1059 returns work_done).

F3 / F4 Runtime shutdown phases and budgets (B4)

enum class ShutdownPhase : std::uint8_t { not_started, closing_admission, draining, cancelling, joining_business,
  stopping_components, flushing_exporters, releasing_components, stopping_io, stopping_workers, releasing, stopped };

Phase order

# Phase What happens
1 closing_admission business scope closes admission
2 draining wait for the business scope to drain (deadline fixed at first entry)
3 cancelling request stop on the business scope
4 joining_business wait for the business scope to finish
5 stopping_components non-exporter components stop
6 flushing_exporters exporters stop (flush deadline fixed at first entry)
7 releasing_components drop every component shared_ptr, so exporters are destroyed here
8 stopping_io owned driver shuts down
9 stopping_workers wait for the owned executor to go idle within budget, then join the reactor and executor
10 releasing budgets and fds; signal gate on the owner thread
11 stopped
  • The ordering assertion exporter_stopped < exporter_destroyed < executor_joined stays.
  • Per-call budget: every shutdown_blocking, poll_shutdown and shutdown_pumping call uses call_deadline = min(options.deadline, deadline_after(clock, total_timeout)) for the work that remains.
  • Phase deadlines: the drain and flush deadlines are fixed when their phase is first entered and stay expired afterwards.
    • Drain expiry moves on to phase 3 and sets drain_grace_expired.
    • Flush expiry requests stop on the exporter operations, sets export_flush_expired, and keeps waiting.
  • Incomplete: if call_deadline expires in a waiting phase (4, 5, 6, 8 or 9), the sequence stops and returns complete=false, with the phase and state recorded as shutdown_incomplete. The next call resumes at that phase.
  • NEW [[nodiscard]] bool Async::ThreadExecutor::idle() const noexcept; (both queues empty and nothing running), used by phase 9 so the executor join is never unbounded.

F5 Host ownership (B3, with the B4 parts)

  • All lifecycle state and teardown live in detail::HostCore, owned by std::unique_ptr. ~HostCore:
    • if the host is started and not stopped, calls shutdown_blocking({}) (unbounded);
    • then gate->uninstall(this_thread == owner). Default move-assign is therefore safe.
  • Moved-from Host (HostState has no moved-from value, Host.hpp:19-29):
    • NEW [[nodiscard]] bool valid() const noexcept;
    • state() returns stopped; is_running() and is_ready() return false; started_worker_count() returns 0.
    • executor() and io() return nullptr; owner_thread() and last_shutdown_report() return nullopt.
    • start, shutdown_* and poll_shutdown return RuntimeErrorCode::invalid_state; spawn returns AdmissionError::stopped.
    • clock() stays safe through its System-clock fallback (:147-151).
    • memory_budget() has the precondition valid(). This is a pre-existing hazard: the 1.x code dereferences a null owned_budget_ after a move (:153-156).
  • ~HostCore running on a Runtime worker, the reactor or an IO worker prints a stderr diagnostic and calls std::terminate. Detection uses:
    • executor->is_executor_thread() (Executor.hpp:86-96)
    • a Runtime tl_reactor marker
    • IO::is_io_worker_thread()
  • SignalGate shape:
    class SignalGate { public: virtual ~SignalGate() = default;
      [[nodiscard]] virtual Void::Result::Result<void> install() = 0;
      virtual void uninstall(bool on_owner_thread) noexcept = 0; };   // replaces uninstall()
    
    • shutdown_* called off the owner thread leaves the gate installed (owner_release_pending=true). A later owner-thread call, or ~HostCore, calls uninstall(this_thread == owner).
    • The System test adapter destroys its SignalWatcher in both cases. 1.x closes the fd on any thread (SignalWatcher.cpp:29-31) but restores the mask only on the owner (:32-36). Off-owner teardown therefore cannot restore the owner's mask; document this.
  • Test: runtime_offowner_destroy_closes_gate_fd_mask_not_restored, which checks the /proc/self/fd delta is 0 and that the owner's mask is still blocked.

F6 Teardown follows ResourceOwnership (B4)

  • An embedded or borrowed executor, driver, clock or memory resource is never shut down, closed or joined by the Host. Phases 8 and 9 are skipped for borrowed resources.
  • Signature:
    [[nodiscard]] Void::Result::Result<ShutdownReport> Host::shutdown_pumping(
        Async::ManualExecutor&, Async::OperationOptions = {}, Async::TimerQueue* timers = nullptr);
    
    It drives progress with IO::pump_until(*io, manual, done, PumpOptions{.operation = call_budget, .timers = timers}), so gate G5 stays.
  • Test: runtime_embedded_shutdown_never_shuts_borrowed_driver_or_executor. After shutdown the borrowed driver still accepts create_mock_stream and the executor still accepts try_post.

F7 AsyncChannel arbitration (A2)

  • One std::mutex covers the buffer and both waiter lists.
  • Waiter nodes live in the awaiter, inside the coroutine frame. Each holds enum class WaiterState { linked, claimed, cancelled, timed_out, closed }. A send waiter holds std::optional<T> value; a receive waiter holds std::optional<T> slot.
  • Pairing a sender with a receiver happens under the lock, in one critical section: unlink and claim the waiter, then move the value. A value is therefore always in exactly one place: the sender node, the buffer or the receiver slot. It is never in limbo.
  • Stop callbacks and timer callbacks take the same lock.
    • If the waiter is still linked, it is unlinked and set to cancelled or timed_out. A sender keeps its value and gets it back.
    • If it is already claimed, the callback does nothing. A sender gets success; a receiver gets the value that is already in its slot.
  • Every resume is dispatched through post_completion after unlock. Each sender gets success or its value back exactly once.
  • Tests:
    • channel_receiver_stop_after_claim_delivers_value_no_loss
    • channel_sender_stop_vs_receive_race_exactly_once_tsan: 10,000 iterations; the multiset of values sent equals values received plus values returned.
    • channel_timer_close_settles_waiter_cancelled (see F12)

F8 Default URBG (A1, B1)

House convention: Retry.hpp:89 seeds with std::random_device.

namespace Void::Retry::detail { template <class G> G seeded_engine()
  { if constexpr (std::is_constructible_v<G, std::random_device::result_type>) return G{std::random_device{}()}; else return G{}; } }
// RetryState::create(spec, start, URBG urbg = detail::seeded_engine<URBG>(), std::optional<SteadyTimePoint> = {})
// BlockingRetryOptions::urbg default member init = detail::seeded_engine<URBG>(); retry_async param default likewise
  • Tests pass seeded std::mt19937_64{42} everywhere except retry_state_default_engine_jitter_in_bounds, which checks bounds only.

F9 Revised D-W11-05: B2 owns the shutdown core, A4 owns thin wrappers

B2 internal primitive in detail::DriverBackend (Backend.hpp):

virtual void begin_shutdown() noexcept = 0;                    // idempotent: close admission, cancel queued, stop active
[[nodiscard]] virtual Void::Result::Result<DriverShutdownReport> advance_shutdown(
    std::optional<Void::Time::MonotonicClock::time_point> deadline, std::stop_token stop) = 0;
[[nodiscard]] virtual bool shutdown_complete() const noexcept = 0;
[[nodiscard]] virtual bool quiescent() const noexcept = 0;    // no owned ops/requests/in-flight syscalls
virtual void teardown_blocking() noexcept = 0;                 // Driver::~Driver only
  • B2 also owns DriverShutdownReport in Types.hpp, using the plan's fields.
  • 1.x shutdown_and_join() becomes advance_shutdown(nullopt, {}) mapped to Result<void>.
  • advance_shutdown details:
    • Waits for the injected-clock deadline in ≤1 ms real slices, re-reading the clock each time.
    • Calls wake() to interrupt the current poller.
    • Runs its own poll turns only while it holds poll ownership.
    • Returns self_join if called on this backend's worker or inside its poll turn.
  • Poll-owner exclusion uses a dedicated std::mutex poll_mu_. poll_once tries the lock and returns std::unexpected(make_io_error(IoErrorCode::busy, ...)) if it can't get it, without touching any fd.
    • I chose busy over 0 for three reasons: busy already means "concurrent op not allowed" (EpollDriver.cpp:533-540); the only library caller in a loop ignores the result (IPC/Session.cpp:1128); and a silent 0 would let a second run() loop spin.
    • Test: io_concurrent_poll_once_second_caller_busy_no_fd_touch_tsan.

A4 public wrappers (inline in Driver.hpp; A4 touches no .cpp):

void begin_shutdown() noexcept;                                           // -> backend_->begin_shutdown()
[[nodiscard]] Void::Result::Result<DriverShutdownReport> shutdown(Async::OperationOptions);  // -> advance_shutdown(o.deadline, o.stop)
[[nodiscard]] Void::Result::Result<std::size_t> run(std::stop_token, std::chrono::nanoseconds max_wait = std::chrono::milliseconds{5});
[[nodiscard]] bool quiescent() const noexcept;

A4 also delivers Pump.hpp/pump_until, the SystemAsync conformance test, and tests.

F10 Roadmap and doc edits (root, before dispatch)

docs/roadmap/modules/Functional.md

  • :95-96: "NEW RetryState exposes begin(now), next(now, outcome) and resume(now): next returns stop or wait_until(absolute time); begin/resume return attempt or stop. Callers map their error to AttemptOutcome with a supplied classifier."
  • :99: append "; the default engine is seeded from std::random_device."
  • :104-106: "Retain 1.x retry/retry_while unchanged, including the zero-attempt default-result defect (recorded for Wave C). NEW retry_blocking takes injected now/sleep callables, so Functional stays standard-library-only and no Time-dependent retry header exists. Async supplies Async::retry_async over TimerQueue."

docs/roadmap/subsystems/Runtime.md

  • :48-51: "Result<void> start(StartOptions); Async::Executor* executor(); IO::Driver* io(); Result<ShutdownReport> shutdown_blocking(Async::OperationOptions); Result<ShutdownReport> poll_shutdown(); Result<ShutdownReport> shutdown_pumping(Async::ManualExecutor&, Async::OperationOptions); An awaited shutdown Task on the host's own executor is not offered, because it would self-join."
  • :73: "install the injected SignalGate (Runtime has no System dependency; System-backed adapter optional) on the owner thread"
  • :77: append "; off-owner teardown calls uninstall(false), which cannot restore the owner's mask."
  • :114-117: "6. After cleanup/export callbacks and backend references retire, drop component/exporter references, then stop owned IO, the reactor and CPU/file workers, and release budgets, descriptors and the signal gate in reverse creation order. Borrowed executor, driver, clock and memory are never shut down or joined by the Host."
  • :119: "Each shutdown call observes min(caller deadline, now + total_timeout (30 s)) for remaining work. Drain-grace and flush deadlines are fixed at first entry to their phase. An incomplete phase stops the sequence and the next call resumes there."
  • :124-126: "Destruction blocks to join only off Runtime threads. Destruction on a Runtime worker, reactor or IO file-worker thread is a programmer error that terminates after a diagnostic."
  • :159: deps become "P2 / S-RUNTIME-01, M-ASYNC-04, S-IO-03; signal gate (injected port)".
  • :160: deps become "P2 / S-RUNTIME-02, S-IO-04".

docs/roadmap/subsystems/IO.md

  • :77-79: "The Driver owns no thread. One thread at a time runs a poll_once turn (the poll owner) and owns interest updates and generations; a concurrent caller gets busy without touching descriptors. Producers wake the owner through eventfd. Runtime or the embedder supplies the thread (Driver::run, pump_until)."
  • :92: "Files use a bounded blocking worker pool started explicitly by start_file_workers() or stepped by run_file_work(). Workers run only the syscall or injected shim and queue its result; completions are delivered only by a poll turn."
  • :118-120: "Driver shutdown closes admission, cancels queued requests, stops active ones, waits for the poll owner and in-flight syscalls, drains completions, joins workers, then closes operation descriptors. Epoll and wake descriptors close in the backend destructor. Blocking teardown runs in Driver::~Driver; destruction on a file worker or inside a poll turn is a programmer error."
  • :121-122: "File::close_and_join returns incomplete_shutdown on expiry and retains the fd and buffers. A dropped File closes its fd after its last in-flight request drains."
  • :154: "optional System/Net adapters" becomes "SystemAsync conformance; Net adapter deferred (Net has no IO use)".

docs/roadmap/MIGRATION.md:61 (Async/IO row, append to the evidence cell) "Recorded W11 changes:

  • Driver::shutdown_and_join blocks for in-flight syscalls and joins file workers.
  • validate_limits rejects max_file_queue == 0.
  • Sync EventBus and Observable/Signal dispatch over snapshots; subscription changes take effect next pass.
  • Nested Observable/Signal updates for copyable types are queued FIFO.
  • Legacy parallel_for waits for all tasks before rethrowing.
  • Async-mode EventBus handler exceptions are counted instead of terminating.
  • Legacy retry zero-attempt result is kept until Wave C."

DECISIONS: amend D-W11-05 per F9, and add F1, F2 and F5 as root decisions.

F11 Within-step failure coverage

  • IO (B2): BackendOptions::before_file_worker_start (NEW, appended):
    std::function<Void::Result::Result<void>(std::size_t)> before_file_worker_start{};
    
    • start_file_workers treats a hook error exactly like a caught std::system_error: it joins the workers already started, returns os_error (with the system code when one exists), and allows a retry.
    • Test: io_file_workers_partial_start_failure_joins_started.
  • ThreadExecutor (A2): start() catches std::system_error from std::thread through the same path as before_worker_start.
  • Runtime (B3):
    struct StartOptions { /*...*/
      std::function<Void::Result::Result<void>(StartStep, std::size_t thread_index)> before_thread_start{};
      std::chrono::milliseconds cleanup_timeout{5000}; };
    
    • before_thread_start is forwarded to the executor and IO hooks and to the reactor's std::thread creation, which also catches std::system_error.
    • Failed-start component cleanup waits at most cleanup_timeout (injected clock). If it runs out, the state is failed_start, resources are retained, and the next shutdown_blocking or ~HostCore continues the cleanup.
  • Tests:
    • runtime_failed_start_thread_fault_each_threaded_step_reverse_cleanup (cpu_executor, file_workers and reactor, at index 0 and at the last index)
    • runtime_failed_start_component_cleanup_timeout_retains_then_completes
    • thread_executor_system_error_path_shared_with_hook

F12 Shared-core lifetimes

  • EventBus (A3):
    • Injected-mode dispatch frames capture std::shared_ptr<detail::BusCore>.
    • ~EventBus closes admission. On an executor thread it does not wait: frames finish against the shared core. Off the executor it calls close_and_join (blocking, or pumping on ManualExecutor).
    • NEW [[nodiscard]] Void::Result::Result<void> flush_blocking(); returns self_join on an executor thread or inside a bus callback, and invalid_argument on a ManualExecutor (Executor.hpp:195).
    • NEW flush_pumping(ManualExecutor&).
    • Legacy flush() in Injected mode calls flush_blocking() and discards the error, because the 1.x signature returns void (EventBus.hpp:193-201). It never deadlocks.
  • TimerQueue (B1):
    enum class TimerEvent : std::uint8_t { expired, closed };
    using TimerCallback = std::move_only_function<void(TimerEvent) noexcept>;
    
    • TimerHandle holds shared_ptr<detail::TimerEntry>, whose state is an atomic pending→{fired, cancelled} transition. cancel() is valid after the queue is destroyed.
    • The callback runs exactly once (expired or closed), or never if cancel() returned true. Queue close or destruction invokes pending callbacks with closed; AsyncChannel maps that to cancelled.
    • Test: timer_handle_cancel_after_queue_destroyed_safe.
  • parallel_for (A2):
    • Shared detail::PForState holds the decay-copied F, the chunk counter and the error slots.
    • The caller waits for every submitted runner future, including runners that were never started.
    • Nested use on the same pool from a pool worker is documented as unsupported.
    • Test: parallel_for_bounded_waits_all_submitted_runners.

F13 File descriptor lifetime (B2)

  • detail::FileState is shared-owned and holds the fd, the shim, the in-flight count, a close_pending flag and the per-file ordering lane. Every request holds a reference to it.
  • When the last handle drops:
    • with no requests in flight, an internal close request is enqueued, using reserved capacity outside max_file_queue;
    • otherwise close_pending is set, and the poll-turn retirement of the last request enqueues the close.
  • Close always executes on a worker, or in run_file_work. Teardown closes any remaining file fds after the workers are joined.
  • File::close_and_join(options) is always admitted.
    • Deadline or stop expiry returns IoErrorCode::incomplete_shutdown; the File stays valid with its fd and buffers retained, so the call can be repeated.
    • Success invalidates the File.
    • A close syscall failure returns os_error, and the fd is treated as closed.
    • This differs from ByteStream::close_and_join, which consumes the stream (Stream.hpp:105); document the difference.
  • Tests:
    • io_file_drop_with_inflight_defers_close_until_drained
    • io_file_close_and_join_expiry_incomplete_retains_then_completes

P3 resolutions

  • retry_blocking template defaults (A1): use defaulted function-template parameters, because deduction cannot read a default function argument:
    template <class F, class NowFn = SteadyNow, class SleepFn = ThreadSleep,
              class Classify = RetryEveryError, class URBG = std::mt19937_64>
    auto retry_blocking(const RetrySpec&, F&&, BlockingRetryOptions<NowFn, SleepFn, Classify, URBG> = {});
    
    Tests spell the option types explicitly; aggregate CTAD is a convenience only.
  • Observable/Signal (A3):
    • Observable<T> with std::copy_constructible<T>: a nested set updates the value immediately and queues (old, new) copies, delivered FIFO after the current pass and bounded at 1,024. On overflow, set keeps the new value and counts a dropped notification. try_set (only when copyable) returns overloaded without changing the value.
    • Move-only T: the 1.x behavior stays — immediate recursive notification — but iteration runs over a listener snapshot. There is no queue and no try_set.
    • Signal<Args...> follows the same rule when (std::copy_constructible<std::decay_t<Args>> && ...); the queue is a mutable member, since emit is const.
    • On a throw, the value stays the new value (as in 1.x, Observable.hpp:40-42), dispatch depth is restored, and that pass's queued notifications are dropped and counted.
  • S-IO-03 downstream build:
    -DVOID_ENABLED_MODULES="IO;IPC;SystemAsync;Storage;CryptoAsync;Runtime;ConfigurationAsync;Testing"
    
    run unfiltered, plus ctest.
  • Error-kind alignment: RuntimeErrorCode::shutdown_incomplete = 9 maps to ErrorKind::conflict, matching IoErrorCode::incomplete_shutdown (IO/Types.hpp:51-53). IO is unchanged. Root pre-commit.
  • D1 regression seam (B2):
    • Test io_epoll_stop_requested_at_deadline_scan_completes_once uses a clock whose now() requests stop. That now() call happens in the wait computation, only when the op has a deadline (EpollDriver.cpp:1083,1098).
    • The sequence:
      1. The socket already has data.
      2. The stop puts the cancel in the queue.
      3. drive_read sees the stop and completes the op (:1452).
      4. The end-of-turn cancel pass hits the same op (:1173).
    • NEW appended telemetry field DriverTelemetry::duplicate_completions_ignored. The test asserts a single delivery and a counter ≥ 1.
  • Mock reactor spin (B3): MockBackend::poll_once ignores max_wait (EpollDriver.cpp:739-741) and its wake only counts (:637-640).
    • The Runtime reactor (and A4's Driver::run) waits on a stop-aware condition variable for max_wait when the backend is mock and a turn did no work.
    • IO is unchanged, so the IoDriver test timing is untouched.
  • Business scope: TaskScopeOptions{.max_tasks = limits.max_cpu_tasks, .stop_on_first_error = false}, because the default is true (TaskScope.hpp:32).
  • ThreadExecutor (A2):
    • After close(), a legacy post() goes onto the completion lane and is counted.
    • join() drains until both lanes are empty and nothing is running. After join, posts resume inline and are counted.
    • No drain cap: abandoning a handle would strand a frame, which C-03 forbids (ARCHITECTURE.md:63-64, "owner until exactly one terminal result"). A handle that re-posts itself forever prevents join; that is documented as a caller error.
    • ~ThreadExecutor without a prior join calls close() then join(). On its own worker it prints a diagnostic and terminates.
  • Runtime worker detection uses IO::is_io_worker_thread() (F1).
  • Layering check (A4):
    rg -n "Void/(Runtime|Net|System)/" include/Void/IO src/IO    # expect no output
    git diff --stat -- src/IO/module.cmake                       # expect empty
    
  • Budget accounting (B4): test runtime_shutdown_budget_bytes_retained_while_incomplete_zero_after_complete.
    • The Host passes memory_budget() as the Driver's pmr resource (Driver.hpp:69-74).
    • An exporter holds a BufferLease across a stalled read.
    • While incomplete: memory_budget().stats().requested_live > 0 (BudgetResource.hpp:106, Memory/Resource.hpp:22-30), and executor()->admitted() and DriverTelemetry::owned_buffer_bytes stay as they were.
    • After release and a second join: all three are 0.
  • M-ASYNC-05 captured-state tests (A3):
    • bus_sync_unsubscribe_releases_captured_state
    • bus_legacy_async_unsubscribe_then_flush_releases_captured_state
    • bus_legacy_async_close_and_join_releases_capture_with_queued_copies All three assert the sentinel's use_count() == 1.

Revised gates and ownership (changes only)

Gates

  • G1–G5 as before.
  • G4 now hands A4 only Driver.hpp (inline wrappers), the NEW Pump.hpp and tests.
  • G6 (new): after A4 merges, all IO files are root-owned. B4 must stop and report if it needs an IO edit.
Step Owned-file delta
Root pre-commit RuntimeErrorCode::shutdown_incomplete maps to conflict (changed from timeout)
B1 adds TimerEvent and the shared-state TimerHandle to Async/Timer.hpp
B2 adds to IO/Driver.hpp: is_io_worker_thread, ~Driver teardown. Adds to IO/Types.hpp: DriverShutdownReport, BackendOptions::before_file_worker_start, DriverTelemetry::duplicate_completions_ignored. Adds to IO/Detail/Backend.hpp: the shutdown primitives. Also src/IO/{EpollDriver.cpp, FileWorkers.{hpp,cpp}} and tests/standalone/IO/IoFile.cpp
A4 include/Void/IO/Driver.hpp (inline wrappers only), include/Void/IO/Pump.hpp (NEW), tests/standalone/IO/{IoShutdown,IoPump}.cpp, tests/standalone/SystemAsync/SystemAsyncShutdown.cpp. Not owned: EpollDriver.cpp, Backend.hpp, Types.hpp, FileWorkers.* (stop and report)
B3 / B4 Runtime/Lifecycle.hpp gains SignalGate::uninstall(bool), StartOptions::{before_thread_start, cleanup_timeout} and the renumbered ShutdownPhase. Host.hpp gains valid() and the 3-argument shutdown_pumping. A2 additionally owns ThreadExecutor::idle()

Root resolutions I'd adjust (not silently changed)

  1. F5 adapter wording. "Releases its fd ... only on the owner thread" doesn't match 1.x: SignalWatcher closes the fd on any thread (SignalWatcher.cpp:29-31). Keeping the fd open off-owner would leak it, because no later owner-thread call is guaranteed. I recommend closing the fd and skipping only the mask restore, exactly as 1.x does; the F5 section above specifies that.
  2. F1(a) "workers never call user code". The injected FileSyscalls shim runs on workers by design. It should be stated as the only exception: a syscall substitute that must not call Driver, Executor or File APIs.
  3. Observable copyable queuing. It changes 1.x nested-set ordering from recursive to FIFO for copyable types. That's acceptable, since the roadmap mandates the queue, but it must appear in the MIGRATION record; F10 includes it.

Checks not run: no builds or tests. All citations come from direct reads during this session.