Repository navigation
fix: keep I/O responsive during queued session writes - #146491
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 12, 2026, 11:13 PM ET / September 13, 2026, 03:13 UTC (Revision 7). ClawSweeper reviewWhat this changesThe PR gives I/O opportunities between queued session writes and updates completion-sensitive, compiler-copy, and port-probe test fixtures. Merge readiness✅ Ready for maintainer review This remains a useful, focused fix: current main still permits uninterrupted ready-write backlogs. No introduced correctness or security defect was found, and the latest Signal fixture correction preserves the meaningful assertions. Priority: P2 Review scores
Verification
How this fits togetherThe shared writer queue serializes session storage and lifecycle operations within a process. Its scheduling determines when waiting writes execute and when the Gateway event loop can service I/O. flowchart TD
A[Session and lifecycle operations] --> B[Per-store FIFO queue]
B --> C[Run writer in caller context]
C --> D[Settle result or failure]
D --> E{Backlog and turn budget reached?}
E -->|Yes| F[Give event loop an I/O turn]
F --> B
E -->|No| B
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +4, Tests +113. Total +117 across 6 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep bounded yielding in the existing queue owner while preserving FIFO execution, caller context, exact outcomes, and complete writer settlement. Do we have a high-confidence way to reproduce the issue? Yes, from source: a blocked writer followed by ready writes drains through microtasks before I/O on current main. The PR provides focused regressions for that mechanism; this review did not execute them. Is this the best way to solve the issue? Yes. Yielding between settled writers repairs scheduling at its existing owner without adding another queue, changing public configuration, or interrupting active writes. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against bd002c80a15f. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (6 earlier review cycles)
|
08c6c8b to
932f573
Compare
450a4c9 to
40cb04f
Compare
40cb04f to
af1811f
Compare
|
Merged via squash.
|
* fix: keep I/O responsive during queued session writes * test(telegram): await debounced dispatch completion * test: prevent inherited writable compiler descriptors * test(signal): allocate the available-port probe through the kernel
) ## What Problem This Solves Multiline `/steer` and `/tell` messages lose later lines when incoming command text still contains newlines. A command-only first line returns usage. Closes #146007. ## Why This Change Was Made Extend the existing argument-preservation policy from goal to steer. Normalized command text has one writer. Match whitespace consistently in the reset reader so a configured `/steer` trigger still resets with newline or tab separators; authorization and anchored payload extraction stay unchanged. Production: `commands-registry-normalize.ts` +7/-2; `session-reset-command.ts` +2/-1. Tests: `commands-steer.test.ts` +17; `session.test.ts` +39. No new owner or configuration key. Growth accepted under the owner's standing acceptance (2026-09-15). ## User Impact Complete instructions reach the active run or normal idle fallback. Configured reset commands keep resetting the conversation with the complete payload. ## Evidence Raw WebChat `chat.send` reproduced truncation on main `3869ac66de02`. Retained real-Gateway recordings at `26d6274c2d67` passed three active-run and three idle cases with a deterministic provider. Each active case was matched to the original held task, and its complete current instruction was inspected at the provider boundary. Empty usage stayed correct. The Control UI's local steering shortcut removes the command prefix and is a separate path. The reset regression fails on `26d6274c2d67` for newline and tab delimiters, then passes with this correction. The non-boundary `/steering` case keeps the existing conversation. These tests call `initSessionState` with seeded state and check the reset revision and complete payload. ## Compatibility No configuration, schema, dependency, or API shape change. Group mention processing and some adapters flatten newlines before normalization; that separate formatting issue is outside this change. Per-channel scope comes from source inspection unless a runtime capture is cited. ## Consumers Shared text-command callers with newline-preserving ingress, plus configured reset detection during admission and session initialization. ## Invalidation No cache lifecycle change. ## Tests The three steering regressions exercise the real command-context builder and registered handler; the retained Gateway proof establishes delivery beyond that boundary. The pinned merge includes main `3869ac66de02`, where 79 focused tests passed before this correction. All 259 tests passed across session initialization, steering, and reset-model suites. After correcting two fixture typing errors, the three seeded-session cases passed again on `d86aebfa4701`. The existing session test file is selected once by the hosted test command. Historical CI failures have retained timing/compiler-launch evidence and passing focused checks with upstream repairs #148107 and #146491. Historical base/parent reruns and full current hosted CI are not claimed. | Before | After | | --- | --- | |  |  | Co-authored-by: Ayaan Zaidi <[email protected]>
…claw#146009) ## What Problem This Solves Multiline `/steer` and `/tell` messages lose later lines when incoming command text still contains newlines. A command-only first line returns usage. Closes openclaw#146007. ## Why This Change Was Made Extend the existing argument-preservation policy from goal to steer. Normalized command text has one writer. Match whitespace consistently in the reset reader so a configured `/steer` trigger still resets with newline or tab separators; authorization and anchored payload extraction stay unchanged. Production: `commands-registry-normalize.ts` +7/-2; `session-reset-command.ts` +2/-1. Tests: `commands-steer.test.ts` +17; `session.test.ts` +39. No new owner or configuration key. Growth accepted under the owner's standing acceptance (2026-09-15). ## User Impact Complete instructions reach the active run or normal idle fallback. Configured reset commands keep resetting the conversation with the complete payload. ## Evidence Raw WebChat `chat.send` reproduced truncation on main `0da26ff6b4cc`. Retained real-Gateway recordings at `26d6274c2d67` passed three active-run and three idle cases with a deterministic provider. Each active case was matched to the original held task, and its complete current instruction was inspected at the provider boundary. Empty usage stayed correct. The Control UI's local steering shortcut removes the command prefix and is a separate path. The reset regression fails on `26d6274c2d67` for newline and tab delimiters, then passes with this correction. The non-boundary `/steering` case keeps the existing conversation. These tests call `initSessionState` with seeded state and check the reset revision and complete payload. ## Compatibility No configuration, schema, dependency, or API shape change. Group mention processing and some adapters flatten newlines before normalization; that separate formatting issue is outside this change. Per-channel scope comes from source inspection unless a runtime capture is cited. ## Consumers Shared text-command callers with newline-preserving ingress, plus configured reset detection during admission and session initialization. ## Invalidation No cache lifecycle change. ## Tests The three steering regressions exercise the real command-context builder and registered handler; the retained Gateway proof establishes delivery beyond that boundary. The pinned merge includes main `0da26ff6b4cc`, where 79 focused tests passed before this correction. All 259 tests passed across session initialization, steering, and reset-model suites. After correcting two fixture typing errors, the three seeded-session cases passed again on `d86aebfa4701`. The existing session test file is selected once by the hosted test command. Historical CI failures have retained timing/compiler-launch evidence and passing focused checks with upstream repairs openclaw#148107 and openclaw#146491. Historical base/parent reruns and full current hosted CI are not claimed. | Before | After | | --- | --- | |  |  | Co-authored-by: Ayaan Zaidi <[email protected]>
Related: #130741
What Problem This Solves
Ready session writes can drain as an uninterrupted microtask backlog, delaying Gateway I/O even after each individual write has finished.
User Impact
I/O gets a turn while queued writes remain pending. Writes keep their FIFO order, and an active write retains ownership until it settles.
Why This Change Was Made
The existing queue now yields between completed writers after four completions or four milliseconds. Idle and explicitly reentrant writes still start immediately, and queued callbacks retain their caller context and exact results or rejection values.
Evidence
The four fairness regressions fail on the main implementation because all queued writes finish before the I/O turn. 61 focused tests passed across queue, SQLite diagnostics, and session lifecycle coverage, including ordering, caller context, rejection, cancellation, and bulk identity locks. This change does not establish the full Swarm latency target.
Canonical changed gates pass on the refreshed base. The full Telegram bot test file also passes (167 tests); its debounce fixtures now await their existing deferred-work promises before checking completed replies, preserving every timer boundary and message assertion.
Earlier CI hit the Gateway profile lifetime fixture's 120-second timeout. This branch now inherits main's fresh-handler-factory repair from #146390, keeping that test change out of the writer slice. The original timeout was not reproduced locally, and replacement-head CI remains required. No timeout or assertion was relaxed.
CI also exposed an intermittent compiler-launch
ETXTBSYfailure in the test fixture. A controlled Linux comparison reproduced Node 24.19's recursive copy leaking a writable descriptor into a concurrently spawned process. The fixture now uses the documented filter option, selecting libuv's close-on-exec copy path. Complete copying and the existing compiler launch remain unchanged.The unchanged TypeScript compiler failed while the inherited descriptor remained open, then ran after it closed. With the filtered copy it ran while the other process remained alive. All 19 real-compiler tests, the fixture's complete changed gate, and fresh independent P1 review pass. This proves the mechanism and prevention; the holder in the original CI run was not identified. Exact final-head CI remains required.
The next CI run stopped during a Matrix binary download connection reset and exposed a separate Signal test race. After closing its listener, that test assumed the released port remained free. A controlled TCP competitor reproduced the assumption's failure. The positive probe now lets the kernel allocate its port; occupied-port refusal, error guidance and listener cleanup stay intact. This changes only the fixture, not operator Signal configuration. All 10 daemon tests and four port-probe siblings pass (one existing alternate-loopback case skips on this host), with full changed checks and fresh P1 review. The failed run remains recorded; validation proceeds on the corrected head.