- 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>
29 KiB
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
FileSyscallsshim 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
FileSyscallsshim) and nothing else. It then pushes{request, result}ontoFileWorkerShared::completionsunder the shared mutex and calls the waker.- Resume tickets are produced only by a poll turn, which drains
completionsthrough the existingcomplete_op_and_collect_tickets/dispatch_ticketspath. run_file_work()executes one syscall on the caller's thread and only queues its result.
- Resume tickets are produced only by a poll turn, which drains
- (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 holdshared_ptr<DriverBackend>.- The waker's raw backend pointer stays valid because workers are joined before the backend can be destroyed:
Driver::~Driverandshutdown_and_joinboth join first.
- The waker's raw backend pointer stays valid because workers are joined before the backend can be destroyed:
- (c)
~EpollBackend,~MockBackendand~FileWorkersnever block.~FileWorkersfinding a joinable thread prints a diagnostic to stderr and callsstd::terminate.- Today
~EpollBackendblocks (EpollDriver.cpp:953-955callsshutdown_and_join); that call is removed. Driver::~Driver(:1737-1742) becomes the blocking teardown:backend_->teardown_blocking().
- Today
- (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'spoll_onceturn)~Driverwith either marker matching prints a one-line stderr diagnostic and callsstd::terminate.
- NEW, declared in
Driver.hppand defined inFileWorkers.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: withManualExecutor,poll_oncedispatches a ticket andexec.drain()on the same thread resumes a coroutine that resets theunique_ptr<Driver>. Teardown must complete with no terminate.io_worker_thread_marker_only_on_file_workers: a gated shim recordsis_io_worker_thread()as true insidepread; 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:142only 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()loadsstd::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_, theCancelForwarderweak→lock at:589-596, andStreamState::lock_backendatBackend.hpp:89-96. - Workers are joined first.
- So the destructor's write happens after every
wake()call, through theshared_ptrcontrol block's acq_rel ordering.
- All
poll_oncechecksshut_down_(acquire) on entry and returns0before touching any fd. That keeps the 1.x return value (:1057-1059returnswork_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_joinedstays. - Per-call budget: every
shutdown_blocking,poll_shutdownandshutdown_pumpingcall usescall_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.
- Drain expiry moves on to phase 3 and sets
- Incomplete: if
call_deadlineexpires in a waiting phase (4, 5, 6, 8 or 9), the sequence stops and returnscomplete=false, with the phase and state recorded asshutdown_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 bystd::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.
- if the host is started and not stopped, calls
- Moved-from Host (
HostStatehas no moved-from value,Host.hpp:19-29):- NEW
[[nodiscard]] bool valid() const noexcept; state()returnsstopped;is_running()andis_ready()return false;started_worker_count()returns 0.executor()andio()returnnullptr;owner_thread()andlast_shutdown_report()returnnullopt.start,shutdown_*andpoll_shutdownreturnRuntimeErrorCode::invalid_state;spawnreturnsAdmissionError::stopped.clock()stays safe through its System-clock fallback (:147-151).memory_budget()has the preconditionvalid(). This is a pre-existing hazard: the 1.x code dereferences a nullowned_budget_after a move (:153-156).
- NEW
~HostCorerunning on a Runtime worker, the reactor or an IO worker prints a stderr diagnostic and callsstd::terminate. Detection uses:executor->is_executor_thread()(Executor.hpp:86-96)- a Runtime
tl_reactormarker 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, callsuninstall(this_thread == owner).- The System test adapter destroys its
SignalWatcherin 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/fddelta 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:
It drives progress with
[[nodiscard]] Void::Result::Result<ShutdownReport> Host::shutdown_pumping( Async::ManualExecutor&, Async::OperationOptions = {}, Async::TimerQueue* timers = nullptr);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 acceptscreate_mock_streamand the executor still acceptstry_post.
F7 AsyncChannel arbitration (A2)
- One
std::mutexcovers 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 holdsstd::optional<T> value; a receive waiter holdsstd::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 tocancelledortimed_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.
- If the waiter is still
- Every resume is dispatched through
post_completionafter unlock. Each sender gets success or its value back exactly once. - Tests:
channel_receiver_stop_after_claim_delivers_value_no_losschannel_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 exceptretry_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
DriverShutdownReportinTypes.hpp, using the plan's fields. - 1.x
shutdown_and_join()becomesadvance_shutdown(nullopt, {})mapped toResult<void>. advance_shutdowndetails:- 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_joinif called on this backend's worker or inside its poll turn.
- Poll-owner exclusion uses a dedicated
std::mutex poll_mu_.poll_oncetries the lock and returnsstd::unexpected(make_io_error(IoErrorCode::busy, ...))if it can't get it, without touching any fd.- I chose
busyover0for three reasons:busyalready 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 silent0would let a secondrun()loop spin. - Test:
io_concurrent_poll_once_second_caller_busy_no_fd_touch_tsan.
- I chose
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
RetryStateexposesbegin(now),next(now, outcome)andresume(now):nextreturnsstoporwait_until(absolute time);begin/resumereturnattemptorstop. Callers map their error toAttemptOutcomewith a supplied classifier." - :99: append "; the default engine is seeded from
std::random_device." - :104-106: "Retain 1.x
retry/retry_whileunchanged, including the zero-attempt default-result defect (recorded for Wave C). NEWretry_blockingtakes injectednow/sleepcallables, so Functional stays standard-library-only and no Time-dependent retry header exists. Async suppliesAsync::retry_asyncoverTimerQueue."
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_onceturn (the poll owner) and owns interest updates and generations; a concurrent caller getsbusywithout 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 byrun_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_joinreturnsincomplete_shutdownon 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_joinblocks for in-flight syscalls and joins file workers.validate_limitsrejectsmax_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_forwaits for all tasks before rethrowing. - Async-mode EventBus handler exceptions are counted instead of terminating.
- Legacy
retryzero-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_workerstreats a hook error exactly like a caughtstd::system_error: it joins the workers already started, returnsos_error(with the system code when one exists), and allows a retry.- Test:
io_file_workers_partial_start_failure_joins_started.
- ThreadExecutor (A2):
start()catchesstd::system_errorfromstd::threadthrough the same path asbefore_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_startis forwarded to the executor and IO hooks and to the reactor'sstd::threadcreation, which also catchesstd::system_error.- Failed-start component cleanup waits at most
cleanup_timeout(injected clock). If it runs out, the state isfailed_start, resources are retained, and the nextshutdown_blockingor~HostCorecontinues 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_completesthread_executor_system_error_path_shared_with_hook
F12 Shared-core lifetimes
- EventBus (A3):
- Injected-mode dispatch frames capture
std::shared_ptr<detail::BusCore>. ~EventBuscloses admission. On an executor thread it does not wait: frames finish against the shared core. Off the executor it callsclose_and_join(blocking, or pumping onManualExecutor).- NEW
[[nodiscard]] Void::Result::Result<void> flush_blocking();returnsself_joinon an executor thread or inside a bus callback, andinvalid_argumenton aManualExecutor(Executor.hpp:195). - NEW
flush_pumping(ManualExecutor&). - Legacy
flush()in Injected mode callsflush_blocking()and discards the error, because the 1.x signature returnsvoid(EventBus.hpp:193-201). It never deadlocks.
- Injected-mode dispatch frames capture
- TimerQueue (B1):
enum class TimerEvent : std::uint8_t { expired, closed }; using TimerCallback = std::move_only_function<void(TimerEvent) noexcept>;TimerHandleholdsshared_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 (
expiredorclosed), or never ifcancel()returned true. Queue close or destruction invokes pending callbacks withclosed; AsyncChannel maps that tocancelled. - Test:
timer_handle_cancel_after_queue_destroyed_safe.
parallel_for(A2):- Shared
detail::PForStateholds the decay-copiedF, 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.
- Shared
F13 File descriptor lifetime (B2)
detail::FileStateis shared-owned and holds the fd, the shim, the in-flight count, aclose_pendingflag 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_pendingis set, and the poll-turn retirement of the last request enqueues the close.
- with no requests in flight, an internal close request is enqueued, using reserved capacity outside
- 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.
- Deadline or stop expiry returns
- Tests:
io_file_drop_with_inflight_defers_close_until_drainedio_file_close_and_join_expiry_incomplete_retains_then_completes
P3 resolutions
retry_blockingtemplate defaults (A1): use defaulted function-template parameters, because deduction cannot read a default function argument:Tests spell the option types explicitly; aggregate CTAD is a convenience only.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> = {});- Observable/Signal (A3):
Observable<T>withstd::copy_constructible<T>: a nestedsetupdates the value immediately and queues(old, new)copies, delivered FIFO after the current pass and bounded at 1,024. On overflow,setkeeps the new value and counts a dropped notification.try_set(only when copyable) returnsoverloadedwithout 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 notry_set. Signal<Args...>follows the same rule when(std::copy_constructible<std::decay_t<Args>> && ...); the queue is amutablemember, sinceemitisconst.- 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:
run unfiltered, plus
-DVOID_ENABLED_MODULES="IO;IPC;SystemAsync;Storage;CryptoAsync;Runtime;ConfigurationAsync;Testing"ctest. - Error-kind alignment:
RuntimeErrorCode::shutdown_incomplete = 9maps toErrorKind::conflict, matchingIoErrorCode::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_onceuses a clock whosenow()requests stop. Thatnow()call happens in the wait computation, only when the op has a deadline (EpollDriver.cpp:1083,1098). - The sequence:
- The socket already has data.
- The stop puts the cancel in the queue.
drive_readsees the stop and completes the op (:1452).- 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.
- Test
- Mock reactor spin (B3):
MockBackend::poll_onceignoresmax_wait(EpollDriver.cpp:739-741) and itswakeonly counts (:637-640).- The Runtime reactor (and A4's
Driver::run) waits on a stop-aware condition variable formax_waitwhen the backend is mock and a turn did no work. - IO is unchanged, so the
IoDrivertest timing is untouched.
- The Runtime reactor (and A4's
- Business scope:
TaskScopeOptions{.max_tasks = limits.max_cpu_tasks, .stop_on_first_error = false}, because the default istrue(TaskScope.hpp:32). - ThreadExecutor (A2):
- After
close(), a legacypost()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. ~ThreadExecutorwithout a prior join callsclose()thenjoin(). On its own worker it prints a diagnostic and terminates.
- After
- 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
BufferLeaseacross a stalled read. - While incomplete:
memory_budget().stats().requested_live > 0(BudgetResource.hpp:106,Memory/Resource.hpp:22-30), andexecutor()->admitted()andDriverTelemetry::owned_buffer_bytesstay as they were. - After release and a second join: all three are 0.
- The Host passes
- M-ASYNC-05 captured-state tests (A3):
bus_sync_unsubscribe_releases_captured_statebus_legacy_async_unsubscribe_then_flush_releases_captured_statebus_legacy_async_close_and_join_releases_capture_with_queued_copiesAll three assert the sentinel'suse_count() == 1.
Revised gates and ownership (changes only)
Gates
- G1–G5 as before.
- G4 now hands A4 only
Driver.hpp(inline wrappers), the NEWPump.hppand 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)
- F5 adapter wording. "Releases its fd ... only on the owner thread" doesn't match 1.x:
SignalWatchercloses 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. - F1(a) "workers never call user code". The injected
FileSyscallsshim 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. - 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.