Skip to content

fix: gateway stalls while reading stored messages - #156772

Merged
steipete merged 10 commits into
mainfrom
codex/history-broadcast-worker
Sep 24, 2026
Merged

steipete merged 10 commits into
mainfrom
codex/history-broadcast-worker

Conversation

@steipete

@steipete steipete commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Stored-message lookups and message counts still ran SQLite work on the Gateway thread while publishing session updates and serving chat requests.

User Impact

These requests can wait for SQLite without blocking unrelated Gateway work. Message content, sequence positions, archive selection, and access checks stay intact. There are no schema, configuration, retention, or update changes.

Why This Change Was Made

Async reader functions now dispatch by-ID lookups and counts to the existing history worker and share its reader kernel. The Gateway retains delivery ordering and current session authorization. On history-worker capacity refusal, the broadcaster uses its existing sessions.changed invalidation after session-row preparation so clients can refresh the committed update. Swift chat clients handle that invalidation through their existing history refresh owner and retain it through explicit retryable worker refusals. Recovery preserves newer transcript messages, follows the selected session and agent, and stops when its owner is replaced or retired. Backoff releases an abandoned view model. The native realtime adapter also reads from one bounded queue instead of prefetching into a second queue. It preserves all event frames, including chat tool-call completion, and checks the current connection after each read. Incognito databases remain with their process owner, and the synchronous SDK is unchanged. The unused synchronous count entry point moves into the existing test support module.

Evidence

  • Both real-broadcaster regressions fail on the original code after returning the correct payload and sequence, because queued event-loop work has not progressed. Both pass with the repair.
  • Request capture, archive, incognito, missing-store, corruption, cancellation, worker close, query-plan, import-boundary, and Doctor cases pass. The final worker/storage run passed 87 tests across seven files.
  • Connected Gateway WebSocket subscribers receive the stored content and sequence for both read paths. Capacity refusals produce a history invalidation, and subsequent updates use the real worker successfully. Both overload regressions time out against the original broadcaster and pass after the fix. The connected-client suites passed all 33 tests, and the unchanged broadcaster/lifecycle siblings passed 55 tests. Independent session-row preparation failures keep their existing behavior.
  • Independent managed reviews are clean through P2.
  • Initial worker-cutover check:changed and full build passed. The final Gateway correction passed production types, all 25 test-type groups, and 12 remaining selected lint/format/architecture/build commands. Its full-core lint run retained three failures in unchanged files; their fixes have since landed separately on main. Exact-head GitHub CI remains a merge gate.
  • The native launcher/exporter suite passed all 32 tests on Blacksmith Testbox, including export after a failing rendered test and joined cleanup. The Swift/native follow-up has clean independent P2 reviews. A hosted macOS baseline passed 2,285 bulk tests and the existing rendered sibling; the new recovery regression failed because the client made no second history request and left the persisted reply missing. The corrected capture is readable and synthetic. The shared Swift package at c3dcb58 passed 1,781 tests, including both original recovery cases. The native app job at 8c8c76e passed 2,288 bulk tests, both rendered tests, and five named-profile Swift tests. The rendered regression made exactly two selected-history requests and displayed the recovered reply before its unchanged deadline.
  • An existing native overflow regression exposed three retained frames with capacity one. The correction keeps its original count assertion and one-second deadline, and adds event filtering, chat delivery, socket retirement, and cancellation coverage. Independent P2 review and the full native runtime run passed; the original overflow case and all three new sibling cases passed.
  • A warm synthetic comparison preserved exact results over 32 samples. For an 8 MiB message, median main-thread CPU was 7.9 → 6.4 ms and the maximum observed event-loop gap was 14.7 → 8.8 ms. Median request time rose from 8.9 → 17.8 ms; small reads also pay worker-dispatch overhead. Process RSS includes the fixture and existing workers, and heap deltas include GC. These measurements do not establish deployed gains or isolate receipt-deserialization cost. Fixture cleanup joined successfully.

The refused-refresh regression was then exercised on hosted macOS at cf73984: the package run reported 1,781 tests and exactly two issues, both retryable-refusal cases timing out without another message event. The ordinary invalidation cases passed. Candidate d67ce09 adds the retry repair and tests for incremental-message ordering, session/agent/route retirement, authoritative refusals, and abandoned-view cleanup. Its fresh independent P2 review is clean. The candidate shared Swift package job passed all 1,785 tests, including all 13 cases across the recovery and lifecycle groups. The candidate native app job passed 2,288 bulk tests, both rendered tests, and all five named-profile tests. Exact-head CI remains the merge gate.

Native transcript recovery

The production transcript view runs with an isolated synthetic transport. Both captures show the same selected conversation after the same message invalidation.

Before: the reply remains missing.

Before: selected transcript still shows only the question

After: the client fetches history and displays the reply.

After: the selected transcript displays the recovered reply

Passing native job · Failing baseline job

Test costs

Measured test-body totals on Blacksmith Testbox: broadcaster 3.1 s, request-capture/queue 0.2 s, lookup 6.8 s, lifecycle 20.5 s, and worker integration 30.3 s. The integration file verifies cold restoration, canonical admission, branch/reset behavior, and cross-thread reads against real SQLite stores; mocks would not exercise those boundaries. The connected-client cases reuse the existing Gateway sessions harness and verify real socket delivery with real SQLite; only the capacity refusal is injected at the existing worker boundary. Import-only test migrations retain their existing assertions.

@clawsweeper

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

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime commands Command implementations size: L labels Sep 23, 2026
@steipete
steipete marked this pull request as ready for review September 23, 2026 21:21
@steipete steipete self-assigned this Sep 23, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 23, 2026
@clawsweeper

clawsweeper Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 24, 2026, 12:57 AM ET / 04:57 UTC (Revision 9).

ClawSweeper review

What this changes

The branch moves Gateway stored-message lookups and counts to the SQLite history worker, adds overload invalidation and native chat recovery, and changes macOS realtime event buffering.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⛔ Blocked before merge - 3 items remain

The prior macOS retry concern is supported by passing current-head jobs. One delivery gap remains: after a worker-overload invalidation, Android can lose its only transcript refresh to another retryable refusal and leave a committed message out of view until a later trigger.

Priority: P1
Reviewed head: d67ce09212aabbf1ef0d5138a54126d91e022746

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Strong boundary and native evidence supports the main repair, but the Android overload path needs one focused delivery fix.
Proof confidence 🐚 platinum hermit (4/6) ✨ media proof bonus Sufficient (screenshot): A connected Gateway WebSocket test exercises stored SQLite delivery and injected overload through the production broadcaster; inspected before/after native screenshots show selected-chat recovery, and exact-head macOS package and app jobs passed the retry cases. Android recovery after a second worker refusal remains a correctness gap. No stored-data contract changes.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Verified Sufficient (screenshot): A connected Gateway WebSocket test exercises stored SQLite delivery and injected overload through the production broadcaster; inspected before/after native screenshots show selected-chat recovery, and exact-head macOS package and app jobs passed the retry cases. Android recovery after a second worker refusal remains a correctness gap. No stored-data contract changes.
Evidence reviewed 9 items Introduced overload fallback: The new catch converts an overloaded stored-message read into an invalidation after session-row preparation.
Android consumer: A selected phase=message invalidation starts one best-effort transcript read; a thrown read becomes Failed, and Transcript-purpose failures do not schedule recovery.
Retryable Gateway response: A busy history worker produces a retryable UNAVAILABLE response with a retry delay, making a second refused read a supported scenario.
Findings 1 actionable finding [P2] Retry Android history after an overload invalidation
Security None None.

How this fits together

The Gateway reads committed session transcripts and sends updates to subscribed chat clients. Those clients combine live events with history requests to display the selected conversation.

flowchart LR
  A[Stored transcript] --> B[Gateway update]
  B --> C[History worker]
  C --> D{Read available?}
  D -->|Yes| E[Message event]
  D -->|Overloaded| F[History invalidation]
  E --> G[Chat clients]
  F --> G
Loading

Before merge

  • Retry Android history after an overload invalidation (P2) - When this catch substitutes sessions.changed for a stored message, Android makes one selected-transcript chat.history request. If the worker is still full, Android catches the retryable refusal and schedules no Transcript-purpose recovery, so the committed message can remain absent without another event. Add a scoped retry in the Android consumer. This is a late discovery: the overload hunk is unchanged since the earlier reviewed a912a8a head.
  • Resolve merge risk (P1) - Under sustained history-worker saturation, Android can receive a message invalidation, lose its one transcript refresh to retryable UNAVAILABLE, and leave the committed message out of view until another trigger.
  • Complete next step (P2) - Repair and validate Android selected-transcript recovery after a retryable history refusal before merge.

Findings

  • [P2] Retry Android history after an overload invalidation — src/gateway/server-session-events.ts:293-299
Agent review details

Security

None.

PR surface

Source +128, Tests +282, Docs +7, Other +652. Total +1069 across 34 files.

View PR surface stats
Area Files Added Removed Net
Source 9 196 68 +128
Tests 15 385 103 +282
Docs 1 7 0 +7
Config 0 0 0 0
Generated 0 0 0 0
Other 9 733 81 +652
Total 34 1321 252 +1069

Review metrics

Metric Value Why it matters
Net code growth production +201 lines, tests +860 lines The worker paths and client recovery justify production growth; regression coverage accounts for most of the added code.

Merge-risk options

Maintainer options:

  1. Repair Android recovery (recommended)
    Retain and retry the selected transcript invalidation after retryable history refusals, with Gateway, agent, and session retirement checks.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Repair Android selected-transcript recovery after a phase=message invalidation when chat.history returns retryable UNAVAILABLE. Retain a bounded retry obligation tied to the current Gateway, agent, and session; cancel it on replacement. Add a focused regression with one refusal followed by success without another event. Preserve the worker cutover and broadcast ordering.

Technical review

Best possible solution:

Keep the worker cutover and ordered broadcasts, and give Android a bounded, current-session-owned retry for message invalidations that survives a temporary history refusal.

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

Yes. Current-main source performs the targeted stored reads on the Gateway thread, and the PR supplies a real broadcaster regression; this read-only review did not execute it. The Android refusal gap follows directly from the new overload path and Android's one-shot consumer.

Is this the best way to solve the issue?

Not yet. The existing history worker is the appropriate read owner, but its invalidation fallback needs reliable recovery in Android as well as the covered clients.

Full review comments:

  • [P2] Retry Android history after an overload invalidation — src/gateway/server-session-events.ts:293-299
    When this catch substitutes sessions.changed for a stored message, Android makes one selected-transcript chat.history request. If the worker is still full, Android catches the retryable refusal and schedules no Transcript-purpose recovery, so the committed message can remain absent without another event. Add a scoped retry in the Android consumer. This is a late discovery: the overload hunk is unchanged since the earlier reviewed a912a8a head.
    Confidence: 0.93
    Late finding: first raised on code an earlier review cycle already covered.

Overall correctness: patch is incorrect
Overall confidence: 0.92

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 6a6f8a6ecec2.

Labels

Label changes:

No label changes.

Label justifications:

  • P1: The PR addresses Gateway responsiveness during active chat and has a remaining selected-message recovery failure.
  • merge-risk: 🚨 message-delivery: The new overload fallback can replace a stored-message event with an invalidation that Android does not reliably recover.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (screenshot): A connected Gateway WebSocket test exercises stored SQLite delivery and injected overload through the production broadcaster; inspected before/after native screenshots show selected-chat recovery, and exact-head macOS package and app jobs passed the retry cases. Android recovery after a second worker refusal remains a correctness gap. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. A connected Gateway WebSocket test exercises stored SQLite delivery and injected overload through the production broadcaster; inspected before/after native screenshots show selected-chat recovery, and exact-head macOS package and app jobs passed the retry cases. Android recovery after a second worker refusal remains a correctness gap. No stored-data contract changes.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. A connected Gateway WebSocket test exercises stored SQLite delivery and injected overload through the production broadcaster; inspected before/after native screenshots show selected-chat recovery, and exact-head macOS package and app jobs passed the retry cases. Android recovery after a second worker refusal remains a correctness gap. No stored-data contract changes.

Evidence

Acceptance criteria:

  • [P1] pnpm android:test.
  • [P1] node scripts/run-vitest.mjs run src/gateway/session-message-events.history-worker.test.ts.
  • [P1] git diff --check.

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vincent Koc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Ayaan Zaidi: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

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

  • Prove Android recovers a selected committed message after a retryable history refusal without another Gateway event.

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 (8 earlier review cycles)
  • reviewed 2026-09-23T21:29:05.733Z sha 73b0b4b :: needs real behavior proof before merge. :: [P2] Preserve transcript broadcasts when worker admission is full
  • reviewed 2026-09-23T22:32:57.669Z sha a912a8a :: blocked before merge. :: [P2] Refresh Swift chat after a worker-overload invalidation
  • reviewed 2026-09-24T01:54:19.836Z sha 06e77a1 :: blocked before merge. :: [P2] Refresh selected native chat after an overload invalidation
  • reviewed 2026-09-24T02:30:22.350Z sha c3dcb58 :: blocked before merge. :: [P2] Retain invalidation when the history refresh is refused
  • reviewed 2026-09-24T03:36:11.730Z sha 8c8c76e :: blocked before merge. :: [P2] Retry a refused history refresh after message invalidation
  • reviewed 2026-09-24T04:00:34.275Z sha 8c8c76e :: blocked before merge. :: [P2] Retry a refused history refresh after message invalidation
  • reviewed 2026-09-24T04:20:13.692Z sha cf73984 :: blocked before merge. :: [P2] Retry a refused history refresh after message invalidation
  • reviewed 2026-09-24T04:29:25.294Z sha d67ce09 :: blocked before merge. :: none

@clawsweeper clawsweeper Bot added merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. 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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 23, 2026
@openclaw-barnacle openclaw-barnacle Bot added app: macos App: macos scripts Repository scripts labels Sep 24, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Sep 24, 2026
@clawsweeper clawsweeper Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Sep 24, 2026
@clawsweeper clawsweeper Bot added the proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. label Sep 24, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 24, 2026
@steipete
steipete merged commit 9ce7d58 into main Sep 24, 2026
246 checks passed
@steipete
steipete deleted the codex/history-broadcast-worker branch September 24, 2026 05:31
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

@roboclaw-bot roboclaw-bot mentioned this pull request Sep 24, 2026
2 of 8 tasks
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 25, 2026
* fix(gateway): offload stored message lookups and counts

* fix: keep message lookup result in shared history contract

* fix: invalidate session history when worker admission is full

* test(macos): capture message invalidation recovery

* test(macos): frame transcript recovery capture

* fix(chat): refresh transcript after message invalidation

* fix(macos): keep realtime events in one bounded queue

* refactor(macos): remove superseded push subscription

* test(chat): cover retryable history refusal

* fix(chat): retain history invalidation through retryable refusals
steipete added a commit that referenced this pull request Oct 13, 2026
* refactor(apple): simplify old shared and macOS bookkeeping

Replace redundant generations with existing cancellation or actual owner
identity, consolidate parallel fallback/policy paths, and remove test-only
forwarding layers. Preserve authority, FIFO, durable state, resource bounds,
public protocol/config shapes, signing, permissions, and visible rendering.

Reuse canonical session-key normalization for Voice Wake delivery selection:
opaque Signal group IDs remain case-sensitive and main aliases are not added.
Use canonical IP-literal policy for discovery labels and remote CLI validation.

Best-effort tradeoffs accepted

- Palette generation (#159350): synthetic direct completions bypassed the sole cancellation-owning caller; unsupported future callers can show stale results until the next search. Current cancellation/request/agent checks remain.
- Link preview generation (#160710): synthetic URL replacement without caller cancellation is outside the SwiftUI task lifecycle; a late cosmetic result can remain until the next refresh. Network/SSRF checks and bounded caches remain.
- Sidebar preview generation (#147197): same-request overlapping cache reads can finish out of order; no linked human failure report, and a later refresh replaces the cosmetic projection. Owner/request checks remain.
- Source-preview producer revision (#148906): duplicate of exact task cancellation, with no human failure report. Consumer revision and authenticated resource authority remain.
- Mermaid generations (#135470/#135746): feature stress fixtures, no linked human race report. Exact subscriber cancellation and job/WebView identity retain the same admission; no extra failure accepted.
- Camera JPEG UUID (#107879): duplicates exact task cancellation; #107804 was a human feature request, not a generation-specific incident. Captured session/agent/route and attachment admission remain.
- Discovery generation (#145435): speculative queued callbacks, no linked human incident. A stopped browser may publish one late discovery projection; next discovery/refresh repairs it. Connection authority remains separate.
- FSEvents generation (#145453): synthetic stop/restart fixtures, no linked human incident. An old callback after restart may cause one extra refresh; serial lifecycle ownership and pending-work cancellation remain.
- Menu generations (#139688): feature-local late-result fixtures, no linked human incident. Exact task cancellation replaces duplicate tokens; drain-before-disconnect and real consumer/window authority remain.
- Cron generation (#131466/#137502): #138209 cut every load over to one cancel-and-drain chain. No direct concurrent load caller remains; cancellation and physical source leases stay checked after awaits.
- WebChat visibility acknowledgement/retry (#113634/#137089): synthetic timeout/reconnect interleavings, no linked human incident. A timed-out visibility update is best effort until the next transition/reconnect; FIFO and live socket leases remain.
- WebChat cleanup UUID (#113634/#137089): retain one bounded completed Task handle per live connection instead of matching cleanup tokens. Completion releases captures; replacement/retirement removes the handle.
- Child-exit polling (#145437): synthetic missed-notification coverage, no linked human report. A lost OS exit notification may wait for the existing deadline; final non-reaping liveness/status checks and cleanup remain.
- Realtime iterator borrowing trap (#156772): every real consumer awaits its own iterator sequentially. Unsupported concurrent next calls no longer get a custom custody protocol; bounded stream/cancellation/socket checks remain.
- Receipt projection admission (#161745): both real callers already match receipt and row identity immediately before synchronous projection. Those effect checks remain; no unsupported internal caller is defended twice.
- Recap attribution heuristics (#112188/#113084): synthetic guard matrix, no linked human race report. Missing initial rows or very late unrelated completion may supply a cosmetic footer; per-session freshness, failed-turn handling and settled results remain.
- PortGuardian per-write schema scans (#110527): synthetic live-handle version advance, no linked human incident. Concurrent external schema upgrades are best effort until reopen; initial admission, migration locks, receipts, transactions and durability remain.
- Unread queue counter (#110019): actual Task equality replaces the duplicate integer token. Exact-tail reclamation, bounded bookkeeping, FIFO and route authority remain unchanged.

Review dispositions: the claimed Task compilation failure is disproved by the
selected SDK's Equatable conformance and native builds. Repeated receipt
identity admission is unnecessary at its internal projector because both real
callers retain it immediately before projection. Per-write schema revalidation
was declined under the explicit best-effort policy above.

Proof and scope

Net production reduction: 369 lines (148 added, 517 deleted), excluding tests.
Fresh seven-day census permits all substantive production edits; the only
recent caller change is the unavoidable one-line fallback-to-parse rename.

Shared Swift build passed. Final focused shared tests passed 396 cases in six
suites (6.683s execution), Watch decoder tests passed five cases (0.003s), and
isolated whole-owner native tests passed 16 cases. macOS SwiftPM compiled all
products and the test bundle. Final macOS and iOS/Watch xcodebuild builds passed
(89.60s and 120.87s wall), without signing changes or app launches.

Canonical Apple lint/format checks passed; the initial iOS format failure in
WatchCommands was ours and corrected, with no gate weakened. Lint-suppression
tests passed 3/3 (14.09s wall). Earlier runtime cycles and Madge each reported 0;
the TypeScript graph is unchanged. Native localization stayed at 4476 entries.
The 45 original packaging/elevation timeout cases passed one focused retry
(94.79s wall), with no assertion/budget change and no claim of a diagnosed fix.

Known gaps: seven issues remained in the earlier ChatStreamReplayTests
narration=false package cases; causality/current-main attribution is unproven.
App-hosted macOS tests were not executed on the operator desktop. No hosted CI
or PR was started: the explicit BELOW-500 rule requires a branch-only handoff.

* refactor(ui): consolidate old UI owners and validation

Share route decoding, attachment retention, gallery preparation, transient
identity encoding, override copying, and extension classification. Remove
duplicate admission/schema mirrors and obsolete supported-browser fallbacks.
Both Lit and Solid paths remain; no rendering change is intended. No config,
protocol, persisted shape, dependency, or public SDK change.

Best-effort tradeoffs accepted

- Malformed internal native requests (#140988): all callers are typed and
  native hosts validate at the effect; their error replaces the renderer mirror.
- Worker replacement during an identity query (#140484): added for synthetic
  autoreview interleavings, not a human incident. Return false; normal worker
  announcements and foreground recovery observe the next active worker.
- Native readiness changing between synchronous checks (#140484/#109719):
  rely on queued events. A broken native event can require another worker event
  or reload; camera readiness retains its existing five-second error deadline.
- Overlapping application-root health reporters (#152638): startup mounts one
  root. Unsupported overlapping roots are last-publication-wins; the actual
  reported health/status feature and native trusted-document checks remain.
- Polling after stop (#139704): its sole owner retires eligibility first.
  Scheduling now uses that owner admission, not a separate read-only generation.
- Resetting an observer without retiring its connection (#116887): no production
  caller does this. Canonical connection epochs remain the sole retirement owner;
  unsupported direct live-scope reset no longer fences an old response separately.
- Upload policy changing during local reads (#158567): decoded/hash work can
  finish. Draft publication and every upload request retain live policy checks.
- Missing supported browser primitives (#105240/#151388/#100024/#102745):
  unsupported runtimes error instead of code-point initials, skipped input yield,
  wall-clock timing, or approximate microtask paint. The human progress-card fix
  in #151386 keeps its browser yield and durable FIFO handoff unchanged.
- URL APIs disappearing after URL creation (#100024/#149330): supported browsers
  keep paired APIs. An unsupported replaced global can throw during cleanup;
  undefined URLs, creation fallback, cancellation and release ordering remain.
- Malformed internal MCP calls bypassing AppBridge (#161747): may throw. The SDK
  still rejects malformed wire blocks before dispatch, proved over real in-memory
  App/AppBridge transport. UI content, authority, confirmation and custody policy
  remain. The introducing PR cites no human incident for the second mirror.

Production: +176/-394, net -218 lines across 21 eligible old files. Tests: +30.
Focused owner/sibling tests, targeted types/lint/format, lint-suppression and
independent P0-P2 review pass. Import edges are unchanged; runtime/Madge cycle
proof remains zero. Whole-tree Knip timed out at existing limits; heavy gallery
renderer runs did not reach assertions, while its owning controller suite passed.

* refactor(ui): remove obsolete Fetch capability branch

The supported Control UI browser floor includes Fetch. Start attachment
metadata reads directly rather than leaving an unsupported runtime in a
permanent checking state.

Best-effort tradeoffs accepted

- Missing global Fetch: the guard originated in #64104, whose feature report
  cites no human missing-Fetch incident. An unsupported runtime that replaces
  Fetch now reaches the existing rejected-request/unavailable path. Metadata
  validation, auth/tickets, allow POST, cancellation, resource admission,
  expiry and bounded retry remain unchanged. No intended rendering change.

Unchanged lifecycle baseline: 21/21, 25.09 s. Final lifecycle and attachment
siblings: 50/50, 14.77 s. UI types, typed lint, formatting and lint-suppression
checks pass. This cut removes five production lines including formatter
reflow, bringing the lane to 223 net production lines removed.
Fresh independent P0-P2 review is scoped-clean with no actionable findings.

* fix(ui): use global frame scheduling APIs

Preserve double-frame paint timing and cancellation without requiring a Window object in renderer-free hosts that supply the standard global APIs. The existing access suite reproduces seven unhandled errors before this fix and passes on main; all 130 affected cases plus 262 timing/state/send sibling cases now pass without test changes.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 14, 2026
…#170823)

* refactor(apple): simplify old shared and macOS bookkeeping

Replace redundant generations with existing cancellation or actual owner
identity, consolidate parallel fallback/policy paths, and remove test-only
forwarding layers. Preserve authority, FIFO, durable state, resource bounds,
public protocol/config shapes, signing, permissions, and visible rendering.

Reuse canonical session-key normalization for Voice Wake delivery selection:
opaque Signal group IDs remain case-sensitive and main aliases are not added.
Use canonical IP-literal policy for discovery labels and remote CLI validation.

Best-effort tradeoffs accepted

- Palette generation (openclaw#159350): synthetic direct completions bypassed the sole cancellation-owning caller; unsupported future callers can show stale results until the next search. Current cancellation/request/agent checks remain.
- Link preview generation (openclaw#160710): synthetic URL replacement without caller cancellation is outside the SwiftUI task lifecycle; a late cosmetic result can remain until the next refresh. Network/SSRF checks and bounded caches remain.
- Sidebar preview generation (openclaw#147197): same-request overlapping cache reads can finish out of order; no linked human failure report, and a later refresh replaces the cosmetic projection. Owner/request checks remain.
- Source-preview producer revision (openclaw#148906): duplicate of exact task cancellation, with no human failure report. Consumer revision and authenticated resource authority remain.
- Mermaid generations (openclaw#135470/openclaw#135746): feature stress fixtures, no linked human race report. Exact subscriber cancellation and job/WebView identity retain the same admission; no extra failure accepted.
- Camera JPEG UUID (openclaw#107879): duplicates exact task cancellation; openclaw#107804 was a human feature request, not a generation-specific incident. Captured session/agent/route and attachment admission remain.
- Discovery generation (openclaw#145435): speculative queued callbacks, no linked human incident. A stopped browser may publish one late discovery projection; next discovery/refresh repairs it. Connection authority remains separate.
- FSEvents generation (openclaw#145453): synthetic stop/restart fixtures, no linked human incident. An old callback after restart may cause one extra refresh; serial lifecycle ownership and pending-work cancellation remain.
- Menu generations (openclaw#139688): feature-local late-result fixtures, no linked human incident. Exact task cancellation replaces duplicate tokens; drain-before-disconnect and real consumer/window authority remain.
- Cron generation (openclaw#131466/openclaw#137502): openclaw#138209 cut every load over to one cancel-and-drain chain. No direct concurrent load caller remains; cancellation and physical source leases stay checked after awaits.
- WebChat visibility acknowledgement/retry (openclaw#113634/openclaw#137089): synthetic timeout/reconnect interleavings, no linked human incident. A timed-out visibility update is best effort until the next transition/reconnect; FIFO and live socket leases remain.
- WebChat cleanup UUID (openclaw#113634/openclaw#137089): retain one bounded completed Task handle per live connection instead of matching cleanup tokens. Completion releases captures; replacement/retirement removes the handle.
- Child-exit polling (openclaw#145437): synthetic missed-notification coverage, no linked human report. A lost OS exit notification may wait for the existing deadline; final non-reaping liveness/status checks and cleanup remain.
- Realtime iterator borrowing trap (openclaw#156772): every real consumer awaits its own iterator sequentially. Unsupported concurrent next calls no longer get a custom custody protocol; bounded stream/cancellation/socket checks remain.
- Receipt projection admission (openclaw#161745): both real callers already match receipt and row identity immediately before synchronous projection. Those effect checks remain; no unsupported internal caller is defended twice.
- Recap attribution heuristics (openclaw#112188/openclaw#113084): synthetic guard matrix, no linked human race report. Missing initial rows or very late unrelated completion may supply a cosmetic footer; per-session freshness, failed-turn handling and settled results remain.
- PortGuardian per-write schema scans (openclaw#110527): synthetic live-handle version advance, no linked human incident. Concurrent external schema upgrades are best effort until reopen; initial admission, migration locks, receipts, transactions and durability remain.
- Unread queue counter (openclaw#110019): actual Task equality replaces the duplicate integer token. Exact-tail reclamation, bounded bookkeeping, FIFO and route authority remain unchanged.

Review dispositions: the claimed Task compilation failure is disproved by the
selected SDK's Equatable conformance and native builds. Repeated receipt
identity admission is unnecessary at its internal projector because both real
callers retain it immediately before projection. Per-write schema revalidation
was declined under the explicit best-effort policy above.

Proof and scope

Net production reduction: 369 lines (148 added, 517 deleted), excluding tests.
Fresh seven-day census permits all substantive production edits; the only
recent caller change is the unavoidable one-line fallback-to-parse rename.

Shared Swift build passed. Final focused shared tests passed 396 cases in six
suites (6.683s execution), Watch decoder tests passed five cases (0.003s), and
isolated whole-owner native tests passed 16 cases. macOS SwiftPM compiled all
products and the test bundle. Final macOS and iOS/Watch xcodebuild builds passed
(89.60s and 120.87s wall), without signing changes or app launches.

Canonical Apple lint/format checks passed; the initial iOS format failure in
WatchCommands was ours and corrected, with no gate weakened. Lint-suppression
tests passed 3/3 (14.09s wall). Earlier runtime cycles and Madge each reported 0;
the TypeScript graph is unchanged. Native localization stayed at 4476 entries.
The 45 original packaging/elevation timeout cases passed one focused retry
(94.79s wall), with no assertion/budget change and no claim of a diagnosed fix.

Known gaps: seven issues remained in the earlier ChatStreamReplayTests
narration=false package cases; causality/current-main attribution is unproven.
App-hosted macOS tests were not executed on the operator desktop. No hosted CI
or PR was started: the explicit BELOW-500 rule requires a branch-only handoff.

* refactor(ui): consolidate old UI owners and validation

Share route decoding, attachment retention, gallery preparation, transient
identity encoding, override copying, and extension classification. Remove
duplicate admission/schema mirrors and obsolete supported-browser fallbacks.
Both Lit and Solid paths remain; no rendering change is intended. No config,
protocol, persisted shape, dependency, or public SDK change.

Best-effort tradeoffs accepted

- Malformed internal native requests (openclaw#140988): all callers are typed and
  native hosts validate at the effect; their error replaces the renderer mirror.
- Worker replacement during an identity query (openclaw#140484): added for synthetic
  autoreview interleavings, not a human incident. Return false; normal worker
  announcements and foreground recovery observe the next active worker.
- Native readiness changing between synchronous checks (openclaw#140484/openclaw#109719):
  rely on queued events. A broken native event can require another worker event
  or reload; camera readiness retains its existing five-second error deadline.
- Overlapping application-root health reporters (openclaw#152638): startup mounts one
  root. Unsupported overlapping roots are last-publication-wins; the actual
  reported health/status feature and native trusted-document checks remain.
- Polling after stop (openclaw#139704): its sole owner retires eligibility first.
  Scheduling now uses that owner admission, not a separate read-only generation.
- Resetting an observer without retiring its connection (openclaw#116887): no production
  caller does this. Canonical connection epochs remain the sole retirement owner;
  unsupported direct live-scope reset no longer fences an old response separately.
- Upload policy changing during local reads (openclaw#158567): decoded/hash work can
  finish. Draft publication and every upload request retain live policy checks.
- Missing supported browser primitives (openclaw#105240/openclaw#151388/openclaw#100024/openclaw#102745):
  unsupported runtimes error instead of code-point initials, skipped input yield,
  wall-clock timing, or approximate microtask paint. The human progress-card fix
  in openclaw#151386 keeps its browser yield and durable FIFO handoff unchanged.
- URL APIs disappearing after URL creation (openclaw#100024/openclaw#149330): supported browsers
  keep paired APIs. An unsupported replaced global can throw during cleanup;
  undefined URLs, creation fallback, cancellation and release ordering remain.
- Malformed internal MCP calls bypassing AppBridge (openclaw#161747): may throw. The SDK
  still rejects malformed wire blocks before dispatch, proved over real in-memory
  App/AppBridge transport. UI content, authority, confirmation and custody policy
  remain. The introducing PR cites no human incident for the second mirror.

Production: +176/-394, net -218 lines across 21 eligible old files. Tests: +30.
Focused owner/sibling tests, targeted types/lint/format, lint-suppression and
independent P0-P2 review pass. Import edges are unchanged; runtime/Madge cycle
proof remains zero. Whole-tree Knip timed out at existing limits; heavy gallery
renderer runs did not reach assertions, while its owning controller suite passed.

* refactor(ui): remove obsolete Fetch capability branch

The supported Control UI browser floor includes Fetch. Start attachment
metadata reads directly rather than leaving an unsupported runtime in a
permanent checking state.

Best-effort tradeoffs accepted

- Missing global Fetch: the guard originated in openclaw#64104, whose feature report
  cites no human missing-Fetch incident. An unsupported runtime that replaces
  Fetch now reaches the existing rejected-request/unavailable path. Metadata
  validation, auth/tickets, allow POST, cancellation, resource admission,
  expiry and bounded retry remain unchanged. No intended rendering change.

Unchanged lifecycle baseline: 21/21, 25.09 s. Final lifecycle and attachment
siblings: 50/50, 14.77 s. UI types, typed lint, formatting and lint-suppression
checks pass. This cut removes five production lines including formatter
reflow, bringing the lane to 223 net production lines removed.
Fresh independent P0-P2 review is scoped-clean with no actionable findings.

* fix(ui): use global frame scheduling APIs

Preserve double-frame paint timing and cancellation without requiring a Window object in renderer-free hosts that supply the standard global APIs. The existing access suite reproduces seven unhandled errors before this fix and passes on main; all 130 affected cases plus 262 timing/state/send sibling cases now pass without test changes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: macos App: macos commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant