Skip to content

fix(test): keep queued Stop cleanup on real timers - #197734

Merged
steipete merged 1 commit into
mainfrom
fix/2430-queued-stop-clock
Nov 12, 2026
Merged

steipete merged 1 commit into
mainfrom
fix/2430-queued-stop-clock

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes a queued-input Stop product fixture that can deadlock its own admission cleanup before reaching its clock-advance barrier.

User Impact

Test-only repair: production behavior and deadlines are unchanged. Public Stop still returns 503 while cleanup is held, and a retry returns 200 with killed: false after cleanup settles. Durable cancellation, input custody, no-dispatch, and teardown assertions remain.

Why This Change Was Made

The fixture froze global setTimeout before public Stop, then waited for source settlement before advancing time. Stop can first drain an admission whose producer releases asynchronously; freezing that release prevents the test from reaching its own barrier. Restoring real timers after the 503 assertion (#197621) cannot repair an earlier wait.

Remove the fake clock and its source-settlement spy/barrier, and wait for the existing 15-second cleanup deadline. The final test shrinks by 27 net lines; no production code, configuration, or timeout changes.

Evidence

  • Existing beginSessionEffect creates a real admission for the synthetic child. Its interruption callback schedules an ordinary asynchronous release. Under the original fixture clock, interruption fires but release and source settlement never occur; the original 120-second test and 180-second hook deadlines fail, followed by 15-second retained session-controller cleanup. This matches the observed failure shape without asserting the original hosted interleaving was traced.
  • With the same controlled admission and real timers, interruption, producer release, source settlement, public 503→200, durable state, and teardown pass. Test 29.898s; total 57.50s including worker preparation, 34.45s user / 59.46s system. These are fixture proof costs, not production performance claims.
  • The control uses existing real admission operations; it adds no production injection seam. Temporary markers/control are retained in investigation evidence and omitted from the final simplified fixture.
  • The invalid fake-clock lifetime originates in refactor(sessions)!: give each session one controller for turns, queues, and Stop #175837 (36e277d). The fixture and relevant Stop/session/ingress owners are unchanged between the failed main-tier source and the qualified c06331c parent. The recent hosted trigger remains unknown; no flaky classification is claimed.

Original repeat failure: https://github.com/openclaw/openclaw/actions/runs/43204708317/job/131137467166. The final clean uninstrumented case passes in 26.153s (88.67s total, including 39.901s worker compilation); independent Codex review through P2 is clean. Required pnpm check:changed --base c06331c4b8e6f7be8ed947a43c5ab9701961fd16 passes, including format, ratchets, gateway-server test types, all dead-export scans, and focused lint.

@clawsweeper

clawsweeper Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: XS labels Nov 12, 2026
@steipete
steipete marked this pull request as ready for review November 12, 2026 12:46
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-12T12:48:42.247962Z ac8a7ba Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Final head ac8a7ba removes the fake-clock-only source spy/barrier and waits for the existing real cleanup deadline. Controlled real-admission red/green proof, clean final focused test, full required changed checks, and independent Codex review are complete. The original hosted interleaving remains explicitly untraced; all public and durable-state assertions remain.

@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 12, 2026
@clawsweeper

clawsweeper Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Removes global fake timers and their settlement spy from the queued-subagent Stop product test.

Example: Stop a yielded child while release of queued input custody is held.

  • Before: A timer-dependent admission release can stall before the fixture reaches its clock-advance barrier.
  • After: Admission release can progress; Stop returns 503 at the existing cleanup deadline, then a retry returns 200 with killed: false after custody releases.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A minimal test repair supported by concrete fixture validation and source-confirmed cleanup ordering; exact-head CI remains incomplete.
Proof confidence 🐚 platinum hermit (4/6) This fixture-only repair requires no separate shipped-entry-point demonstration; the author reports controlled red/green admission proof and a passing final product fixture.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Test only · Worth it: Yes · Fix scope: Complete
User problem: The queued-input Stop product fixture can time out on its own frozen asynchronous cleanup.
Reason: The maintainer-authored repair removes fixture interference while retaining production behavior, deadlines, and distinct lifecycle contracts.

Merge readiness

✅ Ready for maintainer review

This PR is a focused, useful fixture repair with no actionable correctness or security findings; exact-head CI is still running.

Priority: P3
Reviewed head: ac8a7ba5ee6f8acbb7674dc59aee1813f8ce127c

Before merge

None.

Findings

None.

Agent review details

How this fits together

The Gateway product fixture drives real subagent spawning, yielding, ingress custody, and public Stop requests against a synthetic model server, then checks persisted cancellation and teardown.

flowchart LR
  A[Synthetic model server] --> B[Gateway agent runner]
  B --> C[Yielded child]
  D[Queued ingress input] --> C
  E[Public Stop request] --> F[Session controller cleanup]
  C --> F
  F --> G[HTTP result and durable cancellation]
Loading

Technical review

Best possible solution:

Keep this minimal fixture repair, preserving the production cleanup deadline and all observable lifecycle assertions.

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

Source confirms the circular fixture dependency between frozen timer-driven admission release and the later clock-advance barrier; the author reports a controlled reproduction, while the exact hosted interleaving remains unknown and no tests were run during this review.

Is this the best way to solve the issue?

Removing the global fake clock fixes the fixture-owned cause with the existing cleanup owners and preserves every public and durable-state assertion.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Queued Stop fake-clock barrier changes intended behavior with a stated reason (36e277d: The session-controller cutover synchronized fake-clock advancement with source cleanup so the fixture would not advance before the cleanup deadline was armed.)
  • Restoring real timers after the 503 assertion keeps the original intent (37e568b: The earlier repair prevented fake timers from stalling Gateway teardown; removing fake timers entirely supersedes that restoration.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Tests -27. Total -27 across 1 file. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 2 29 -27
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 2 29 -27

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Production versus test LOC Production +0/-0; tests +2/-29 Removes fixture-only clock machinery without adding a production injection seam or weakening retained assertions.

Labels

Label changes:

  • add P3: Focused test maintenance repairs CI coverage without changing shipped runtime behavior.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P3: Focused test maintenance repairs CI coverage without changing shipped runtime behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

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.

Reviewed November 12, 2026, 7:51 AM ET / 12:51 UTC.

@steipete
steipete merged commit ad5fb63 into main Nov 12, 2026
181 of 183 checks passed
@steipete
steipete deleted the fix/2430-queued-stop-clock branch November 12, 2026 14:26
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Nov 12, 2026
…plugin-reload-runtime-20261112

* commit '5d6a026e43757ea6302e4c1151d6ace28468ced0':
  fix(logging): avoid main-thread stalls when resolving default log files (#197742)
  fix(sessions): commit selected invitations with original messages (#184512)
  improve: make Telegram tool progress easier to scan (#197523)
  fix(test): keep queued Stop cleanup on real timers (#197734)
  fix: keep usage pricing from blocking the Gateway on filesystem lookups (#197599)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. gateway Gateway runtime size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant