Skip to content

fix(gateway): resume interrupted turns after workspace preparation - #196423

Merged
steipete merged 2 commits into
mainfrom
steipete/perf-micro-resume-workspace-not-ready-20260919
Nov 10, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/perf-micro-resume-workspace-not-ready-20260919

Conversation

@steipete

@steipete steipete commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes interrupted turns being abandoned after a Gateway restart when their managed workspace is still pending preparation.

User Impact

Restart recovery waits for workspace preparation and resumes the interrupted turn once. Genuine setup errors retain their normal actionable errors. Retained yield waits remain parked, and other recovery classifications and ordering are unchanged.

Why This Change Was Made

A restarted process has lost the previous turn's workspace-readiness scope. Restart admission now re-enters the existing workspace preparation queue before reply admission, using current session and operator authority. The saved restart marker remains durable until admission transfers custody or definitively fails; shutdown draining prevents recovery from erasing the next restart's marker.

No retry loop, config option, cache, or schema change. The production increase is 69 net lines: the existing workspace owner is connected to restart admission, and the existing marker covers the resulting wait. Unchanged retained markers no longer trigger a redundant entry replacement.

Evidence

132 focused tests passed, including the real Gateway regression and existing permission, prompt-stability, worktree, and restart paths. The final 33-test restart run passed after the owner integration. Core/test/script typechecks, affected-file lint, line-cap and import-cycle checks, and pnpm build:ci-artifacts pass.

Two Codex autoreviews of the complete local change against af7fd744c051987b0199dc7427b80c39b877d8bd are scoped-clean through P2, with no accepted/actionable findings. The review included the workspace, source-authority, admission, shutdown, and marker owners. The reviewer inspected source; it did not execute the tests.

The full pnpm check:changed exposed 28 unused-export findings (21 production, 7 full-tree) reproduced byte-for-byte on the exact clean parent. These are existing main defects, with causal attribution reused from prior maintainer proof; no unrelated export cleanup is included. Full-tree introducers: #130634, #190544, #191513, #194455. Production-only introducers additionally include #103537, #151777, #191326, #190205, #132716, #129184, #139911, and a7436c8b4a93bff59d099661d2b206bb0627ac2b.

CI run 42752144696, attempt 1 exposes a separate main regression: ci workflow guards > preserves authenticated toolchain archives during dependency store repair fails with ENOENT calls.jsonl. It reproduces on exact clean parent af7fd744c051987b0199dc7427b80c39b877d8bd. Commit e1af43161bd8982f3092c9069cb5c1222d93de31 / #196352 moved pnpm discovery ahead of the Node path prepend, while this older fixture exposes its fake pnpm only through NODE_BIN. The test, action, and install script are byte-identical between that parent, CI main parent a0ec2b5b4ba6532237705777a470a1d154cd1ccc, and this PR head. This is an unresolved main regression, not a passing check or a restart-recovery defect.

An earlier, superseded extraction candidate had one 90-second isolated Gateway timeout under concurrent compiler load; an unchanged traced reproduction passed. The original stall remains unattributed. The final owner implementation passed serially (latest Gateway run: 49.3 seconds) with the timeout and assertions unchanged.

The full Gateway regression fails on the parent with SessionWorkStartError / workspace_pending. The fixed path waits at a real Git checkout boundary, completes one loopback-provider turn, persists its final transcript, and does not duplicate it on a second recovery pass. Additional admission tests fail on the parent when restart interrupts pending admission; they protect both retained custody and the newer shutdown marker. The test-line allocation covers these regressions (252 added test lines).

Synthetic scale proof uses a 35.129 GiB SQLite database with 10,000 sessions and 1,000,000 transcript rows, plus 62,000 workspace files totaling 1.116 GB. Five counterbalanced A/B pairs and A/A controls measure owner wall time, process CPU, and sampled main-isolate allocations. No production data was used. Measurements run on APFS; they do not establish btrfs or remote sandbox performance. The owner benchmark substitutes immediate model completion after real admission; the separate Gateway regression verifies provider execution and the final transcript.

Scale measurements and accepted correctness tradeoff

Final source: 762c82d41df001a4901c9678aafadfa1d84eef0d; exact baseline: af7fd744c051987b0199dc7427b80c39b877d8bd. Acceptance: recover the pending turn exactly once, preserve ready/skipped outcomes and ordering, and disclose cost. Five counterbalanced pairs; separate timing and allocation processes. Ready trials contain ten owner calls (50 measured calls per arm); their values are per-call block averages, and p95 is the maximum of five block averages. Pending trials contain one call. Every sample, including outliers, is retained.

Workload Metric Baseline p50 / p95 Candidate p50 / p95
Ready A/B Wall ms 102.516 / 212.889 112.161 / 113.184
Ready A/B Process CPU ms 141.039 / 422.696 156.134 / 161.379
Ready A/B Sampled allocation MiB 12.797 / 13.342 14.177 / 14.314
Ready A/A Wall ms 104.932 / 111.373 107.317 / 108.089
Ready A/A Process CPU ms 147.045 / 159.373 150.425 / 158.760
Ready A/A Sampled allocation MiB 12.706 / 13.048 12.800 / 12.902
One pending A/B Wall ms 454.804 / 549.552 727.765 / 1278.541
One pending A/B Process CPU ms 588.620 / 1393.086 829.788 / 2970.606
One pending A/B Sampled allocation MiB 13.516 / 14.564 21.771 / 23.959
One pending A/A Wall ms 440.235 / 469.668 453.742 / 456.344
One pending A/A Process CPU ms 549.380 / 617.209 581.581 / 597.269
One pending A/A Sampled allocation MiB 13.778 / 14.135 13.737 / 13.829

Pending: baseline resumes three and rejects one; candidate prepares the workspace and resumes all four. The same eight stale/orphan outcomes and ready sibling order remain. Ready: four resumes per call, all 40 keys per block in ten exact repetitions of the same order, zero warnings. Candidate history-worker tasks remain 18 per call; baseline ranges 18–18.4 due to retained background work. This counter does not measure SQL transactions.

Maintainer tradeoff accepted for this correctness repair: ready median wall time rises 9.4%, process CPU 10.7%, and sampled main-isolate allocation 10.8% (A/A: 2.3%, 2.3%, 0.7%). That is approximately 9.65 ms wall, 15.09 ms process CPU, and 1.38 MiB sampled allocation per four ready resumes. The final current-generation marker retirement protects custody across another restart or session replacement. Redundant unchanged-entry replacement was removed. The larger pending cost includes work the baseline abandons; no speedup is claimed.

A prior candidate's marginal ready CPU median rose 23.3%. Publication was held for simplification and longer samples; that result is superseded, not discarded as noise. Main-thread ready CPU is 26.27→30.35 ms. Process CPU includes Node workers but excludes child Git process CPU. Full-process profiles include loader/bootstrap work and do not isolate database-worker stacks; they do not prove that marker writes alone caused the process-CPU delta. Cold arm timings include asymmetric imports and are not a causal A/B comparison.

Reproduce with the committed scripts/perf/restart-resume-measure.ts: --resume --markers --workspace --baseline-resumes 3 --iterations 1, supplying synthetic fixture root and frozen baseline/current source files as described in its header. Use --workspace-ready --baseline-resumes 4 --iterations 10 for ready paths, --control for A/A, and separate --allocation runs. Fixture construction/imports/GC are outside warm timing. Local APFS and sampled main-isolate allocation are explicit limits; no btrfs, remote sandbox, or worker-allocation claim.

Await the existing workspace owner before restart event admission and retain the restart marker until custody transfers. Preserve current setup authority, genuine setup errors, parked waits, and queued-input ordering.

Add 252 regression-test lines for real Gateway completion after delayed checkout and marker retention across cancellation or another shutdown. Synthetic-scale owner measurements cover timing, process CPU, allocation, and A/A controls.
Only submit a recovery replacement when lifecycle repair, legacy cleanup, or marker disposition changes the entry. Existing shutdown markers already provide durable custody until the post-admission clear.
@clawsweeper

clawsweeper Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime scripts Repository scripts size: L labels Nov 10, 2026
@steipete
steipete marked this pull request as ready for review November 10, 2026 03:51
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-10T03:54:12.366422Z 762c82d Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@steipete
steipete merged commit ea3eb71 into main Nov 10, 2026
240 of 246 checks passed
@steipete
steipete deleted the steipete/perf-micro-resume-workspace-not-ready-20260919 branch November 10, 2026 04:09
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 10, 2026
…penclaw#196423)

* fix(gateway): resume interrupted turns after workspace preparation

Await the existing workspace owner before restart event admission and retain the restart marker until custody transfers. Preserve current setup authority, genuine setup errors, parked waits, and queued-input ordering.

Add 252 regression-test lines for real Gateway completion after delayed checkout and marker retention across cancellation or another shutdown. Synthetic-scale owner measurements cover timing, process CPU, allocation, and A/A controls.

* perf(gateway): avoid rewriting retained restart markers

Only submit a recovery replacement when lifecycle repair, legacy cleanup, or marker disposition changes the entry. Existing shutdown markers already provide durable custody until the post-admission clear.
steipete added a commit that referenced this pull request Nov 10, 2026
Allocate nine missing lines for #196385 and correct #196416 from 33 to its actual 36 test lines. #196423 is already fully allocated. Restore exactly 6615748 lines of ceiling with zero slack; preserve all regression coverage and the shared scalar.
steipete added a commit that referenced this pull request Nov 10, 2026
#196432)

* fix(test): reconcile warm reload and procfs test-line debt

Allocate nine missing lines for #196385 and correct #196416 from 33 to its actual 36 test lines. #196423 is already fully allocated. Restore exactly 6615748 lines of ceiling with zero slack; preserve all regression coverage and the shared scalar.

* fix(test): account for the latest main test-line offset

Main #196305 removed one test line after the first reviewed candidate. Reduce the warm-reload debt allocation from nine to eight so total credit is exactly 11 and the current 6615839-line tree has zero slack.
RomneyDa pushed a commit that referenced this pull request Nov 10, 2026
#196432)

* fix(test): reconcile warm reload and procfs test-line debt

Allocate nine missing lines for #196385 and correct #196416 from 33 to its actual 36 test lines. #196423 is already fully allocated. Restore exactly 6615748 lines of ceiling with zero slack; preserve all regression coverage and the shared scalar.

* fix(test): account for the latest main test-line offset

Main #196305 removed one test line after the first reviewed candidate. Reduce the warm-reload debt allocation from nine to eight so total credit is exactly 11 and the current 6615839-line tree has zero slack.

(cherry picked from commit 644ff7d)
RomneyDa added a commit that referenced this pull request Nov 10, 2026
…esults (#196266)

* improve(tool-search): show input signatures for MCP tools in search results

tool_search rendered input "unknown" for every MCP tool, so models called
tool_describe before almost every MCP call. Render the same bounded,
structure-only signature used for OpenClaw tools from the MCP input schema.
Client tools keep "unknown" because Code Mode lists them in its system prompt
from the same compact entries.

Remote schemas can carry huge literals, so string literals longer than the
hint budget are rejected before serialization. Code Mode prompt construction
skips MCP entries before compaction; it never listed them.

Co-authored-by: jalehman <[email protected]>
Co-authored-by: GrahamMcBain <[email protected]>

* improve(tool-search): show input signatures for MCP tools in search results

Worked on by:
- @jalehman
- @GrahamMcBain

Co-authored-by: jalehman <[email protected]>
Co-authored-by: GrahamMcBain <[email protected]>
OpenClaw-Publication: a0929bba-b988-4c27-b67d-606a685a1e6e

* fix(test): restore the main test-line budget after warm reload changes (#196432)

* fix(test): reconcile warm reload and procfs test-line debt

Allocate nine missing lines for #196385 and correct #196416 from 33 to its actual 36 test lines. #196423 is already fully allocated. Restore exactly 6615748 lines of ceiling with zero slack; preserve all regression coverage and the shared scalar.

* fix(test): account for the latest main test-line offset

Main #196305 removed one test line after the first reviewed candidate. Reduce the warm-reload debt allocation from nine to eight so total credit is exactly 11 and the current 6615839-line tree has zero slack.

(cherry picked from commit 644ff7d)

* test(agents): align host-denial proof with immediate failure settlement

---------

Co-authored-by: roboclaw-bot <[email protected]>
Co-authored-by: jalehman <[email protected]>
Co-authored-by: GrahamMcBain <[email protected]>
Co-authored-by: Dallin Romney <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 11, 2026
openclaw#196432)

* fix(test): reconcile warm reload and procfs test-line debt

Allocate nine missing lines for openclaw#196385 and correct openclaw#196416 from 33 to its actual 36 test lines. openclaw#196423 is already fully allocated. Restore exactly 6615748 lines of ceiling with zero slack; preserve all regression coverage and the shared scalar.

* fix(test): account for the latest main test-line offset

Main openclaw#196305 removed one test line after the first reviewed candidate. Reduce the warm-reload debt allocation from nine to eight so total credit is exactly 11 and the current 6615839-line tree has zero slack.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 11, 2026
…esults (openclaw#196266)

* improve(tool-search): show input signatures for MCP tools in search results

tool_search rendered input "unknown" for every MCP tool, so models called
tool_describe before almost every MCP call. Render the same bounded,
structure-only signature used for OpenClaw tools from the MCP input schema.
Client tools keep "unknown" because Code Mode lists them in its system prompt
from the same compact entries.

Remote schemas can carry huge literals, so string literals longer than the
hint budget are rejected before serialization. Code Mode prompt construction
skips MCP entries before compaction; it never listed them.

Co-authored-by: jalehman <[email protected]>
Co-authored-by: GrahamMcBain <[email protected]>

* improve(tool-search): show input signatures for MCP tools in search results

Worked on by:
- @jalehman
- @GrahamMcBain

Co-authored-by: jalehman <[email protected]>
Co-authored-by: GrahamMcBain <[email protected]>
OpenClaw-Publication: a0929bba-b988-4c27-b67d-606a685a1e6e

* fix(test): restore the main test-line budget after warm reload changes (openclaw#196432)

* fix(test): reconcile warm reload and procfs test-line debt

Allocate nine missing lines for openclaw#196385 and correct openclaw#196416 from 33 to its actual 36 test lines. openclaw#196423 is already fully allocated. Restore exactly 6615748 lines of ceiling with zero slack; preserve all regression coverage and the shared scalar.

* fix(test): account for the latest main test-line offset

Main openclaw#196305 removed one test line after the first reviewed candidate. Reduce the warm-reload debt allocation from nine to eight so total credit is exactly 11 and the current 6615839-line tree has zero slack.

(cherry picked from commit b67d29e)

* test(agents): align host-denial proof with immediate failure settlement

---------

Co-authored-by: roboclaw-bot <[email protected]>
Co-authored-by: jalehman <[email protected]>
Co-authored-by: GrahamMcBain <[email protected]>
Co-authored-by: Dallin Romney <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
RomneyDa added a commit that referenced this pull request Nov 12, 2026
…196423)

Adapt the workspace readiness repair to the release's graceful restart markers.
Keep marker custody until ordinary admission or explicit disposition, and preserve
the original cancellation reason when another restart interrupts recovery.

(cherry picked from commit ea3eb71)

Independent local review omitted by release-owner instruction.

Validation: 16 passing consumer tests; two existing loopback readiness probes
receive proxy HTTP 502. Real workspace recovery reaches accepted admission and
agent execution, but provider connection fails; completion remains unqualified.
Scoped static gates pass. Retain all failed assertions without weakening.

Co-authored-by: RomneyDa <[email protected]>
Co-authored-by: vincentkoc <[email protected]>
(cherry picked from commit 6a3cb4d62d59e4a6e615989e9a9912c1f21d21e3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime scripts Repository scripts size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant