Repository navigation
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: stale review; fresh review needed. Summary Next step Review history (19 earlier review cycles; latest 8 shown)
|
bee7fb7 to
47b68c1
Compare
|
Addressed the review items in P1 — transport cleanup after admission closes. Confirmed against source: signal-driven restart marks draining synchronously ( Real behavior evidence (also in the PR body):
CI Proof limitation (unchanged, stated honestly): a live Meet meeting with real Chrome departure across a real process restart needs Meet credentials and cannot run here; the evidence above exercises the real admission/close lifecycle in-process with the voice/browser boundary mocked. |
47b68c1 to
49ea240
Compare
|
Addressed the revision-2 review items in P1 — carry shutdown cleanup through the request-entry owner. The review was right: the real close prelude ( Real-behavior evidence at the boundary the review named (real close prelude + real RPC dispatch, replacing the direct-admission stand-in):
CI failures at Remaining honest limitation: a live Meet meeting with real Chrome departure across an actual gateway process restart requires Meet credentials and a real meeting and cannot run here; the evidence above covers the real close prelude, real request entry, real router dispatch, and the real Meet leave path in-process (voice-gateway RPC boundary and browser transport mocked). |
|
CI attribution for the remaining red checks on
|
49ea240 to
3481443
Compare
|
Rebased onto current
Upstream did not touch any of this PR's changed files since the previous base ( |
2476a58 to
f58bbd7
Compare
|
CI attribution for the last red check on
Rebased onto current CI on |
|
Revision 5 ( Real end-to-end topology (all real processes on one host; the only stand-in is the Meet origin itself): real gateway process → real node host (
The e2e exposed a fourth barrier: the close sequence drains received connection work before the Details and full logs are in the PR body Evidence section. @clawsweeper re-review |
|
CI attribution for the red Failure: Reproduction on pure At Upstream fix in flight: #153519 ( |
d385d3a to
c37c079
Compare
|
CI diagnosis for the two red lanes on the previous head (
Local verification on the pushed head Two test-only alignments came with the rebase (no product-code change): the shutdown-admission fixture now mocks |
c37c079 to
dd44b98
Compare
|
Rebased onto current Merge conflict resolution. Main moved past this branch's last base (
Verification on Local-environment notes, none in this PR's delta: Transport-ordering question for the shutdown owner (carried over from the last review): should Meet cleanup be ordered before node socket closure, or is best-effort capture and departure after the existing five-second plugin-service grace acceptable? Current contract in this branch: the drain runs inside |
…scripts never finalize Register a google-meet plugin service so gateway shutdown drains active sessions through the same leave path as googlemeet.leave, finalizing durable transcripts (stoppedAt + summary) and releasing transports. Fixes openclaw#150143
…oses Signal-driven restart draining fences ordinary request roots before plugin services stop, so shutdown cleanup that issues gateway RPCs (Google Meet final caption capture, browser departure, voicecall.end) was rejected with "unavailable during gateway restart" and transcripts could finalize with a failed final capture while the browser stayed joined. Give the close sequence a shutdown-owned cleanup root around pluginServices.stop: the router admits gateway requests from that chain while external requests stay fenced for the whole drain. Also move the google-meet shutdown-service tests into a sibling module (service-shutdown.test.ts) so index.test.ts stops growing past the line-cap ratchet.
…work The close sequence drains received connection work (closing that scope) before the gateway close step runs plugin-service cleanup, so the Meet drain's browser.request dispatches — routed through the canonical request context whose trackExecution tracks into connectionWork — were rejected with "Async work scope is closed". Chrome never clicked Leave call and transcripts could only finalize from already-captured lines. Shutdown-cleanup-chain executions now track into the calling chain's scope (the close's cleanup work) instead of the drained connection scope. Verified end-to-end: a real gateway process joined a Meet capture through a real paired browser node and Chrome 151; on SIGTERM the drain clicked Leave call in the page, wrote stopped_at + a summary row, and the gateway exited cleanly (1.4-1.7s, exit code 0). Without the fix the same run leaves stopped_at NULL, no summary, and no leave click.
The new cleanup-admission regression pushed server-request-context.test.ts past its 1000-line ratchet cap. Move the shared context/client fixtures to server-request-context.test-support.ts (no coverage change).
Rebase adaptations for APIs that changed on main since the original base (a81afcc): - kernel.beginClosePrelude() is no longer exported; the close prelude now runs inside prepareClose, so the request-entry regression drives the real kernel.prepareClose() (same pattern as main's own 'admits exact pending node cleanup replies while close drains'). - gateway-work-admission moved currentRootWork out of GATEWAY_WORK_ADMISSION_STATE into a standalone export; isInsideGatewayShutdownCleanupChain now reads the exported context. - server-request-entry now throws GatewayClientRequestError (UNAVAILABLE, retryable) instead of a bare Error; the merged enter() keeps that richer refusal and adds the cleanup-chain admission condition. - startPluginServices now requires a scheduler; the shutdown-admission test imports the services.test-support.js wrapper (auto test scheduler) and replaces its inline close-deps fixture with the shared createGatewayCloseTestDepsFactory plus server-close.mocks.test-support.js (acp-session-manager, worktree-run-end, scheduler, stopScheduler steps). - google-meet test seams were desloped upstream: the testing export and setCallGatewayFromCliForTests/setPlatformForTests are gone, the voice call gateway moved to openclaw/plugin-sdk/meeting-runtime with renamed exports, and the harness routes runtime.gateway.request into the methods map by default. service-shutdown.test.ts follows main's index.test.ts patterns (spy on callGatewayFromCli + createGoogleMeetToolGatewayForTest, plugin-sdk meeting-runtime mocks). - index.test.ts keeps its net-zero delta: the two upstream-removed low-value Twilio tests stay deleted.
checks-fast-baseline-ratchets failed only in its test-lines slot: this PR's net-new regression lines (+381) exceeded the tree's remaining slack. Record the justified growth in a tracked allocation instead of deleting unrelated coverage, and leave the shared baseline scalar untouched. Each allocated line covers a distinct barrier that rejected the shutdown drain's cleanup RPCs in a real restart run: router admission, the close prelude's request entry lifetime, the drained connection-work scope, the draining close lifecycle, and the google-meet plugin drain itself. Fixes openclaw#150143
dd44b98 to
4b4225d
Compare
|
CI fix for the one red lane on Diagnosis (from the job log, run 42080562822 / job 127433213694). Inside that job only the So the failure is the test-line budget, not a code defect: this PR's 381 net-new regression lines exceeded the tree's remaining slack. Fix ( Why the growth is necessary — each allocated line covers a distinct barrier that rejected the shutdown drain's cleanup RPCs and was reproduced in the real SIGTERM restart run posted earlier:
Local verification on the rebased head (rebased onto Two honest environment notes, neither in this PR's delta:
PR body Evidence section updated with the same diagnosis, allocation justification, and numbers. |
Closes #150143
What Problem This Solves
--mode transcribe) would lose the session entirely when the gateway restarted mid-meeting:openclaw googlemeet statusreported no sessions, the durable transcript stayed unfinalized forever (meeting_transcript_sessions.stopped_atNULL, no row inmeeting_transcript_summaries), and no summary was ever written.browser.requestfor final captions/browser departure,voicecall.endfor the phone transport) were rejected — first at the router withunavailable during gateway restart, then (revision 2) even earlier atGatewayRequestEntryLifetime.enter()withGateway request entry is closed; the transcript bridge could then store a summary after a failed final capture while the browser stayed joined.clawsweeper:queueable-fix/clawsweeper:fix-shape-clear/clawsweeper:source-repro; the ClawSweeper Codex review confirmed the restart gap exists in current main and that no open transcript PR supplies Google Meet shutdown cleanup.Why This Change Was Made
googlemeet.leave— durable transcripts finalize (stoppedAt+ summary rows), transports are released, and per-session cleanup failures are logged without blocking the remaining sessions.MeetingSessionRuntime.leave→ durable transcript stop → transport cleanup); the only missing piece was the plugin-lifecycle connection. Gateway close already invokes registered plugin services (pluginServices.stop), so registering agoogle-meetservice whosestopperforms the drain is the narrowest repair. The shutdown hook only drains an already-initialized runtime; it never instantiates the runtime just to discover there is nothing to clean up.completeGatewayClosenow wrapspluginServices.stop()in a shutdown-owned cleanup root (runWithGatewayShutdownCleanupAdmissioninsrc/process/gateway-work-admission.ts). This is the owner-bound cleanup path the review asked for: the gateway router admits requests issued from the close sequence's own async chain (nested root via the existingAsyncLocalStorageadmission path inserver-methods.ts), while external/ordinary requests stay fenced for the whole drain — the fence is not reopened process-wide. The tracked root also joins the existingwaitForGatewayRestartFenceSettlement/drain accounting, so a stalled cleanup still surfaces in shutdown diagnostics instead of outliving exit.47b68c1): the real close prelude (markClosePreludeStartedinserver-lifecycle.ts) abortsrequestEntryLifetimebeforecompleteGatewayClosestops plugin services, so the drain's in-process RPCs were rejected indispatchGatewayRequestInProcessRaw→GatewayRequestEntryLifetime.enter()before the router ever consulted the cleanup root.enter()now also admits chains that own the shutdown cleanup root (isInsideGatewayShutdownCleanupChain()reads the sameAsyncLocalStorageadmission context the close sequence runspluginServices.stop()in). Cleanup entries stay tracked in the lifetime's active set, sosealAndJoin()still joins them before transports close; external callers never observe the cleanup context and stay fenced for the whole drain, and once entries seal the barrier is absolute again.shutdown step "received connection work"→connectionWork.drain()) before thegateway closestep runspluginServices.stop(). The real gateway's canonical request context bindstrackExecutiontoconnectionWork(server-request-context.ts), so the drain'sbrowser.requestdispatches were rejected with"Async work scope is closed"— Chrome never clicked Leave call, and the failed leave path stalled the whole close (60s+, no exit). Unit tests missed it because their contexts used a caller-scopetrackExecution.trackExecutionnow tracks shutdown-cleanup-chain executions into the calling chain's scope (the close'scleanupWork) instead of the drained connection scope; external requests keep the original binding and still reject after the drain. Regression:server-request-context.test.ts"tracks shutdown cleanup chain executions into the caller scope after connection work drains" (a drained realAsyncWorkScoperejects outside the chain, resolves inside it).extensions/google-meet/service-shutdown.test.tsbecauseextensions/google-meet/index.test.tsis over the line cap and the baseline ratchet rejects any growth there (CIchecks-fast-baseline-ratchetsfailure on the first revision); coverage is unchanged.stopped_at IS NULLrows and re-attaching to still-open Meet tabs (both larger alternatives per the issue); forced-kill scenarios cannot be covered by any in-process hook. No new configuration or storage semantics.MCP_RUNTIME_CLOSE_GRACE_MSviadisposeRuntimeWithShutdownGrace) lets the remaining close steps (channels, harnesses, runtime disposal) advance while the drain is still running, and every cleanup RPC carries its own dispatch deadline, so a hung transport cannot extend the join indefinitely. Per the close sequence's pre-existing contract, retirement still joins plugin-service cleanup and its request entries before transports and the registry close (await pluginServicesCleanup+finishRequestEntriesin the close finally phase) — so a slow Meet leave can extend shutdown completion up to its RPC deadlines, the same join-before-retirement behavior every plugin service already had, now visible because the drain actually executes. Finalization in the overrun case (a leave still running when its dispatch deadlines expire) is not guaranteed; observed live in the real restart e2e: a normal drain completes the whole close in 1.4–1.7s (exit code 0, stopped_at + summary + Leave click), and a deliberately slow leave (page only reaches post-call 8s after the click, past the 5s leave window) still finalizes the transcript (stopped_at + summary written ~400ms after SIGTERM) and exits cleanly in 5.1s with the browser tab released, matching the join-before-retirement contract above.User Impact
stopped_atis set from the live capture, the summary is written, andopenclaw transcriptsno longer shows a dangling session withno summary.md. Saved utterances remain readable either way.stopped_atand a summary row, matching an explicitgooglemeet leave.src/gateway/server-request-entry.ts(cleanup-chain admission insideenter(), covered byserver-request-entry.test.ts"admits shutdown-owned cleanup RPCs through request entry after the close prelude", which drives the realkernel.beginClosePrelude()+ realdispatchGatewayRequestInProcessRaw+ real method registry),src/process/gateway-work-admission.ts+src/gateway/server-close.ts(shutdown-owned cleanup root aroundpluginServices.stop, withsrc/gateway/server-close.shutdown-admission.test.tsnow probing through a real abortedGatewayRequestEntryLifetimeduring the real draining close lifecycle),src/gateway/server-request-context.ts(shutdown-cleanup-chain executions track into the caller's scope once connection work has drained, covered byserver-request-context.test.ts),extensions/google-meet/index.ts(newapi.registerServiceshutdown drain + initialized-runtime peek), and the regression tests inextensions/google-meet/service-shutdown.test.ts("registers a shutdown service that leaves active sessions through the leave path", "keeps draining remaining sessions when one leave fails during shutdown", "stops cleanly when the runtime was never initialized").Evidence
990fc1bd88b; real gateway kernel close prelude (kernel.beginClosePrelude()), real in-process RPC dispatch (dispatchGatewayRequestInProcessRaw) with a real method registry, real gateway close lifecycle (prepareGatewayClose/completeGatewayClose), realstartPluginServiceshost, realGatewayRequestEntryLifetime, and the real process-wide admission module (src/process/gateway-work-admission.ts) exercised insrc/gateway/server-request-entry.test.ts+src/gateway/server-close.shutdown-admission.test.ts; realGoogleMeetRuntime/MeetingSessionRuntimeleave path exercised in-process (external voice-gateway RPC boundary mocked).A full real-process end-to-end restart run (see the next two evidence items) additionally exercised the real gateway process, a real paired node host (
openclaw node runwithbrowser.proxy+googlemeet.chrome), a real headless Chrome 151 managed through CDP by the browser plugin, and the real transcript SQLite state database. The only external stand-in was the Google Meet origin itself: a local TLS server serving a stateful Meet-like page (pre-join → in-call with rolling caption rows → post-call) that satisfies the realmeetStatusScript/meetTranscriptScript/meetLeaveScriptDOM contracts, reached through Chrome's--host-resolver-rulesmapping so the plugin still dispatches againsthttps://meet.google.com/...URLs.761ace8b68f):markGatewayRestartDraining→ real close prelude abortingrequestEntryLifetime→ realcompleteGatewayClose), a plugin service stop that issues gateway requests passes both shutdown barriers:GatewayRequestEntryLifetime.enter()admits the chain because it owns the shutdown cleanup root, and the router admits it through the same root — so the Google Meet drain'sbrowser.requestfinal capture/departure andvoicecall.endRPCs reach their handlers instead of being rejected withGateway request entry is closed/unavailable during gateway restart. Cleanup entries stay tracked in the lifetime's active set, sosealAndJoin()still joins them before transports close; ordinary external requests stay fenced before, during, and after cleanup (verified by real dispatches that keep rejecting withGateway request entry is closed), and the cleanup root settles so drain accounting is unchanged. At the plugin level, invoking the registered service'sstopwith a joined session still ends the call via the real leave path (endMeetVoiceCallGatewayCallinvoked,googlemeet.statusreportsended); one failing leave does not strand the remaining sessions;stopwithout prior runtime use is a clean no-op. Transcript DB finalization on leave (stoppedAt+ summary rows) is exercised by the existing durable-transcript coverage (src/meeting-bot/session-runtime.test.ts), which this shutdown path reuses verbatim.requestEntryLifetimebarrier still rejected them (Gateway request entry is closed) — both proven by the RED runs above — so final captions were lost, the browser could stay joined, andstopped_atstayed NULL (issue repro steps 2–4).meet.google.comorigin (the end-to-end run below substitutes the Meet origin with a local TLS stand-in page that satisfies the plugin's real page-script DOM contracts — every process boundary in between is real, including the gateway process, node host, Chrome 151, CDP, RPC routing, and the transcript SQLite database); forced SIGKILL termination (not coverable by any in-process shutdown hook); CI lanes pending on this PR.server-close.plugin-failure.test.tsrestart-mode harness. The real-process e2e below closes the remaining gap end to end (real signal → real drain → real Chrome departure click in a real page → real transcript finalization in the gateway SQLite → real exit code 0), with the Meet origin itself replaced by the local stand-in page.49ea240a07d; revision-4 remaining items addressed by the real-process e2e below and by761ace8b68f(connection-work tracking): (1) real restart proof with final transcript rows,stopped_at, and Chrome departure now observed live (the e2e's Meet origin stand-in is documented honestly — no Meet credentials were used, and no Google service was contacted); (2) slow-cleanup overrun observed live (8s slow leave: transcript still finalizes ~400ms after SIGTERM, gateway exits cleanly in 5.1s); (3) the e2e itself exposed a fourth barrier the in-process tests could not see — the drainedconnectionWorkscope rejecting the drain's dispatches — fixed in761ace8b68fwith its own regression. CI is green onf58bbd72ab5(215 checks, 0 failures).ca97ceb8f9b): the only red lane on the previous head waschecks-node-compact-large-10→src/config/sessions/session-history-archive-pruning.admission.test.ts > keeps drain archive maintenance inside its writer FIFO (cold: true, outcome: revoked)(promise resolved "undefined" instead of rejecting). That file is untouched by this PR; the run was based on main123b8acdcd8, which predates the upstream hardening of that test (bef4401fbc5addsclearOpenClawAgentIntegrityVerificationinside the revoke path). Rebased onto current main and re-ran locally:session-history-archive-pruning.admission.test.ts18/18 passed. The rebase also required two test-only alignments: the shutdown-admission fixture now mocksmaintenance.stopPeriodicTasks(upstream replacedstopTelemetryChecks, which produced aperiodic-maintenanceshutdown warning), and a duplicated copy of the request-context regression test was removed. Local re-verification on the rebased head: gateway suites (server-close,server-close.shutdown-admission,server-request-entry,server-request-context,gateway-work-admission,service-shutdown) green both combined and re-run individually,extensions/google-meet216 passed (extensions lane) + 179 passed (database-workers lane:index.test.ts,index.create.test.ts), tsgotsconfig.extensions.test.json0 errors,pnpm tsgo:coreexit 0, line-cap and assertion-safety ratchets OK.dd44b98d7f2→ this revision4b4225de979):checks-fast-baseline-ratchetswas the only red lane, and inside that job only thetest-linesslot failed:Test lines: 6500665; ceiling: 6500295; over by: 370; net delta: +381.Every other slot in the same job was green (max-lines, line-cap, assertion-safety, database-dialect, timeout-race, mock-exports, config-docs, plugin-inventory, database-worker). Cause: this PR's 381 net-new regression lines exceeded the tree's remaining slack; nothing in the failure is a code defect. This revision takes the documented route (docs/ci/local-proof.md→ test-line budget,docs/help/testing/writing-tests.md→ Cost budget) and adds one tracked record,config/test-lines-allocations/google-meet-shutdown-drain-150143.txt= 381 — exactly this PR's net test-line delta, which is also the most the allocation-credit guard allows (credit ≤ added test lines). The sharedconfig/test-lines-baseline.txtscalar is untouched, and no unrelated test was deleted to pay for the growth.Why the growth is necessary: each allocated line covers a distinct barrier that rejected the shutdown drain's cleanup RPCs and was reproduced in the real restart run recorded above — router admission (
gateway-work-admission.test.ts), the close prelude's request-entry lifetime (server-request-entry.test.ts), the drained connection-work scope (server-request-context.test.ts+ its newtest-supportfixture), the real draining close lifecycle (server-close.shutdown-admission.test.ts), and the plugin drain itself (extensions/google-meet/service-shutdown.test.ts, split out of the over-capextensions/google-meet/index.test.tsbecause the line-cap ratchet rejects growth there). None duplicates existing coverage; dropping any one file would leave a barrier that a real SIGTERM run hit completely untested.Rebased onto
origin/maind1b1e78b445(the rebase leaves this PR's diff patch-id unchanged and upstream touched none of the 12 changed files). Local verification on the rebased head: