Skip to content

fix(beam): stop mirroring after service shutdown - #126589

Merged
steipete merged 3 commits into
mainfrom
steipete/laughing-shamir-806cd8
Aug 23, 2026
Merged

steipete merged 3 commits into
mainfrom
steipete/laughing-shamir-806cd8

Conversation

@steipete

@steipete steipete commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

AI-assisted: yes

What Problem This Solves

Fixes an issue where disabling or reloading the Beam mirror while a catalog scan was already running could let that scan continue processing local session data after the service had stopped, or leave Gateway reload waiting for a stalled catalog operation.

Why This Change Was Made

The Beam runner owns one abortable active scan and races non-cancellable session-catalog list/read operations against its lifecycle signal, so shutdown completes promptly even when catalog I/O remains pending. Late catalog results cannot resume transcript reads, uploads, or session updates. Guarded network delivery receives the same signal, but shutdown still awaits response-body cancellation and guarded resource release after transport abort. Overlapping timer ticks join the same active scan.

User Impact

Removing mirror consent, stopping the plugin, or reloading its configuration now takes effect promptly as a terminal lifecycle boundary: no later transcript read or mirror delivery begins from the retired service instance, while in-flight network resources are cleaned up before shutdown completes.

Evidence

  • Before the catalog-abort fix, the service-level stalled-list regression failed with AssertionError: expected false to be true because service shutdown remained pending while the catalog promise was unreleased.
  • node scripts/run-vitest.mjs extensions/beam/src/mirror.test.ts (32 tests passed)
  • node_modules/.bin/oxfmt extensions/beam/src/mirror.ts extensions/beam/src/mirror.test.ts
  • node scripts/run-tsgo.mjs -p tsconfig.extensions.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/extensions.tsbuildinfo
  • node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.extensions.test.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/extensions-test.tsbuildinfo
  • node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.extensions.json extensions/beam/src/mirror.test.ts extensions/beam/src/mirror.ts
  • git diff --check
  • Focused coverage proves prompt stop while catalog list/read remain pending, ignores late catalog results, joins overlapping ticks, awaits guarded cleanup, and aborts a real stalled loopback transport.
  • Codex autoreview: clean, no accepted/actionable findings.
  • Production LOC +82/-21 (net +61), required for Beam-owned lifecycle cancellation and safe guarded transport cleanup; tests +261/-3 (net +258).

@clawsweeper

clawsweeper Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added plugin: beam Beam session sharing plugin size: M labels Aug 20, 2026
@steipete
steipete marked this pull request as ready for review August 20, 2026 07:51
@openclaw-barnacle openclaw-barnacle Bot added the maintainer Maintainer-authored PR label Aug 20, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 20, 2026
@clawsweeper

clawsweeper Bot commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 23, 2026, 6:08 PM ET / 22:08 UTC.

ClawSweeper review

What this changes

This PR makes Beam stop an active session-mirroring scan during plugin shutdown, preventing late catalog results from starting transcript reads or mirror uploads.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

The revised Beam lifecycle patch addresses the prior stalled-catalog blocker and has no actionable correctness finding; it remains open for normal maintainer handling because current main and the latest release do not contain the repair.

Priority: P2
Reviewed head: 0916d1223c7b3ed7b2a7ed9b9df880247df1765d

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused lifecycle repair with boundary-level regression coverage and no actionable source finding; exact-head validation remains before landing.
Proof confidence 🌊 off-meta tidepool Not applicable: Not applicable: repository context identifies this as a MEMBER-authored PR, so the external-contributor proof gate does not apply; the body still supplies useful focused loopback-test evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Not applicable: repository context identifies this as a MEMBER-authored PR, so the external-contributor proof gate does not apply; the body still supplies useful focused loopback-test evidence.
Evidence reviewed 7 items Current main still lacks runner shutdown ownership: Current main exposes only tick, retains a non-abortable running flag, and service stop only clears the interval, so an already-started catalog scan remains outside the stop boundary.
PR owns the lifecycle boundary: The proposed runner races non-cancellable catalog work against one abort signal, fences post-await work, and service stop returns the runner stop promise after clearing the interval.
Gateway awaits asynchronous plugin stops: The plugin-service manager awaits each registered service stop, so Beam's returned promise is part of the real reload and shutdown boundary.
Findings None None.
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs extensions/beam/src/mirror.test.ts

Result: FAIL (failed) — execution before step 1 run: live-proof package manager pnpm is unavailable after its official installer (curl -fsSL https://get.pnpm.io/install.sh | sh -): command failed without output

live-proof package manager pnpm is unavailable after its official installer (curl -fsSL https://get.pnpm.io/install.sh | sh -): command failed without output

Assertions:

  • FAIL expect_output: 32 passed

How this fits together

Beam mirrors selected local session transcripts to a configured receiver. Its background scan reads the active session catalog and delivers uploads, while the plugin-service lifecycle starts and stops that scan during Gateway operation and reload.

flowchart LR
  A[Active session catalogs] --> B[Beam mirror scan]
  C[Plugin stop or reload] --> D[Runner abort]
  D --> B
  B --> E[Transcript read]
  E --> F[Guarded upload]
  F --> G[Configured receiver]
  D --> H[Joined transport cleanup]
Loading

Before merge

  • Resolve merge risk (P1) - Merging deliberately changes shutdown timing: an active guarded response now remains joined until its body cancellation and resource release finish, so the rebased exact head should complete the focused checks before landing.
Agent review details

Security

None.

PR surface

Source +61, Tests +258. Total +319 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 82 21 +61
Tests 1 261 3 +258
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 343 24 +319

Review metrics

Metric Value Why it matters
Lifecycle repair size production +61, tests +258 The production growth replaces a boolean scan guard with runner-owned abort and cleanup ownership; the larger test growth covers the stop boundary and transport behavior.

Merge-risk options

Maintainer options:

  1. Validate the joined cleanup boundary (recommended)
    Rebase onto current main and land only after the exact head confirms that service stop remains prompt while acquired transport cleanup finishes.

Technical review

Best possible solution:

Keep one Beam-owned abort boundary that detaches unabortable catalog work, fences every later side effect, and joins only already-acquired transport cleanup.

Do we have a high-confidence way to reproduce the issue?

Yes: current main clears only the timer while an already-started catalog promise can continue; the revised service-level test models that exact withheld-list sequence, although this read-only review did not execute it.

Is this the best way to solve the issue?

Yes: the runner that initiates catalog reads and uploads now owns the terminal abort signal, instead of asking the service caller to compensate for late results.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 977bbe266772.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Not applicable: repository context identifies this as a MEMBER-authored PR, so the external-contributor proof gate does not apply; the body still supplies useful focused loopback-test evidence.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: The repair is limited to the optional Beam plugin but affects its stop and reload behavior.
  • merge-risk: 🚨 availability: The patch changes whether plugin shutdown waits for active scan and guarded transport cleanup.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Not applicable: repository context identifies this as a MEMBER-authored PR, so the external-contributor proof gate does not apply; the body still supplies useful focused loopback-test evidence.

Evidence

What I checked:

  • Current main still lacks runner shutdown ownership: Current main exposes only tick, retains a non-abortable running flag, and service stop only clears the interval, so an already-started catalog scan remains outside the stop boundary. (extensions/beam/src/mirror.ts:264, 977bbe266772)
  • PR owns the lifecycle boundary: The proposed runner races non-cancellable catalog work against one abort signal, fences post-await work, and service stop returns the runner stop promise after clearing the interval. (extensions/beam/src/mirror.ts:281, 0916d1223c7b)
  • Gateway awaits asynchronous plugin stops: The plugin-service manager awaits each registered service stop, so Beam's returned promise is part of the real reload and shutdown boundary. (src/plugins/services.ts:205, 0916d1223c7b)
  • Prior blocker has focused boundary coverage: The new service-level test stops while catalog list is pending and verifies that later completion cannot start reads or uploads; adjacent tests cover paused reads, coalesced ticks, guarded cleanup, and a loopback socket abort. (extensions/beam/src/mirror.test.ts:590, 0916d1223c7b)
  • Generic catalog boundary, not a Codex-runtime dependency: Beam consumes the generic active session-catalog facade; the local Codex catalog is one provider behind that facade, so this patch does not affirmatively depend on the sibling Codex runtime or protocol. (src/plugins/session-catalog-active.ts:4, 0916d1223c7b)
  • Feature provenance: Blame and history identify the current-main Beam mirror introduction as the source of the non-abortable runner; the current PR commits are all authored by the same area owner. (extensions/beam/src/mirror.ts:264, bca206d794bd)

Likely related people:

  • steipete: Current-main history and blame attribute the Beam mirror introduction to Peter Steinberger, and all supplied commits for this lifecycle repair are by steipete. (role: feature owner and recent lifecycle contributor; confidence: high; commits: bca206d794bd, 47af07bc1a74, cf34abe50070; files: extensions/beam/src/mirror.ts, extensions/beam/src/mirror.test.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Rebase onto current main and let the focused lifecycle checks finish on the exact head.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-20T07:58:46.958Z sha 47af07b :: found issues before merge. :: [P2] Do not await unabortable catalog work during stop

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 23, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready verification for 0916d1223c7b3ed7b2a7ed9b9df880247df1765d:

ClawSweeper's prior P2 and rank-up moves are addressed on this head: shutdown completes while catalog work remains pending, and late catalog settlement cannot start reads or uploads. The refreshed publisher review is still queued, but there are no unresolved head-specific findings.

@steipete
steipete merged commit 7882645 into main Aug 23, 2026
114 checks passed
@steipete
steipete deleted the steipete/laughing-shamir-806cd8 branch August 23, 2026 22:36
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 24, 2026
* fix(beam): stop mirror work after service shutdown

* fix(beam): avoid waiting on stalled catalogs during shutdown

* refactor(beam): tighten catalog abort cleanup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P2 Normal backlog priority with limited blast radius. plugin: beam Beam session sharing plugin rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant