15 KiB
W11-PREFLIGHT-2 output (opus-reviewer, 2026-11-29)
Verbatim agent return. Advisory input; root dispositions are recorded in DECISIONS.md.
Task W11-PREFLIGHT-2. Verdict: CHANGES_REQUIRED. The addendum and the root edits fix the first review's P1 (F1) and most of F2–F13. Six P2 gaps remain. One is a contradiction inside the addendum itself (N1). Four are gaps that the addendum's own resolutions create (N3–N6), and one is a state the addendum never covers (N2). All six can be fixed by adding sentences to the contract text. No re-plan, gate change or ownership change is needed.
- Blocked until the text is amended: B2 (N3, N4), B3/B4 (N1, N2, N3), A2's channel deadlines (N5; the rest of A2 can proceed), A3's EventBus work (N6). A4 picks up N3's loop rules when its spec is written.
- Not blocked: A1 (M-FUNCTIONAL-03) can continue. B1 (M-TIME-03) can continue but needs one documentation-only note (N5). Neither needs an interface change.
Paths are relative to /home/faumaray/Projects/VoidLibrary. "Addendum" means docs/agent-workflow/tasks/W11-PLAN-REV1-OUTPUT.md; "plan" means W11-PLAN-OUTPUT.md.
Item status
| Item | Status | Evidence / residual |
|---|---|---|
| F1 | RESOLVED | Workers only run a syscall and queue the result, so no completion runs on a worker. They hold a separate worker-pool object, never the backend. Backend destructors never block, and only ~Driver does a blocking teardown, behind two terminate markers. Residual: P3-9. |
| F2 | RESOLVED for sockets | The epoll and wake fds still close in the backend destructor (EpollDriver.cpp:953-963). Every socket-path wake() caller holds a strong reference (:589-596, Backend.hpp:89-96, Stream.hpp:105-120). The file path depends on N4. |
| F3 | RESOLVED | Phase 7 drops the components before IO stops (phase 8) and before the executor is joined (phase 9). |
| F4 | PARTIAL | The per-call budget fixes the zero-budget repeat call, but it contradicts the destructor rule (N1). Phase 2 is missing from the waiting-phase list (P3-1). |
| F5 | PARTIAL | Moved-from rules are fine; gaps in N1, N2, P3-3 and P3-7. |
| F6 | PARTIAL | Borrowed resources are skipped, but the embedded ManualExecutor path hangs (N2). |
| F7 | PARTIAL | The single-lock claim/hand-off rule is sound. The timer callback can still reach a destroyed waiter (N5). |
| F8 | RESOLVED | seeded_engine is in M-FUNCTIONAL-03.md:114-142. Nit: P3-6. |
| F9 | PARTIAL | The routing fix is done. Choosing busy without loop rules creates N3. |
| F10 | RESOLVED | The 7f95f89 doc edits match the addendum. Small gaps: P3-4. |
| F11 | RESOLVED | The IO and executor start hooks plus cleanup_timeout cover failures inside a step (a later destructor finishes the cleanup, see N1). |
| F12 | PARTIAL | TimerHandle shared state and the parallel_for shared state are fine. Gaps: N5 (timer) and N6 (EventBus). |
| F13 | PARTIAL | The FileState deferred close is right in direction. The fd state machine is incomplete (N4). |
First-review P3 items
| Item | Status |
|---|---|
retry_blocking template defaults |
RESOLVED (M-FUNCTIONAL-03.md:135-142) |
| Observable/Signal move-only and "state restored" | RESOLVED |
| Downstream build list | RESOLVED |
| Error-kind alignment | RESOLVED; observed in Runtime/Options.hpp, shutdown_incomplete maps to conflict |
| D1 regression seam | RESOLVED (seam at :1083/:1098); see P3-5 |
| Mock reactor spin | PARTIAL: the mock case is covered, the epoll cases are open (N3) |
Business scope stop_on_first_error |
RESOLVED |
MIGRATION: shutdown_and_join blocks / max_file_queue==0 / Sync snapshot / parallel_for |
RESOLVED, all four observed in MIGRATION.md:61 |
Unspecified: concurrent poll_once |
PARTIAL (N3) |
| Unspecified: IO file ownership after G5 | RESOLVED (G6) |
| Unspecified: stop-and-report if an IO edit is needed | PARTIAL: stated for B4 and A4, not for B3 |
| Unspecified: worker detection | RESOLVED (is_io_worker_thread) |
ThreadExecutor endless drain, destructor without join |
RESOLVED |
Acceptance gaps (layering rg, within-step faults, ordering, budget test, receiver stop, legacy-mode captures) |
RESOLVED; budget test lifetime in P3-2 |
Named checks (§3)
| Check | Answer |
|---|---|
busy breaking existing callers |
It does not. The only library loop that polls is ~Session (src/IPC/Session.cpp:1118-1129): bounded to 1,000 iterations, result ignored. Every test drives a driver from one thread, and the one cross-thread test polls from only one thread (IoDriver.cpp:458-508). The hazard is in the new loops (N3). |
wake_closed_ atomic argument |
Sound. The last shared_ptr release orders the destructor after every wake(). The flag is effectively optional because the fd closes only in the destructor. The file wake path is not enumerated (N4). |
FileState reserved close capacity |
Bounded only if files take descriptor slots. The addendum doesn't say so (N4). |
ThreadExecutor::idle() in phase 9 |
Usable, but it is a snapshot, so "join never unbounded" is overstated (posts after the snapshot still extend the join). Safe in Runtime because phase 8 has already stopped IO dispatch. |
Named hazards (§6.2)
| Hazard | Answer |
|---|---|
| Raw waker pointer lifetime | Sound for workers: every backend destruction path goes through ~Driver, which joins the workers first. ~File must not use that waker (N4). |
busy and loop callers |
See N3. |
| Reserved close capacity unbounded | See N4. |
| Phase-9 idle wait vs inline resume after join | Unreachable from IO, because phase 8 runs first. External posts (stop callbacks, user threads) resume inline; this is documented. |
~HostCore unbounded shutdown on destruction |
Contradicted by the per-call budget (N1). Hangs in embedded mode (N2). |
Planner adjustments
| Adjustment | Verdict |
|---|---|
| Signal adapter closes its fd off the owner thread | Agree. It matches src/System/SignalWatcher.cpp:27-37, and Runtime.md is updated. Test hygiene: P3-3. |
| Injected syscall shim as the one exception | Agree. IO.md:94-96 is updated. |
| Observable FIFO ordering change | Agree. It is recorded in MIGRATION.md. |
New findings
N1 (P2, observed contradiction): the destructor's shutdown is called "unbounded" but the budget rule caps it at 30 s.
- Where: addendum
:85says "(unbounded)". Addendum:75-79caps every call atmin(deadline, now + total_timeout)and returnscomplete=falseon expiry.validate_optionsrejectstotal_timeout <= 0, so the cap can't be switched off. The failed-start continuation (:230) relies on the same path. - What happens: a stall longer than 30 s makes
~HostCorereturn from the shutdown call incomplete. A joinable reactorstd::threadthen callsstd::terminate. If it didn't, members would tear down while components still exist. - Related:
poll_shutdown()takes no options, so its budget restarts on every call. The plan testruntime_shutdown_budget_min_caller_policy_manual_clock (poll_shutdown)(plan:745) can therefore never see an expiry. - Fix:
~HostCoreloopsshutdown_blocking({})untilcomplete(or calls an internal no-deadline variant). State "destruction blocks until complete". Move that test toshutdown_blockingwith an expired or manual-clock deadline. Define howpoll_shutdownrelates to the budget.
N2 (P2, inferred hang): embedded mode with a borrowed ManualExecutor.
- Where:
~HostCorecallsshutdown_blocking. Phase 4 then reachesTaskScope::join_blocking, which waits on a condition variable that nothing will ever pump (include/Void/Async/TaskScope.hpp:289-303). Componentstop()tasks also need pumping. - What happens: destroying an unstopped embedded Host that has a business task or any component hangs forever.
- Second problem: the terminate check uses
executor->is_executor_thread(), which is true inside an ordinarymanual.drain()of the borrowed executor. - Fix:
shutdown_blockingreturnsinvalid_argumentwhen the executor has no background workers, asflush_blockingalready does.~HostCorewith aManualExecutorpumps, following the~TaskScopepattern (TaskScope.hpp:562-575).- The terminate check applies only to owned executors.
shutdown_pumpingin managed mode returnsinvalid_argument, because the reactor owns polling andpump_untilwould just getbusy.
N3 (P2, inferred spin plus one hang path): who polls during shutdown is never specified.
- Spins:
busyreturns immediately, so the B3 reactor loop (poll_once(5ms)), A4'sDriver::runandpump_untilspin hot whileadvance_shutdownholds poll ownership.- The 1.x early return once stopping is set (
EpollDriver.cpp:1057-1059) skipsepoll_wait, so loops spin throughout the shutdown window. - After
shut_down_,poll_oncereturns 0 immediately, so the reactor spins until phase 9 joins it.
- Hang: the addendum doesn't say where file completions are drained relative to that early return. If the drain sits after
epoll_wait(the natural place, next todrain_wake_fd), in-flight file requests are never retired.quiescent()then never becomes true,advance_shutdownnever completes, andteardown_blockingin~Driverhangs. - Undefined behaviour:
try_lockonpoll_mu_by the thread that already owns it, reachable through an inline resume inside a turn. - Fix, one sentence each:
- Cancels, controls and file completions drain before any stop-flag return.
- Say whether
begin_shutdownsetsstopping_. - Library loops wait up to
max_wait(stop-aware) onbusyand exit onshutdown_complete(). - Choose one: phase 8 stops and joins the reactor before
advance_shutdown, or the reactor exits on completion. advance_shutdowneither releasespoll_mu_between its 1 ms slices or makes the other pollers park.poll_oncechecks the thread-local polling marker beforetry_lock.- Define what
advance_shutdownreturns when its stop token fires.
N4 (P2, inferred double close / use-after-free): the File fd state machine is incomplete (F13).
- Missing invariants:
- The transitions between handle drop, in-flight count and
close_pendinghappen under one mutex, so exactly one close is enqueued. - A File that outlives shutdown completion or
~Driverholds an fd that teardown closed. A later~Fileorclose_and_joinmust not close that number again, because it may now belong to someone else. Reads and writes must returnclosedwithout a syscall. close_and_joinafter the workers are joined has nothing to run the close on ("close always executes on a worker orrun_file_work").~Filemust wake through a weak→strong backend lock or the worker condition variable, never the raw waker.- Reserved close capacity is not stated as bounded.
- The transitions between handle drop, in-flight count and
- Fix:
- Give
FileStateanopen → closing → closedstate under the pool mutex; whoever closes setsclosed. - After completion,
close_and_joinreturns at once and~Filedoes nothing. - Files count against
max_descriptors, which bounds the reserved close capacity. - Preallocate the close node inside
FileState, so thenoexcept~Filepath never allocates.
- Give
N5 (P2, inferred use-after-free; affects B1, which is running): channel timer callbacks vs waiter nodes.
- Where:
M-TIME-03.md:63-65,89,113says callbacks fire outside the lock after pending→fired, and thatcancel()returning true means "never runs". It does not cover a callback that has fired and is still running. Addendum F7 puts waiter nodes in coroutine frames and has the timer callback "do nothing if claimed". - What happens: a sender claims the waiter, the receiver resumes and its
cancel()returns false, its frame is destroyed, and the in-progress callback then reads the dead node. - Fix:
- B1, documentation only:
cancel()==falsedoes not mean the callback has finished. B1 may continue. - A2: the timer callback captures shared waiter state, or the channel plus a waiter id that it looks up under the channel lock. It must never hold a raw pointer into a frame.
- B1, documentation only:
N6 (P2, inferred use-after-free): ~EventBus on an executor thread doesn't wait (F12).
- Where:
Subscriptionholds a rawEventBus*(include/Void/Async/EventBus.hpp:137-146), and handlers commonly captureEventBus&to publish follow-up events. - What happens: frames already queued keep delivering after the destructor returns, and any handler that touches the bus hits a dead object.
- Fix:
~EventBusgates every admitted-but-not-started delivery on every thread before it returns. Either wait for callbacks running on other threads (excluding the current one, via a thread-local depth) or document that residual.
P3 (each changes one spec line)
- Add phase 2 to the list of phases that return incomplete when the call deadline expires. Today a caller deadline shorter than the drain grace is ambiguous.
- The owned BudgetResource, executor and driver objects must live until
~HostCore.- The budget test reads
memory_budget()andadmitted()aftercomplete, andadmitted()needsThreadExecutor, notExecutor*. - A
BufferLeasethat outlives its resource is a use-after-free.
- The budget test reads
- Signal gate:
- The borrowed
signal_gatemust outlive the Host. uninstallmust be idempotent or tracked, because failed-start cleanup already uninstalls.- The off-owner signal test must restore the owner's mask and drain SIGUSR2 at the end.
- The borrowed
- MIGRATION and Runtime.md:
- Add "concurrent
poll_oncereturnsbusy" and "~Driveron a file worker or inside a poll turn terminates" to MIGRATION. Runtime.mdis missing theTimerQueue*parameter onshutdown_pumping.
- Add "concurrent
- The D1 seam clock must be armed after submission.
submit_ioreads the clock at:503, and a stop there takes the pre-queue path, so D1 never reproduces. - Use
G(std::random_device{}())(parentheses). Braces are a narrowing error for engines whose seed type is narrower thanunsigned. Documentation-only for A1. - Moved-from Host and HostCore:
- The moved-from rules omit the reference accessors (
options,lifecycle_plan,embedded_resources). - HostCore must not hold pointers into Host members, because Host is movable.
- The moved-from rules omit the reference accessors (
- Carry D-W11-06's condition into A3: a throwing
error_sinkis caught and counted. Add a B3 stop-and-report rule for IO edits. - Teardown with an already-joined
ThreadExecutorresumes continuations inline inside the shutdown's own poll turn. Either dispatch after releasing ownership, or document that the executor must not be joined before the Driver is torn down (the Runtime order already satisfies this).
Re-review scope
Only the amended text for N1–N6 and the P3 lines above. This can be checked on the B2, B3, B4, A2 and A3 task specs; no new planner round is needed.
Checks not run
- No builds, tests or compile probes. Everything above comes from direct
sed/rgreads. No Serena or codebase-memory coverage checks. - Not read:
EpollDriver.cpp:1475-1640(the rest ofdrive_readanddrive_write),ThreadPool.hpp,ResourceGraph.hpp, theRuntimeHost.cpptests, and TASKS/STATE. M-TIME-03.mdandM-FUNCTIONAL-03.mdwere only partly read.- A new commit,
a8a9249(D-039), landed during the review. I checked it: it does not touch the W11 contracts.