Skip to content

fix(googlechat): setup tests fail on a cold transform cache, breaking unrelated PR CI - #159189

Closed
TeaCup404 wants to merge 1 commit into
openclaw:mainfrom
TeaCup404:fix/googlechat-setup-test-cold-import
Closed

TeaCup404 wants to merge 1 commit into
openclaw:mainfrom
TeaCup404:fix/googlechat-setup-test-cold-import

Conversation

@TeaCup404

Copy link
Copy Markdown
Contributor

Closes #159188

What Problem This Solves

Fixes: extensions/googlechat/src/setup.test.ts fails whenever it runs with a cold Vitest transform cache, which turns the changed-extensions messaging CI shard red for unrelated PRs (for example #158895).

User Impact

User impact: no product change. Contributors whose PRs pull in that shard no longer get false openclaw/ci-gate failures from this test.

Why This Change Was Made

startAccount loads ./channel.runtime.js lazily, and the test's mock of that module imports the real monitor module. On a cold cache, that import takes more than the 1s vi.waitFor budget, so the first lifecycle test sees 0 calls and the late call leaks into the next test. The test now imports the mocked runtime in beforeAll, so the timed waits cover only the lifecycle behavior. Assertions and timeouts are unchanged.

Evidence

Local, Node 24.21.0, OPENCLAW_VITEST_MAX_WORKERS=3, with all Vitest/Vite caches (.cache/vitest, .artifacts/vitest-worker-cache, node_modules/.vite*) deleted before every run:

main @ a1019cb cold runs result
without this change 2 2 failed | 28 passed (30) both times, the same two tests as CI
with this change 3 30 passed (30) every time (~15 s)

The full messaging shard folders run cold with this change (extensions/googlechat/src extensions/nextcloud-talk/src extensions/tlon/src, 3 workers) give Test Files 90 passed (90) and Tests 766 passed (766). oxfmt --check is clean.

CI failures this addresses: https://github.com/openclaw/openclaw/actions/runs/36269525064/job/108481449405 and https://github.com/openclaw/openclaw/actions/runs/36271785340/job/108487654326.

Test cost: one extra import() of an already-mocked module in beforeAll, which the first lifecycle test paid anyway.

Prepared with an AI coding agent.

…cache

`extensions/googlechat/src/setup.test.ts` waits up to 1s (vi.waitFor default)
for the mocked monitor to start. `startAccount` loads `./channel.runtime.js`
lazily, and that mock imports the real monitor module. On a cold transform
cache (every fresh CI shard) that import alone takes longer than 1s, so
"keeps startAccount pending until abort" sees 0 calls and the late call
leaks into the next test ("called once, but got 2 times").

Load the mocked channel runtime in beforeAll so the timed waits only cover
the lifecycle behavior under test.
@clawsweeper

clawsweeper Bot commented Sep 26, 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 channel: googlechat Channel integration: googlechat size: XS labels Sep 26, 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 26, 2026
@clawsweeper

clawsweeper Bot commented Sep 26, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 26, 2026, 5:33 PM ET / 21:33 UTC.

ClawSweeper review

What this changes

Preloads Google Chat’s mocked runtime before setup tests begin so cold module transformation does not consume the lifecycle assertion timeout.

Merge readiness

✅ Ready for maintainer review

The fix remains useful: current main still has the timed lifecycle tests without a cold-import preload, and the PR reports passing cold runs after the change. The linked bug should remain open while this PR is reviewed.

Priority: P2
Reviewed head: 65da6dd754d52152392c1193860fa3ce9b1a0dc8

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused fixture change matches the lazy-import cause and has direct reported cold-run evidence without a concrete review finding.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): For the changed CI test behavior, the PR reports cold-cache execution of the actual Google Chat Vitest suite before and after the fixture change, followed by a passing cold messaging shard; 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 (terminal): For the changed CI test behavior, the PR reports cold-cache execution of the actual Google Chat Vitest suite before and after the fixture change, followed by a passing cold messaging shard; no stored-data contract changes.
Evidence reviewed 7 items Introduced change: The pinned PR delta adds a beforeAll import of the mocked Google Chat runtime; the verified test merge changes the same test file only.
Lazy startup path: Account startup awaits a lazy import of the same runtime module before resolving the webhook path and starting the monitor.
Cold transform inside mock: The runtime mock imports the real monitor module, while the lifecycle helper waits for the monitor mock to be called.
Findings None None.
Security None None.

How this fits together

Google Chat’s Gateway account startup loads its channel runtime on demand, then starts a webhook monitor and publishes lifecycle status. The setup tests mock that runtime and check the resulting monitor calls and status.

flowchart LR
  A[Setup test] --> B[Preload mocked runtime]
  B --> C[Cold module transform]
  C --> D[Start Gateway account]
  D --> E[Monitor call]
  E --> F[Lifecycle assertions]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests +6. Total +6 across 1 file.

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

Review metrics

Metric Value Why it matters
Reported cold-run result 2 failing baseline runs; 3 passing patched runs The reported comparison exercises the cache state responsible for the CI failure.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #159188
Summary: This PR is the candidate fix for the linked cold-cache Google Chat 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 the runtime preload in the test fixture so cold CI transforms finish before lifecycle timing begins, while preserving the existing assertions.

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

Yes. The linked report gives a cold-cache Vitest command and records repeat failures on the pre-fix main revision; this read-only review did not rerun it.

Is this the best way to solve the issue?

Yes. Preloading the exact lazily imported mock removes transform time from the existing wait without widening the timeout or weakening the assertions.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: The test failure disrupts contributor CI for affected shards but does not change the shipped Google Chat runtime.
  • add proof: sufficient: Contributor real behavior proof is sufficient. For the changed CI test behavior, the PR reports cold-cache execution of the actual Google Chat Vitest suite before and after the fixture change, followed by a passing cold messaging shard; no stored-data contract changes.
  • 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. Sufficient (terminal): For the changed CI test behavior, the PR reports cold-cache execution of the actual Google Chat Vitest suite before and after the fixture change, followed by a passing cold messaging shard; no stored-data contract changes.

Label justifications:

  • P2: The test failure disrupts contributor CI for affected shards but does not change the shipped Google Chat runtime.
  • 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. Sufficient (terminal): For the changed CI test behavior, the PR reports cold-cache execution of the actual Google Chat Vitest suite before and after the fixture change, followed by a passing cold messaging shard; no stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. For the changed CI test behavior, the PR reports cold-cache execution of the actual Google Chat Vitest suite before and after the fixture change, followed by a passing cold messaging shard; no stored-data contract changes.

Evidence

What I checked:

  • Introduced change: The pinned PR delta adds a beforeAll import of the mocked Google Chat runtime; the verified test merge changes the same test file only. (extensions/googlechat/src/setup.test.ts:96, 65da6dd754d5)
  • Lazy startup path: Account startup awaits a lazy import of the same runtime module before resolving the webhook path and starting the monitor. (extensions/googlechat/src/gateway.ts:17, 841f6f78e5f6)
  • Cold transform inside mock: The runtime mock imports the real monitor module, while the lifecycle helper waits for the monitor mock to be called. (extensions/googlechat/src/setup.test.ts:44, 65da6dd754d5)
  • Current-main necessity: The fetched main revision retains the mock and timed wait without the PR’s preload; no change to this file occurred between the pinned merge base and fetched main. (extensions/googlechat/src/setup.test.ts:89, 841f6f78e5f6)
  • Reported direct proof: The PR body reports two cold baseline runs with the same two failures, three cold patched runs with all 30 tests passing, and a cold messaging shard with 90 test files and 766 tests passing. These are contributor-reported executions, not runs performed during this read-only review. (65da6dd754d5)
  • Feature history: Recent merged history of the test and Gateway paths includes lifecycle work by Peter Steinberger and Google Chat blocked-status work by Masato Hoshino; shallow blob availability prevented source-line introduction verification. (extensions/googlechat/src/setup.test.ts, 4c66ed561589)

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Masato Hoshino: 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.

steipete added a commit that referenced this pull request Sep 26, 2026
The setup mock imports the real monitor lazily. Cold transforms exceed the
one-second lifecycle assertion wait, then the late monitor call contaminates
the next test. Load the mock in beforeAll; retain the real webhook resolver,
all lifecycle assertions, and existing deadlines. No runtime behavior changes.

Adapts the fix proposed in #159189. Main reproduced two failures both alone
and in the original 109-file messaging CI shard. Validation: 20 cold-cache
standalone runs (30 tests each), three original-shard runs (1,179 tests each),
check:changed with extension test types and lint, and Codex review through P2.
Standalone cold runs took 19-72 seconds including compiler preparation.

Co-authored-by: Gabriel Bogdanovsky <[email protected]>
@steipete

Copy link
Copy Markdown
Contributor

Thanks @TeaCup404! Your fix landed on main as an adaptation in a3dcaa1 (fix(googlechat): preload setup lifecycle runtime fixture), with you credited as co-author. It keeps your approach of loading the setup lifecycle runtime before the tests, so cold transforms no longer eat the lifecycle assertion's wait budget. It was validated with 20 cold-cache standalone runs and three original messaging-shard runs.

Closing this one as superseded by that commit. Much appreciated.

@steipete steipete closed this Sep 27, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 27, 2026
The setup mock imports the real monitor lazily. Cold transforms exceed the
one-second lifecycle assertion wait, then the late monitor call contaminates
the next test. Load the mock in beforeAll; retain the real webhook resolver,
all lifecycle assertions, and existing deadlines. No runtime behavior changes.

Adapts the fix proposed in openclaw#159189. Main reproduced two failures both alone
and in the original 109-file messaging CI shard. Validation: 20 cold-cache
standalone runs (30 tests each), three original-shard runs (1,179 tests each),
check:changed with extension test types and lint, and Codex review through P2.
Standalone cold runs took 19-72 seconds including compiler preparation.

Co-authored-by: Gabriel Bogdanovsky <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: googlechat Channel integration: googlechat 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.

[Bug]: googlechat setup.test.ts lifecycle tests fail on a cold Vitest transform cache

2 participants