Skip to content

fix(google-meet): gateway restart drops active Meet captures and transcripts never finalize - #150588

Open
LiuwqGit wants to merge 7 commits into
openclaw:mainfrom
LiuwqGit:feat/issue-150143-meet-shutdown-cleanup
Open

LiuwqGit wants to merge 7 commits into
openclaw:mainfrom
LiuwqGit:feat/issue-150143-meet-shutdown-cleanup

Conversation

@LiuwqGit

@LiuwqGit LiuwqGit commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

AI-assisted: yes

Closes #150143

What Problem This Solves

  • Fixes an issue where users running a Google Meet capture (--mode transcribe) would lose the session entirely when the gateway restarted mid-meeting: openclaw googlemeet status reported no sessions, the durable transcript stayed unfinalized forever (meeting_transcript_sessions.stopped_at NULL, no row in meeting_transcript_summaries), and no summary was ever written.
  • Also fixes the transport-admission defect ClawSweeper flagged on the first two revisions (P1): on SIGTERM/SIGUSR1 restarts the run loop closes root-work admission and the close prelude aborts the gateway request entry before plugin services stop, so the shutdown drain's gateway RPCs (browser.request for final captions/browser departure, voicecall.end for the phone transport) were rejected — first at the router with unavailable during gateway restart, then (revision 2) even earlier at GatewayRequestEntryLifetime.enter() with Gateway request entry is closed; the transcript bridge could then store a summary after a failed final capture while the browser stayed joined.
  • Related: Meeting transcripts: gateway restart during a Meet capture loses the session; transcript never finalized (stopped_at NULL, no summary) #150143 carries 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

  • Intended outcome: On gateway shutdown, the Google Meet plugin now drains every active session through the exact same leave path as an explicit googlemeet.leave — durable transcripts finalize (stoppedAt + summary rows), transports are released, and per-session cleanup failures are logged without blocking the remaining sessions.
  • The plugin already owns a complete leave/finalization flow (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 a google-meet service whose stop performs 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.
  • Shutdown cleanup admission (core fix): completeGatewayClose now wraps pluginServices.stop() in a shutdown-owned cleanup root (runWithGatewayShutdownCleanupAdmission in src/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 existing AsyncLocalStorage admission path in server-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 existing waitForGatewayRestartFenceSettlement/drain accounting, so a stalled cleanup still surfaces in shutdown diagnostics instead of outliving exit.
  • Request-entry cleanup admission (revision 3, P1 from the ClawSweeper review of 47b68c1): the real close prelude (markClosePreludeStarted in server-lifecycle.ts) aborts requestEntryLifetime before completeGatewayClose stops plugin services, so the drain's in-process RPCs were rejected in dispatchGatewayRequestInProcessRaw → GatewayRequestEntryLifetime.enter() before the router ever consulted the cleanup root. enter() now also admits chains that own the shutdown cleanup root (isInsideGatewayShutdownCleanupChain() reads the same AsyncLocalStorage admission context the close sequence runs pluginServices.stop() in). Cleanup entries stay tracked in the lifetime's active set, so sealAndJoin() 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.
  • Connection-work tracking admission (revision 5, found by a real end-to-end restart run): the close sequence drains received connection work (shutdown step "received connection work" → connectionWork.drain()) before the gateway close step runs pluginServices.stop(). The real gateway's canonical request context binds trackExecution to connectionWork (server-request-context.ts), so the drain's browser.request dispatches 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-scope trackExecution. trackExecution now tracks shutdown-cleanup-chain executions into the calling chain's scope (the close's cleanupWork) 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 real AsyncWorkScope rejects outside the chain, resolves inside it).
  • The google-meet shutdown-service tests moved to extensions/google-meet/service-shutdown.test.ts because extensions/google-meet/index.test.ts is over the line cap and the baseline ratchet rejects any growth there (CI checks-fast-baseline-ratchets failure on the first revision); coverage is unchanged.
  • Out of scope: startup reconciliation of historically orphaned stopped_at IS NULL rows 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.
  • Highest-risk area: gateway shutdown sequencing — a slow leave could delay shutdown.
  • How is that risk mitigated? Sessions drain sequentially through the existing per-meeting lock, and per-session errors are caught and logged so one failed leave cannot strand the others. The five-second plugin-service grace (MCP_RUNTIME_CLOSE_GRACE_MS via disposeRuntimeWithShutdownGrace) 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 + finishRequestEntries in 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

  • After a gateway restart (graceful stop/drain), meeting transcripts captured before the restart are finalized: stopped_at is set from the live capture, the summary is written, and openclaw transcripts no longer shows a dangling session with no summary.md. Saved utterances remain readable either way.
  • Success criteria: with an active Meet capture, stopping the gateway leaves the session through the normal leave path; the transcript session row gets stopped_at and a summary row, matching an explicit googlemeet leave.
  • What should reviewers focus on? src/gateway/server-request-entry.ts (cleanup-chain admission inside enter(), covered by server-request-entry.test.ts "admits shutdown-owned cleanup RPCs through request entry after the close prelude", which drives the real kernel.beginClosePrelude() + real dispatchGatewayRequestInProcessRaw + real method registry), src/process/gateway-work-admission.ts + src/gateway/server-close.ts (shutdown-owned cleanup root around pluginServices.stop, with src/gateway/server-close.shutdown-admission.test.ts now probing through a real aborted GatewayRequestEntryLifetime during 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 by server-request-context.test.ts), extensions/google-meet/index.ts (new api.registerService shutdown drain + initialized-runtime peek), and the regression tests in extensions/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

  • Real environment tested: git worktree rebased onto origin/main 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), real startPluginServices host, real GatewayRequestEntryLifetime, and the real process-wide admission module (src/process/gateway-work-admission.ts) exercised in src/gateway/server-request-entry.test.ts + src/gateway/server-close.shutdown-admission.test.ts; real GoogleMeetRuntime/MeetingSessionRuntime leave 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 run with browser.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 real meetStatusScript/meetTranscriptScript/meetLeaveScript DOM contracts, reached through Chrome's --host-resolver-rules mapping so the plugin still dispatches against https://meet.google.com/... URLs.
  • Exact steps or commands run after this patch:
    # RED/GREEN at the real request-entry boundary (same tests, with vs without
    # the enter() cleanup-chain admission in src/gateway/server-request-entry.ts):
    node scripts/run-vitest.mjs run src/gateway/server-request-entry.test.ts \
      src/gateway/server-close.shutdown-admission.test.ts
    # Post-rebase affected suites + full google-meet extension suite:
    node scripts/run-vitest.mjs run src/gateway/server-close.test.ts \
      src/gateway/server-close.shutdown-admission.test.ts src/gateway/server-request-entry.test.ts \
      src/process/gateway-work-admission.test.ts src/gateway/server-in-process-dispatch.abort.test.ts \
      src/gateway/server-in-process-dispatch.error-cause.test.ts \
      src/gateway/server-in-process-execution-lifetime.test.ts extensions/google-meet/
    node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.extensions.test.json --incremental \
      --tsBuildInfoFile .artifacts/tsgo-cache/extensions-test.tsbuildinfo
    node scripts/run-tsgo.mts -b test/tsconfig/tsconfig.core.test.gateway-server.json --builders 1
    node --import ./scripts/tsx.mjs scripts/check-line-cap-ratchet.mts --base origin/main
    node --import ./scripts/tsx.mjs scripts/check-assertion-safety-ratchet.mts --base origin/main
    skills/fix-pr/scripts/validate.sh src/gateway/server-request-entry.ts \
      src/gateway/server-request-entry.test.ts src/gateway/server-close.shutdown-admission.test.ts \
      src/process/gateway-work-admission.ts extensions/google-meet/service-shutdown.test.ts
  • Evidence after fix:
    # RED — real close prelude (kernel.beginClosePrelude) + real in-process dispatch,
    # WITHOUT the enter() cleanup-chain admission:
    × server-request-entry.test.ts > admits shutdown-owned cleanup RPCs through
      request entry after the close prelude
      → Error: Gateway request entry is closed
    × server-close.shutdown-admission.test.ts > keeps plugin service cleanup admitted
      after restart draining fences ordinary requests
      → AssertionError: expected [ 'plugin-services' ] to strictly equal []
    Tests  2 failed | 13 passed (15)
    
    # GREEN — with isInsideGatewayShutdownCleanupChain() consulted in enter():
    ✓ admits shutdown-owned cleanup RPCs through request entry after the close prelude
      (cleanup-chain dispatch reaches the real handler: { ok: true, payload: { cleaned: true } })
    ✓ keeps plugin service cleanup admitted after restart draining fences ordinary requests
    Tests  15 passed (15)
    
    # Real-module probes (tsx against the real server-request-entry.ts + gateway-work-admission.ts,
    # real restart ordering: markGatewayRestartDraining → lifetime.beginClose → cleanup chain):
    # before fix — cleanup RPC rejected at the entry barrier the review pointed at:
    {"probe":"plugin-service-stop-rpc-during-drain","admitted":false,"error":"Gateway request entry is closed"}
    # after fix — cleanup chain admitted, external requests fenced before/during/after cleanup:
    {"probe":"external-ordinary-request-during-drain","admitted":false,"error":"Gateway request entry is closed"}
    {"probe":"plugin-service-stop-rpc-during-drain","admitted":true}
    {"probe":"router-root-admission-in-cleanup-chain","admitted":true}
    {"probe":"external-ordinary-request-after-cleanup","admitted":false,"error":"Gateway request entry is closed"}
    
    # Post-rebase affected suites (origin/main 990fc1bd88b):
    gateway close/entry/dispatch suites:  Test Files  6 passed (6)   Tests  107 passed (107)
    src/process/gateway-work-admission.test.ts:  Tests  41 passed (41)
    extensions/google-meet/ (full):  Test Files  29 passed (29)   Tests  395 passed (395)
    tsgo test/tsconfig/tsconfig.extensions.test.json:  0 errors
    tsgo core.test.gateway-server shard:  exit 0
    check-line-cap-ratchet: Line-cap ratchet OK: 9 changed source files; no new violations.
    check-assertion-safety-ratchet: exit 0
    validate.sh (oxfmt + oxlint + related tests + tsgo:core):  [validate] 全部通过 ✅
    
  • Real-process end-to-end restart evidence (added for the revision-4 "needs proof" items; commit 761ace8b68f):
    # Topology: one host, all real processes; only the Meet origin is a local stand-in.
    #   fake-meet-server.mjs (TLS 127.0.0.1:8443)  <- Chrome --host-resolver-rules MAP meet.google.com 127.0.0.1:8443
    #   real gateway process (openclaw gateway run, transcripts enabled, google-meet + browser plugins)
    #   real node host process (openclaw node run --commands browser.proxy,googlemeet.chrome)
    #   real headless Chrome 151 (browser plugin managed CDP)
    #   real CLI: openclaw googlemeet join https://meet.google.com/red-shut-run --transport chrome --mode transcribe
    # Then: kill -TERM <gateway> and observe the page event log + the gateway's SQLite.
    RED   (both fixes removed — reproduces main):  SIGTERM -> gateway exits 449ms (no drain)
          meeting_transcript_sessions: stopped_at = NULL, summaries = 0 rows, leave-clicked = 0
          (issue #150143 repro: orphaned capture, transcript never finalizes)
    
    GREEN (this PR, real leave through the real page):
          SIGTERM 08:02:24.612 -> gateway exit code=0 after 1734ms
          leave-clicked at 08:02:25.278, post-call-shown at 08:02:25.279   (real Chrome Leave-call click)
          stopped_at = 2026-09-18T08:02:25.175Z (SIGTERM+~400ms), summaries = 1 row,
          utterances = 21 rows captured live from the caption stream before the restart,
          summary participants = [Ada Lovelace, Grace Hopper], overview/decisions/actionItems
          generated from the real captured lines by the real heuristic summarizer.
          googlemeet transcript <id> before the restart already returned live caption lines.
    
    SLOW  (same run, page only reaches post-call 8s after the leave click):
          SIGTERM -> stopped_at + summary written SIGTERM+364ms, gateway exit code=0 after 5060ms
          leave-clicked = 13 (persistent clicks across the leave window); the post-call switch
          itself lands past the 5s leave deadline, so browser tab release is best-effort here —
          matching the overrun caveat above (transcript finalization still guaranteed by the
          final capture, which had already collected the caption buffer).
    
    # The GREEN/SLOW runs first failed before 761ace8b68f with exactly:
    #   "Browser control could not leave the Meet tab: Async work scope is closed"
    # and the gateway then never exited (>60s) — see the connection-work bullet above.
    
    # Post-fix unit/validate: server-request-context.test.ts + server-request-entry.test.ts +
    # server-close.shutdown-admission.test.ts + gateway-work-admission.test.ts: 79 passed;
    # validate.sh (oxfmt + oxlint + related tests + tsgo:core): all green.
    
  • Observed result after fix: during a real restart drain (markGatewayRestartDraining → real close prelude aborting requestEntryLifetime → real completeGatewayClose), 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's browser.request final capture/departure and voicecall.end RPCs reach their handlers instead of being rejected with Gateway request entry is closed / unavailable during gateway restart. Cleanup entries stay tracked in the lifetime's active set, so sealAndJoin() still joins them before transports close; ordinary external requests stay fenced before, during, and after cleanup (verified by real dispatches that keep rejecting with Gateway request entry is closed), and the cleanup root settles so drain accounting is unchanged. At the plugin level, invoking the registered service's stop with a joined session still ends the call via the real leave path (endMeetVoiceCallGatewayCall invoked, googlemeet.status reports ended); one failing leave does not strand the remaining sessions; stop without 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.
  • Before evidence (optional, visual changes encouraged): before the patch, nothing connected gateway shutdown to the Meet session runtime (no plugin service). Revision 1 registered the service but the drain's RPCs were rejected by router admission during restart draining; revision 2 added the cleanup root but the real close prelude's earlier requestEntryLifetime barrier 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, and stopped_at stayed NULL (issue repro steps 2–4).
  • What was not tested: a meeting on the real meet.google.com origin (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.
  • Proof tier: L3 (real-process end-to-end restart: signal → drain → Chrome departure → transcript finalization → clean exit)
  • Proof limitations: the in-process suites mock the external voice-gateway RPC boundary and browser transport; the full signal-to-exit run loop is covered by the existing server-close.plugin-failure.test.ts restart-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.
  • Review state: revision-2 P1 (request-entry owner boundary) addressed in 49ea240a07d; revision-4 remaining items addressed by the real-process e2e below and by 761ace8b68f (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 drained connectionWork scope rejecting the drain's dispatches — fixed in 761ace8b68f with its own regression. CI is green on f58bbd72ab5 (215 checks, 0 failures).
  • CI rediagnosis (rebase onto ca97ceb8f9b): the only red lane on the previous head was checks-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 main 123b8acdcd8, which predates the upstream hardening of that test (bef4401fbc5 adds clearOpenClawAgentIntegrityVerification inside the revoke path). Rebased onto current main and re-ran locally: session-history-archive-pruning.admission.test.ts 18/18 passed. The rebase also required two test-only alignments: the shutdown-admission fixture now mocks maintenance.stopPeriodicTasks (upstream replaced stopTelemetryChecks, which produced a periodic-maintenance shutdown 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-meet 216 passed (extensions lane) + 179 passed (database-workers lane: index.test.ts, index.create.test.ts), tsgo tsconfig.extensions.test.json 0 errors, pnpm tsgo:core exit 0, line-cap and assertion-safety ratchets OK.
  • CI rediagnosis (test-line budget; previous head dd44b98d7f2 → this revision 4b4225de979): checks-fast-baseline-ratchets was the only red lane, and inside that job only the test-lines slot 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 shared config/test-lines-baseline.txt scalar 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 new test-support fixture), 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-cap extensions/google-meet/index.test.ts because 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/main d1b1e78b445 (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:
    check-test-lines-ratchet --base origin/main --no-merge-base
      before the record:  Test lines: 6503614; ceiling: 6503238; over by: 376; net delta: +381.   (exit 1)
      after  the record:  Test lines OK: 6503614; ceiling: 6503619; slack: 5.                      (exit 0)
    check-line-cap-ratchet / check-assertion-safety-ratchet:                                      OK
    src/process/gateway-work-admission.test.ts:                                                   40 passed
    extensions/google-meet/service-shutdown.test.ts:                                              3 passed
    server-close.shutdown-admission + server-request-entry + server-request-context:              54 passed
    src/gateway/server-close.test.ts:  21 failed | 23 passed — byte-identical with this PR's
      sources and with origin/main's versions of the same four source files (this EL8 host has
      glibc 2.31, so the native child-reaping helper reports "native child reaping is
      unavailable"); CI runs this file green, so it is not attributed to this PR.
    pnpm tsgo:core: NOT RUN locally on this base — upstream's lockfile now pins
      @tsrs/linux-x64-gnu 0.18.0 which requires GLIBC_2.32+ (host has 2.31); types are left to
      the CI test-types lane on this head.
    

@clawsweeper

clawsweeper Bot commented Sep 17, 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.

@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 17, 2026
@clawsweeper

clawsweeper Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: stale review; fresh review needed.

Summary
The latest durable ClawSweeper review was for head c37c07949dcd351e25e036d3f2eea4323bb0741b, but the PR head is now 4b4225de9796e7d6a56f385964479cae6a9c4bcb. Its old verdict and PR readiness labels are no longer current.

Next step
Comment @clawsweeper re-review when the current head is ready; pushes after the first review are not reviewed automatically.

Review history (19 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-18T10:03:01.171Z sha 08921d169aee6939b917e9e0e796aa2758cb3223 :: blocked before merge. :: none
  • reviewed 2026-09-20T07:18:00.560Z sha 5b2b0f7d79f403df464ebd587a2d85c10fec0b59 :: blocked before merge. :: none
  • reviewed 2026-09-20T08:02:50.135Z sha 367ced2810f15fc3d6398bee1a4b6cf62702978d :: blocked before merge. :: none
  • reviewed 2026-09-20T10:10:14.620Z sha b936ad8687b0b3a74b03ff3462868df68b575a41 :: blocked before merge. :: none
  • reviewed 2026-09-22T10:24:38.450Z sha d385d3aa01117563fea04eeda99581503e6f93b6 :: blocked before merge. :: none
  • reviewed 2026-09-22T12:12:17.546Z sha c37c07949dcd351e25e036d3f2eea4323bb0741b :: blocked before merge. :: none
  • reviewed 2026-10-06T04:54:26.864Z sha c37c07949dcd351e25e036d3f2eea4323bb0741b :: blocked before merge. :: none
  • reviewed 2026-10-29T02:08:53.224Z sha c37c07949dcd351e25e036d3f2eea4323bb0741b :: blocked before merge. :: none

@LiuwqGit
LiuwqGit force-pushed the feat/issue-150143-meet-shutdown-cleanup branch from bee7fb7 to 47b68c1 Compare September 17, 2026 05:48
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: L and removed size: S labels Sep 17, 2026
@LiuwqGit

Copy link
Copy Markdown
Contributor Author

Addressed the review items in 47b68c1 (details in the updated PR body Evidence section):

P1 — transport cleanup after admission closes. Confirmed against source: signal-driven restart marks draining synchronously (run-loop.ts), completeGatewayClose stops plugin services afterwards, and every plugin runtime.gateway.request goes through the ordinary router (dispatchGatewayRequestInProcessRaw → handleGatewayRequest), which rejects new roots during the drain. The close sequence now wraps pluginServices.stop() in a shutdown-owned cleanup root (runWithGatewayShutdownCleanupAdmission): the router's existing nested-ALS admission path admits requests from the close's own chain, while external requests stay fenced for the whole drain and the tracked root joins the existing drain accounting.

Real behavior evidence (also in the PR body):

  • New regression src/gateway/server-close.shutdown-admission.test.ts runs the real prepareGatewayClose/completeGatewayClose + real startPluginServices under markGatewayRestartDraining("restart (SIGTERM)"). Without the fix the service-stop admission probe observes [false] (RPC would be rejected unavailable during gateway restart); with the fix [true], warnings empty.
  • src/process/gateway-work-admission.test.ts: cleanup chain admitted while draining; ordinary roots (tryBeginGatewayRootWorkAdmission, tryBeginGatewayIndependentRootWorkAdmission) still rejected before/during/after cleanup; active root count settles to 0.
  • Real-module probes via tsx: {"probe":"plugin-service-stop-rpc-during-drain","draining":true,"admitted":false} before → "admitted":true,"ownsRoot":false after; external probes stay "admitted":false.
  • No close regressions: server-close.test.ts + new file 82 passed; extensions/google-meet/ 29 files / 395 passed (post-rebase).

CI checks-fast-baseline-ratchets. The failure was line-cap growth in extensions/google-meet/index.test.ts (6994 → 7051, over cap). The shutdown-service tests moved to the sibling module extensions/google-meet/service-shutdown.test.ts; check-line-cap-ratchet.mts --base origin/main now reports OK (no coverage trimmed, max-lines untouched).

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.

@LiuwqGit
LiuwqGit force-pushed the feat/issue-150143-meet-shutdown-cleanup branch from 47b68c1 to 49ea240 Compare September 17, 2026 08:43
@LiuwqGit

Copy link
Copy Markdown
Contributor Author

Addressed the revision-2 review items in 49ea240a07d (rebased onto 4bc73868a82). Summary of the real-behavior evidence, details in the PR body Evidence section.

P1 — carry shutdown cleanup through the request-entry owner. The review was right: the real close prelude (markClosePreludeStarted → requestEntryLifetime.beginClose() in server-lifecycle.ts) runs before completeGatewayClose, and dispatchGatewayRequestInProcessRaw calls GatewayRequestEntryLifetime.enter() before the router consults any admission root — so the revision-2 cleanup root never reached that barrier. The fix now goes through the request-entry owner: enter() admits chains that own the shutdown cleanup admission root (isInsideGatewayShutdownCleanupChain() in src/process/gateway-work-admission.ts — the same AsyncLocalStorage context in which completeGatewayClose runs pluginServices.stop()). Cleanup entries stay tracked in the lifetime's active set, so sealAndJoin() still joins them before transports close; external callers never observe the cleanup context and stay fenced, and once entries seal the barrier is absolute.

Real-behavior evidence at the boundary the review named (real close prelude + real RPC dispatch, replacing the direct-admission stand-in):

  • New regression in server-request-entry.test.ts: real gateway kernel → kernel.beginClosePrelude() → markGatewayRestartDraining() → real dispatchGatewayRequestInProcessRaw("test.cleanup", …) against a real method registry.
    • RED (without the enter() fix): cleanup-chain dispatch rejects with Error: Gateway request entry is closed; the close-lifecycle test fails with warnings: ['plugin-services'] — Tests 2 failed | 13 passed (15).
    • GREEN: cleanup-chain dispatch reaches the real handler ({ ok: true, payload: { cleaned: true } }), while external dispatches before and after cleanup keep rejecting with Gateway request entry is closed — Tests 15 passed (15).
  • server-close.shutdown-admission.test.ts now probes through a real GatewayRequestEntryLifetime aborted by the prelude, during the real prepareGatewayClose/completeGatewayClose + real startPluginServices drain (service stop enters request entry and the router root; both admitted only inside the cleanup chain), with finishRequestEntries: () => lifetime.sealAndJoin() wired like production.
  • Real-module probes (tsx against the real server-request-entry.ts + gateway-work-admission.ts, real restart ordering drain → beginClose → cleanup chain):
    before: {"probe":"plugin-service-stop-rpc-during-drain","admitted":false,"error":"Gateway request entry is closed"}
    after:  {"probe":"plugin-service-stop-rpc-during-drain","admitted":true}
    external stay fenced: {"probe":"external-ordinary-request-during-drain","admitted":false,"error":"Gateway request entry is closed"}
                          {"probe":"external-ordinary-request-after-cleanup","admitted":false,"error":"Gateway request entry is closed"}
    
  • Post-rebase suites: gateway close/entry/dispatch 6 files / 107 tests passed, gateway-work-admission 41 passed, full extensions/google-meet/ 29 files / 395 passed; tsconfig.extensions.test.json and the core.test.gateway-server type shard clean; line-cap + assertion-safety ratchets OK; validate.sh green.

CI failures at 47b68c1: check-test-types (mock property typo speakMeetVoiceCallGateway in service-shutdown.test.ts) and check-lint-core-1 (floating promise in the shutdown-admission teardown) are fixed in this revision. The extensions/slack failures in checks-node-changed-extensions-bundle-28 and the slack TS error in check-test-types came from the stale base interacting with newer main (fixed upstream by #150656 / #150678) — the branch is rebased onto 4bc73868a82, so they are no longer part of this PR's delta.

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).

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Sep 17, 2026
@LiuwqGit

Copy link
Copy Markdown
Contributor Author

CI attribution for the remaining red checks on 49ea240a07d — none are in this PR's delta:

  • The originally failing checks are resolved: check-test-types ✅, check-lint-core-1 ✅, checks-node-changed-extensions-bundle-28 ✅ (the slack-extension failures came from the stale base interacting with newer main, fixed upstream by fix(slack): require an acknowledgement sender for envelope guards #150656/fix(test): narrow Slack socket payload bytes #150678; branch is rebased onto 4bc73868a82).
  • checks-node-compact-small-37 — test/scripts/test-projects.test.ts > keeps PR automation workflow edits on workflow guard tests reproduces on pristine origin/main (9ab47386778) without any commit from this PR: 1 failed | 804 passed, identical assertion (labeler.yml routing now also selects test/scripts/ancillary-workflow-concurrency.test.ts while the fixture still expects 3 targets). Introduced by fix(ci): preserve labeler work on ignored PR edits #150728; upstream red, not chased here.
  • checks-node-compact-small-27 — test/scripts/doctor-install-switch-transport.test.ts passes locally on this head (4/4); the CI failure (expected 'systemctl' to be 'busctl') is runner-environment dependent.
  • checks-node-compact-large-15 — src/agents/bash-tools.process.delivery.test.ts passes locally on this head (18/18); the CI failure was a code mode timeout exceeded flake under runner load.

openclaw/ci-gate aggregates these three. A rerun (or a rebase once main's test-projects fixture is fixed upstream) should clear the two flakes; the compact-small-37 shard stays red for every PR until #150728's fixture lands a fix on main.

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. label Sep 17, 2026
@LiuwqGit
LiuwqGit force-pushed the feat/issue-150143-meet-shutdown-cleanup branch from 49ea240 to 3481443 Compare September 17, 2026 11:27
@LiuwqGit

Copy link
Copy Markdown
Contributor Author

Rebased onto current origin/main (bd8b00f63d) as 34814433c3e to pick up the upstream fixes for the previously red shards:

Upstream did not touch any of this PR's changed files since the previous base (git diff --stat 4bc73868..origin/main -- <PR files> is empty), so the diff is unchanged: same 9 files, 612 insertions. Post-rebase verification: test/scripts/test-projects.test.ts + test/scripts/doctor-install-switch-transport.test.ts 809/809 passed, pnpm tsgo:core clean.

@LiuwqGit
LiuwqGit force-pushed the feat/issue-150143-meet-shutdown-cleanup branch 2 times, most recently from 2476a58 to f58bbd7 Compare September 17, 2026 16:35
@LiuwqGit

Copy link
Copy Markdown
Contributor Author

CI attribution for the last red check on 2476a589ce8 — not in this PR's delta:

  • checks-node-compact-large-16 — src/agents/cli-runner/bundle-mcp.requester-lifecycle.test.ts line 163 asserted the process-wide SessionMcpRuntimeManager runtime-key set was exactly [], and failed on four session keys (internal-session-effects-*, private-memory-source) leaked by unrelated tests in the same worker. That strict global assertion was flaky by construction; upstream test: scope MCP lifecycle drain assertion #150910 (1d5e6ab1c1a, "test: scope MCP lifecycle drain assertion") scoped it to the test's own session, landing on main after this branch's base — so this branch ran the old assertion.

Rebased onto current origin/main (1a44e41ddfc) as f58bbd72ab5 to pick up that upstream fix. Upstream did not touch any of this PR's 9 changed files since the previous base (git diff --stat 80f148f5b81..origin/main -- <PR files> is empty), so the diff is unchanged. Post-rebase verification: the previously failing test plus this PR's test files pass locally (server-close.shutdown-admission, server-request-entry, gateway-work-admission, google-meet/service-shutdown, bundle-mcp.requester-lifecycle — 5 files, 4 shards, all green) and pnpm tsgo:core is clean.

CI on f58bbd72ab5 is now fully green (215 checks, 0 failures; mergeStateStatus: CLEAN).

@fuller-stack-dev fuller-stack-dev self-assigned this Sep 18, 2026
@LiuwqGit

Copy link
Copy Markdown
Contributor Author

Revision 5 (b234754d821) adds the real-process restart proof the review asked for — and it found one more real barrier that the in-process tests could not see.

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 (browser.proxy + googlemeet.chrome) → real headless Chrome 151 under CDP → a local TLS stateful Meet-like page satisfying the plugin's real meetStatusScript/meetTranscriptScript/meetLeaveScript DOM contracts (reached via Chrome --host-resolver-rules, so the plugin still dispatches against https://meet.google.com/...). Join via the real CLI (googlemeet join --transport chrome --mode transcribe), then SIGTERM the gateway and observe the page event log + the gateway's SQLite.

  • RED (fixes removed, reproduces main): gateway exits in 449ms with no drain — stopped_at stays NULL, no summary row, Chrome never clicks Leave. (Issue repro.)
  • GREEN: gateway exits code 0 in 1.7s; Chrome clicks Leave call in the real page (leave-clicked + post-call events); stopped_at written SIGTERM+~400ms; 21 live-captured utterances; summary row with real participants/overview/decisions from the actual caption stream.
  • SLOW (page reaches post-call 8s after the click): transcript still finalizes SIGTERM+364ms; gateway still exits cleanly in 5.1s; post-call switch itself lands past the 5s leave deadline, matching the documented overrun caveat.

The e2e exposed a fourth barrier: the close sequence drains received connection work before the gateway close step runs pluginServices.stop(), and the real canonical request context binds trackExecution to that drained scope — so the drain's browser.request dispatches were rejected with Async work scope is closed, Chrome never left, and the whole close stalled (>60s, no exit). The in-process tests missed it because their contexts used a caller-scope trackExecution. b234754d821 tracks shutdown-cleanup-chain executions into the calling chain's scope instead (external requests keep the original binding), with a regression test using a drained real AsyncWorkScope. After the fix, the same e2e is fully green including clean exit.

Details and full logs are in the PR body Evidence section. @clawsweeper re-review

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels Sep 18, 2026
@LiuwqGit

Copy link
Copy Markdown
Contributor Author

CI attribution for the red preflight on 367ced2810f — this is a repository-wide planning-cap breach on current main, not something this PR's delta can fix or avoid.

Failure: Error: Canonical pull_request Node matrix has 121 jobs, exceeding limit 120 (the final-matrix guard in ci.yml, nodeMatrixLimit = 120 for pull-request mode).

Reproduction on pure main (76cf13b65b5, no PR files involved): planning a change to a single unrelated core file (src/gateway/server-close.ts alone) makes createChangedNodeTestShards fail safe to the compact fallback, and the resulting matrix is identical to this PR's:

precise plan: null (falls back)
matrix nonDist = 121 vs CI limit 120 (base compact = 80, changed-extension fallback = 43)

At ee1173e0f4b (this PR's previous CI base, where preflight was green) the same probe yields exactly 120 — at the cap. 86f19c734de (#151300, browser extension tests) added one changed-extension fallback row, pushing every compact-fallback PR to 121. Any PR touching core src/ now fails preflight on current main until the cap is raised.

Upstream fix in flight: #153519 (ci: raise compact and Node matrix row caps slightly, caps 120→130 PR / 64→70 push) is open and review-only. Once it lands (or main otherwise drops a row), a rebase here re-triggers CI; nothing in this PR needs to change. All test/lint/type checks on this PR's own delta passed in the previous run at the same delta (5b2b0f7d79f: only the unrelated ci-platform-checkout harness flake was red, verified 74/74 green locally).

@LiuwqGit
LiuwqGit force-pushed the feat/issue-150143-meet-shutdown-cleanup branch 3 times, most recently from d385d3a to c37c079 Compare September 22, 2026 11:47
@LiuwqGit

Copy link
Copy Markdown
Contributor Author

CI diagnosis for the two red lanes on the previous head (d385d3aa011) — both reproduce on a clean checkout of main with none of this PR's commits, so neither is caused by this diff. Rebased onto a81afcc78cf (head is now c37c07949dc), which already fixes the first one.

  1. checks-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). This PR does not touch that file. The failing run was based on main 123b8acdcd8, which predates bef4401fbc5 ("fix(sessions): order WAL recovery and join probe release") — the commit that hardens exactly this revoke path (clearOpenClawAgentIntegrityVerification inside arrive()). On the rebased head that lane is green (run 35714875829 → checks-node-compact-large-10 pass), and locally the file is 18/18.

  2. check-prod-types →

    test/vitest/vitest.shared.config.ts(10,34): error TS7016: Could not find a declaration
    file for module '../../scripts/lib/tsx-cli-shim.mjs'.
    

    tsgo:ui reaches that file through ui/vitest.config.ts → test/vitest/vitest.shared.config.ts, whose resolveTsxImport import landed on main in 9fd45e587ab. Reproduced on a detached worktree at origin/main 0ed077d468c with zero PR commits:

    $ pnpm tsgo:ui          # pure origin/main, this PR not applied
    test/vitest/vitest.shared.config.ts(10,34): error TS7016: ... implicitly has an 'any' type.
    [tsgo] FAILED (exit 1)
    

    Fixed upstream by 80b9608a25e ("fix(tooling): declare tsx CLI shim exports", adds scripts/lib/tsx-cli-shim.d.mts), which the current base contains — pnpm tsgo:ui now exits 0 locally on this head. This PR intentionally does not add that declaration itself, to avoid colliding with the upstream fix.

  3. Heads-up on a lane that may still be red for upstream reasons: checks-node-compact-large-7 → src/gateway/embeddings-http.test.ts (4 failures in CI: serializes cleanup when a remote request creates a local provider, does not bypass local cleanup with a model override, allows providers without cleanup resources to embed concurrently, drains retained provider cleanup during gateway shutdown, plus cascading OpenClaw state database still has active native borrowers in teardown). This PR touches neither that test nor embeddings-http.ts. Locally the same file fails identically with and without this PR's commits — same six tests, same messages, both with --maxWorkers=2 and --maxWorkers=1:

    # detached worktree at origin/main 0ed077d468c (no PR commits):
    × does not admit a replacement while provider cleanup is pending        → called 21 times, expected 20+1
    × does not create a provider for a disconnected request waiting behind cleanup
    × serializes cleanup when a remote request creates a local provider
    × does not bypass local cleanup with a model override
    × allows providers without cleanup resources to embed concurrently      → Embedding request completed before provider entry (200)
    × drains retained provider cleanup during gateway shutdown              → timed out (120s)
    Tests  6 failed | 37 passed (43)
    # same run with this PR's 5 commits applied: identical 6 failed | 37 passed (43)
    

    fix(tests): observe queued embeddings serialization #155658 ("fix(tests): settle embedding cleanup fixtures") is the in-flight upstream fix; I'll rebase again once it lands if this lane stays red.

Local verification on the pushed head c37c07949dc (base origin/main a81afcc78cf):

oxfmt --check / oxlint (all 12 changed files):        clean
gateway suites (server-close, server-close.shutdown-admission,
  server-request-entry, server-request-context):      Test Files 4 passed, Tests 113 passed
extensions/google-meet (extensions lane):             Test Files 27 passed, Tests 216 passed
extensions/google-meet (database-workers lane:
  index.test.ts, index.create.test.ts):               Test Files 2 passed, Tests 179 passed
src/config/sessions/session-history-archive-pruning.admission.test.ts: Tests 18 passed
pnpm tsgo:core:                                       exit 0
pnpm tsgo:ui:                                         exit 0
tsgo test/tsconfig/tsconfig.extensions.test.json:     exit 0
tsgo core.test.gateway-server shard:                  exit 0
check-line-cap-ratchet / check-assertion-safety-ratchet: OK

Two test-only alignments came with the rebase (no product-code change): the shutdown-admission fixture now mocks maintenance.stopPeriodicTasks (main replaced stopTelemetryChecks, which otherwise records a periodic-maintenance shutdown warning), and a duplicated copy of the request-context regression test was dropped.

@roboclaw-bot roboclaw-bot added the clawtributors PR from a clawtributor label Oct 29, 2026
@clawsweeper clawsweeper Bot added status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 29, 2026
@LiuwqGit
LiuwqGit force-pushed the feat/issue-150143-meet-shutdown-cleanup branch from c37c079 to dd44b98 Compare November 5, 2026 18:01
@LiuwqGit

LiuwqGit commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current origin/main (990fc1bd88b9, head dd44b98d7f2) to resolve the reported merge conflict; the transport-ordering question is restated below for the shutdown owner. @clawsweeper re-review

Merge conflict resolution. Main moved past this branch's last base (a81afcc78cf, Sep 22) and touched 10 of the 12 changed files. The rebase keeps the fix semantics and adopts the current main APIs the old base predates:

  • kernel.beginClosePrelude() is no longer exported (the prelude now runs inside prepareClose); the request-entry regression drives the real kernel.prepareClose() — the same pattern main's own "admits exact pending node cleanup replies while close drains" uses.
  • server-request-entry.ts's closed-entry refusal is now a GatewayClientRequestError (UNAVAILABLE, retryable) on main; the merged enter() keeps that richer refusal and adds the cleanup-chain admission condition.
  • currentRootWork moved out of GATEWAY_WORK_ADMISSION_STATE into a standalone export; isInsideGatewayShutdownCleanupChain reads the exported context.
  • 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 main's shared createGatewayCloseTestDepsFactory + server-close.mocks.test-support.js (acp-session-manager, worktree-run-end, scheduler steps).
  • The google-meet test seams were desloped on main (testing export, setCallGatewayFromCliForTests, setPlatformForTests removed; voice-call gateway moved to openclaw/plugin-sdk/meeting-runtime with renamed exports): service-shutdown.test.ts now follows main's own index.test.ts patterns (callGatewayFromCli spy + createGoogleMeetToolGatewayForTest, plugin-sdk meeting-runtime mocks). index.test.ts keeps its net-zero delta — the two upstream-removed low-value Twilio tests stay deleted.

Verification on dd44b98d7f2 (CI lanes pending; local targeted):

gateway-work-admission / server-request-entry / server-close.shutdown-admission:  55 passed
server-request-context:                                                          39 passed
extensions/google-meet (full suite):                            30 files, 220 passed
pnpm tsgo:core / tsconfig.extensions.test / core.test.gateway-server shard:      clean
check-line-cap-ratchet / check-assertion-safety-ratchet:                          OK
oxfmt --check (all changed files):                                               clean

Local-environment notes, none in this PR's delta: server-close.test.ts's supervisor cases fail identically with and without this PR's commits ("native child reaping is unavailable" — the native helper binary is absent on this EL8 host; verified by restoring origin/main's versions of all changed source files and reproducing the same failures); local oxlint panics on every file on this glibc (formatting checked with oxfmt, types with tsgo).

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 pluginServices.stop() under the shutdown-owned cleanup admission, joined by the close sequence before shared-state retirement, so a settling drain still extends shutdown completion and its RPCs carry their own dispatch deadlines; the five-second grace lets the later close steps (channels, harnesses, runtime disposal) advance while the drain is still running, so a multi-session drain whose later sessions exceed the grace window would lose their browser transport mid-leave (single-session and fast multi-session drains — the common case, e.g. the recorded 1.4–1.7s real-process restart — finalize everything). If the owner prefers guaranteed departure for arbitrarily slow multi-session drains, ordering pluginServices.stop before node socket teardown is the change to make; happy to implement it on their call.

…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
@LiuwqGit
LiuwqGit force-pushed the feat/issue-150143-meet-shutdown-cleanup branch from dd44b98 to 4b4225d Compare November 5, 2026 19:08
@LiuwqGit

LiuwqGit commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor Author

CI fix for the one red lane on dd44b98d7f2 — checks-fast-baseline-ratchets (new head 4b4225de979)

Diagnosis (from the job log, run 42080562822 / job 127433213694). Inside that job only the test-lines slot failed; every other slot was green (max-lines, line-cap, assertion-safety, database-dialect, timeout-race, mock-exports, config-docs, plugin-inventory, database-worker):

$ node --import ./scripts/tsx.mjs scripts/check-test-lines-ratchet.mts --base refs/remotes/origin/ci-ratchet-base --no-merge-base
Test lines: 6500665; ceiling: 6500295; over by: 370; net delta: +381.
Offset the added lines by deleting or consolidating tests elsewhere, or add a justified allocation in config/test-lines-allocations/<change>.txt.
##[error]test-lines failed (exit 1)

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 (4b4225de979). Took the documented route (docs/ci/local-proof.md → test-line budget, docs/help/testing/writing-tests.md → Cost budget) instead of deleting unrelated coverage: one new tracked record config/test-lines-allocations/google-meet-shutdown-drain-150143.txt = 381, i.e. exactly this PR's net test-line delta (also the ceiling the allocation-credit guard allows: credit ≤ added test lines). The shared config/test-lines-baseline.txt scalar is untouched; the record's # comments state the necessity.

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:

barrier regression file added lines
router admission during restart draining src/process/gateway-work-admission.test.ts 23
close prelude's request-entry lifetime src/gateway/server-request-entry.test.ts 41
drained connection-work scope src/gateway/server-request-context.test.ts + new server-request-context.test-support.ts 34
real draining close lifecycle src/gateway/server-close.shutdown-admission.test.ts 96
the plugin drain itself extensions/google-meet/service-shutdown.test.ts (+5 in plugin-harness.ts) 187

service-shutdown.test.ts lives in its own file because extensions/google-meet/index.test.ts is already over the line cap and check-line-cap-ratchet rejects growth there (that was the first revision's red lane). Dropping any one of these files would leave a barrier that a real restart hit completely untested.

Local verification on the rebased head (rebased onto origin/main d1b1e78b445; the rebase leaves this PR's diff patch-id unchanged — 51c3631e22c8fe9ddc610aed1bcfa07d80c2624a before and after — and upstream touched none of the 12 changed files):

check-test-lines-ratchet --base origin/main --no-merge-base
  before the record:  Test lines: 6503614; ceiling: 6503238; over by: 376; net delta: +381.   (exit 1 — reproduces CI)
  after  the record:  Test lines OK: 6503614; ceiling: 6503619; slack: 5.                      (exit 0)
check-line-cap-ratchet:       Line-cap ratchet OK: 12 changed source files; no new violations or over-cap growth.
check-assertion-safety-ratchet: assertion SAFETY ratchet OK: 2384 files, 5413 grandfathered assertions.
src/process/gateway-work-admission.test.ts:            40 passed
extensions/google-meet/service-shutdown.test.ts:       3 passed
server-close.shutdown-admission + server-request-entry + server-request-context:  54 passed

Two honest environment notes, neither in this PR's delta:

  • src/gateway/server-close.test.ts fails on this host identically with and without this PR: 21 failed | 23 passed when running this branch's sources, and 21 failed | 23 passed after git checkout origin/main -- src/gateway/server-close.ts src/gateway/server-request-entry.ts src/gateway/server-request-context.ts src/process/gateway-work-admission.ts (then restored). Cause: glibc 2.31 here, so the native child-reaping helper reports native child reaping is unavailable (code: 'helper-unavailable'). CI runs this file green.
  • pnpm tsgo:core could not run locally on this base: upstream's lockfile now pins @tsrs/linux-x64-gnu 0.18.0, which requires GLIBC_2.32+ (host has 2.31). Types are left to the CI test-types lane on this head — flagged rather than claimed.

PR body Evidence section updated with the same diagnosis, allocation justification, and numbers. @clawsweeper re-review

@clawsweeper clawsweeper Bot removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Nov 8, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawtributors PR from a clawtributor gateway Gateway runtime P1 High-priority user-facing bug, regression, or broken workflow. plugin: google-meet size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Meeting transcripts: gateway restart during a Meet capture loses the session; transcript never finalized (stopped_at NULL, no summary)

3 participants