Skip to content

refactor(gateway): keep worker transcript reads off the Gateway thread - #153335

Merged
steipete merged 19 commits into
mainfrom
codex/worker-hydration-composed-20260920
Sep 22, 2026
Merged

steipete merged 19 commits into
mainfrom
codex/worker-hydration-composed-20260920

Conversation

@steipete

@steipete steipete commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Built on #153325, now landed on main.

What Problem This Solves

Worker-turn preparation and workspace-result reconciliation load full transcripts synchronously on the Gateway thread.

User Impact

These reads await the existing history worker while preserving admitted history and pending workspace results. Revoked execution owners cannot proceed to credentials or launch after hydration; accepted terminal results can still settle after execution cancellation.

Why This Change Was Made

The callers use the asynchronous session view and recheck their captured transcript target and live placement claim after each new await. Terminal and workspace reads retain pending-result authority, while writes remain with the existing admission owner. Main's credential acknowledgment, reconnect recovery, and canonical cleanup are preserved. Recorder-prefix preparation follows separately.

Views remain finite snapshots, without a new freshness poll or transcript lease through later transport waits. Earlier rejected snapshot-freshness review concerns remain recorded separately from the subsequent clean feature review.

Evidence

On the current main 29e7a6c0 composition, seven existing ownership and terminal-settlement cases passed with one worker (48.797 seconds including worker preparation and verification). They exercise the newly shared hydration helper through the real worker entry and preserve accepted terminal settlement after execution cancellation. The owning Gateway type graph passed in 11.525 seconds; source stayed unchanged, and diff checks passed.

All eight feature changes and the six caller/test postimages remain identical to the reviewed caller patch; only main's additive routing entries changed. Earlier full-file, compiled Node/Bun, review, and green CI results retain their original source identities. The original failed runs and broad lint timeout remain recorded.

This head carries the canonical archive-fixture and type-partition repairs already landed in #155751 and #155734. It also carries the canonical Memory fixture from #155745 rather than the superseded warmup alternative. That separate Memory proof has three passing canonical cases and two expected failures with the old blocking behavior; its postprocessor error and skipped final hash assertions remain explicitly recorded, with cleanup verified. These component results are not relabeled as new executions of this PR.

Current-head hosted CI and the normal native main-targeted review/landing gates remain required.

@clawsweeper

clawsweeper Bot commented Sep 20, 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 gateway Gateway runtime size: L maintainer Maintainer-authored PR labels Sep 20, 2026
@steipete
steipete marked this pull request as ready for review September 20, 2026 01:40
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 20, 2026
@clawsweeper

clawsweeper Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 22, 2026, 12:01 PM ET / 16:01 UTC (Revision 18).

ClawSweeper review

What this changes

Moves worker-turn and workspace-result transcript reads onto the existing history worker, with ownership checks after asynchronous reads and regression coverage for cancellation and settlement.

Merge readiness

⛔ Blocked before merge - 1 item remains

This remains useful: current main and the latest release retain the synchronous reads. No actionable introduced defect was found, and the previous migration-proof blocker does not apply to this caller-only change.

Priority: P2
Reviewed head: 0897e3284e01bd255234437e1813a724d92215fb

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused migration with useful boundary coverage and no supported blocking defect.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer-authored proof exemption applies. Reported entrypoint tests exercise real hydration with mocked remote transport; they are not a live remote-worker run. The diff preserves existing authority owners and changes no stored-data contract, so no migration-proof gate applies.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-authored proof exemption applies. Reported entrypoint tests exercise real hydration with mocked remote transport; they are not a live remote-worker run. The diff preserves existing authority owners and changes no stored-data contract, so no migration-proof gate applies.
Evidence reviewed 8 items Pinned production change: The introduced production hunks replace five synchronous full-transcript reads with the existing asynchronous reader and retain write admission. They introduce no schema, serialized format, migration, configuration, or plugin API change.
Still needed on current main: Fetched main still opens full transcripts synchronously during initial preparation, recorder-leaf recovery, and terminal-result validation; workspace reconciliation also retains its synchronous reads.
Latest-release check: The v2026.9.5 source likewise retains synchronous full-transcript opens at lines 106, 138, and 465. The requested caller migration is not present there.
Findings None None.
Security None None.

How this fits together

Gateway worker coordination prepares conversation history for remote execution and reconciles completed workspace results. Transcript snapshots feed launch preparation and result validation, while existing admission owners retain control over writes.

flowchart TD
  A[Worker turn or completed result] --> B[Capture transcript identity]
  B --> C[History worker reads snapshot]
  C --> D{Relevant owner still current?}
  D -->|Execution owner| E[Prepare credentials and launch]
  D -->|Pending result owner| F[Validate and settle result]
  D -->|No| G[Reject stale operation]
  F --> H[Existing admitted transcript writer]
Loading

Before merge

  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source +21, Tests +677. Total +698 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 2 52 31 +21
Tests 6 681 4 +677
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 733 35 +698

Review metrics

Metric Value Why it matters
Production versus validation growth Production net +21 lines; tests/support net +660; test routing +17 Production growth adds checks around new asynchronous boundaries; most added code exercises ownership and settlement invariants.

Stored data model

Persistent data-model change detected: unknown-data-model-change: src/gateway/worker-environments/worker-turn-execution.ts. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Keep transcript hydration with the existing history worker and preserve separate execution and pending-result ownership through the established admission boundaries.

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

Yes, from source: current-main worker preparation and reconciliation call synchronous transcript readers directly. No runtime latency reproduction was executed during this read-only review.

Is this the best way to solve the issue?

Yes. Reusing the already-landed asynchronous reader and existing write-admission owner is a focused solution; this delta requires no data migration.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded Gateway responsiveness improvement with no demonstrated urgent user-facing outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The maintainer-authored proof exemption applies. Reported entrypoint tests exercise real hydration with mocked remote transport; they are not a live remote-worker run. The diff preserves existing authority owners and changes no stored-data contract, so no migration-proof gate applies.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • vincentkoc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (17 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-20T10:31:29.788Z sha 31dd062 :: blocked before merge. :: none
  • reviewed 2026-09-20T11:01:06.626Z sha 9f26b5f :: blocked before merge. :: none
  • reviewed 2026-09-20T21:00:14.995Z sha eebba35 :: blocked before merge. :: none
  • reviewed 2026-09-22T08:56:45.935Z sha 252e3ca :: blocked before merge. :: none
  • reviewed 2026-09-22T13:06:21.651Z sha ce7a818 :: blocked before merge. :: none
  • reviewed 2026-09-22T14:00:31.926Z sha 720fb4d :: blocked before merge. :: none
  • reviewed 2026-09-22T14:15:21.482Z sha afbd81f :: blocked before merge. :: none
  • reviewed 2026-09-22T15:22:17.877Z sha 9d803b1 :: blocked before merge. :: none

@steipete
steipete force-pushed the codex/session-hydration-publication-20260919 branch from f285b3a to 9954f52 Compare September 20, 2026 02:47
@steipete
steipete force-pushed the codex/worker-hydration-composed-20260920 branch from 7d0f8ec to 791ad1d Compare September 20, 2026 02:58
@steipete
steipete force-pushed the codex/session-hydration-publication-20260919 branch from 9954f52 to 8199034 Compare September 20, 2026 03:24
@steipete
steipete force-pushed the codex/worker-hydration-composed-20260920 branch from 791ad1d to 549c034 Compare September 20, 2026 03:36
@steipete
steipete force-pushed the codex/session-hydration-publication-20260919 branch from 8199034 to cc7ed4a Compare September 20, 2026 05:01
@steipete
steipete force-pushed the codex/worker-hydration-composed-20260920 branch from 549c034 to b31d2c4 Compare September 20, 2026 05:14
@steipete
steipete force-pushed the codex/session-hydration-publication-20260919 branch 3 times, most recently from 21fb89d to 7bdafba Compare September 20, 2026 10:05
@steipete
steipete force-pushed the codex/worker-hydration-composed-20260920 branch from b31d2c4 to 31dd062 Compare September 20, 2026 10:23
@steipete
steipete force-pushed the codex/session-hydration-publication-20260919 branch from 7bdafba to 80145ce Compare September 20, 2026 10:37
@steipete
steipete force-pushed the codex/worker-hydration-composed-20260920 branch from 31dd062 to 9f26b5f Compare September 20, 2026 10:42
@steipete
steipete force-pushed the codex/session-hydration-publication-20260919 branch from 80145ce to 050320c Compare September 20, 2026 18:54
@steipete
steipete force-pushed the codex/worker-hydration-composed-20260920 branch from 9f26b5f to eebba35 Compare September 20, 2026 20:37
@steipete
steipete force-pushed the codex/session-hydration-publication-20260919 branch 5 times, most recently from c081523 to cd92e10 Compare September 22, 2026 00:33
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation scripts Repository scripts agents Agent runtime and tooling plugin: file-transfer size: XL and removed size: L labels Sep 22, 2026
@openclaw-barnacle openclaw-barnacle Bot added size: L and removed docs Improvements or additions to documentation scripts Repository scripts agents Agent runtime and tooling plugin: file-transfer size: XL labels Sep 22, 2026
steipete added a commit that referenced this pull request Sep 22, 2026
Integrate the reviewed Plain successor based on landed hydration main. All
three Recorder feature files and the complete feature patch remain identical.
The reached transcript, admission, framing, and worker owners are unchanged.

Retain the exact feature review and compiled entry/type evidence by parity,
plus the current Plain owning-type proof. Prior Recorder head bc61065 passed
hosted CI; the earlier catalog timeout and separate prerequisite readiness
failure remain recorded without attributing or claiming fixes here.

Source: #153337; depends on #153335.
steipete added a commit that referenced this pull request Sep 22, 2026
Absorb the reviewed Plain successor and already-landed archive fixture repair.
All three Recorder feature files and the complete feature patch remain exact.
No Recorder request, dependency manifest, or ownership contract changed.

Retain source-bound feature review and compiled-entry evidence by parity.
The prior catalog timeout and subsequent green Recorder CI remain separate
observations; no additional product fix is claimed by this composition.

Source: #153337; depends on #153335.
steipete added a commit that referenced this pull request Sep 22, 2026
Absorb the reviewed Plain successor and already-landed owning type graph fix.
All three Recorder feature files and the complete feature patch remain exact.
No reached Recorder runtime, admission, session owner, or manifest changed.

Retain source-bound feature review and compiled-entry evidence by parity,
including green hosted CI for the prior Recorder head. The Plain owner passed
its current owning type graph; no duplicate fix or runtime replay is claimed.

Source: #153337; depends on #153335.
steipete added a commit that referenced this pull request Sep 22, 2026
Absorb the reviewed Plain successor and canonical main fixes. All three
Recorder feature files and the complete feature patch remain exact.

Retain the Recorder feature review and compiled-entry proof by parity. The
Plain owner separately passed seven current ownership/terminal cases and
owning types for the shared hydration extraction. The canonical memory repair
passed three positive cases and failed both historical blocking controls;
its postprocessing limitation and verified cleanup remain recorded.

Source: #153337; depends on #153335.
@steipete
steipete merged commit 2736e94 into main Sep 22, 2026
201 checks passed
@steipete
steipete deleted the codex/worker-hydration-composed-20260920 branch September 22, 2026 16:56
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

steipete added a commit that referenced this pull request Sep 22, 2026
Integrate actual main after the Plain prerequisite landed. The resulting diff
against main contains only the exact three reviewed Recorder feature files;
there is no remaining hydration or Plain prerequisite delta.

Validate the current dependency graph with a normal physical frozen install
including fs-safe 0.18.1. All nine selected admitted-history/currentness cases
and the owning Gateway type graph passed on the exact composed tree. Retain
the prior feature-scoped review by byte-identical patch parity.

Source: #153337; builds on merged #153335.
steipete added a commit that referenced this pull request Sep 22, 2026
…ges (#153337)

* refactor(sessions): reconcile hydration with current worker context

* fix(sessions): remove unused hydration worker type export

Keep the hydration input private to its shared worker union owner while retaining the externally consumed SQLite target input export. This clears the unused-export finding without changing emitted runtime code.

* refactor(gateway): hydrate worker transcript reads asynchronously

* fix(gateway): keep worker history at admitted input

Wait for canonical recorder persistence before preparing cloud-worker history.
Read the exact admitted prefix and use its user entry as the transcript base,
so later activity cannot shift or duplicate the current input during replay.
Preserve current authority checks, asynchronous credential acknowledgment,
and replacement-worker recovery.

Validation: current owning Gateway types and 24 admitted-history cases with
freshly compiled transcript workers, plus fresh independent P2 review. Exact
feature bytes retain prior strict lint, formatting, and 55-case caller proof;
the earlier broader run's slow fork-shutdown warning remains documented.

Release-note context: cloud-worker launches keep the current user admission
out of replay and retain its correct transcript base across persistence races.
Source: #153337; depends on #153335.

* fix(sessions): stream full hydration within worker memory limits

Transfer canonical transcript chunks through the existing history worker while retaining one read-only snapshot and complete caller-side results. Preserve SQLite text encodings, BOM errors, cancellation, current-owner checks, and native cleanup without raising the worker heap limit.

* test(sessions): align hydration error controls with streaming

Model interactive admission and the canonical streaming result in the
existing quarantine error fixture, preserving its cleanup and retirement
assertions. Remove a redundant unknown-alias assertion from the reader;
emitted production JavaScript is unchanged.

The complete 21-case worker error file, assertion ratchet, owning types,
scoped lint, and fresh P0-P2 review pass.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 23, 2026
openclaw#153335)

* refactor(sessions): reconcile hydration with current worker context

* fix(sessions): remove unused hydration worker type export

Keep the hydration input private to its shared worker union owner while retaining the externally consumed SQLite target input export. This clears the unused-export finding without changing emitted runtime code.

* refactor(gateway): hydrate worker transcript reads asynchronously

* fix(sessions): stream full hydration within worker memory limits

Transfer canonical transcript chunks through the existing history worker while retaining one read-only snapshot and complete caller-side results. Preserve SQLite text encodings, BOM errors, cancellation, current-owner checks, and native cleanup without raising the worker heap limit.

* test(sessions): align hydration error controls with streaming

Model interactive admission and the canonical streaming result in the
existing quarantine error fixture, preserving its cleanup and retirement
assertions. Remove a redundant unknown-alias assertion from the reader;
emitted production JavaScript is unchanged.

The complete 21-case worker error file, assertion ratchet, owning types,
scoped lint, and fresh P0-P2 review pass.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 23, 2026
…ges (openclaw#153337)

* refactor(sessions): reconcile hydration with current worker context

* fix(sessions): remove unused hydration worker type export

Keep the hydration input private to its shared worker union owner while retaining the externally consumed SQLite target input export. This clears the unused-export finding without changing emitted runtime code.

* refactor(gateway): hydrate worker transcript reads asynchronously

* fix(gateway): keep worker history at admitted input

Wait for canonical recorder persistence before preparing cloud-worker history.
Read the exact admitted prefix and use its user entry as the transcript base,
so later activity cannot shift or duplicate the current input during replay.
Preserve current authority checks, asynchronous credential acknowledgment,
and replacement-worker recovery.

Validation: current owning Gateway types and 24 admitted-history cases with
freshly compiled transcript workers, plus fresh independent P2 review. Exact
feature bytes retain prior strict lint, formatting, and 55-case caller proof;
the earlier broader run's slow fork-shutdown warning remains documented.

Release-note context: cloud-worker launches keep the current user admission
out of replay and retain its correct transcript base across persistence races.
Source: openclaw#153337; depends on openclaw#153335.

* fix(sessions): stream full hydration within worker memory limits

Transfer canonical transcript chunks through the existing history worker while retaining one read-only snapshot and complete caller-side results. Preserve SQLite text encodings, BOM errors, cancellation, current-owner checks, and native cleanup without raising the worker heap limit.

* test(sessions): align hydration error controls with streaming

Model interactive admission and the canonical streaming result in the
existing quarantine error fixture, preserving its cleanup and retirement
assertions. Remove a redundant unknown-alias assertion from the reader;
emitted production JavaScript is unchanged.

The complete 21-case worker error file, assertion ratchet, owning types,
scoped lint, and fresh P0-P2 review pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant