Skip to content

fix(gateway): preserve admitted worker history during transcript changes - #153337

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

steipete merged 28 commits into
mainfrom
codex/worker-recorder-composed-20260920

Conversation

@steipete

@steipete steipete commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Builds on merged #153335.

What Problem This Solves

Worker turns could prepare history before pending input persistence established its boundary, or replay a later transcript tail for already-recorded input.

User Impact

Cloud-worker launches use the history preceding their admitted input and keep that input's original transcript anchor across supported retries. Later messages do not enter that history, and excluding the current input preserves earlier unanswered user messages.

Why This Change Was Made

Preparation joins recorder persistence and reads the canonical admitted prefix through the existing model-context worker. It checks the current run, cancellation, turn claim, session target, and blocked-input state after the read. The ordinary admission receipt remains usable across pre-handoff recovery. Main's asynchronous credential acknowledgment, Stop/reconnect recovery, and the authority check after node-context preparation remain intact.

The reader returns a detached snapshot. It does not retain a transcript lease through subsequent transport setup; canonical destructive lifecycle operations and transaction-owned transcript commits keep their existing responsibilities. This does not establish exclusion against arbitrary standalone SDK or raw database writes.

Evidence

The actual-main composition passed all nine selected admitted-history/currentness cases and the owning Gateway type graph with a normal physical frozen dependency install, including fs-safe 0.18.1. The other 15 cases in the test file were outside this focused selection. Current compiled workers were prepared and verified, and source hashes remained unchanged. A type-driver preflight initially collided with the test driver's Git index capture before the compiler started; the typecheck then ran sequentially and passed.

The diff against landed main contains only the three reviewed Recorder files. Their complete feature patch is byte-identical, so the earlier clean feature-scoped P2 review and lint/formatting evidence are retained. Normal merge hooks passed. Earlier full 24-case and broader 55-case proof retain their source identities; the broader run's slow fork-shutdown warning remains recorded. No live remote worker launch was performed.

The preceding head passed CI run 35750816813. Historical failures remain separately recorded: an earlier native model-catalog timeout was reproduced without a causal fix, and an old timed memory fixture was replaced by the independently qualified canonical repair. That repair passed three positive cases and two historical blocking controls; its driver postprocessor failed afterward, later hash assertions were skipped, and raw results plus cleanup were independently verified. No cold-start latency claim is made.

Fresh CI for this actual-main head and canonical maintainer landing checks 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: M maintainer Maintainer-authored PR labels Sep 20, 2026
@steipete
steipete marked this pull request as ready for review September 20, 2026 01:41
@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, 1:17 PM ET / 17:17 UTC (Revision 21).

ClawSweeper review

What this changes

Cloud-worker preparation waits for input persistence, reads the history preceding that input, and preserves its transcript anchor across retries, with regression coverage for races and recovery.

Merge readiness

⛔ Blocked before merge - 1 item remains

The fix remains necessary on current main. The previous merge-conflict blocker is resolved, the reviewed feature files are unchanged, and no introduced correctness or security defect was found.

Priority: P2
Reviewed head: 39776e772c55f72feeb54efdcb2cc4ccb2d6600c

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair using existing owners, with meaningful race and retry coverage and no supported blocking finding.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer-authored PR is exempt from the external-contributor proof gate. Reported compiled-reader checks and inspected launch-boundary tests cover history preparation, but use a substituted remote transport and do not establish a live worker launch. No stored-data contract changes.
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 PR is exempt from the external-contributor proof gate. Reported compiled-reader checks and inspected launch-boundary tests cover history preparation, but use a substituted remote transport and do not establish a live worker launch. No stored-data contract changes.
Evidence reviewed 6 items Introduced production behavior: The pinned introduction delta replaces latest-tail selection with persistence joining and an explicit admission-bound history read. It retains the no-recorder fallback and checks run, cancellation, placement, session identity, and blocked input after preparation.
Current main still needs the fix: Fetched main still opens context without passing the recorder admission and removes the final message only when the current leaf is a user message. Later assistant activity can therefore enter replay and shift the base away from the admitted input. The supplied latest release is v2026.9.5; its source object was unavailable locally, so no released-fix claim is made.
Existing canonical reader contract: The existing asynchronous model-context reader accepts an admission receipt, copies it, and validates its continued identity after reading. The underlying fence checks transcript identity, store, generation, entry position, and user-message role. This patch consumes that contract without adding a competing reader, stored format, or authorization grant.
Findings None None.
Security None None.

How this fits together

The Gateway prepares conversation history and the current request before launching a cloud worker. The transcript recorder supplies the persisted input boundary, and the history reader supplies the earlier messages used by the worker.

flowchart TD
  A[Admitted user request] --> B[Transcript recorder]
  B --> C[Wait for persistence]
  C --> D[Read history before input]
  D --> E[Recheck current run and session]
  E -->|Current| F[Prepare worker launch]
  E -->|Cancelled or replaced| G[Reject launch]
Loading

Before merge

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

Security

None.

PR surface

Source -3, Tests +190. Total +187 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 40 43 -3
Tests 2 243 53 +190
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 283 96 +187

Review metrics

None.

Stored data model

Persistent data-model change detected: serialized state: src/gateway/worker-environments/worker-turn-execution.ts, 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:

Use the existing recorder admission and asynchronous history reader to preserve the input boundary while retaining current launch authority and recovery contracts.

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

Yes, from source: persist the current input, append later assistant activity, then prepare its worker turn; current main selects the later tail instead of the admitted prefix. This review did not execute that scenario.

Is this the best way to solve the issue?

Yes. Passing the existing admission receipt to the canonical reader fixes the boundary directly and avoids introducing another history-selection owner.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This repairs a bounded cloud-worker history and retry correctness problem without evidence of a widespread urgent 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 PR is exempt from the external-contributor proof gate. Reported compiled-reader checks and inspected launch-boundary tests cover history preparation, but use a substituted remote transport and do not establish a live worker launch. No stored-data contract changes.

Evidence

What I checked:

  • Introduced production behavior: The pinned introduction delta replaces latest-tail selection with persistence joining and an explicit admission-bound history read. It retains the no-recorder fallback and checks run, cancellation, placement, session identity, and blocked input after preparation. (src/gateway/worker-environments/worker-turn-execution.ts:106, 39776e772c55)
  • Current main still needs the fix: Fetched main still opens context without passing the recorder admission and removes the final message only when the current leaf is a user message. Later assistant activity can therefore enter replay and shift the base away from the admitted input. The supplied latest release is v2026.9.5; its source object was unavailable locally, so no released-fix claim is made. (src/gateway/worker-environments/worker-turn-execution.ts:108, 673048954c9b)
  • Existing canonical reader contract: The existing asynchronous model-context reader accepts an admission receipt, copies it, and validates its continued identity after reading. The underlying fence checks transcript identity, store, generation, entry position, and user-message role. This patch consumes that contract without adding a competing reader, stored format, or authorization grant. (src/agents/sessions/session-manager.ts:360, 39776e772c55)
  • Review continuity: Comparison with the previous reviewed head returns no changes in any of the three feature files. The supplied verified raw parent records show the new head incorporates the pinned main prerequisite, and current GitHub context reports mergeable=true. The stale test-merge object was not used to infer merge contents. (src/gateway/worker-environments/worker-turn-execution.ts, 39776e772c55)
  • Boundary coverage and proof limits: The inspected tests exercise the production placement provider, recorder, and history reader while substituting the remote transport. They check later appends, excluded inputs, removed admissions, cancellation, replacement, blocked input, and pre-handoff retries. The captured PR body reports nine selected current-head cases and the owning type graph passing, with earlier broader results retained separately; it explicitly reports no live remote launch. This review executed no tests. (src/gateway/worker-environments/worker-turn-detached-context.test.ts:103, 39776e772c55)
  • Merged prerequisite and routing history: The supplied GitHub metadata verifies refactor(gateway): keep worker transcript reads off the Gateway thread #153335 merged as 2736e94. Its description explicitly leaves recorder-prefix preparation to this follow-up. Current-main history connects Peter Steinberger to that hydration work and several nearby lifecycle changes; unavailable older blobs prevent stronger source-line introduction attribution. (src/gateway/worker-environments/worker-turn-execution.ts, 2736e94e2709)

Likely related people:

  • steipete: 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 (20 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-20T21:01:40.435Z sha 25b7ef8 :: blocked before merge. :: none
  • reviewed 2026-09-22T09:05:48.391Z sha a355c96 :: blocked before merge. :: none
  • reviewed 2026-09-22T13:14:14.001Z sha 60d5a4b :: blocked before merge. :: none
  • reviewed 2026-09-22T13:35:57.798Z sha bc61065 :: blocked before merge. :: none
  • reviewed 2026-09-22T14:25:40.651Z sha a1a7549 :: blocked before merge. :: none
  • reviewed 2026-09-22T15:23:18.974Z sha a0ad89c :: blocked before merge. :: none
  • reviewed 2026-09-22T16:04:55.052Z sha 028f7f0 :: blocked before merge. :: none
  • reviewed 2026-09-22T17:04:34.287Z sha 028f7f0 :: needs changes before merge. :: none

@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/worker-recorder-composed-20260920 branch from abb285f to 42ed7ef Compare September 20, 2026 02:59
@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/worker-recorder-composed-20260920 branch from 42ed7ef to ce6aab5 Compare September 20, 2026 03:37
@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/worker-recorder-composed-20260920 branch from ce6aab5 to 7ac223f Compare September 20, 2026 05:14
@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/worker-recorder-composed-20260920 branch from 7ac223f to a3178a1 Compare September 20, 2026 10:24
@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/worker-recorder-composed-20260920 branch from a3178a1 to 65d51e5 Compare September 20, 2026 10:42
@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/worker-recorder-composed-20260920 branch from 65d51e5 to 25b7ef8 Compare September 20, 2026 20:39
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.
Preserve current sharing projections, membership facts, database identity checks, and incognito ownership while retaining the canonical metadata-unavailable error import. Hydration feature changes remain identical to the prior qualified source.
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.
Route the canonical row-facts operation through the extracted history reader owner, preserving the 64-key bound and captured inputs. Retain hydration cancellation, database custody, and worker retirement while incorporating current main types, dispatch, and snapshot reads.
Integrate the reviewed Plain and hydration successors with their additive
session row-facts support. All three Recorder feature files and the complete
feature patch remain byte-identical to the reviewed Recorder source.

Reuse the feature-scoped P2 review and current 24-case compiled-history and
owning-type proof. The hydration owner separately qualified the row-facts
integration, currentness controls, types, lint, and independent review.
No Recorder request or hydration API changed in this composition.

Source: #153337; depends on #153335.
Preserve main database-root reuse and scoped cleanup while retaining
captured-environment controls on isolated per-test transcript roots.
Keep rootOverride third and captured environment fourth in the fixture.

All 32 admission cases, core/session types, scoped lint, formatting, and
fresh P0-P2 fixture-integration review pass. Hydration production files
remain byte-identical to the preceding qualified candidate.
Compose the landed quarantine reader and graph codec with asynchronous
hydration while retaining metadata error identities in the shared owner.
Keep the canonical singleton cleanup class, persisted quarantine cause,
and aggregate-only wire classification.

A real history-worker quarantine refusal preserves the manager view.
All 103 selected owner, stream, cancellation, and cleanup cases pass,
along with owning types, scoped lint, and fresh P0-P2 integration review.
Integrate the reviewed Plain and hydration successors while preserving all
three Recorder feature files and the complete feature patch byte-for-byte.

Validation: nine selected admitted-history, persistence, append-race and
cancellation cases passed with current compiled workers; owning Gateway types
passed on the exact composed tree. Retain feature-scoped independent review
for the identical patch. Hydration and Plain separately qualified full-stream
snapshot, cleanup, quarantine, and terminal-settlement behavior.

Source: #153337; depends on #153335.
Keep the new membership-facts operation in the existing extracted
history-reader owner, preserving main capture and publication fences.
Retain the moved sharing facade, row-facts ownership cutover, and H
streaming, cancellation, and metadata error contracts.

All 28 selected membership, sharing, stream, and SDK cases pass, along
with owning types, scoped lint, formatting, and fresh P0-P2 review.
@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. label Sep 22, 2026
Integrate the reviewed Plain and hydration successors. All three Recorder
feature files and the complete feature patch remain byte-identical; the new
membership reader lives in the existing owner without changing Recorder's
history request, signal, or stream callback contracts.

Reuse the Recorder feature review and nine-case/type proof with exact patch
parity, plus the separately qualified hydration integration and current Plain
execution/types proof. The prior hosted native catalog timeout remains
unattributed and is not represented as fixed by this source composition.

Source: #153337; depends on #153335.
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.
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.
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.
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.
Base automatically changed from codex/worker-hydration-composed-20260920 to main September 22, 2026 16:56
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
steipete merged commit b763261 into main Sep 22, 2026
191 checks passed
@steipete
steipete deleted the codex/worker-recorder-composed-20260920 branch September 22, 2026 18:59
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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: M 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