Repository navigation
perf(nodes): finish remote session turns faster when files did not change - #160231
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 real behavior proof before merge. Reviewed September 28, 2026, 1:03 PM ET / 17:03 UTC (Revision 18). ClawSweeper reviewWhat this changesThe branch speeds unchanged remote session turns by skipping workspace application, moves node manifest capture into a resident worker, adjusts a CI lint runner route, and updates tests and documentation. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness⛔ Blocked before merge - 6 items remain The optimization remains useful and is absent from current main. The earlier blocking finding remains on this head: unchanged acceptance occurs after the last remote and lease checks, leaving a window for stale workspace state to reach durable publication. Priority: P2 Review scores
Verification
How this fits togetherAfter a remote session turn, the Gateway compares the node workspace with its last accepted state and records a durable result before settling the turn. The node host captures manifests, while the Gateway manages reconciliation, quiescence, and publication. flowchart LR
A[Remote session turn] --> B[Node manifest capture]
B --> D{Both workspaces match base?}
C[Gateway workspace] --> D
D -->|Yes| E[Unchanged acceptance]
D -->|No| F[Full reconciliation]
E --> G[Durable result publication]
F --> G
H[Quiescence lease] --> G
Before merge
Findings
Agent review detailsSecurityNeeds attention: The workflow edit adds no supply-chain privilege, but unchanged-result publication can outlive the last verified remote quiescence lease. PR surfaceSource 0, Tests +573, Docs +6, Config 0. Total +579 across 54 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the fast path only when the remote lease and both workspaces remain valid at publication, while preserving durable result recovery when a final check fails. Do we have a high-confidence way to reproduce the issue? No production fault trace reproduces the late-authority failure. The current-head finalizer and focused test ordering establish a clear source-level path for injecting a write or lease loss after the second remote check. Is this the best way to solve the issue? No: skipping application when both workspaces match is a reasonable optimization, but the proposed finalization must revalidate remote state and quiescence after acceptance before publishing. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against f010fc0b5790. LabelsLabel changes: No label changes. Label justifications:
EvidenceSecurity concerns:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (17 earlier review cycles; latest 8 shown)
|
c306bc6 to
50fb25e
Compare
de68782 to
3304094
Compare
3304094 to
dba037a
Compare
…ange Require both workspaces to match the accepted base before skipping apply. Reuse the shared manifest computation owner while retaining quiescence, live authority, cancellation settlement, and durable result recovery. Remove the unused immediate-apply path and consolidate manifest adapters.
dba037a to
861c439
Compare
|
Merged via squash.
|
…ange (openclaw#160231) Require both workspaces to match the accepted base before skipping apply. Reuse the shared manifest computation owner while retaining quiescence, live authority, cancellation settlement, and durable result recovery. Remove the unused immediate-apply path and consolidate manifest adapters.
What Problem This Solves
Remote session turns spend hundreds of milliseconds reconciling workspaces even when no files changed.
User Impact
Paired-node and cloud-worker sessions finish unchanged turns sooner. Warm reconciliation fell from 719 / 718 ms in the original baseline to 396 / 397 ms on the same lease (about 45% lower); the final rebased candidate measured 313 / 292 ms on a replacement machine. Changed files retain the full reconciliation and conflict-handling path.
The 150 ms reconciliation target remains unmet. Live measurements cover Linux loopback, not Windows or real network latency.
Why This Change Was Made
The existing finalizer always applied a staged result and repeated its post-apply checks, while node manifest verification started fresh child processes. This change accepts the unchanged path only when both the Gateway and remote workspace match the accepted base. It verifies both sides around quiescence renewal, revalidates live authority before acceptance/publication, and retains journals, durable result refs, cancellation settlement, and recovery behavior.
Manifest capture uses the shared bounded computation owner and the same canonical program used by the standalone transport. Git subprocesses remain host-owned. The unused immediate-apply reconciliation path is removed: repository-wide searches at the original base and rebased main confirmed every production local caller already requests durable staging.
Compatibility: the existing
worker.workspace.exec.v1contract and argv/result formats are unchanged. Resident capture admits only an exact built-in program and validated workspace arguments; other program versions continue through the existing child executor. No new capability, dialect, schema, configuration, or migration is required.Evidence
Second refresh uses main
eed9d9bf225e517e4be07048bb66bec604eb2bb7; one commit, final candidatedba037a3a4f0681d9f80ab21da4caeca6427b8fe. This base contains all six requested main fixes:136cfdc7a6cf,6d1826f1ad1f,7510c4bd5289,d923cd088b8d,ea6bf83e821f, and6dd3011e9f56. Production LOC versus the merge base is +462 / −462, net 0. No instrumentation is committed.The initial rebase was patch-identical. Its CI exposed two PR-caused gaps: the newer shutdown recovery fixture still returned the retired reconciliation shape, and inline spread iteration violated lint. The fixture now uses the production staging owner's prepare/apply/publish hooks instead of manually staging, recording, and applying the result. Conflict lifting retains an explicit snapshot, preserving bounded iteration while the conflict set changes. A subsequent CI run found session-delete fixtures failing at the first pre-apply fence instead of their intended post-apply fence. Those existing worker-turn/remote-exec cases and the analogous dispatch case now use the existing third-verification failure hook, with manifest and live-claim assertions added. Recovery assertions were strengthened. Exact byte-estimator formula checks tied to the retired estimator were removed from the publication artifact test; exact Git artifact equality, transfer detachment, caller immutability, and the canonical byte-limit boundary remain asserted. No protocol, authority, or recovery behavior changed in these repairs.
The latest rebase resolved actual merge conflicts while preserving main's shared launcher fixtures and canonical
captureWorkspaceManifestnaming. The shared unchanged-reconciliation fixture supplies the required publish/discard callbacks once. A redundant private manifest-projection wrapper was removed; all three production callers destructure the existing decoder result with the same expected ref and abort signal. The full post-rebase run exposed a test fixture whose default staging directory was the caller workspace, so cleanup deleted the workspace before verification. The fixture now requires a separate staging directory and both callers provide one.Validation on the replacement Linux AWS Crabbox lease covers 1,389 passing tests across 38 full files, with one existing Windows-only skip:
node scripts/run-vitest.mjs <36 changed and affected test files>plus the repaired full-file recheck: 876 passing tests across 36 files. The initial run exposed the staging-fixture ENOENT described above; after repair, the fullnode-worker-tunnel.test.tspassed 20 tests / 14.43 s. Retention and unchanged-reconciliation siblings passed 11 tests / 33.85 s;agent-runner-node-authority.test.tspassed 33 tests / 90.33 s. Previously passing files remain unchanged. The skipped case preserves foreign executable modes through Windows workspace transfers; this Linux run is not Windows proof.node scripts/run-vitest.mjs test/scripts/ci-workflow-planning.test.ts test/scripts/ci-workflow-evidence.test.ts: 513 passed / 164.21 s. The existing routing guard's 324 cases also passed in the 36-file run.pnpm tsgo:core: passed, latest 9.10 s incremental after the fixture repair; initial post-rebase run 51.08 s.node scripts/run-tsgo-core-test-shards.mjs --ci-graphs-json '["core-test-gateway-other"]': passed, latest 7.87 s.pnpm tsgo:test:root: all four graphs passed, 210.97 s.node --import ./scripts/tsx.mjs scripts/run-oxlint-shards.mts --files-json '<changed source paths selected by isOxlintSourcePath>': passed / 33.37 s. Tooling tests outside that canonical source inventory are covered by formatting and root test types.pnpm check:workflows: passed / 29.35 s. Scopedpnpm exec oxfmt --checkandgit diff --check: passed.Fresh instrumented
qaRuntimebuild passed in 56.6 s. Livemeasure.sh … 3used a loopback node, a real provider, andopenai/gpt-5.6-luna. Warm turns 2 / 3, milliseconds:204b00bf083e, 32-core leaseThe fresh local comparator measured TTFT 1409 / 1857 ms and final 1653 / 2827 ms. The original 32-core lease expired and final validation used a 16-vCPU replacement. Hardware, main, and provider timing differ, so these end-to-end numbers are not a controlled attribution of every difference to this PR. Earlier same-machine candidate measurement was 396 / 397 ms reconciliation versus the original 719 / 718 ms baseline. The 150 ms target remains unmet.
Retained earlier proof: a real node file write reconciled byte-for-byte to the Gateway. The real-Gateway browser test
pnpm test ui/src/e2e/worker-initial-setup.real-gateway.e2e.test.ts --maxWorkers=1passed on prior headc306bc689eef(1 test, 173.80 s wall including runtime preparation; case 29.708 s). That browser test was not repeated for these internal repairs. The complete architecture command passed on the previous repaired lease candidate, and the hosted architecture job passed on this refresh's initial CI run.Review disposition
The prior ClawSweeper P2 asks for another remote/lease fence after unchanged acceptance. Source inspection does not support that as an introduced gap: unchanged acceptance only performs
unchanged.verifyLocalStable(), the current-owner assertion, and a synchronous journal commit. It does not apply workspace files. The final tail remains remote verification, local verification, then durable publication, matching the full path after its last renewal. The extra renewal and verification on the full path surround actual awaited workspace application. Existing quiescence heartbeat renewal remains active. Late writes at the final remote/local fences and stale authority are covered by the unchanged-reconciliation tests. This finding is not accepted; the existing final live-authority and durable-result safeguards remain required.Exact-head CI
The landing refresh rebased the branch without conflicts onto main
4f94275e92cc92dfabe8ce222bd5ca207c16401e, including the bounded Vitest fixture repair4902e4ae49a6. Published head:861c439c9f151f27fc0dfcaefa78bef304027775.git range-diffconfirms the PR patch is identical todba037a3a4f0; production/tooling stays +462 / -462, net zero. The existing focused tests, typecheck, live proof, and clean independent autoreview remain prior-head evidence. No fresh local test or live measurement is claimed. The only overlapping staging-owner change on main awaits retained cleanup refs and is disjoint from this PR's preparation/acceptance path. Exact-head CI run 36454487474 completed successfully: 151 successful jobs, 13 skips, no failures or cancellations, includingdocker-seed-e2eandopenclaw/ci-gate(job109051974936). Required checks report SUCCESS. No rerun or additional source push was needed. ClawSweeper completed this exact head at 17:03:54 UTC on September 28, 2026; its repeated finding is addressed in the review disposition above. Native review artifacts validated READY and GitHub-pending preparation completed at this same head. Landing is being submitted through the native workflow.Previous-head CI investigation is retained below.
Run 36440583897 is attached to final head
dba037a3a4f0681d9f80ab21da4caeca6427b8fe. As of 15:42 UTC on September 28, 2026, it has 77 successful jobs, 1 originating failure, 83 fail-fast cancellations, and 13 skips. The downstream gate (job109000406618) is still queued forubuntu-24.04, with no assigned runner and no executed steps; the workflow has no final conclusion yet. Preflight,security-fast, and all five core-lint rows passed. The repository's externally selectedgithubrunner override means those lint results validate hosted fallback, not native hybrid allocation. The PR remains open, mergeable, and unmerged.The sole originating failure is independently reproduced on current main, not caused by this PR. Job
108992030996(checks-node-compact-small-25) failed two cases intest/scripts/run-vitest-bounded.test.ts:prepares the direct E2E reader generation once: successobservedruntime, ai, aiinstead ofruntime, ai;...: prebuiltobservedaiinstead of an empty build list. Its exact checkout was merge03f7282648d9afe65fdae2fa161d47c352c10190, whose main parent is741c9cb56bdec3bc62e1ca7594e82b31a0b838e3.Main commit
9c69495d6f0caddedpreparePrebuiltAiPackage. Atscripts/lib/vitest-build-prerequisites.mts:465–475, missing declarations cause another AI build; the bounded fixture attest/scripts/run-vitest-bounded.test.ts:276–282only records a successful builder and exits without materializing declarations. Its assertion at line 364 consequently sees the extra build. The preparation owner, runner, and test file match current main and are untouched by this PR.A clean checkout of current main
1b919d5ee2ec6abe413a4d6c148370d308a4b709on the Linux lease reproduced the exact same two failures, with 248 passing tests, in 102.40 s wall. Replay usedCI=1, four-CPU affinity,NODE_OPTIONS=--max-old-space-size=8192, the unchangedcore-tooling-6-hosted-2group and two-worker group setting from CI, throughnode --import tsx scripts/ci-run-node-test-shard.mts. The full four-file group wasci-platform-checkout.test.ts,macos-native-test-launch.test.ts,preflight-frozen-target-contracts.test.ts, andrun-vitest-bounded.test.ts, all undertest/scripts/. No case filters, test edits, retry, timeout changes, or declaration artifacts were used to hide the failure. The latest inspected scheduled-main run preceded the introducing commit and cannot establish this case; the clean-main reproduction supplies independent evidence.This meets the work order's stopping condition of only documented main-caused failures remaining. The gate is not green, and cancelled jobs remain unverified. No blind rerun or additional push was made. The task-owned replacement lease was released; the native owner confirmed cleanup complete and no remaining resource.
Run 36422187813 tested
de6878250b03d35ef21c7f8a58890010f4f7340fand completed cancelled: 122 succeeded, 1 failed, 1 cancelled, 19 skipped. All test jobs passed, including the previously failing publication and requester-wake shards.check-lint-core-2(job108932443319) exceeded its 15-minute job limit while processing its final core stripe; it emitted no lint diagnostic. The downstreamopenclaw/ci-gate(job108940212387) failed solely because that required job was cancelled. This is not a green gate or a proven inherited-main failure.The final head contains the bounded capacity repair: retain the existing first-row 16-class route and give the second packed row the same class only for the resolved hybrid backend. Trust, hosted/retry/frozen/manual and RunsOn routing, the 15-minute deadline, coverage, job/registration counts, and max-parallel remain unchanged. The exact earlier CI merge tree
46f86f8e8e84ff18b1d79e95d5c7344ef4a9fcdbpassed all packed stripes 3/4/5 with zero warnings/errors in 137.37 s on the lease with four-CPU affinity, a 16-GiB cgroup cap, and the existing larger-runner Go policy. The failed stripe alone passed in 125.00 s with the smaller-runner Go policy; an initial 8-GiB hard-cap experiment OOMed and is not timing proof. Guard, planning/evidence siblings, workflow validation, types, and independent review all passed on the final rebased source. Head3304094cafeefirst carried this repair but was conflicting; the current rebase resolved those actual conflicts before publication.Run 36417798839 tested
6e63119540dd895bcf23c4df7b2b855590a6b13aand ended cancelled after fail-fast: 96 succeeded, 3 failed, 26 cancelled, 19 skipped. Preflight,security-fast, all hosted core test types, repaired core lint, and the previously failing session-lifecycle shard passed. The originating failures were:108913936520,checks-node-changed-compact-large-13: three publication-input cases asserted the retired size-estimator formula (663 / 1506 bytes instead of the generic estimator's 1551 / 2394 bytes). The test-only cleanup above removes these implementation mirrors while retaining artifact, transfer, immutability, and canonical byte-limit contracts; all 17 cases now pass.108913940220,checks-node-changed-1: one requester-wake E2E case,preserves serial continuation without replaying an accepted wave (cli, next child accepted=false, requester final=false), failed with a persistedworker task timed outresult. The test, requester-wake lifecycle, worker pool, and session admission owners are byte-identical between the PR and CI's main parentbff74e5f0b6d57d9bb383bbadbfed799bd371af6. Advancing fake time by 151,000 ms across asynchronously launched native work is a plausible cause, not a proven diagnosis. A clean main build and the original first three isolated invocations in order, on two CPUs with CI worker/heap settings, all passed: 1 / 14 / 18 cases, 55.41 / 71.50 / 76.34 s. The same ordered candidate replay also passed: 1 / 14 / 18 cases, 139.69 / 61.51 / 70.77 s. This is unreproduced and not proven fixed or independently failing on main. No timeout, retry, assertion, or runtime behavior was changed to mask it.The third failed job was the downstream gate. Cancelled jobs remain unverified. Later run 36422187813 passed the requester shard. This does not establish a fix for the earlier timeout; subsequent pushes carried verified source/fixture/capacity repairs rather than a blind retry.
Run 36415467201 tested
43a197f1a0e6457706d9fb68e7497f32da3d4aaaand ended cancelled after fail-fast: 56 succeeded, 2 failed, 66 cancelled, 19 skipped. Preflight,security-fast, and the repairedcheck-lint-core-1passed. The sole originating failure waschecks-node-changed-compact-large-20, job108906148608: two session-delete recovery cases expected a retained pending result after injecting failure at the pre-apply fence. Both cases now target the post-apply fence and retain stronger recovery assertions. The downstream gate failed; test types were cancelled, not passing. The pinned base's full main run 36410528009 passed, confirming this fixture migration belongs to the PR. The test-only repair is independently reviewed and verified above; no production changes or new performance run were needed.Run 36412033041 tested initial refreshed head
a42d3e96dbb96c9bafc53b1a284a5f8e9278dbdeand ended cancelled after fail-fast: 59 succeeded, 3 failed, 64 cancelled, 19 skipped. Preflight,security-fast, andcheck-additional-runtime-topology-architecturepassed. Originating failures werecheck-test-types-core-1(job108895944187: shutdown fixture missingpublishStagedResult/discardPreparedStagedResult) andcheck-lint-core-1(job108895944201:unicorn/no-useless-spreadin preflight conflict iteration). The third failure was the downstreamopenclaw/ci-gate. Both originating defects are repaired and locally verified above. Cancelled jobs are not passing proof; no blind rerun was used.Previous run 36406651773 ended cancelled after the independently confirmed main ACP mock failure;
ea6bf83e821ffixes that source and is included in the current base. Run 36402999792 ended cancelled after the earlier PR type-import cycle; the repaired computation-contract direction passed the complete architecture command and the new hosted architecture job. Run 36392840008 ended cancelled after inherited package-update reliability-export and container-timeout failures, fixed byda2efd83band136cfdc7a6cfin the current base.Measured test costs and retained coverage
Rows retain prior-head measured costs from one standalone
pnpm test <file> --maxWorkers=1invocation on the lease; wall time includes compiler/runner startup and teardown. The shutdown case took 7.535 s. The final post-rebase run revalidated these suites; standalone costs below were collected on the original lease before the last rebase.Summed test-case execution for the new manifest suite was 0.427 s, unchanged reconciliation 0.929 s, and finalizer 0.062 s; these remain within the 5 s test-time target.
src/gateway/worker-environments/workspace-publication-input.test.tssrc/gateway/server.sessions.worker-placement-lifecycle.test.tssrc/gateway/worker-environments/placement-dispatch.test.tssrc/auto-reply/reply/agent-runner-node-authority.test.tssrc/gateway/worker-environments/cloud-transcript-write-admission.test.tssrc/gateway/worker-environments/node-worker-tunnel.test.tssrc/gateway/worker-environments/node-workspace-transfer-retention.test.tssrc/gateway/worker-environments/placement-dispatch-reclaim.test.tssrc/gateway/worker-environments/placement-dispatch-staged-results.test.tssrc/gateway/worker-environments/worker-turn-attachments.boundary.test.tssrc/gateway/worker-environments/worker-turn-execution.test.tssrc/gateway/worker-environments/worker-turn-launcher-build-recovery.test.tssrc/gateway/worker-environments/worker-turn-launcher-claim-admission.test.tssrc/gateway/worker-environments/worker-turn-launcher-computer.test.tssrc/gateway/worker-environments/worker-turn-launcher-failure-recovery.test.tssrc/gateway/worker-environments/worker-turn-launcher-initial-setup.test.tssrc/gateway/worker-environments/worker-turn-launcher-media.test.tssrc/gateway/worker-environments/worker-turn-launcher-reclaimed-placement.test.tssrc/gateway/worker-environments/worker-turn-launcher-reconciliation-authority.test.tssrc/gateway/worker-environments/worker-turn-launcher-remote-handoff.test.tssrc/gateway/worker-environments/worker-turn-launcher-terminal-results.test.tssrc/gateway/worker-environments/worker-turn-launcher.test.tssrc/gateway/worker-environments/worker-turn-shutdown.test.tssrc/gateway/worker-environments/workspace-finalize.test.tssrc/gateway/worker-environments/workspace-local-reconciliation.test.tssrc/gateway/worker-environments/workspace-result-finalize.test.tssrc/gateway/worker-environments/workspace-result-repository.test.tssrc/gateway/worker-environments/workspace-sync-tunnel.git.test.tssrc/gateway/worker-environments/workspace-sync-tunnel.memo.test.tssrc/gateway/worker-workspace-recovery-binding.test.tssrc/node-host/node-worker-workspace-manifest.test.tsLonger existing authority, placement, launcher, and repository suites retain their integration case sets. Their real admission, persistence, rollback, and shutdown interactions cannot be established by the new manifest helper tests. The fixture migrations add required staging hooks rather than new Gateway/process boots, sleeps, polling, or test cases to those suites. Two tests tied solely to the removed unstaged path were deleted. Exact arithmetic checks of the retired estimator were also deleted; the publication artifact and canonical byte-limit assertions remain, and the worker-pool admission tests passed. The new behavior is covered by the focused manifest and unchanged-reconciliation suites plus the finalizer's ordering/error-disposition cases.
Production cleanup keeping this change net neutral