Skip to content

perf(worker): deliver replies before workspace reconciliation - #169484

Merged
steipete merged 3 commits into
mainfrom
codex/nodew-r6-earlyfinal-base
Oct 12, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/nodew-r6-earlyfinal-base

Conversation

@steipete

@steipete steipete commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Node worker replies waited for workspace synchronization after the final assistant message was already durable, adding hundreds of milliseconds to the visible reply tail.

User Impact

Worker-turn replies now finish before workspace reconciliation. A quick follow-up is accepted into durable custody and starts against the reconciled workspace. Conflicts and reconciliation failures appear as separate transcript notices and through existing placement/recovery state; they do not replace a delivered reply. No new RPC or stored state is added.

Why This Change Was Made

Decision: Peter, 2026-10-11 — deliver the reply when the worker is terminal and its transcript is durable; reconcile the workspace in the background.

The existing turn owner retains execution, the result claim, transcript scope, and recovery handling while delivering the reply separately. Context candidates are recorded before returning; workspace-dependent maintenance still follows acceptance. The old conflict suffix and assistant delta are removed.

A completed prior reply joins its existing settlement promise before a follow-up prepares placement state. This prevents a real placement-read invalidation during claim release while preserving live-turn collision and duplicate-run behavior. Production LOC: +59, within the approved +80 contract-change allowance.

Evidence

Same-box Hetzner ccx33, OpenAI gpt-4.1-mini, two warmups and five measured turns per route and revision. Values are milliseconds:

Path Request → provider, before → after TTFT, before → after Provider terminal → chat final, before → after
Local 438 → 381 1720 → 1783 120 → 118
Loopback node 492 → 1045 1741 → 2321 412 → 236

The node reply tail improved 176 ms (42.7%), with a flat local control. Requests are sent immediately after the preceding final: the longer next-request admission deliberately includes the remaining prior reconciliation wait. TTFT includes that wait and provider variance; this is a reply-tail improvement, not a throughput or TTFT claim. All final replies and post-final agent.wait observations succeeded.

  • Instrumented census confirms reconciliation finishes after chat final. Remaining node overhead is primarily terminal receipt/journal/transport handoff. Shorter reply-window counts do not imply that all background reconciliation work was deleted.
  • Boundary proof covers durable early reply, retained result claim, immediate follow-up reading reconciled files, separate conflict notice, failure notice/recovery custody, and Stop/Move behavior. The accepted case fails on original production while reconciliation is held.
  • New regression command: pnpm test src/gateway/worker-environments/worker-turn-early-final.test.ts --maxWorkers=1, 3/3 passed, 55.19 s local wall time including setup; approximately 8.8 CI seconds for the three cases in the initial hosted run. Remote runs also passed 111 sibling tests in 589.48 s and the final remaining 60 cases in 391.18 s; overlapping proof is not counted twice.
  • Final-head CI run is green, including required CI, source contracts, core lint, production types, all test type stripes, and runtime tests. Earlier CI caught obsolete settlement assertions, the quick-follow-up read race, and a detached callback receiver-type contract; all are fixed.
  • Codex autoreview: no actionable P0/P1 findings. Formatting and git diff --check pass. No limits, timeouts, or baselines were raised.
  • dbasync overlap checked: no shared production changes; the shared build-recovery test file has a separate fixture-initialization hunk in perf(runtime): consume prepared session and placement facts #169432.

The optional two-machine measurement could not complete worker installation through the relay, so no remote-node performance claim is made.

Release-note context: worker-turn final replies no longer wait for workspace synchronization; queued follow-ups still use the reconciled workspace, and workspace problems remain visible separately.

@clawsweeper

clawsweeper Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: M labels Oct 12, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 12, 2026
@clawsweeper

clawsweeper Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR delivers durable worker replies before workspace reconciliation while retaining settlement custody and delaying follow-up execution.

Example: A worker returns "Worker reply" while accepted.txt still contains "before reconciliation".

  • Before: The final reply waits until workspace reconciliation completes.
  • After: The reply returns early, while the next turn waits for accepted.txt to contain "accepted worker content".

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The approved optimization has useful boundary coverage, but two correctness defects and the required authority proof remain unresolved.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦪 silver shellfish (2/6) Security review found an item that needs attention.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Remote replies remain unfinished while workspace reconciliation runs after the assistant message is already durable.
Reason: The recorded feature-owner decision supports earlier reply completion and accepts the remaining reconciliation wait before successor execution.

Merge readiness

⛔ Blocked before merge - 7 items remain

Keep this PR open: the approved latency improvement remains absent from main, but both earlier correctness findings remain unresolved.

Priority: P2
Reviewed head: 0743de509c9dcf4af9ea050811df2720fca33111

Before merge

  • Add real behavior proof - Authority-chain proof required: the body reports loopback reply-tail measurements and successful follow-ups, but supplies no inspectable trace showing detached settlement after foreground completion and rejection of an exact revoked result claim or replaced session before transcript writes and workspace I/O; provide redacted terminal output or logs, removing IPs, API keys, phone numbers, and non-public endpoints. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Defer outer-owned maintenance until workspace acceptance (P2) - When run-entry supplies onContextEngineTurnCandidate for a durable context engine, this branch records the candidate before reconciliation and returns it through the early reply. run-entry.ts then invokes finalizeAcceptedContextEngineTurn, which drains accepted turns and calls context-engine maintenance without joining worker workspace acceptance. Workspace-dependent maintenance can read pre-reconciliation files or overlap apply, contrary to the preserved post-acceptance contract. The context test substitutes a recording callback and never invokes that outer finalizer. Preserve early candidate recording, but defer its outer-owned maintenance until workspace acceptance. This earlier finding remains unresolved.
  • Deliver later workspace warnings to the originating channel (P2) - For a worker turn started from Telegram or another messaging channel, this returns the reply before reconciliation and discards the returned conflict report. Removing the conflict suffix and assistant delta leaves only custom transcript notices and placement state; neither sends a warning to the original channel. A user receives "Worker reply" without learning that local versions were retained or reconciliation failed. Deliver the separate notice through the captured channel, account, conversation, and thread after settlement without starting another agent turn. This earlier finding remains unresolved.
  • Resolve security concern: Verify detached settlement authority - The patch removes the foreground writer fence and exits its transcript context while retaining exact pending-result and session-lifecycle checks. No concrete bypass was established, but those replacement checks have not been demonstrated rejecting revoked claims or replaced sessions before transcript writes and workspace I/O.
  • Resolve merge risk - Before merge, establish that retained result authority rejects revoked claims and replaced sessions before detached transcript or workspace effects.
  • Improve patch quality - Add final-effect proof for revoked result claims and replaced sessions, alongside successful settlement after foreground completion.
  • Explain or restore the original intent of Post-turn context ordering - 06d4475: Share Gateway-owned context handling and run post-turn context work after workspace reconciliation while the placement claim remains held.

Findings

  • [P2] Defer outer-owned maintenance until workspace acceptance — src/gateway/worker-environments/worker-turn-payload.ts:486-487
  • [P2] Deliver later workspace warnings to the originating channel — src/gateway/worker-environments/worker-turn-payload.ts:552-553
  • [medium] Verify detached settlement authority — src/gateway/worker-environments/worker-turn-payload.ts:385

Provenance

  • Post-turn context ordering changes intended behavior without addressing why it exists (06d4475: Share Gateway-owned context handling and run post-turn context work after workspace reconciliation while the placement claim remains held.)

Tests

  • Missing end-to-end proof: Provide final-effect authority evidence and exercise outer maintenance after acceptance plus subsequent workspace-warning delivery on Telegram's Test Server.
Agent review details

How this fits together

The Gateway worker launcher receives terminal worker receipts, validates committed transcripts, produces reply payloads, and retains placement ownership until workspace settlement finishes.

flowchart TD
A[Worker terminal receipt] --> B[Validate durable transcript]
B --> C[Deliver reply]
B --> D[Retained result owner]
D --> E[Reconcile workspace]
E --> F[Publish acceptance and notices]
F --> G[Release claim and admit follow-up]
Loading

Technical review

Best possible solution:

Keep early replies while preserving acceptance-before-maintenance ordering, originating-channel warnings, and live result authority.

Do we have a high-confidence way to reproduce the issue?

Main source establishes the reply barrier, and the changed owner plus its callers establish the remaining defects; no target code or tests were executed during this read-only review.

Is this the best way to solve the issue?

Separating reply completion from the existing settlement owner is a reasonable approved approach, provided downstream maintenance and warning delivery retain their contracts.

Full review comments:

  • [P2] Defer outer-owned maintenance until workspace acceptance — src/gateway/worker-environments/worker-turn-payload.ts:486-487
    When run-entry supplies onContextEngineTurnCandidate for a durable context engine, this branch records the candidate before reconciliation and returns it through the early reply. run-entry.ts then invokes finalizeAcceptedContextEngineTurn, which drains accepted turns and calls context-engine maintenance without joining worker workspace acceptance. Workspace-dependent maintenance can read pre-reconciliation files or overlap apply, contrary to the preserved post-acceptance contract. The context test substitutes a recording callback and never invokes that outer finalizer. Preserve early candidate recording, but defer its outer-owned maintenance until workspace acceptance. This earlier finding remains unresolved.
    Confidence: 0.97
  • [P2] Deliver later workspace warnings to the originating channel — src/gateway/worker-environments/worker-turn-payload.ts:552-553
    For a worker turn started from Telegram or another messaging channel, this returns the reply before reconciliation and discards the returned conflict report. Removing the conflict suffix and assistant delta leaves only custom transcript notices and placement state; neither sends a warning to the original channel. A user receives "Worker reply" without learning that local versions were retained or reconciliation failed. Deliver the separate notice through the captured channel, account, conversation, and thread after settlement without starting another agent turn. This earlier finding remains unresolved.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against f466872e035b.

Merge-risk options

Maintainer options:

  1. Demonstrate retained result authority (recommended)
    Provide successful settlement after foreground completion and rejection before final effects when the exact result claim is revoked or the session is replaced.
  2. Retain the reply barrier temporarily
    Defer early completion until the detached settlement authority contract can be demonstrated.

Provenance checked

  • Worker reply completion and conflict reporting changes intended behavior with a stated reason (8631832: Complete conflicted turns without wedging the session while making retained local versions and staged cloud results visible.)
  • Retained worker settlement ownership keeps the original intent (6786915: Prevent successors from reusing a workspace before write-capable preparation and dispatched worker work have settled.)
  • Cancelled finishing acknowledgment keeps the original intent (9b90bef: Allow the exact cancelled owner to acknowledge cleanup without reopening execution authority.)

Testing

Proof path: in-process harness.

Security

Needs attention: The retained result owner needs final-effect rejection evidence after foreground writer authority closes.

Evidence

Security concerns:

  • [medium] Verify detached settlement authority — src/gateway/worker-environments/worker-turn-payload.ts:385
    The patch removes the foreground writer fence and exits its transcript context while retaining exact pending-result and session-lifecycle checks. No concrete bypass was established, but those replacement checks have not been demonstrated rejecting revoked claims or replaced sessions before transcript writes and workspace I/O.
    Confidence: 0.96

What I checked:

  • Approved product direction: The body records the feature owner's decision to deliver terminal, durable replies before reconciliation and explicitly accepts the remaining reconciliation wait in subsequent request admission. (0743de509c9d)
  • Current main retains the reply barrier: Current main awaits reconciliation and adds its conflict summary to the reply before returning; this PR still provides distinct work. (src/gateway/worker-environments/worker-turn-payload.ts:434, f466872e035b)
  • Outer maintenance bypasses workspace acceptance: The patch records context candidates before early delivery; run-entry.ts subsequently calls finalizeAcceptedContextEngineTurn, whose maintenance dispatch does not join worker workspace acceptance. (src/gateway/worker-environments/worker-turn-payload.ts:486, 0743de509c9d)
  • Originating-channel warning path removed: The introduced diff removes conflict text from reply payloads and assistant deltas; remaining custom transcript reports notify session-history consumers without sending to the originating messaging channel. (src/gateway/worker-environments/worker-turn-payload.ts:552, 0743de509c9d)
  • Retained authority replaces foreground writer scope: Settlement drops expectedWriterRunId and exits the attempt-owned transcript context; exact pending-result authority and session-lifecycle checks remain, but supplied evidence does not exercise forbidden final effects after revocation or replacement. (src/gateway/worker-environments/worker-turn-payload.ts:385, 0743de509c9d)
  • Useful boundary coverage: The new test exercises early replies, retained claims, reconciled follow-up reads, conflict reports, and failure custody through production launcher code with a simulated worker transport; it does not exercise the outer context finalizer or channel delivery. (src/gateway/worker-environments/worker-turn-early-final.test.ts:38, 0743de509c9d)

PR surface

Source +59, Tests +242, Docs +2. Total +303 across 21 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 5 137 78 +59
Tests 15 280 38 +242
Docs 1 7 5 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 21 424 121 +303

Review metrics

Metric Value Why it matters
Production versus test growth Production +137/-78; tests and support +279/-38. Production growth extends the existing settlement owner; the main added regression protects reply timing, retained custody, and follow-up ordering.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded worker reply-latency improvement with maintenance-ordering and warning-delivery defects.
  • merge-risk: 🚨 session-state: Outer-owned context maintenance can run before the worker workspace is accepted.
  • merge-risk: 🚨 message-delivery: Messaging users lose the conflict warning previously included in their reply.
  • merge-risk: 🚨 security-boundary: Detached settlement changes the authority protecting transcript and workspace effects.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.
  • proof: telegram-e2e: This PR needs Telegram Test Server proof with the repository E2E skill. Removing conflict text from reply payloads changes Telegram-visible output; prove the early reply and subsequent conflict or recovery notice on Telegram's Test Server.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (4 earlier review cycles)
  • reviewed 2026-10-12T01:01:25.259Z sha 8bea1d7 :: needs real behavior proof before merge. :: [P2] Defer outer-owned maintenance until workspace acceptance | [P2] Deliver later workspace warnings to the originating channel
  • reviewed 2026-10-12T01:12:31.781Z sha 8bea1d7 :: needs real behavior proof before merge. :: [P2] Defer outer-owned maintenance until workspace acceptance | [P2] Deliver later workspace warnings to the originating channel | [P2] Await settlement in the remaining launcher contract tests
  • reviewed 2026-10-12T04:31:18.367Z sha a7f54ec :: needs real behavior proof before merge. :: [P2] Defer outer-owned maintenance until workspace acceptance | [P2] Deliver later workspace warnings to the originating channel
  • reviewed 2026-10-12T05:16:41.791Z sha 0743de5 :: needs real behavior proof before merge. :: [P2] Defer outer-owned maintenance until workspace acceptance | [P2] Deliver later workspace warnings to the originating channel

Reviewed October 12, 2026, 2:08 AM ET / 06:08 UTC (Revision 5).

@steipete
steipete marked this pull request as ready for review October 12, 2026 01:06
Keep live-turn collision semantics while waiting for the prior delivered reply to finish workspace settlement. Update recovery fixtures to distinguish reply completion from claim release.
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Oct 12, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Oct 12, 2026
@steipete
steipete merged commit 883d61f into main Oct 12, 2026
141 checks passed
@steipete
steipete deleted the codex/nodew-r6-earlyfinal-base branch October 12, 2026 06:12
steipete added a commit that referenced this pull request Oct 13, 2026
## What Problem This Solves

After #169484 delivered worker final replies before workspace reconciliation, session subscribers could observe reconciliation in progress without receiving its later completion. The claim owner installed internal row-change facts on completion, but that notification does not reach the existing WebSocket lifecycle bridge.

## Change

Publish the existing placement lifecycle event after an owned closure commits with both the turn claim and pending workspace result cleared. Subscribers receive the settled placement after its facts are installed. Retained recovery fences stay pending; ordinary local-turn receipts are excluded.

Production LOC: +9, a bounded correctness fix. Three files change; the archive assertion now includes its response for diagnostics without changing the expected result. The existing owner boundary test proves acceptance stays silent and completion publishes already-cleared claim and result authority. No new RPC, lifecycle state, timer, or polling.

## Evidence

Changed-file formatting, type-aware lint, and independent review passed with no actionable P0/P1 findings. `pnpm test src/gateway/worker-environments/placement-store.turn-claim-closure.test.ts --maxWorkers=1` was not run locally under the CI-only host constraint; local test wall time is unavailable. The integrated [CI run 38340516247](https://github.com/openclaw/openclaw/actions/runs/38340516247) at 7be861c selected and passed all four affected E2Es with both production fixes: native-slot 36.141 test seconds, upgrade-wire 158.587, same-session 82.785, and skill-library 41.308. Native A/B claims clear, and all four same-session pairs publish the settled placement. This PR runs the focused owner regression and required static gates independently. The four E2E contract updates are tracked separately in #170537.

Release-note context: session subscriptions publish worker workspace settlement after an early final reply.

Focused CI run 38341715059 passed all 42 tests in the owner group (21.40 seconds), including the new completion-publication assertion (665 ms), abort and lifecycle closure cases. All selected static gates passed. The prior head had a separate orphaned-provisioning archive failure. Current main passed all 10 archive tests in [probe CI](https://github.com/openclaw/openclaw/actions/runs/38343515030/job/115119831896), so no inherited-failure exception is claimed. This branch is refreshed against that main baseline, and the archive assertion now reports the response if it fails again.

Final head 38916dd: [CI 38344022221](https://github.com/openclaw/openclaw/actions/runs/38344022221) passes the archive cases (successful orphan cleanup 2.261s, failing cleanup 2.280s) and all 42 owner-group tests (24.55s, new publication assertion 650ms). The earlier archive failure did not recur after main integration; it is not claimed as inherited proof.

The sole remaining static failure is inherited from main #170530: `src/commands/config-preflight-snapshot.test.ts:41` imports `readConfigPreflightSnapshot`, which that main commit made private. The CI checkout is merge 137ab4a7c73d03c5d5cb1f2713e68b966cb3614c (main 33a438a plus this head); neither config file is changed here. Both files are identical to current main: implementation blob afc97b5, test blob b85a1d9. [Exact TS2724 job](https://github.com/openclaw/openclaw/actions/runs/38344022221/job/115121788481). This is recorded for the config owner; landing uses the authorized inherited-static-failure exception. No behavioral failure is waived.
steipete added a commit that referenced this pull request Oct 13, 2026
## What Problem This Solves

Three selectively run node-worker E2Es assert ordering that #169484 intentionally retired by delivering the durable reply before workspace reconciliation. The skill-library E2E also exposed a retained-transcript regression during its sequential worker flow; its original assertions did not explicitly equate a final reply with settlement.

## User Impact

The final diff is test-only. It verifies early replies while preserving claim release, workspace settlement, upgrade recovery, retained-session continuation, and skill-library behavior.

## Change

- Native-slot waits on the existing session-change signal, then asserts that the claim and pending result are gone before proving physical-slot reuse.
- Upgrade-wire checks its attempted upload after the existing durable recovery observation.
- Required-native receives A's final while quiescence is held, preserves the queued-follow-up proof, and waits for B's settled placement.
- Skill-library joins workspace settlement before sequential turns; its wire fixture exposes existing events.

The updated waits uncovered two production defects: #169622 tied retained transcript facts to a writer that early final releases, and successful claim closure did not reach the existing lifecycle/WebSocket bridge. Those fixes landed separately in #170556 and #170575. Main is now integrated at 38033f1, and the final diff contains only the five test/fixture files. Production LOC: 0. No timers, polling, retries, budgets, or assertion weakening were added.

## Evidence

[Integrated CI 38340516247](https://github.com/openclaw/openclaw/actions/runs/38340516247) at 7be861c passed all four E2Es and the required CI gate:

| File | Test seconds | Runner seconds |
| --- | ---: | ---: |
| native-worker-slot | 36.141 | 45.72 |
| paired-node-worker-upgrade-wire | 158.587 | 168.53 |
| required-native-same-session | 82.785 | 94.17 |
| skill-library-worker-wire | 41.308 | 67.21 |

[Native/upgrade/same-session log](https://github.com/openclaw/openclaw/actions/runs/38340516247/job/115110480812) shows A and B claims clearing and all four same-session pairs settling on their retained environments. [Skill log](https://github.com/openclaw/openclaw/actions/runs/38340516247/job/115110480823) shows eight remote placements move from reconciling to clear; the complete authoring, continuation, cancellation, and reclaim flow passes.

The [unchanged-main probe](https://github.com/openclaw/openclaw/actions/runs/38331787910/job/115083216251) reproduced the original four failures. [Control CI 38339534658](https://github.com/openclaw/openclaw/actions/runs/38339534658/job/115107577910), with only the test alignment and the extra active-run condition removed, still reached a reconciling placement twice and received no further event before the 300-second watchdog. No E2E artifacts were uploaded; the retained Vitest resource was watchdog cleanup evidence, not proof of a product child leak.

Changed-file formatting, type-aware lint, and independent review pass with no actionable P0/P1 findings. Local diagnostic command `pnpm test:e2e:gateway test/e2e/qa-lab/runtime/native-worker-slot.e2e.test.ts --maxWorkers=1` took 179.68 seconds before test execution and refused to proceed because artifact separation could not be verified. The guard was preserved; subsequent proof used GitHub CI only, with no leases.

The earlier skill local-first rejection with an unsettled database writer remains recorded for the session-actor campaign; this change does not alter that guard. Related credential-diagnostics PR: #170257.

Final-head CI 38344788931 has the same inherited main-only TS2724 error as #170575: config-preflight-snapshot.test.ts:41 imports the function made private by main #170530. CI checkout 1e93e8ab merges this head into main 88e5ae8; this test-only PR does not change either config file. [Exact static failure](https://github.com/openclaw/openclaw/actions/runs/38344788931/job/115124083706). The config owner follow-up is recorded; no worker behavior failure is waived.

Final test-only head 38033f1 passes all four selected E2Es in CI 38344788931: native-slot 45.28s Vitest / 46.69s runner; upgrade-wire 166.37s / 167.94s; required same-session 100.49s / 102.91s; skill-library 64.35s / 66.24s. Final diff is exactly five test/fixture files and zero production LOC. The only remaining failure is the documented inherited main TS2724 check; landing uses that scoped static-failure exception.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 13, 2026
…aw#169484)

## What Problem This Solves

Node worker replies waited for workspace synchronization after the final assistant message was already durable, adding hundreds of milliseconds to the visible reply tail.

## User Impact

Worker-turn replies now finish before workspace reconciliation. A quick follow-up is accepted into durable custody and starts against the reconciled workspace. Conflicts and reconciliation failures appear as separate transcript notices and through existing placement/recovery state; they do not replace a delivered reply. No new RPC or stored state is added.

## Why This Change Was Made

Decision: **Peter, 2026-10-11** — deliver the reply when the worker is terminal and its transcript is durable; reconcile the workspace in the background.

The existing turn owner retains execution, the result claim, transcript scope, and recovery handling while delivering the reply separately. Context candidates are recorded before returning; workspace-dependent maintenance still follows acceptance. The old conflict suffix and assistant delta are removed.

A completed prior reply joins its existing settlement promise before a follow-up prepares placement state. This prevents a real placement-read invalidation during claim release while preserving live-turn collision and duplicate-run behavior. Production LOC: **+59**, within the approved +80 contract-change allowance.

## Evidence

Same-box Hetzner ccx33, OpenAI `gpt-4.1-mini`, two warmups and five measured turns per route and revision. Values are milliseconds:

| Path | Request → provider, before → after | TTFT, before → after | Provider terminal → chat final, before → after |
|---|---:|---:|---:|
| Local | 438 → 381 | 1720 → 1783 | 120 → 118 |
| Loopback node | 492 → 1045 | 1741 → 2321 | **412 → 236** |

The node reply tail improved **176 ms (42.7%)**, with a flat local control. Requests are sent immediately after the preceding final: the longer next-request admission deliberately includes the remaining prior reconciliation wait. TTFT includes that wait and provider variance; this is a reply-tail improvement, not a throughput or TTFT claim. All final replies and post-final `agent.wait` observations succeeded.

- Instrumented census confirms reconciliation finishes after chat final. Remaining node overhead is primarily terminal receipt/journal/transport handoff. Shorter reply-window counts do not imply that all background reconciliation work was deleted.
- Boundary proof covers durable early reply, retained result claim, immediate follow-up reading reconciled files, separate conflict notice, failure notice/recovery custody, and Stop/Move behavior. The accepted case fails on original production while reconciliation is held.
- New regression command: `pnpm test src/gateway/worker-environments/worker-turn-early-final.test.ts --maxWorkers=1`, 3/3 passed, **55.19 s** local wall time including setup; approximately **8.8 CI seconds** for the three cases in the initial hosted run. Remote runs also passed 111 sibling tests in 589.48 s and the final remaining 60 cases in 391.18 s; overlapping proof is not counted twice.
- Final-head [CI run](https://github.com/openclaw/openclaw/actions/runs/38206809322) is green, including required CI, source contracts, core lint, production types, all test type stripes, and runtime tests. Earlier CI caught obsolete settlement assertions, the quick-follow-up read race, and a detached callback receiver-type contract; all are fixed.
- Codex autoreview: no actionable P0/P1 findings. Formatting and `git diff --check` pass. No limits, timeouts, or baselines were raised.
- dbasync overlap checked: no shared production changes; the shared build-recovery test file has a separate fixture-initialization hunk in openclaw#169432.

The optional two-machine measurement could not complete worker installation through the relay, so no remote-node performance claim is made.

Release-note context: worker-turn final replies no longer wait for workspace synchronization; queued follow-ups still use the reconciled workspace, and workspace problems remain visible separately.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 13, 2026
…170575)

## What Problem This Solves

After openclaw#169484 delivered worker final replies before workspace reconciliation, session subscribers could observe reconciliation in progress without receiving its later completion. The claim owner installed internal row-change facts on completion, but that notification does not reach the existing WebSocket lifecycle bridge.

## Change

Publish the existing placement lifecycle event after an owned closure commits with both the turn claim and pending workspace result cleared. Subscribers receive the settled placement after its facts are installed. Retained recovery fences stay pending; ordinary local-turn receipts are excluded.

Production LOC: +9, a bounded correctness fix. Three files change; the archive assertion now includes its response for diagnostics without changing the expected result. The existing owner boundary test proves acceptance stays silent and completion publishes already-cleared claim and result authority. No new RPC, lifecycle state, timer, or polling.

## Evidence

Changed-file formatting, type-aware lint, and independent review passed with no actionable P0/P1 findings. `pnpm test src/gateway/worker-environments/placement-store.turn-claim-closure.test.ts --maxWorkers=1` was not run locally under the CI-only host constraint; local test wall time is unavailable. The integrated [CI run 38340516247](https://github.com/openclaw/openclaw/actions/runs/38340516247) at 7be861c selected and passed all four affected E2Es with both production fixes: native-slot 36.141 test seconds, upgrade-wire 158.587, same-session 82.785, and skill-library 41.308. Native A/B claims clear, and all four same-session pairs publish the settled placement. This PR runs the focused owner regression and required static gates independently. The four E2E contract updates are tracked separately in openclaw#170537.

Release-note context: session subscriptions publish worker workspace settlement after an early final reply.

Focused CI run 38341715059 passed all 42 tests in the owner group (21.40 seconds), including the new completion-publication assertion (665 ms), abort and lifecycle closure cases. All selected static gates passed. The prior head had a separate orphaned-provisioning archive failure. Current main passed all 10 archive tests in [probe CI](https://github.com/openclaw/openclaw/actions/runs/38343515030/job/115119831896), so no inherited-failure exception is claimed. This branch is refreshed against that main baseline, and the archive assertion now reports the response if it fails again.

Final head 38916dd: [CI 38344022221](https://github.com/openclaw/openclaw/actions/runs/38344022221) passes the archive cases (successful orphan cleanup 2.261s, failing cleanup 2.280s) and all 42 owner-group tests (24.55s, new publication assertion 650ms). The earlier archive failure did not recur after main integration; it is not claimed as inherited proof.

The sole remaining static failure is inherited from main openclaw#170530: `src/commands/config-preflight-snapshot.test.ts:41` imports `readConfigPreflightSnapshot`, which that main commit made private. The CI checkout is merge 137ab4a7c73d03c5d5cb1f2713e68b966cb3614c (main 33cbbd1 plus this head); neither config file is changed here. Both files are identical to current main: implementation blob afc97b5, test blob b85a1d9. [Exact TS2724 job](https://github.com/openclaw/openclaw/actions/runs/38344022221/job/115121788481). This is recorded for the config owner; landing uses the authorized inherited-static-failure exception. No behavioral failure is waived.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 13, 2026
## What Problem This Solves

Three selectively run node-worker E2Es assert ordering that openclaw#169484 intentionally retired by delivering the durable reply before workspace reconciliation. The skill-library E2E also exposed a retained-transcript regression during its sequential worker flow; its original assertions did not explicitly equate a final reply with settlement.

## User Impact

The final diff is test-only. It verifies early replies while preserving claim release, workspace settlement, upgrade recovery, retained-session continuation, and skill-library behavior.

## Change

- Native-slot waits on the existing session-change signal, then asserts that the claim and pending result are gone before proving physical-slot reuse.
- Upgrade-wire checks its attempted upload after the existing durable recovery observation.
- Required-native receives A's final while quiescence is held, preserves the queued-follow-up proof, and waits for B's settled placement.
- Skill-library joins workspace settlement before sequential turns; its wire fixture exposes existing events.

The updated waits uncovered two production defects: openclaw#169622 tied retained transcript facts to a writer that early final releases, and successful claim closure did not reach the existing lifecycle/WebSocket bridge. Those fixes landed separately in openclaw#170556 and openclaw#170575. Main is now integrated at 38033f1, and the final diff contains only the five test/fixture files. Production LOC: 0. No timers, polling, retries, budgets, or assertion weakening were added.

## Evidence

[Integrated CI 38340516247](https://github.com/openclaw/openclaw/actions/runs/38340516247) at 7be861c passed all four E2Es and the required CI gate:

| File | Test seconds | Runner seconds |
| --- | ---: | ---: |
| native-worker-slot | 36.141 | 45.72 |
| paired-node-worker-upgrade-wire | 158.587 | 168.53 |
| required-native-same-session | 82.785 | 94.17 |
| skill-library-worker-wire | 41.308 | 67.21 |

[Native/upgrade/same-session log](https://github.com/openclaw/openclaw/actions/runs/38340516247/job/115110480812) shows A and B claims clearing and all four same-session pairs settling on their retained environments. [Skill log](https://github.com/openclaw/openclaw/actions/runs/38340516247/job/115110480823) shows eight remote placements move from reconciling to clear; the complete authoring, continuation, cancellation, and reclaim flow passes.

The [unchanged-main probe](https://github.com/openclaw/openclaw/actions/runs/38331787910/job/115083216251) reproduced the original four failures. [Control CI 38339534658](https://github.com/openclaw/openclaw/actions/runs/38339534658/job/115107577910), with only the test alignment and the extra active-run condition removed, still reached a reconciling placement twice and received no further event before the 300-second watchdog. No E2E artifacts were uploaded; the retained Vitest resource was watchdog cleanup evidence, not proof of a product child leak.

Changed-file formatting, type-aware lint, and independent review pass with no actionable P0/P1 findings. Local diagnostic command `pnpm test:e2e:gateway test/e2e/qa-lab/runtime/native-worker-slot.e2e.test.ts --maxWorkers=1` took 179.68 seconds before test execution and refused to proceed because artifact separation could not be verified. The guard was preserved; subsequent proof used GitHub CI only, with no leases.

The earlier skill local-first rejection with an unsettled database writer remains recorded for the session-actor campaign; this change does not alter that guard. Related credential-diagnostics PR: openclaw#170257.

Final-head CI 38344788931 has the same inherited main-only TS2724 error as openclaw#170575: config-preflight-snapshot.test.ts:41 imports the function made private by main openclaw#170530. CI checkout 1e93e8ab merges this head into main 8526c5b; this test-only PR does not change either config file. [Exact static failure](https://github.com/openclaw/openclaw/actions/runs/38344788931/job/115124083706). The config owner follow-up is recorded; no worker behavior failure is waived.

Final test-only head 38033f1 passes all four selected E2Es in CI 38344788931: native-slot 45.28s Vitest / 46.69s runner; upgrade-wire 166.37s / 167.94s; required same-session 100.49s / 102.91s; skill-library 64.35s / 66.24s. Final diff is exactly five test/fixture files and zero production LOC. The only remaining failure is the documented inherited main TS2724 check; landing uses that scoped static-failure exception.
steipete added a commit that referenced this pull request Oct 14, 2026
Node-worker owner changes now select 13 keyless process E2Es through an explicit path-to-test mapping. Hourly main retains the complete group in one serial row with a shared build, inside the existing matrix cap. No production code changes.

Validation: aggressive planner selects all 13 files for node-launch-adapter changes and none for docs-only changes; hourly plans fit 77/77 hybrid and 76/77 hosted rows. Independent review is clean after enforcing serial execution in the manifest.

CI: https://github.com/openclaw/openclaw/actions/runs/38510459970
Related: #169484
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 15, 2026
Node-worker owner changes now select 13 keyless process E2Es through an explicit path-to-test mapping. Hourly main retains the complete group in one serial row with a shared build, inside the existing matrix cap. No production code changes.

Validation: aggressive planner selects all 13 files for node-launch-adapter changes and none for docs-only changes; hourly plans fit 77/77 hybrid and 76/77 hosted rows. Independent review is clean after enforcing serial execution in the manifest.

CI: https://github.com/openclaw/openclaw/actions/runs/38510459970
Related: openclaw#169484
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 merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: L status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant