Skip to content

fix(gateway): prevent stalls from oversized workspace reconciliation - #194475

Merged
steipete merged 3 commits into
mainfrom
steipete/perf-micro-reconcile-patch-main-thread-wedge-20260919
Nov 7, 2026
Merged

steipete merged 3 commits into
mainfrom
steipete/perf-micro-reconcile-patch-main-thread-wedge-20260919

Conversation

@steipete

@steipete steipete commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: a large worker workspace result can stall the Gateway main thread during local reconciliation and repeatedly fail recovery without a durable rejected outcome.

User Impact

Oversized unapplied results now fail visibly with exclusion/splitting guidance and a preserved recovery reference. Local agents can correct retained files and checkpoint again; a corrected canonical source can be imported during explicit sandbox preparation. Automatic settlement leaves rejected results parked. Accepted receipts and rollback journals remain recoverable. No configuration or database schema change is required.

Why This Change Was Made

Conflict retention scanned every conflict for each applied path, causing quadratic main-thread work and transient string allocation. One ancestor set preserves the same conflict result with linear path processing. Patch creation, tree preparation, rollback-pack hashing, and recovery diff collection use the existing Git worker and transfer owned buffers.

Historical unapplied results now receive publication's 50,000 changed-path admission limit before materialization, alongside existing byte limits. Local rejection is recorded by the database owner in the existing checkpoint receipt; cloud recovery retires only an unaccepted, durably staged result without a mutation journal. Disposable local output should be moved to checkout-root .openclaw/tmp/ or removed before a new explicit checkpoint; .gitignore alone does not exclude already admitted local sandbox files.

Release-note context: keep the Gateway responsive while reconciling large worker workspaces, report oversized results once with repair guidance, and preserve rejected work for recovery.

Evidence

Production-shaped synthetic btrfs proof uses real Git and applyStagedWorkerWorkspace: 20,000 changed files / 491.52 MB with a controlled concurrent writer, producing exactly the same 20,000 conflicts before and after. Five runs per arm, including A/A controls:

Measurement Before After
Median wall time 35.261 s 27.704 s
Median main-thread CPU 9.168 s 0.527 s
Maximum heartbeat gap 7,917.8 ms 52.84 ms
Sampled main-thread allocation 8.15 GB 143 MB

A 65,000-file / 1.10 GB synthetic result rejects at the apply owner in 0.995 ms, with an 11.05 ms maximum heartbeat gap and actionable error. CPU profiles locate the baseline stall in the nested conflict scan. After the existing worker idle GC runs, retained RSS is approximately 3% higher, while main live heap is approximately 1% lower. Patch-only generation did not reproduce the spin; these measurements demonstrate the owner defect, not the duration or exact stack of an uncaptured production incident.

Final lifecycle suites: 95 passed (two platform/environment skips); checkpoint store/manifest/CAS consumers: 39 passed; patch/recovery/worker siblings: 37 passed (one macOS broker skip, covered on the Linux rig). The new admission, durable quarantine, and terminal recovery regressions all fail on exact parent 2ab781210c6f. Codex autoreview is scoped-clean at P0–P2.

pnpm check:changed completed: typechecks, formatting, structural/database guards, and all dead-export scans passed. Its PR-caused import-form and benchmark-brace lint errors were corrected and pass targeted lint. The remaining local changelog attribution failure reproduces on exact branch parent 2ab781210c6f (20 historical bot-thanks entries), introduced by 266a7aa0fe69 (#194364). No changelog is changed here.

Initial CI exposed a real error-propagation regression: a committed publication update could leave the projection snapshot stale, and the new rejection catch masked the original publication error. The catch now checks the quota error code before reading state; the existing publication boundary test is red before and green after, alongside the quarantine regression. The worker adapter now has a distinct exported name; the export-collision guard passes. Hosted review also found that rejected canonical-to-sandbox imports needed an explicit repair path. Both directions now have red/green coverage that preserves guest edits and the original Git ref; unchanged source stays parked. Four final focused cases pass, including base-refresh recovery and publication-error preservation. Final full-diff Codex autoreview is scoped-clean P0–P2; targeted lint, production/test types, format, line caps and test-line budgets pass.

Full Linux pnpm build completed in 7m 11.6s, including unified declarations, 102 plugin distributions, SDK export checks and Control UI. The build printed non-blocking UI bundle-budget warnings; no UI-imported module is changed. The subsequent catch/import/naming corrections are covered by focused compiled-worker proof and targeted checks.

Initial CI's architecture failure is inherited from its exact main parent dd11a9c2da98 (#191935): that commit adds the type back-edge control-ui-static.ts → server-control-ui-root.ts. The native Madge guard passes on branch ancestor 2ab781210c6f and reproduces the identical single cycle on dd11a9c2da98. This is a newly introduced main regression, reported for separate repair. The second CI run passed all PR-owned runtime, export and lint jobs. It also exposed an unrelated fresh-browser heading assertion on the newer main parent; exact-parent reproduction is in progress. Final exact-head CI is pending.

Final-head CI qualification

Final reviewed head 9c7ad689bc2ac59d665e0415ec3772ed8bfd43cf, CI 42343228061, attempt 1. Actual tested merge e1db18c724a2a2b287acf54ba93db5cc18f6f9c5 has main parent f231ad6693d808e8da6008ca2643058072ebbb3a and this PR head. All PR-owned runtime/type/lint checks and security-fast pass. Three inherited failures plus their aggregate remain, each reproduced on that exact main parent:

These are main regressions for separate repair, not ignored noise. The authorized native inherited-failure landing route retains failed CI and exact-head evidence; it does not claim green CI. No production deployment is part of this PR.

Reject and preserve oversized unapplied results with a durable repairable outcome. Move patch construction into the Git worker and replace quadratic conflict retention with ancestor membership. Accepted receipts and rollback journals remain recoverable.
@clawsweeper

clawsweeper Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review in progress

ClawSweeper is reviewing this revision. This supersedes any previous blocked status.

View the workflow run.

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

chatgpt-codex-connector Bot commented Nov 7, 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-07T05:36:42.879783Z 9c7ad68 New commits
ℹ️ 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.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 7, 2026
Classify quota errors before reading a possibly stale projection after a committed publication update. Keep unrelated recovery errors intact, distinguish the worker patch adapter export, and correct benchmark lint.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4e0a58539e

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Recapture a corrected canonical source during explicit sandbox preparation while unchanged rejected inputs remain parked. Preserve guest edits and the rejected Git result; prove both sync directions and keep base-refresh recovery intact.
@steipete
steipete merged commit c1bf1cc into main Nov 7, 2026
144 of 151 checks passed
@steipete
steipete deleted the steipete/perf-micro-reconcile-patch-main-thread-wedge-20260919 branch November 7, 2026 05:51
@steipete

steipete commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

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

@fisallllll280-code fisallllll280-code left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reconciliation improvements are a valuable contribution, particularly the reduction in main-thread CPU time and heartbeat gaps under large workspace workloads.

One important aspect is the durable handling of rejected reconciliation results through checkpoint receipts and recovery mechanisms.

It would be useful to document the operational behavior at the 50,000-path admission limit, including recovery guarantees, retry semantics, and observability when the limit is reached.

The published benchmarks are promising. Additional production-scale measurements would help validate their generalizability.

Thank you for the detailed engineering work.

steipete added a commit that referenced this pull request Nov 7, 2026
* fix: keep ignored build outputs out of worker results

Apply standard Git exclusions at local and remote result capture while preserving tracked source, admitted paths, and accepted custody. Reuse the same capture owner during overflow recovery. Keep the result byte cap and recovery behavior from #194475 and #194642 unchanged.

* fix(workspaces): retain ignored artifacts and break capture cycle

* fix(workspaces): select capture scope at the caller

* fix(workspaces): preserve staged-input capture eligibility
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 8, 2026
…penclaw#194475)

* fix(gateway): prevent stalls from oversized workspace reconciliation

Reject and preserve oversized unapplied results with a durable repairable outcome. Move patch construction into the Git worker and replace quadratic conflict retention with ancestor membership. Accepted receipts and rollback journals remain recoverable.

* fix(gateway): preserve publication errors during workspace settlement

Classify quota errors before reading a possibly stale projection after a committed publication update. Keep unrelated recovery errors intact, distinguish the worker patch adapter export, and correct benchmark lint.

* fix(gateway): allow repair of rejected canonical workspace imports

Recapture a corrected canonical source during explicit sandbox preparation while unchanged rejected inputs remain parked. Preserve guest edits and the rejected Git result; prove both sync directions and keep base-refresh recovery intact.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 8, 2026
* fix: keep ignored build outputs out of worker results

Apply standard Git exclusions at local and remote result capture while preserving tracked source, admitted paths, and accepted custody. Reuse the same capture owner during overflow recovery. Keep the result byte cap and recovery behavior from openclaw#194475 and openclaw#194642 unchanged.

* fix(workspaces): retain ignored artifacts and break capture cycle

* fix(workspaces): select capture scope at the caller

* fix(workspaces): preserve staged-input capture eligibility
github-actions Bot pushed a commit to clawhaven/openclaw that referenced this pull request Nov 23, 2026
…penclaw#194475)

(cherry picked from commit c1bf1cc)

Release adaptation: Only retainedConflictPaths ancestor membership optimization and an equivalent-output 10,000-entry regression. Preserves existing workspacePathAncestors and blocking-conflict filtering. Excludes quarantine, routing, receipts, reconciliation state redesign and generated code. Companion audit found broader redesign unnecessary for this standalone loop replacement.

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

Labels

clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. docs Improvements or additions to documentation gateway Gateway runtime scripts Repository scripts size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants