Repository navigation
fix(test): prepared model-catalog worker tests time out on loaded hosts while polling hook markers - #162572
Conversation
Catalog tests polled marker files and capture removal against 1,000 ms expect.poll/vi.waitFor and 30,000 ms marker deadlines. Healthy credential preparation, worker dispatch, and asynchronous capture release could outlast those observation deadlines on loaded hosts. Await broadcast worker-entry receipts, synchronous parent callback events, and the capture owner's release promise instead. Observe actual catalog acquisition settlement and consult durable marker records when replies beat receipts. Bind waits to the Vitest test signal so abort reaches cleanup, and keep catalog observation opt-in to avoid competing spies. Remove the unused marker poll. Preserve product and test timeouts and the existing lifecycle, custody, queueing, and catalog assertions.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed October 1, 2026, 5:15 AM ET / 09:15 UTC. ClawSweeper reviewWhat this changesThe PR replaces catalog-worker test polling with worker-entry receipts, parent callbacks, and observed cleanup promises while preserving existing assertions and timeouts. Merge readiness✅ Ready for maintainer review This remains a useful, focused test-reliability fix that current main does not contain. No actionable correctness or security defect was found in the introduced changes. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw prepares model catalogs through parent-side credential preparation and background worker threads. These integration tests exercise catalog refresh, shared-worker queueing, cancellation, and captured-plugin cleanup. flowchart TD
A[Catalog test request] --> B[Parent credential preparation]
B --> C[Catalog worker]
C --> D[Fixture marker and entry receipt]
D --> E[Test waits for owned signal]
E --> F[Catalog and lifecycle assertions]
G[Test cancellation] --> H[Release barriers and retire workers]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceTests +272. Total +272 across 10 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Synchronize these integration tests on owner-produced events and cleanup completion while retaining their catalog, queueing, and retirement contracts. Do we have a high-confidence way to reproduce the issue? Yes: a 1,500 ms fixture-entry delay exceeds current main's default 1 s polling window, and supplied Testbox comparisons report the intended original failures and fixed passes. This review inspected source without executing tests. Is this the best way to solve the issue? Yes: the patch extends the existing receipt owner and observes real callbacks and release promises, preserving assertions and avoiding longer observation deadlines or production-only test hooks. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against b3e5991d4a6d. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
…ts while polling hook markers (openclaw#162572) The prepared model-catalog worker integration tests waited for the catalog worker thread to reach its augmentation hook by expect.poll-ing marker files with the default 1 s deadline. On a loaded host, worker dispatch and catalog preparation outlast it. These fixtures run inside a product-owned worker thread, and the supersession fixture blocks its thread with a synchronous spin right after reporting entry, so a socket receipt could not leave the thread until the spin ended. test/helpers/fixture-receipts.ts therefore gains a worker-thread client: the channel also listens on a uniquely named BroadcastChannel, and fixtureReceiptWorkerClientSource() posts receipts synchronously (unref'd) so the test thread receives them while the worker blocks. Socket and broadcast receipts share one record/waiter path and malformed-receipt failure. Fixtures still write their markers before reporting, and waits raced against an operation consult that durable record. No product source, test timeout, product timeout, or assertion meaning changed. Part of the polling audit from openclaw#162274. Proof on Blacksmith Testbox: delayed-dispatch fault probes fail the original bytes and pass these bytes, including a supersession probe that requires the receipt to arrive while the worker still spins; forced-abort probes reach cleanup; 100/100 standalone runs across the five files; 3/3 replays of bundle-infra-small-runtime-15; targeted tsgo; Codex autoreview and ClawSweeper clean.
What Problem This Solves
Fixes: the prepared model-catalog worker integration tests fail on a loaded host when the catalog worker thread takes longer than about 1 s to reach its augmentation hook, because they
expect.pollmarker files with the default 1 s deadline.User Impact
No user-visible change. The
prepared-model-catalog-worker*.integrationsuites stop failing spuriously on slow machines; a hook that is never reached now fails at the Vitest test timeout instead of racing a 1 s timer.Why This Change Was Made
Part of the polling audit from #162274. These fixtures run inside a product-owned worker thread, and one of them (supersession) blocks its thread with a synchronous spin right after reporting entry, so a socket receipt could not leave the thread until the spin ended.
test/helpers/fixture-receipts.tstherefore gains a worker-thread client:openFixtureReceiptChannel()also listens on a uniquely namedBroadcastChannel, andfixtureReceiptWorkerClientSource()posts receipts synchronously (unref'd) so the test thread receives them even while the worker blocks. Socket and broadcast receipts share one record/waiter path and the same malformed-receipt failure. Fixtures keep writing their marker files before reporting, and waits raced against an operation the worker can settle consult that durable record (the #162274 rule). No product source, test timeout, product timeout, or assertion meaning changed.Release-note context: test-only change, no user-visible behavior change.
Per-site conversions
Old lines are the work-order/original-byte locations. Category 3 includes the explicitly authorized worker-thread broadcast variant of fixture receipts.
src/agents/prepared-model-catalog-worker.custody.integration.test.ts:123expect.poll(existsSync)/ 1,000 msrelease()promise; then direct removal assertion / 1prepared-model-catalog-worker.ts:177suppliescapture.release;worker-task-pool-retirement.ts:189joins termination before resource release;plugin-source-capture-directory.ts:723awaits removal before release settles.src/agents/prepared-model-catalog-worker.integration.test.ts:238expect.poll(readFileSync)/ 1,000 msstartbefore broadcast, held hook, and reply; original exact file-content assertion remains.src/agents/prepared-model-catalog-worker.integration.test.ts:416waitForMarker/ 30,000 msentereddeferred / 1src/agents/prepared-model-catalog-worker.integration.test.ts:430waitForMarker/ 30,000 msaborteddeferred / 1src/agents/prepared-model-catalog-worker.integration.test.ts:676expect.poll(readFileSync)/ 30,000 mssrc/agents/prepared-model-catalog-worker.integration.test.ts:864waitForMarker/ 30,000 mssrc/agents/prepared-model-catalog-worker.integration.test.ts:918waitForMarker/ 30,000 mssrc/agents/prepared-model-catalog-worker.integration.test.ts:951waitForMarker/ 30,000 mspostMessageenqueues synchronously; the test thread receives while the worker spins. Existingstart-only assertion proves interruption before completion.src/agents/prepared-model-catalog-worker.pool.integration.test.ts:148expect.poll(readFileSync)/ 1,000 mssrc/agents/prepared-model-catalog-worker.pool.integration.test.ts:276expect.poll(readFileSync)/ 1,000 mssrc/agents/prepared-model-catalog-worker.pool.integration.test.ts:422expect.poll(readFileSync)/ 1,000 mssrc/agents/prepared-model-catalog-worker.pool.integration.test.ts:477expect.poll(readFileSync)/ 1,000 mssrc/agents/prepared-model-catalog-worker.pool.integration.test.ts:589expect.poll(readFileSync)/ 1,000 mssrc/agents/prepared-model-catalog-worker.pool.integration.test.ts:746expect.poll(readFileSync)/ 1,000 mssrc/agents/prepared-model-catalog-worker.retirement.integration.test.ts:84waitForMarker/ 30,000 msaborteddeferred / 1src/agents/prepared-model-catalog-worker.scope.integration.test.ts:307vi.waitFor(readFileSync)/ 1,000 msentereddeferred / 1parent\ncontent assertion remains.src/agents/prepared-model-catalog-worker.scope.integration.test.ts:373waitForMarker/ 30,000 msaborteddeferred / 1Worker races observe the actual
loadCatalog()acquisition promise, not only the bounded foregroundloadFullModelCatalog()result.prepared-model-runtime.catalog-access.ts:668permits a foreground return while background acquisition continues. The fixture observer is opt-in for integration and pool suites, andcatalogFixtureEventBeforeSettlementconsults the durable start record if acquisition settles before delivery of its independent receipt. Parent event waits useawaitGateBeforeSettlement; all new waits use the Vitest test signal throughwithinTest. Parameterized parent tests useit.for.The shared receipt helper adds only the approved transport: unique
broadcastName, common schema/store/waiters/failure handling, receiver closure inclose(), and a lazy unreferenced ESM worker client. Socket receipts remain available for product-spawned processes. Node v24.21.0's installedinternal/worker/iosource was inspected:postMessagedirectly invokes the handle at lines 421–429 andunrefdelegates to the handle at lines 454–458. The real supersession proof below verifies the cross-thread behavior.Stops, residuals, and deliberately unconverted sites
No requested site remains unconverted, and no new residual filesystem/process poll was added. The now-unused
waitForMarkerwas removed after a reference search across all consumers of the catalog fixture module. Existing in-memory catalog/publication/pool-state checks, sharedwaitForWorkers, and fixture input barrier watchers remain outside the 17 requested observation sites. The existing five-second bounded foreground behavior and its result/rejection assertions remain unchanged.Evidence
All proof ran on Blacksmith Testbox through
node scripts/crabbox-wrapper.mjsone-shot runs; no local Vitest.Fault and forced-abort probes
Four healthy-path delay comparisons passed: original failed and fixed passed for integration augmentation entry, pool stable-catalog entry, pool generic augmentation entry, and scoped parent auth entry. The exact same 1,500 ms delay was applied to original and fixed fixture bytes, conditioned on the existing held barrier, and reverted byte-exactly. These cover all class-A sites through their shared fixture families.
Original failure evidence:
Matcher did not succeed in time, while expecting the additionalstartrecord.Matcher did not succeed in time, while expecting the marker to differ.AssertionError: expected '' to contain 'parent\n'.Final fault comparisons: 4/4 original failures for the intended assertion; 4/4 fixed passes. See
initial-proof-compact.logandfinal-proof.log.Forced-abort proof: 3/3 validated. Parent deferred used a temporary 3,000 ms timeout; receipt and capture observation used temporary 10,000 ms timeouts. Each log shows the selected wait, the first-finally marker, and the no-live-worker check before fallback termination. Parent:
created:0, threadIds:[]; capture and worker receipt: one worker,threadId:-1. Exact input bytes were restored. Seefinal-proof-continuation.log.Worker-thread spin proof passed with
SPIN_RECEIPT_BEFORE_SUPERSESSIONandSPIN_TERMINATED_BEFORE_END. The originalstart-only final assertion remained intact. This proves delivery while the 10,000 ms synchronous spin was active. Seesweep-proof.log.The earlier candidate also passed 100/100 standalone runs and the owning shard; it exposed the one type error described above. It is retained as evidence and is not substituted for the final frozen-byte proof.
Standalone repetitions (flake-triage bar)
Final candidate: 100/100 standalone file runs, one owning-shard replay, targeted core-test typecheck, core typecheck, and root-test/helper typecheck all passed. Four different files ran concurrently at most, each with a distinct cache, and no file overlapped itself. Candidate hashes in
closure-proof.logmatch the committed files.Commands:
All remote payloads used exactly the one-shot shape:
createNodeTestShardBundles({ includeReleaseOnlyToolingShards: true })selectedbundle-infra-small-runtime-15for all five changed test files. Its exact{shard_name, configs, includePatterns}group is recorded underOWNING_SHARDSin the final log. No release-only owner was omitted.tsgo-core-testtsgo-coretsgo-rootshard-bundle-infra-small-runtime-15Owning CI shard replays
initial-proof.logtbx_01m3v0yer2ydcqj0bbsqqb8j7finitial-proof-compact.logtbx_01m3v188c44yr8gg17bjqksc47final-proof.logtbx_01m3v2a6wbcfdt40r8gak0mt89final-proof-continuation.logtbx_01m3v2s7q9qqrabnx67yxwdwjqsweep-proof.logtbx_01m3v3ejds9ngnbwyb6qrmqzm7closure-proof.logtbx_01m3v6a647jrd7h13k23kdx5d1Each one-shot wrapper recorded its owned Testbox as stopped. No kept lease or manually reused ID was created. Some failed proof-tool runs emitted a portal-sync warning after cleanup; their wrapper exit and timing JSON remain the outcome evidence.
Coordinator shard replays (flake-triage bar: 3 total with the lane's replay above)