Skip to content

test(codex): stabilize one-shot cleanup during cold startup - #154683

Merged
steipete merged 1 commit into
mainfrom
codex/fix-one-shot-fixture-clock350
Sep 21, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/fix-one-shot-fixture-clock350

Conversation

@steipete

@steipete steipete commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: Codex one-shot cleanup tests fail during cold startup before they exercise the intended cleanup outcome. Related: #154393.

User Impact

User impact: no runtime behavior change. This keeps CI focused on cleanup receipts without changing production deadlines or weakening cleanup assertions.

Why This Change Was Made

The completed/cancelled fixture mixed a five-second real-time attempt budget with request polling and one event-loop turn as its readiness signal. Keep that table's clock under test control and wait for the existing turn_accepted event. The shared teardown restores real timers before sibling cases. No tests, retries, higher timeouts, or production seams were added.

The sibling native-process fixture has its own landed repair in 9247701; this PR addresses the remaining one-shot fixture.

Evidence

  • Controlled contention (two workers on one CPU): unchanged fixture failed its first completed case while awaiting turn/start; the candidate passed all 19 cases across both affected files. Its completed case took 7.356s and still checked the same successful terminal outcome and uncertain-cleanup warning. Candidate wall: 51.764s. This proves load sensitivity; it does not establish the exact timing of the historical CI failure.
  • The original failing CI merge was replayed first using the decoded 12-file selection and two workers: 390/390 passed in 105.707s, a non-reproduction. The same selection on the candidate passed twice locally: 390/390 in 104.121s (99.59s Vitest) and 85.643s (82.80s Vitest). The plan's file list was retained; exact concurrent dispatch timing is not available from CI logs.
  • pnpm test extensions/codex/src/app-server/run-attempt-one-shot-cleanup.test.ts --maxWorkers=1: 9/9 passed; 82.022s wall, 78.02s Vitest including cold transforms, 15.909s summed test cases. The original CI completed case failed after 5.683s. All 20 standalone runs passed 9/9 without retries; subsequent warm runs took 21.398–24.163s wall (median 21.945s).
  • All 20 selected changed checks passed in 670.495s, including extension test types, lint, formatting, plugin boundaries, and dead exports. Fresh independent Codex review is clean through P2.

Repeated-run qualification complete: 20/20 standalone runs and 3/3 original-shard runs passed, including sibling coverage. The three shard runs comprise two local runs and hosted CI run 35584290125, job 106284238408, whose decoded ordered 12-file selection, Vitest config, and two-worker setting match the original shard. Its name changed from changed-extensions-config-40 to changed-extensions-config-15; it passed 390/390 on its first observed attempt in 122.77s Vitest / 124.75s wrapper time. The nine one-shot cases totaled 9.828s, including 2.085s for the completed case and 0.290s for cancellation. The reviewed fixture bytes stayed unchanged throughout qualification. There is no claim of statistical flake elimination or a runtime cleanup fix.

Control the completed/cancelled fixture clock and await turn acceptance so cold startup cannot exhaust the unrelated attempt deadline before cleanup assertions run. Production deadlines and cleanup assertions stay unchanged.
@clawsweeper

clawsweeper Bot commented Sep 21, 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.

@steipete
steipete marked this pull request as ready for review September 21, 2026 09:36
@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 21, 2026
@clawsweeper

clawsweeper Bot commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed September 21, 2026, 5:45 AM ET / 09:45 UTC.

ClawSweeper review

What this changes

The PR controls the cleanup test’s clock and waits for turn acceptance so cold startup does not exhaust its attempt deadline before cleanup assertions run.

Merge readiness

⛔ Needs changes before merge - 1 item remains

Keep open: this remains a useful, focused fixture repair absent from current main. No introduced correctness defect was found; the stated repeated-run qualification remains unfinished.

Priority: P3
Reviewed head: c2a8464b57d3968cf6d194ee28298010632b9849

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, sound fixture repair with useful contention evidence and an explicitly unfinished qualification gate.
Proof confidence 🌊 off-meta tidepool Not applicable: The contributor runtime-proof gate does not apply to this maintainer-authored fixture repair; the reported mocked-client and shard runs validate test behavior, not a production cleanup fix.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The contributor runtime-proof gate does not apply to this maintainer-authored fixture repair; the reported mocked-client and shard runs validate test behavior, not a production cleanup fix.
Evidence reviewed 9 items Pinned introduced change: The merge-base-to-head diff changes only the cleanup fixture: it freezes Date and timeout APIs, forwards the existing execution-phase callback, and replaces request polling plus an event-loop turn with turn acceptance. Terminal outcome, termination, and warning assertions remain intact.
Readiness and timer lifecycle: The production owner installs the abort listener before emitting turn_accepted. The shared fixture restores real timers during teardown and before each case; its default attempt budget remains 5,000 ms. The in-memory transport emits exit through setImmediate, which this patch does not fake.
Still needed on fetched main: The cleanup test is unchanged between the pinned merge base and fetched main, so main retains the polling and real-time fixture addressed here.
Findings None None.
Security None None.

How this fits together

OpenClaw’s Codex plugin runs agent turns through an app-server client and records cleanup outcomes separately from completion or cancellation. These tests feed simulated server responses into that lifecycle and check terminal outcomes and cleanup warnings.

flowchart LR
  A[Test-controlled clock] --> B[One-shot attempt]
  C[Simulated server replies] --> B
  B --> D[Turn accepted]
  D --> E[Complete or cancel]
  E --> F[Terminal cleanup]
  F --> G[Outcome and warning assertions]
Loading

Before merge

  • Complete next step (P2) - Complete the remaining 19 standalone and two original-shard qualification runs and record their results in the PR body before landing.
Agent review details

Security

None.

PR surface

Tests +14. Total +14 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 20 6 +14
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 20 6 +14

Review metrics

Metric Value Why it matters
Flake qualification 1/20 standalone runs; 1/3 original-shard runs The captured evidence leaves 19 standalone runs and two shard runs outstanding under the repository’s stated qualification bar.

Technical review

Best possible solution:

Keep cleanup assertions synchronized to the attempt owner’s readiness signal while leaving production deadlines and cleanup semantics unchanged.

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

Unclear for the exact historical CI failure: its shard replay passed. Source supports the timing-sensitive fixture mechanism, and the PR reports a controlled-contention baseline failure; this review did not execute it.

Is this the best way to solve the issue?

Yes. Controlling this fixture’s clock and using the existing turn-accepted event isolates cleanup behavior without increasing production timeouts or weakening assertions.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P3: This is a focused test-fixture reliability repair with no production behavior change.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The contributor runtime-proof gate does not apply to this maintainer-authored fixture repair; the reported mocked-client and shard runs validate test behavior, not a production cleanup fix.

Label justifications:

  • P3: This is a focused 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 contributor runtime-proof gate does not apply to this maintainer-authored fixture repair; the reported mocked-client and shard runs validate test behavior, not a production cleanup fix.

Evidence

What I checked:

  • Pinned introduced change: The merge-base-to-head diff changes only the cleanup fixture: it freezes Date and timeout APIs, forwards the existing execution-phase callback, and replaces request polling plus an event-loop turn with turn acceptance. Terminal outcome, termination, and warning assertions remain intact. (extensions/codex/src/app-server/run-attempt-one-shot-cleanup.test.ts:72, c2a8464b57d3)
  • Readiness and timer lifecycle: The production owner installs the abort listener before emitting turn_accepted. The shared fixture restores real timers during teardown and before each case; its default attempt budget remains 5,000 ms. The in-memory transport emits exit through setImmediate, which this patch does not fake. (extensions/codex/src/app-server/run-attempt-active-turn.ts:628, c2a8464b57d3)
  • Still needed on fetched main: The cleanup test is unchanged between the pinned merge base and fetched main, so main retains the polling and real-time fixture addressed here. (extensions/codex/src/app-server/run-attempt-one-shot-cleanup.test.ts:105, 99e7d3e7a5b3)
  • Latest-release comparison: The supplied latest release, v2026.9.5, maps this test to blob 8b212ff5ebff7c2e96f7d19c4626d16f9558de43. Reading that blob through GitHub confirms the old request-polling and setImmediate readiness sequence remains there. (extensions/codex/src/app-server/run-attempt-one-shot-cleanup.test.ts, ec9c1a13db89)
  • Captured validation and remaining qualification: The supplied PR body reports a baseline failure under two-worker, one-CPU contention and a candidate pass of all 19 sibling cases. The original 12-file shard replay passed both baseline and candidate, so it did not reproduce the historical CI failure. Reported qualification is 1/20 standalone runs and 1/3 original-shard runs; the body explicitly requires completion before landing. No tests were executed during this read-only review. (c2a8464b57d3)
  • Applicable flake qualification: The testing guide requires 20 clean standalone runs, three clean original-shard runs, and sibling coverage for flake repairs. The reported remaining work matches this existing qualification requirement. Public docs: docs/help/testing/writing-tests.md. (docs/help/testing/writing-tests.md, c2a8464b57d3)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Complete and record the remaining 19 standalone and two original-shard qualification runs.

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.

@steipete
steipete merged commit 268ee66 into main Sep 21, 2026
177 of 179 checks passed
@steipete
steipete deleted the codex/fix-one-shot-fixture-clock350 branch September 21, 2026 10:09
@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 22, 2026
Control the completed/cancelled fixture clock and await turn acceptance so cold startup cannot exhaust the unrelated attempt deadline before cleanup assertions run. Production deadlines and cleanup assertions stay unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: codex 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