Repository navigation
fix: keep Discord capture teardown safe after broker startup failures - #200983
Conversation
|
🦞👀 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. What this changesThis PR permits broker IPC through the Discord capture test fence and repairs resource cleanup after catalog capture construction fails. Example: Background catalog preparation calls net.connect('/tmp/capture.sock') while the Discord capture E2E fence is installed.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it addresses a concrete failure still present on current main, preserves native-resource custody, and has green exact-head CI; no actionable correctness defect was found. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherCatalog worker preparation acquires plugin capture resources through the local spawn broker; attachment and source owners retain responsibility until construction fails safely or native cleanup is confirmed. flowchart TD
A[Discord capture E2E fence] --> B[Local IPC socket]
C[Catalog worker pool] --> D[Plugin capture owner]
D --> E[Retained native source]
E --> F[Broker attachment]
F --> B
B --> G[Spawn broker resource]
G --> E
Technical reviewBest possible solution: Keep the narrow repair in the existing fence, attachment, source, and pool owners while preserving native close receipts after dispatch. Do we have a high-confidence way to reproduce the issue? Current-main source exposes the IPC rejection and rejected-promise cleanup paths, corroborated by the exact-main-parent reproduction recorded in #200372; this review executed no target code. Is this the best way to solve the issue? The patch fixes the producers: it distinguishes IPC from TCP, abandons only undispatched claims, retains failed cleanup with the native source, and stores only successfully acquired capture owners. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 97b03f7428d3. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +13, Tests +34. Total +47 across 5 files. Added test files: 0. View PR surface stats
Preflight sourceSource 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
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 17, 2026, 11:28 PM ET / November 18, 2026, 04:28 UTC. |
|
Merged via squash.
|
…#200983) (cherry picked from commit 929f2e7) Co-authored-by: RomneyDa <[email protected]> Release adaptation: required #200320 companion; safely abandon native factories that never dispatched and retain cleanup obligations after broker startup failure.: (cherry picked from commit f2af7017a4995544bfcdca0001076661681fa6c3)
…openclaw#200983) (cherry picked from commit 929f2e7) Release adaptation: approved 2026.11.7 models replay; see models-hook-safe-v2/REPORT.md. Co-authored-by: RomneyDa <[email protected]>
What Problem This Solves
The Discord transcript capture E2E can fail during teardown when background model catalog preparation opens the local spawn-broker socket. Its network fence mistakes IPC for an unexpected
null:NaNnetwork destination, and failed capture creation then leaves cleanup unable to finish. This signature appeared on five unrelated PR heads within three hours.User Impact
Developers retain the test's unexpected-network protection without rejecting local IPC. Catalog resource construction failures can settle cleanly; genuine cleanup failures remain owned and visible at shutdown. No configuration or public API changes.
Why This Change Was Made
Allow nonempty IPC
pathoptions through the test fence while retaining its TCP host/port checks. Exercise a real IPC connection and negative TCP controls inside the existing E2E.At the production owner, record whether an attachment attempted to dispatch its factory. A connection rejected before dispatch can abandon its uncreated broker claim through the existing
abandonUnattachedcontract. After dispatch, native cleanup receipts remain mandatory. If construction cleanup itself fails, retain that obligation with the native source. The catalog pool stores only an acquired capture owner, so later close does not replay a settled creation failure.Root cause and lifecycle producer inventory
The fence's host/port extraction was the immediate defect (
test/e2e/gateway-transcripts-discord-capture.e2e.test.ts:126). Node normalizesnet.connect(path)to an options object withpath, without host or port. The broker client uses that exact call (src/process/spawn-broker/resource-client.ts:121).Background catalog work is intentional: publication invokes
refreshCommittedProviderCatalogswithout awaiting discovery (src/agents/prepared-model-runtime.ts:590,prepared-model-runtime.refresh-scope.ts:53). Timing decides when the cold pool needs IPC. Pool preparation is joined byWorkerTaskPoolCore.closeandjoinWorkerTaskPreparationCleanups; there is no evidence that this signature requires an unjoined pool-startup defect.Task producers traced through this lifecycle:
closeModelRuntimejoins thempending,nativePending,pendingAuth; generation custody spans acquisitionscaptures, abort controllers and watchdog;stopaborts and joins probestasks, pool task custody; requestfinallystops the watchdog and releases credential batchesgatewayCatalog.rotating/ recovery, registered process-close callback; retirement stops borrowers and closes the poolpreparingRoot, core preparation cleanup,releaseRoot, capture-owner closeagent.wait,startupSettled, Gateway close andcloseSkillsWatchers; test fence stays installed through cleanupPreviously, the rejected connect made
attachment.close()throw beforelease.close()/release(), producingNative resource creation cleanup failed. The pool also cached the rejected capture promise, so its own close rethrew creation failure. Process runtime close correctly aggregates failed cleanup and keeps shutdown retained; this patch fixes the resource producers rather than suppressing that safeguard.Smallest-fix pass completed. Delta: production +22/-9 lines; tests +41/-7 lines. No shared test helper, retries, timeout increases, assertion weakening, skips, baseline or changelog edits.
Evidence
net.connect(path)reproducedunexpected socket destination null:NaN; the fix accepted string/options IPC and allowed loopback TCP, while rejecting a foreign host, foreign port, empty-path TCP and numeric-string TCP.git diff --checkpassed. The pool regression now requires successful close after failed factory creation and adds a synchronous connect-refusal case, retaining the broker-retirement assertion.timeout 180s env OPENCLAW_TEST_RUNTIME=node node scripts/run-vitest.mjs run --config test/vitest/vitest.e2e.config.ts test/e2e/gateway-transcripts-discord-capture.e2e.test.ts --maxWorkers=1. It exited 2 before collection: this worktree has nonode_modules. The pool suite has not run locally; test wall time and CI seconds are unavailable.tsrs/package.json); typechecking remains unverified.timeout 50s crabbox run --timing-json -- CI=1 node scripts/run-vitest.mjs test/e2e/gateway-transcripts-discord-capture.e2e.test.ts --maxWorkers=1failed before allocation because the resolvedascii-boxprovider requiresASCII_BOX_API_KEY. No box or run URL was created. No stress, broad suite, install, container or browser work ran on the production host. PR CI supplies broad proof; the repeat campaign remains uncovered.4a44f2031e866e7ee430d01ece41340cefddac5e, identical to committed head54b6e220fcad67cde9b9f5844a897261c544721b: scoped-clean, no actionable findings. Review included unchanged broker claims, pool preparation/close, catalog request and generation lifetime owners; it did not execute tests or builds.