Repository navigation
fix(gateway): make activeRunIds presence mean a complete exact run set - #126106
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: found issues before merge. Reviewed August 19, 2026, 3:49 AM ET / 07:49 UTC. ClawSweeper reviewWhat this changesThe PR redefines Gateway Merge readiness⛔ Blocked by patch quality or review findings - 7 items remain Keep open: the new Priority: P1 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherGateway combines direct, projected, and embedded run ownership into session snapshots and events. Web and native caches consume those facts to show session activity and exact run-owned UI safely. flowchart LR
A[Direct and hidden run owners] --> B[Gateway run-state resolver]
B --> C[Snapshot exact-set projection]
B --> D[Incremental event tombstone]
C --> E[Web and updated native caches]
D --> E
D --> F[Existing Apple clients]
E --> G[Current session activity UI]
F --> H[Stale run identity risk]
Decision needed
Why: The new event meaning conflicts with current-main Apple merge semantics, and selecting a protocol capability or release-coordination boundary requires maintainer ownership. Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +32, Tests +179, Docs +20, Other +294. Total +525 across 29 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Introduce an owner-approved, capability-gated transition: preserve the legacy clear encoding for pre-change native clients and emit the null tombstone only to clients that explicitly support it, with legacy-client regression coverage and after-fix native evidence. Do we have a high-confidence way to reproduce the issue? Yes, from source: start a current-main Apple cache with an exact ID, then deliver this PR's Gateway event containing Is this the best way to solve the issue? No: the updated-client cache repair is sound, but unconditional null emission is not the best solution while supported Apple clients use the current non-null-only merge behavior. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 0151ef17b3d6. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (6 earlier review cycles)
|
7a76547 to
c3eb3d6
Compare
Session rows no longer emit activeRunIds: [] while hasActiveRun is true. Presence now means the complete exact set of direct run ids; omission means identities are unavailable (projected/embedded owners); [] only ever represents proven idle. Consumers stop guessing: soleActiveSessionRunId() replaces the arbitrary [0] fallbacks in the observer digest, transcript cache key, activity inspector, and stale-terminal reconciliation, each falling back to its owner fact. Follows the maintainer direction from #125983: the field stays as Gateway-owned exact facts; producer-side liveness/observer projections are a named follow-up.
c3eb3d6 to
881f8aa
Compare
This comment has been minimized.
This comment has been minimized.
|
@clawsweeper re-review The compatibility P1 is resolved by owner-directed decoder evidence now recorded in the PR body. At both installed beta tags, Apple decodes |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review Retrying once because run 32230132956 completed its model review but stalled past lease expiry in |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Merged via squash.
|
openclaw#126106) * fix(gateway): make activeRunIds presence mean a complete exact run set Session rows no longer emit activeRunIds: [] while hasActiveRun is true. Presence now means the complete exact set of direct run ids; omission means identities are unavailable (projected/embedded owners); [] only ever represents proven idle. Consumers stop guessing: soleActiveSessionRunId() replaces the arbitrary [0] fallbacks in the observer digest, transcript cache key, activity inspector, and stale-terminal reconciliation, each falling back to its owner fact. Follows the maintainer direction from openclaw#125983: the field stays as Gateway-owned exact facts; producer-side liveness/observer projections are a named follow-up. * fix(gateway): clear unavailable active run ids in events * fix(gateway): preserve idle active run sets * fix(clients): close active run id cache gaps * test(android): isolate history run snapshot
Related: #125983
What Problem This Solves
Sessions could report
hasActiveRun: truewithactiveRunIds: []because exact IDs came only from direct chat abort controllers while aggregate liveness also includes projected lifecycle and embedded owners. That empty list looked like a proven idle exact set even though another owner was active. Incremental events also needed an explicit way to invalidate an exact set already cached by a client when ownership moved to a source that exposes only aggregate liveness.Why This Change Was Made
This implements the supported direction in the #125983 maintainer close decision: the field remains Gateway-owned exact fact. Full snapshots use presence for a complete exact set, omission for identities unavailable, and
[]for proven idle. Incremental session-change and lifecycle events use an event-onlynulltombstone to clear a previously cached exact set to unavailable; plain event omission remains no change.One
soleActiveSessionRunId()helper replaces arbitrary first-run selection in observer digest, transcript cache keys, activity inspection, and stale-terminal reconciliation, each with its owner-fact fallback. Gateway event projection now owns the tombstone, while web, Android, and Apple cache reconciliation preserve the distinction between omitted and explicitly null fields. Producer-side liveness/observer projections beyond this exact-set contract remain the named follow-up requiring an owner-level Gateway contract.Protocol Compatibility Decision
Owner direction was to decide the event-only
nulltombstone by the decoders shipped in the installed beta lines, not to gate the repair by default. Both inspected lines are null-tolerant, so the tombstone remains unchanged:v2026.8.1-beta.2, generated SwiftGatewayModels.swiftlines 6010-6072 defineSessionRowwithoutactiveRunIds; generated KotlinGatewayProtocol.ktlines 42-44 carry event payloads as nullableJsonElementand line 602 only namessessions.changed. The actual Apple event decoder inChatTransport.swiftlines 152-156 usesdecodeIfPresent, includingactiveRunIdsat line 181. The Android parser inChatController.ktlines 6620-6623 usesasArrayOrNull, whose safe-cast implementation at line 7417 turnsJsonNullintonull.v2026.7.2-beta.7, generated SwiftGatewayModels.swiftlines 4961-5016 likewise omit the field; generated KotlinGatewayProtocol.ktlines 42-44 use nullableJsonElementand line 524 only names the event. The Apple decoder usesdecodeIfPresentatChatTransport.swiftlines 120-125 and applies it toactiveRunIdsat line 149. Android uses the null-safe array parse atChatController.ktlines 6259-6262, backed by the safe cast at line 7056.Therefore already-installed beta-line native clients decode a present
nullwithout rejecting the event. They treat it as nil and retain their current pre-fix stale-ID behavior until upgraded; there is no crash or new failure mode. These beta builds carry no compatibility obligation, andactiveRunIdswas schema-absent implementation surface in their generated protocol models.User Impact
Projected or hidden-owner sessions no longer masquerade as idle or retain a stale exact run ID after ownership changes. Otherwise behavior is unchanged.
Evidence
activeRunIdsinstead of emitting[]; the focused list suite failed 3 tests while the identities-unavailable assertion stayed correct.session.message; Android has the equivalent reconnect-history regression, while the web snapshot replacement regression was already green.node scripts/run-vitest.mjs src/gateway/server.sessions.list-changed.test.ts src/gateway/server-methods/session-active-runs.test.ts src/gateway/server-methods/chat-history-handler.test.ts— 56 tests passed, covering idle[], unavailable omission, and the already-consistent history path.node scripts/run-vitest.mjs src/gateway/server-methods/session-change-event.test.ts src/gateway/server-session-events.test.ts src/gateway/server-chat.agent-events.test.ts ui/src/lib/sessions/reconcile.test.ts— 203 tests passed for event tombstones and client reconciliation.node scripts/run-vitest.mjs ui/src/lib/sessions/reconcile.test.ts— 22 tests passed, covering snapshot replacement plus delta omission/tombstone behavior.swift test --package-path apps/shared/OpenClawKit --filter ChatViewModelTests— 286 tests passed, including snapshot, reconnect, ordinary event, lifecycle, andsession.messagecache paths.swift test --package-path apps/shared/OpenClawKit --filter ChatSessionSidebarModelTests— 39 tests passed.ui/src/lib/observer-digest.test.ts,ui/src/lib/sessions/index.test.ts,ui/src/pages/chat/chat-projection-run-id.test.ts,src/gateway/server-methods/session-active-runs.test.ts) — 50 tests passed.sessions.listremoved the row before the history assertion. The regression now holds that list request pending so it measures the authoritative history snapshot directly; the same run also had an unrelated managed-child-process timing flake.pnpm check:docs— clean: 0 Markdown issues and 0 broken internal links.f81b16c82571b869b9b348524944994ae7907788(run 32222591000, attempt 2), including Android, Swift, Node, docs, and UI E2E.The source-blind overlap harness cannot manufacture projected/embedded owner state, so this PR claims focused owner-boundary and client-cache regressions plus exact-head CI, not live overlap proof.