Skip to content

fix(ui): retire stale Gateway event-log observers - #117169

Merged
steipete merged 1 commit into
mainfrom
codex/qa400-gateway-event-log-owner
Aug 1, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/qa400-gateway-event-log-owner

Conversation

@steipete

@steipete steipete commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Refactor the private Gateway event-log owner to retire observer delivery whenever its socket is replaced/stopped or a nested event supersedes the published log.
  • Reuse the existing canonical observer-publication predicate; preserve retained history, listener membership snapshots, failure isolation, raw events, presence ownership, and healthy Debug updates.

Root cause

recordGatewayEvent was the only application Gateway publication that omitted the canonical notifyGatewayObservers ownership predicate. A synchronous first subscriber could reconnect or stop its originating client while later log subscribers, including Debug, still received the retired event. A reentrant event likewise published the newest snapshot and then rolled Debug back to its obsolete older snapshot. Capturing the producing client once at the existing owner and fencing delivery to both the current client and exact current log snapshot fixes this owner-boundary invariant without a consumer-side workaround, public API change, compatibility shim, or new dependency.

Production delta: ui/src/app/gateway-store.ts +4/-2 (net +2); one root cause, with three precise regressions. No protocol, configuration, authentication, security, persistence, or SDK surface changes.

Exact baseline RED

Frozen baseline fdcb321bfaaadb5a1e7d123b6be7a934980f8b12 with production untouched: node scripts/run-vitest.mjs ui/src/app/gateway-store.observers.test.ts produced 3 new failures and 10 existing passes:

  1. A second log observer received an event after the first observer replaced its Gateway client.
  2. A second log observer received an event after the first observer stopped its Gateway client.
  3. A reentrant event delivered histories [2, 1] instead of the authoritative [2].

Verification

  • Blacksmith Testbox tbx_01kyxj1dsfygk7dtrh7pjsjha8: 120/120 focused tests passed, zero failed, across Gateway owner/observers, app-host lineage and shell, Debug/source replacement, and bootstrap; two Vitest shards.
  • The reusable Testbox preserves its workflow Git HEAD and syncs branch changes as a working-tree patch. Before executing any tests, the remote command verified frozen-baseline ancestry and the exact immutable eeffb08840ec43acaaaa4e92e68220b9b7980653 Git blob for both changed files: owner 5a12523b09e7540a2b21037658322537eb1cdf2d; observer tests 6709f64d6899d5b2c5c4c60b04ae67f9cc68e40a. This is patch-identical source proof, not a claim that the workflow checkout HEAD equals the private commit.
  • Exact-source remote type-aware oxlint: 0 warnings / 0 errors; oxfmt and git diff --check clean. Remote timing JSON exitCode=0; the lease was stopped and independently verified completed.
  • Independent actual Google Chrome 150 used the real production Gateway store, 14 genuine challenge/device-authenticated WebSocket hellos, 16 sequenced real Gateway frames, and the rendered Debug DOM: baseline RED → immutable candidate GREEN, 26/26 assertions, zero uncaught page errors. Coverage includes replacement, stop, nested delivery, retained history, healthy events, raw-event isolation, and failing-observer isolation.
  • Two independent strict whole-owner P0–P3 reviews: zero findings, confidence 0.99 and 0.98; both inspected callers, presence/snapshot/raw-event siblings, listener lifecycle, and Debug consumers.
  • Genuine full-branch Codex autoreview against exact frozen baseline through P3: zero findings, overall confidence 0.93, TruffleHog clean.

Agent transcript

  • Read the current complete root and scoped UI ownership guides; inspected the existing Gateway owner, sibling publications, presence path, historical changes, actual Debug consumers, and existing regression tests.
  • Froze fdcb321bfaaadb5a1e7d123b6be7a934980f8b12, authored three focused tests first, and captured the genuine baseline RED before changing production.
  • Refactored only the existing owner-boundary guard, froze immutable candidate eeffb08840ec43acaaaa4e92e68220b9b7980653, and had separate agents independently verify real browser/WebSocket behavior and whole-owner P0–P3 correctness.
  • Used one lazily acquired, branch-scoped Testbox, verified both exact immutable source blobs before execution, completed focused proof, and stopped/verified the lease.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui size: S maintainer Maintainer-authored PR labels Aug 1, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal backlog priority with limited blast radius. labels Aug 1, 2026
@steipete
steipete merged commit 91aff80 into main Aug 1, 2026
107 of 115 checks passed
@clawsweeper

clawsweeper Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 31, 2026, 10:33 PM ET / August 1, 2026, 02:33 UTC.

ClawSweeper review

What this changes

This PR updates the Control UI Gateway store so an event-log callback stops notifying later observers when the socket is replaced/stopped or a nested event has already published a newer log snapshot.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

The patch is a focused, source-backed repair for stale Control UI event-log delivery and introduces no actionable correctness or security finding. It should remain open because the PR carries the protected maintainer label; its clean three-way merge and strong proof support a human decision to land after the remaining required checks complete.

Priority: P2
Reviewed head: eeffb08840ec43acaaaa4e92e68220b9b7980653
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused owner-boundary fix with precise regression coverage and strong real-browser evidence; no correctness finding was identified.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR body supplies after-fix browser/WebSocket evidence using the production Gateway store and rendered Debug DOM, including the replacement, stop, and nested-delivery cases; the reported Real behavior proof check also passed.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body supplies after-fix browser/WebSocket evidence using the production Gateway store and rendered Debug DOM, including the replacement, stop, and nested-delivery cases; the reported Real behavior proof check also passed.
Evidence reviewed 5 items Current-main defect location: Current main records a Gateway event and notifies event-log listeners without the existing ownership predicate, while snapshot and raw-event delivery already use guarded observer publication.
Owner-boundary repair: The branch captures the producing client before presence processing and makes each log callback contingent on both the unchanged event-log snapshot and the still-current client, matching the established guarded-observer pattern.
Regression coverage: The added observer tests cover both connection replacement and stop from the first log observer, plus a reentrant event where an older log snapshot must not overwrite the newer one.
Findings None None.
Security None None.

How this fits together

The Control UI Gateway store receives WebSocket events from the selected Gateway client, retains a bounded event history, and publishes that history to subscribers. The Debug page subscribes to this event log, so stale publication can display an obsolete event sequence after a connection lifecycle change.

flowchart LR
  A[Gateway WebSocket event] --> B[Control UI Gateway store]
  B --> C[Record bounded event log]
  C --> D{Current client and log snapshot?}
  D -->|Yes| E[Event-log observers]
  D -->|No| F[Retire obsolete delivery]
  E --> G[Debug page event log]
  H[Reconnect, stop, or nested event] --> D
Loading

Decision needed

Question Recommendation
Should the recent Gateway owner merge this focused event-log ownership repair once the remaining required checks finish? Merge after required checks: Accept the current focused repair because it preserves existing retained-history and listener semantics while preventing obsolete Debug updates.

Why: The implementation is cleanly mergeable and evidence-backed, but the protected maintainer label requires an explicit human merge decision rather than automated cleanup.

Before merge

None.

Agent review details

Security

None.

PR surface

Source +2, Tests +52. Total +54 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 4 2 +2
Tests 1 52 0 +52
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 56 2 +54

Review metrics

None.

Technical review

Best possible solution:

Keep one canonical guarded observer-publication rule in the Gateway store and merge this focused repair once the protected maintainer review confirms the exact head.

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

Yes, from source: on current main, the first event-log observer can synchronously replace or stop the client, or record a nested event, before later log observers receive the original snapshot. The PR adds focused regressions for all three paths; this read-only review did not execute them locally.

Is this the best way to solve the issue?

Yes. The repair belongs at the shared event-log publication owner, reuses the existing guarded observer predicate, and avoids a Debug-specific workaround or public API change.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 7fba71eb7aeb.

Labels

Label changes:

  • add P2: A stale Debug event log is a bounded Control UI state regression with a focused repair and no evidence of broader message or session loss.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies after-fix browser/WebSocket evidence using the production Gateway store and rendered Debug DOM, including the replacement, stop, and nested-delivery cases; the reported Real behavior proof check also passed.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body supplies after-fix browser/WebSocket evidence using the production Gateway store and rendered Debug DOM, including the replacement, stop, and nested-delivery cases; the reported Real behavior proof check also passed.

Label justifications:

  • P2: A stale Debug event log is a bounded Control UI state regression with a focused repair and no evidence of broader message or session loss.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body supplies after-fix browser/WebSocket evidence using the production Gateway store and rendered Debug DOM, including the replacement, stop, and nested-delivery cases; the reported Real behavior proof check also passed.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies after-fix browser/WebSocket evidence using the production Gateway store and rendered Debug DOM, including the replacement, stop, and nested-delivery cases; the reported Real behavior proof check also passed.

Evidence

What I checked:

  • Current-main defect location: Current main records a Gateway event and notifies event-log listeners without the existing ownership predicate, while snapshot and raw-event delivery already use guarded observer publication. (ui/src/app/gateway-store.ts:237, 7fba71eb7aeb)
  • Owner-boundary repair: The branch captures the producing client before presence processing and makes each log callback contingent on both the unchanged event-log snapshot and the still-current client, matching the established guarded-observer pattern. (ui/src/app/gateway-store.ts:237, eeffb08840ec)
  • Regression coverage: The added observer tests cover both connection replacement and stop from the first log observer, plus a reentrant event where an older log snapshot must not overwrite the newer one. (ui/src/app/gateway-store.observers.test.ts:196, eeffb08840ec)
  • Caller and consumer map: The Gateway client first rejects queued events from replaced sockets, then records the event before guarded raw-event delivery; the Debug page is the concrete event-log subscriber that reads the retained history. (ui/src/app/gateway-store.ts:415, eeffb08840ec)
  • History and merge safety: The closely related current-main ownership work is commit 3c81eb4, authored July 31, 2026; a three-way merge from the PR base to current main applies both changed files cleanly. (ui/src/app/gateway-store.ts:237, 3c81eb49257e)

Likely related people:

  • steipete: Peter Steinberger authored the current-main Gateway reconnect-lineage repair and the proposed event-log ownership repair in the same store and observer-test surface. (role: recent Gateway owner; confidence: high; commits: 3c81eb49257e, eeffb08840ec; files: ui/src/app/gateway-store.ts, ui/src/app/gateway-store.observers.test.ts)

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.

@steipete
steipete deleted the codex/qa400-gateway-event-log-owner branch August 1, 2026 02:39
@steipete

steipete commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit to chenyangjun-xy/openclaw that referenced this pull request Aug 1, 2026
* origin/main:
  refactor(ui): replace duplicated locale bundles with canonical translation memory (openclaw#117157)
  fix(ui): retire stale Gateway event-log observers (openclaw#117169)
  fix(agents): keep subagent status consistent after restart and large fan-outs (openclaw#117141)
  test(voice-call): stress paced audio queue drains
  fix(voice-call): avoid shifting paced audio queues
pull Bot pushed a commit to liudf0716/openclaw that referenced this pull request Aug 1, 2026
* commit '7e78de747b8a64d52f30aee948b697bf4c528691': (359 commits)
  refactor(ui): replace duplicated locale bundles with canonical translation memory (openclaw#117157)
  fix(ui): retire stale Gateway event-log observers (openclaw#117169)
  fix(agents): keep subagent status consistent after restart and large fan-outs (openclaw#117141)
  refactor(ui): unify filtered session list ownership (openclaw#117158)
  refactor(agents): consolidate context budgets and compaction recovery (openclaw#117149)
  fix(net-policy): redact sig and x-* auth params in URLs and bodies (openclaw#116957)
  refactor(agents): remove duplicate generated-media delivery fallbacks (openclaw#117150)
  refactor(reply): unify turn lifecycle state ownership (openclaw#117145)
  fix(ui): preserve emoji agent avatar initials (openclaw#104912)
  refactor(auto-reply): unify command and directive ownership (openclaw#117143)
  refactor(plugins): consolidate descriptor and startup ownership (openclaw#117146)
  fix(messages): reply actions leak citation markers and reply/poll answers draw the no-reply fallback (openclaw#116909)
  fix(slack): let durable ingress retry transient thread lookups (openclaw#117135)
  refactor(doctor): consolidate shipped state migration ownership (openclaw#117142)
  fix(ai): Codex stream shows internal parser text on a malformed frame (openclaw#116966)
  fix: guard every migrated session accessor path (openclaw#117140)
  fix(terminal): measure unicode display width consistently (openclaw#117062)
  fix(openai): clear ChatGPT SSE fallback per session (openclaw#117123)
  fix(mistral): reject incomplete streamed tool terminals (openclaw#117137)
  fix(ai): preserve structured chat content and refusals (openclaw#117136)
  ...
wingwkyuen pushed a commit to tcgoidc/openclaw that referenced this pull request Aug 1, 2026
* commit '6938f7dddb63bad59862c014c427d63f0a41a6f4': (368 commits)
  fix: allow gateway service commands for named profiles (openclaw#116314)
  fix(plugins): invalidate bundled artifact locations after metadata refresh (openclaw#117041)
  fix(ollama): honor model requests and pull completion contracts (openclaw#117171)
  fix(agents): prevent fallback after stale lifecycle abort (openclaw#117168)
  fix(telegram): confirm polling before long poll (openclaw#116970)
  fix(tlon): wire autoDiscoverChannels through the settings-store round-trip (openclaw#114949)
  fix(gateway): yield before post-ready background work (openclaw#117083)
  fix(ui): keep canvas lease renewals lifecycle-owned and timer-safe (openclaw#117173)
  fix(teams): restore the official square product icon (openclaw#117170)
  refactor(ui): replace duplicated locale bundles with canonical translation memory (openclaw#117157)
  fix(ui): retire stale Gateway event-log observers (openclaw#117169)
  fix(agents): keep subagent status consistent after restart and large fan-outs (openclaw#117141)
  refactor(ui): unify filtered session list ownership (openclaw#117158)
  refactor(agents): consolidate context budgets and compaction recovery (openclaw#117149)
  fix(net-policy): redact sig and x-* auth params in URLs and bodies (openclaw#116957)
  refactor(agents): remove duplicate generated-media delivery fallbacks (openclaw#117150)
  refactor(reply): unify turn lifecycle state ownership (openclaw#117145)
  fix(ui): preserve emoji agent avatar initials (openclaw#104912)
  refactor(auto-reply): unify command and directive ownership (openclaw#117143)
  refactor(plugins): consolidate descriptor and startup ownership (openclaw#117146)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 1, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 1, 2026
* commit '5148236bbe050f6c05ee59190986a7215b41ce1c': (359 commits)
  refactor(ui): replace duplicated locale bundles with canonical translation memory (openclaw#117157)
  fix(ui): retire stale Gateway event-log observers (openclaw#117169)
  fix(agents): keep subagent status consistent after restart and large fan-outs (openclaw#117141)
  refactor(ui): unify filtered session list ownership (openclaw#117158)
  refactor(agents): consolidate context budgets and compaction recovery (openclaw#117149)
  fix(net-policy): redact sig and x-* auth params in URLs and bodies (openclaw#116957)
  refactor(agents): remove duplicate generated-media delivery fallbacks (openclaw#117150)
  refactor(reply): unify turn lifecycle state ownership (openclaw#117145)
  fix(ui): preserve emoji agent avatar initials (openclaw#104912)
  refactor(auto-reply): unify command and directive ownership (openclaw#117143)
  refactor(plugins): consolidate descriptor and startup ownership (openclaw#117146)
  fix(messages): reply actions leak citation markers and reply/poll answers draw the no-reply fallback (openclaw#116909)
  fix(slack): let durable ingress retry transient thread lookups (openclaw#117135)
  refactor(doctor): consolidate shipped state migration ownership (openclaw#117142)
  fix(ai): Codex stream shows internal parser text on a malformed frame (openclaw#116966)
  fix: guard every migrated session accessor path (openclaw#117140)
  fix(terminal): measure unicode display width consistently (openclaw#117062)
  fix(openai): clear ChatGPT SSE fallback per session (openclaw#117123)
  fix(mistral): reject incomplete streamed tool terminals (openclaw#117137)
  fix(ai): preserve structured chat content and refusals (openclaw#117136)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 1, 2026
* commit '55215cd9edd2b585cbaee5481d5352aabf7e4399': (368 commits)
  fix: allow gateway service commands for named profiles (openclaw#116314)
  fix(plugins): invalidate bundled artifact locations after metadata refresh (openclaw#117041)
  fix(ollama): honor model requests and pull completion contracts (openclaw#117171)
  fix(agents): prevent fallback after stale lifecycle abort (openclaw#117168)
  fix(telegram): confirm polling before long poll (openclaw#116970)
  fix(tlon): wire autoDiscoverChannels through the settings-store round-trip (openclaw#114949)
  fix(gateway): yield before post-ready background work (openclaw#117083)
  fix(ui): keep canvas lease renewals lifecycle-owned and timer-safe (openclaw#117173)
  fix(teams): restore the official square product icon (openclaw#117170)
  refactor(ui): replace duplicated locale bundles with canonical translation memory (openclaw#117157)
  fix(ui): retire stale Gateway event-log observers (openclaw#117169)
  fix(agents): keep subagent status consistent after restart and large fan-outs (openclaw#117141)
  refactor(ui): unify filtered session list ownership (openclaw#117158)
  refactor(agents): consolidate context budgets and compaction recovery (openclaw#117149)
  fix(net-policy): redact sig and x-* auth params in URLs and bodies (openclaw#116957)
  refactor(agents): remove duplicate generated-media delivery fallbacks (openclaw#117150)
  refactor(reply): unify turn lifecycle state ownership (openclaw#117145)
  fix(ui): preserve emoji agent avatar initials (openclaw#104912)
  refactor(auto-reply): unify command and directive ownership (openclaw#117143)
  refactor(plugins): consolidate descriptor and startup ownership (openclaw#117146)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 1, 2026
* origin/main:
  refactor(ui): replace duplicated locale bundles with canonical translation memory (openclaw#117157)
  fix(ui): retire stale Gateway event-log observers (openclaw#117169)
  fix(agents): keep subagent status consistent after restart and large fan-outs (openclaw#117141)
  test(voice-call): stress paced audio queue drains
  fix(voice-call): avoid shifting paced audio queues
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S 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