Repository navigation
fix(test): stop cross-file state leaks in media suites - #116027
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 29, 2026, 2:55 PM ET / 18:55 UTC. ClawSweeper reviewWhat this changesThe branch changes eleven media test files to reset mocked module state and drain pending playback transcodes, preventing shared Vitest workers from leaking state into later media tests. Merge readinessThis test-only repair has credible after-fix evidence and no definite patch defect in the supplied diff, but the current PR is behind Priority: P2 Review scores
Verification
How this fits togetherOpenClaw’s media suite tests fetching, probing, QR rendering, storage, and playback transcoding under shared Vitest workers. Test setup, module mocking, and teardown feed the CI shard that validates media behavior and determines whether later test files see clean state. flowchart LR
A[Media test files] --> B[Shared Vitest workers]
B --> C[Module and mock registry]
B --> D[Playback transcode jobs]
C --> E[Test setup and teardown]
D --> E
E --> F[Media CI shard results]
Decision needed
Why: The patch is test-only and the supplied proof is strong, but shared-worker ordering and module-cache behavior are explicitly base-sensitive; the protected Before merge
Agent review detailsSecurityNone. PR surfaceTests +100. Total +100 across 11 files. View PR surface stats
Review metricsNone. Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Rebase onto current Do we have a high-confidence way to reproduce the issue? Yes, with medium confidence: the PR documents a concrete current-main failure mode where the single playback file passes but the shared-worker Is this the best way to solve the issue? Yes, provisionally: resetting test-owned module/mock state and draining test-created background transcodes is narrower and safer than enabling Vitest isolation or weakening assertions. The final rebased run is still required to establish that this is the best durable cleanup on current AGENTS.md: unclear because the file could not be read completely. Codex review notes: model internal, reasoning high; reviewed against 83aca8a59c7c. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
80cf629 to
0ed6589
Compare
|
Rebased onto current Branch was 13 commits behind; now rebased to Re-ran Three runs rather than one because these failures are order and timing sensitive; a single green run would not distinguish a fix from a lucky scheduling. |
|
Merged via squash.
|
* origin/main: fix(codex): avoid transcript mirror snapshot churn (openclaw#115070) fix(test): stop cross-file state leaks in media suites (openclaw#116027) feat(hooks): add persistent hook session mode (openclaw#75918)
* origin/main: (151 commits) feat(plugins): allow per-turn tool narrowing in prompt hooks (openclaw#114151) docs(hooks): mark pairing hook observation-only (openclaw#116055) docs(control-ui): document composer capability menu (openclaw#115858) fix(build): bound declaration memory use (openclaw#116021) fix: Slack replies recover after gateway startup replay (openclaw#115991) fix(azure-speech): keep valid voices from malformed catalogs (openclaw#115067) fix(agents): prevent model runtime startup timeout (openclaw#116039) fix(ui): explain unavailable MCP tool catalogs (openclaw#115994) fix(skills): run experience review outside released request roots (openclaw#116040) docs(security): add safe Gmail reader setup (openclaw#116041) chore: refresh browser gateway runtime (openclaw#116043) test: isolate gateway sequence lifecycle coverage docs: note gateway reconnect sequence fix test: cover gateway sequence reset on restart test: cover gateway sequence reset on reconnect fix: reset gateway event sequence on reconnect fix(codex): avoid transcript mirror snapshot churn (openclaw#115070) fix(test): stop cross-file state leaks in media suites (openclaw#116027) feat(hooks): add persistent hook session mode (openclaw#75918) fix(memory): return early for blank searches (openclaw#116034) ...
What Problem This Solves
mainis red on thecore-runtime-media-uishard, and the failures rotate rather than repeat, which makes them read as flake and get rerun instead of fixed.Reproduced on clean
main:node scripts/run-vitest.mjs src/media/playback-transcode.test.tsalone → 26/26 passnode scripts/run-vitest.mjs src/media(whole directory, shared workers) → 24 failed across 7 files, 783 passedAnd in CI (
checks-node-compact-large-4, run 30473348999):The repo runs Vitest with
isolate: falsedeliberately, so shared workers surface module-registry and module-state leaks close to whatever introduced them. These are real defects in the tests, not an argument for turning isolation on.Why This Change Was Made
Diagnosis established concrete poisoner→victim edges rather than guessing:
web-media.test.ts→fetch(3 failures),ffmpeg-exec(4),media-probe(9),audio-transcode(5)qr-image.test.ts↔qr-terminal.test.ts— reversing the seed moved 2 terminal failures into 5 image failuresstore.test.ts↔store.outside-workspace.test.ts— reversing order produced 1 versus 8 failuresimage-ops.helpers.test.ts→ Rastermill adapter (1 failure)Two root-cause clusters. The
{ kind: 'preparing' }leak is legitimate playback runtime state (a transcode registry) combined with tests that finished without draining their background work, so a later "already portable" input observed an in-flight job from an earlier file. The rest are leaked module and mock caches, where avi.mockfrom one file survived into a file expecting the real module.Fixes are test-only: reset module state before dynamic imports, unmock and reset afterward, preserve the actual QR and Rastermill exports and error identities rather than substituting stub classes, and await all background transcodes before a test completes. No production code changed — the runtime registries are correct; the tests were not draining them.
User Impact
None at runtime. This restores a trustworthy signal from the
core-runtime-media-uishard so genuine regressions there stop being masked by rotating noise, and unrelated PRs stop being blocked by breakage they did not cause.Evidence
src/mediarun three consecutive times, since these failures are order and timing sensitive: 58 files / 807 tests green each time (12.61s, 11.51s, 12.17s).core-runtime-media-uishard grouping reproduced on Blacksmith Testboxtbx_01kyqg0x52h90562qpqc0st6b3(Actions run 30477215921): passed in 158.68s.pnpm check:test-types, both deadcode lanes (zero unused exports), full lint (zero warnings/errors), formatting,git diff --check: all passing.--isolate, no.skip, no retries, no baseline or ignore-file edits, no weakened assertions.