Skip to content

fix: shutdown test fails before recap model starts - #162133

Merged
jalehman merged 1 commit into
mainfrom
shutdown-008/shutdown-recap
Sep 30, 2026
Merged

jalehman merged 1 commit into
mainfrom
shutdown-008/shutdown-recap

Conversation

@jalehman

@jalehman jalehman commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes the shutdown cancellation regression test failing before its model work starts on resource-constrained CI workers.

Related: #151218. This separate repair PR was explicitly requested by a maintainer.

User Impact

No user-visible behavior changes. The test continues to verify cancellation before connection drain, waiting for physical model settlement, and suppression of late recap persistence.

Why This Change Was Made

ensure() returns a projected state before the real transcript worker finishes reading. The test incorrectly treated the default one-second vi.waitFor polling window as a model-start guarantee. In a fresh-main six-file replay with two CPUs and two workers, admission succeeded immediately, imports and scope preparation completed within 5 ms, the assertion failed at 1,004 ms, and the worker returned 64 transcript events at 2,408 ms—after cleanup had already disposed the service.

Wait for an explicit signal from the mocked model call instead. Use the existing test-abort-aware helper so timeout still unwinds fixture cleanup, and it.for to receive that test context. No production changes, timeout increases, sleeps, retries, broader mocks, or weakened assertions.

Evidence

  • Reproduced the original assertion on fresh main 1bf0175f8c78a845f04692a07b62de6bfa6f2fbe: 57/58 in the original six-file, two-CPU/two-worker shard. Original CI failure.
  • Corrected candidate: the same resource-matched shard passed 58/58 three consecutive times, with no retries after failure.
  • Standalone shutdown file passed 20/20 runs (2/2 cases each); recap lifecycle/retry and connection-work siblings passed 60/60.
  • check:changed --staged --base 1bf0175f8c78a845f04692a07b62de6bfa6f2fbe --timed passed, including gateway-server typecheck, formatting, lint, ratchets, boundaries, and dead-export scans. git diff --check passed.
  • Independent autoreview: scoped-clean, no actionable P0–P2 findings.
  • All execution used secretless AWS Crabbox, Node 24.19.0, fresh HOME, no credential hydration, IAM role, or Tailscale. Successful validation run, exit 0. Candidate source tree verified as eed6c21dd00cf512ab77a2c26f94b122ce006507.
  • Rechecked main through 3bf892b2158ca4ed52b4e54ef8c7d3068064574d and matching open PRs before publication; no competing fix found in the shutdown test/direct source.

Full repository build/test suites were not run for this one-file test-only change; GitHub CI remains the broader integration gate. No live Gateway or original PR worktree was modified.

Test-value audit, mutation proof, and cost

Retain this integration regression. It checks that Gateway shutdown cancels auxiliary recap work before draining inherited connection work, still joins physical settlement, and rejects late persistence. Generic connection-work tests and recap-service disposal tests do not exercise that wiring together.

Breaking mutation: in a fresh isolated checkout, delete only the params.signal.addEventListener("abort", stopSessionBackgroundWork, { once: true }) subscription. The unchanged shutdown assertion then fails because modelSignal.aborted is false, while the before-startup case and all 60 cheaper component siblings remain green (61 passed / 1 failed). The exact published candidate passes the control 2/2. The audit harness checked the intended assertion and sibling counts, then exited 0. Mutation proof run. This deliberate mutation is not part of the PR.

Simplification/LOC: 0 production LOC changed; test diff +8/−4, net +4 (136 → 140 physical lines). No new helper, dependency, timeout, sleep, or polling loop. The existing shared helpers replace the polling assertion. Both event gates are necessary: one observes model admission, the other controls physical completion. Model and audit I/O are already stubbed; replacing the remaining integration path with service mocks would lose the demonstrated wiring coverage.

Before/after timing: original six-file, two-CPU/two-worker diagnostic run: 83.85s, 57/58 tests. Corrected runs: 86.57s / 84.75s / 86.81s, 58/58 each. Shutdown case: 2.981s failing before, 3.203s / 4.382s / 2.865s passing after. These observations are not a speedup claim: the before run fails and includes diagnostics. The repair removes an invalid one-second race rather than optimizing runtime.

Single-worker file command wall time: pnpm test src/gateway/server-runtime-subscriptions.shutdown.test.ts --maxWorkers=1 passed all twenty runs. Measured with /usr/bin/time in secretless AWS Crabbox (Node 24.19.0, process affinity restricted to two CPUs): 45.52s for the initial invocation, then 35.16–36.09s for the subsequent nineteen invocations. These are whole-command wall times, including startup/source preparation—not individual test-case durations or GitHub CI file seconds. Startup/source preparation dominates the approximately 3–4 seconds spent in the cases.

Wait for the actual model-start signal instead of polling while the real history worker prepares the recap. Keep test-abort cleanup and cancellation/drain assertions intact.

Local task: shutdown-b21
@clawsweeper

clawsweeper Bot commented Sep 30, 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 labels Sep 30, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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 30, 2026
@clawsweeper

clawsweeper Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed September 30, 2026, 6:01 PM ET / 22:01 UTC (Revision 3).

ClawSweeper review

What this changes

The branch makes the Gateway shutdown test wait for the activity recap model to start before checking cancellation, connection drain, and late persistence.

Merge readiness

⛔ Needs changes before merge - 1 item remains

Current main and the latest release retain the timing-sensitive assertion. This focused repair has stronger flake evidence than the overlapping open PR, which is not a safe superseding target.

Priority: P2
Reviewed head: 2bcd0188a1c6e09752555d00a446e285152ff6de

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The repair and flake evidence are strong; the remaining gap is the repository-required per-file CI cost disclosure.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): The changed test exercises production Gateway subscriptions, the transcript-backed recap path, and connection drain with a stubbed model call. The captured body reports the original assertion failing on fresh main and the corrected test passing three resource-matched shards, 20 standalone runs, and sibling checks; linked Crabbox logs were unavailable to this reviewer. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The changed test exercises production Gateway subscriptions, the transcript-backed recap path, and connection drain with a stubbed model call. The captured body reports the original assertion failing on fresh main and the corrected test passing three resource-matched shards, 20 standalone runs, and sibling checks; linked Crabbox logs were unavailable to this reviewer. No stored-data contract changes.
Evidence reviewed 9 items Current main still polls: The fetched main revision retains the one-second model-call polling assertion.
Latest release still polls: The v2026.9.7 version of the test also retains the polling assertion.
Introduced repair: The pinned PR delta replaces polling with a deferred model-start signal and retains the call-count and shutdown assertions.
Findings None None.
Security None None.

How this fits together

Gateway subscriptions start activity recaps from session transcripts and dispose of them during connection shutdown. This test checks that in-flight model work is canceled before connection work drains and that no late recap is saved.

flowchart LR
  A[Session transcript] --> B[Gateway subscriptions]
  B --> C[Activity recap]
  C --> D[Model start signal]
  D --> E[Shutdown test]
  E --> F[Connection drain]
  E --> G[No late recap saved]
Loading

Before merge

  • Complete next step (P2) - Add the changed test file’s per-file CI seconds to the PR body, or explain why the completed CI run does not expose them.
Agent review details

Security

None.

PR surface

Tests +4. Total +4 across 1 file.

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

Review metrics

Metric Value Why it matters
Single-worker file wall time 45.52 s initial; 35.16–36.09 s subsequent The reported cost exceeds the guide’s 30-second threshold; the PR explains why this integration boundary needs the time.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #162114
Summary: The canonical issue identifies the exact shutdown assertion. Two open PRs propose event-gated fixes, while the broader flake report includes a separate recap-test failure.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Keep one event-gated Gateway shutdown regression test that preserves the cancellation, drain-order, and no-late-persistence checks.

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

Yes. The captured CI failure and reported fresh-main six-file replay reach the same model-call assertion, which current main still contains; this read-only review did not rerun the shard.

Is this the best way to solve the issue?

Yes. Waiting for the model-start event addresses the false one-second timing assumption without changing production behavior or weakening the shutdown assertions.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 5fe8304fd622.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: An intermittent Gateway test failure disrupts unrelated PR validation without changing user-facing runtime behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The changed test exercises production Gateway subscriptions, the transcript-backed recap path, and connection drain with a stubbed model call. The captured body reports the original assertion failing on fresh main and the corrected test passing three resource-matched shards, 20 standalone runs, and sibling checks; linked Crabbox logs were unavailable to this reviewer. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The changed test exercises production Gateway subscriptions, the transcript-backed recap path, and connection drain with a stubbed model call. The captured body reports the original assertion failing on fresh main and the corrected test passing three resource-matched shards, 20 standalone runs, and sibling checks; linked Crabbox logs were unavailable to this reviewer. No stored-data contract changes.

Evidence

What I checked:

Likely related people:

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

Rank-up moves

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

  • Add the changed test file’s CI seconds to the PR body, or explain why the completed CI run does not expose them.

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 (2 earlier review cycles)
  • reviewed 2026-09-30T21:12:17.806Z sha 2bcd018 :: blocked before merge. :: none
  • reviewed 2026-09-30T21:24:15.512Z sha 2bcd018 :: blocked before merge. :: none

@jalehman
jalehman merged commit 22d7946 into main Sep 30, 2026
122 checks passed
@jalehman
jalehman deleted the shutdown-008/shutdown-recap branch September 30, 2026 22:04
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 1, 2026
Wait for the actual model-start signal instead of polling while the real history worker prepares the recap. Keep test-abort cleanup and cancellation/drain assertions intact.

Local task: shutdown-b21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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