Skip to content

fix(test): initialize context readers before worker launch assertions - #145657

Merged
steipete merged 1 commit into
mainfrom
codex/worker-context-test-startup-20260912
Sep 12, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/worker-context-test-startup-20260912

Conversation

@steipete

@steipete steipete commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Related: #145591. Detected in CI for #145612.

What Problem This Solves

Fixes intermittent worker-history test failures during cold source-worker initialization. The fixtures placed their five-second launch observation timer around initialization of the real model-context worker, which has its own existing 60-second task deadline. On a slow cold start, the observation timer aborted the reader before its module or query handler became ready, then later cases started another cold worker.

Why This Change Was Made

Initialize the real empty model-context reader in each fixture's existing setup, before seeding the conversation and starting the launch observation. Each test still performs its fresh context read and keeps every history, payload, persistence, authority, and cleanup assertion.

The five-second observation, 60-second worker task, and existing hook deadlines are unchanged. There are no retries, sleeps, new mocks, assertion changes, or production-code changes. Initialization failures still fail setup; real cold loading, cancellation/replacement, and snapshot behavior remain covered by the existing owner suites.

User Impact

No runtime behavior changes. CI's worker-history assertions no longer depend on cold TypeScript worker startup finishing within their unrelated launch-observation window.

Evidence

An instrumented local reproduction on CI merge 1657840776c5f9aa95657b1650270c388963fbca failed six asynchronous cases: each five-second observer aborted and joined its worker before module readiness or SQL handler entry. The two synchronous recorder cases passed.

With real initialization in setup, the same eight-case suite passed. The first worker took about 8.7 seconds from online to module readiness, its first SQL handler took 13 ms, and the first actual launch observation took 48 ms. This diagnoses the fixture boundary; it is not a production-latency or host-contention claim. Historical CI did not retain these stage timestamps.

All 36 uninstrumented tests passed on the current main-based candidate across the two worker fixtures, real WorkerTaskPool/source-loader suites, and SessionManager snapshot suite. Independent P0-P2 review is clean. Native changed checks and exact-head CI passed. The Linux Testbox proof also passed all36 tests against the exact source tree, and its owned lease is completed. An initial remote preflight stopped before tests because it compared the capsule carrier commit with the source commit; the corrected check verifies source content-tree identity and tracked bytes under the native source attestation.

@clawsweeper

clawsweeper Bot commented Sep 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 gateway Gateway runtime size: XS maintainer Maintainer-authored PR labels Sep 12, 2026
@steipete
steipete marked this pull request as ready for review September 12, 2026 05:49
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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 12, 2026
@clawsweeper

clawsweeper Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 12, 2026, 2:14 AM ET / 06:14 UTC (Revision 2).

ClawSweeper review

What this changes

Initialize the real conversation-context reader during setup in two Gateway worker test suites so cold worker startup does not consume their launch-observation deadline.

Merge readiness

✅ Ready for maintainer review

The PR remains useful: current main lacks this fixture initialization, and the change preserves the tests’ behavioral assertions. No actionable correctness or security findings remain.

Priority: P3
Reviewed head: 7c926bcf8be50f844e5dcf4b278496382e335307

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused fixture repair preserves meaningful coverage and has no identified merge-blocking defect.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied repository state identifies a maintainer-authored, test-only PR, so the external-contributor proof gate does not apply; reported cold-start measurements directly address the fixture boundary, with raw-log inspection limits recorded in evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied repository state identifies a maintainer-authored, test-only PR, so the external-contributor proof gate does not apply; reported cold-start measurements directly address the fixture boundary, with raw-log inspection limits recorded in evidence.
Evidence reviewed 7 items Verified introduced change: The pinned merge-base-to-head diff adds only awaited reader initialization and its explanation in the two setup hooks; assertions, observation deadlines, mocks, and production code are unchanged.
Fresh reads remain inside the observation: The complete fixtures initialize before seeding history and installing observation hooks. The detached-context cases retain history/base-leaf parity and cancellation, claim-loss, caller-revocation, and session-rebinding checks; the footprint cases still require zero inactive payloads.
Reader lifecycle and implementation boundary: SessionManager requests a fresh detached snapshot for each asynchronous read. The OpenClaw-owned reader uses a reusable single-worker pool with a 60-second task deadline; the fixture’s launch observation uses five seconds. No Codex harness or protocol dependency determines this change.
Findings None None.
Security None None.

How this fits together

Gateway worker preparation reads the selected conversation history before preparing a remote turn. These tests exercise that preparation using real transcript readers and controlled transport endpoints.

flowchart TD
  A[Test fixture setup] --> B[Initialize context worker]
  B --> C[Seed conversation history]
  C --> D[Observe worker turn preparation]
  D --> E[Read fresh selected history]
  E --> F[Check history and authority outcomes]
  F --> G[Join operations and clean up]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests +4. Total +4 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 2 4 0 +4
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 4 0 +4

Review metrics

None.

Technical review

Best possible solution:

Keep cold reader initialization in fixture setup while preserving fresh per-turn reads, unchanged launch deadlines, and separate worker-lifecycle coverage.

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

Yes for the conditional failure mechanism: a cold context-worker startup exceeding five seconds consumes the fixture observation budget and triggers cancellation. The supplied body reports that scenario; this review inspected source without executing it.

Is this the best way to solve the issue?

Yes. Initializing the existing real reader before measurement isolates the intended launch behavior without extending deadlines or weakening assertions.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P3: This is a bounded test-fixture reliability repair with no production behavior change.
  • 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 supplied repository state identifies a maintainer-authored, test-only PR, so the external-contributor proof gate does not apply; reported cold-start measurements directly address the fixture boundary, with raw-log inspection limits recorded in evidence.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit aa7eabb adds src/gateway/worker-environments/worker-turn-detached-context.test.ts:215 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: aa7eabb1f6d6; files: src/gateway/worker-environments/worker-turn-detached-context.test.ts)

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 (1 earlier review cycle)
  • reviewed 2026-09-12T05:54:43.632Z sha 7c926bc :: needs maintainer review before merge. :: none

@steipete
steipete merged commit 72be357 into main Sep 12, 2026
174 of 176 checks passed
@steipete
steipete deleted the codex/worker-context-test-startup-20260912 branch September 12, 2026 06:20
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

steipete added a commit that referenced this pull request Sep 12, 2026
Prevent healthy Gateway worker preparation from failing a test-only five-second observation deadline on loaded hosts. Await execution completion and credential readiness while preserving early-settlement errors and unjoined-owner cleanup guards. Extend the existing replay case to cross the former deadline without changing its base-leaf or history assertions.

Use two concurrent worktrees for stale-retention reconciliation, preserving the upload barrier, real manifests and Git operations, binary result checks, journals, and released claims. Production code is unchanged.

CI run 34679294250, job 103514926295 failed six detached-context cases and timed out the 50-turn reconciliation case; #145349 was blocked on this shard.
https://github.com/openclaw/openclaw/actions/runs/34679294250/job/103514926295

Recorded proof: controlled regression failed before and passed after; the reduced reconciliation case failed the historical retention mutation; the contention suite passed all 13 tests; the full agentic-gateway-core-2 shard passed 255 files and 5,038 tests. Exact-head CI run 34680987053 is green for b3edad9 and was reverified with the native watcher before preparation.
https://github.com/openclaw/openclaw/actions/runs/34680987053

The lead's P1 autoreview is scoped-clean. ClawSweeper found no actionable findings on the approved head; no fixups or skips were needed.

Refs #145349, #145379. Follow-up to #145657.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 13, 2026
…5770)

Prevent healthy Gateway worker preparation from failing a test-only five-second observation deadline on loaded hosts. Await execution completion and credential readiness while preserving early-settlement errors and unjoined-owner cleanup guards. Extend the existing replay case to cross the former deadline without changing its base-leaf or history assertions.

Use two concurrent worktrees for stale-retention reconciliation, preserving the upload barrier, real manifests and Git operations, binary result checks, journals, and released claims. Production code is unchanged.

CI run 34679294250, job 103514926295 failed six detached-context cases and timed out the 50-turn reconciliation case; openclaw#145349 was blocked on this shard.
https://github.com/openclaw/openclaw/actions/runs/34679294250/job/103514926295

Recorded proof: controlled regression failed before and passed after; the reduced reconciliation case failed the historical retention mutation; the contention suite passed all 13 tests; the full agentic-gateway-core-2 shard passed 255 files and 5,038 tests. Exact-head CI run 34680987053 is green for b3edad9 and was reverified with the native watcher before preparation.
https://github.com/openclaw/openclaw/actions/runs/34680987053

The lead's P1 autoreview is scoped-clean. ClawSweeper found no actionable findings on the approved head; no fixups or skips were needed.

Refs openclaw#145349, openclaw#145379. Follow-up to openclaw#145657.
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 P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS 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