Skip to content

refactor(gateway): generalize bulk session patches - #120629

Merged
steipete merged 4 commits into
mainfrom
steipete/sessions-patch-many
Aug 8, 2026
Merged

steipete merged 4 commits into
mainfrom
steipete/sessions-patch-many

Conversation

@steipete

@steipete steipete commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

The first fast multi-session archive path introduced an archive-specific sessions.archiveMany RPC while other sidebar batch mutations still serialized sessions.patch calls. That left two mutation shapes for the same policy owner and did not improve bulk read/unread or category changes.

Why This Change Was Made

This replaces the unshipped archive-specific contract outright with bounded sessions.patchMany({ targets, patch }). The shared patch supports the existing singular mutation surface, derives write/admin scope from the patch fields, authorizes every target before dispatch, and delegates each target to canonical sessions.patch with target-local commit-time authorization fencing.

The Control UI now uses the same batch path for archive/restore, read/unread, and category assignment. Older Gateways fall directly back to serial sessions.patch; no sessions.archiveMany alias or compatibility layer remains.

User Impact

Multi-select session organization keeps the fast archive behavior and now applies it consistently to read/unread and category changes. Ordered partial failures, stale-scope protection, one authoritative refresh, archive undo, and older-Gateway behavior are preserved. An all-archived selection also now displays the correct Restore {count} action label.

Evidence

  • Protocol/scope/list tests: 241 passed.
  • Gateway/plugin authorization tests: 35 passed.
  • Control UI/sidebar/mock tests: 298 passed.
  • Focused final Gateway/UI mutation tests: 24 passed.
  • Browser E2E: 8 passed, including one modern batch RPC, zero singular patch RPCs for archive, one final refresh, and ordered partial failures.
  • pnpm build: passed.
  • Plugin SDK API manifest, deadcode, boundaries, i18n, formatting, core/UI typechecks, and core lint: passed through the classified changed-file gate.
  • Autoreview: clean with no accepted/actionable findings.
  • Local app lint gap: SwiftLint crashed before source diagnostics because local SourceKit could not load sourcekitdInProc.framework; exact-head hosted CI is required to prove that lane.
  • The isolated real-Gateway baseline from the preceding fast-path change remains 10/10 archives in 307 ms versus more than 15 seconds before batching; this refactor retains the same canonical concurrent dispatch and broadens it to other organizational patches.

@openclaw-barnacle openclaw-barnacle Bot added app: android App: android app: web-ui App: web-ui gateway Gateway runtime labels Aug 8, 2026
@steipete
steipete marked this pull request as ready for review August 8, 2026 16:12
@steipete
steipete requested a review from a team as a code owner August 8, 2026 16:12
@openclaw-barnacle openclaw-barnacle Bot added size: XL maintainer Maintainer-authored PR labels Aug 8, 2026
@steipete

steipete commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added 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. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels Aug 8, 2026
@clawsweeper

clawsweeper Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 8, 2026, 5:47 PM ET / 21:47 UTC.

ClawSweeper review

What this changes

The branch replaces the unshipped archive-only bulk session RPC with a bounded shared bulk patch RPC used by Control UI archive, read-state, and category actions.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

No actionable patch defect was found. This protected maintainer PR keeps session mutation policy in the Gateway’s canonical singular patch path; it needs exact-current-main integration review before merge.

Priority: P1
Reviewed head: b4d828d8595605e7264c23174c74f88ef28de586

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch has coherent owner-boundary design and focused coverage, with current-main integration refresh as the remaining material confidence reducer.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is outside the external-contributor proof gate; its reported browser and real-Gateway evidence is supportive but was not needed to classify the gate.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is outside the external-contributor proof gate; its reported browser and real-Gateway evidence is supportive but was not needed to classify the gate.
Evidence reviewed 5 items Canonical mutation owner: The proposed batch handler validates a bounded shared patch, authorizes targets, and delegates each outcome to the existing singular session-patch owner instead of creating a second writer.
Authorization fencing: The PR normalizes bulk targets and retains target-local authorization fencing immediately before each canonical mutation; focused tests cover padded identities and replacement rejection.
Legacy-client behavior: The UI sends the batch method when available and otherwise falls back before dispatch to serial sessions.patch calls for older Gateways.
Findings None None.
Security None None.

How this fits together

Control UI and native clients send session organization requests to the Gateway, which validates scope and authorization before applying canonical per-session patches. Batch outcomes then drive a single sidebar refresh while older Gateways retain serial patch behavior.

flowchart LR
  UI[Control UI multi-select] --> RPC[Bulk session patch request]
  Native[Native clients] --> RPC
  RPC --> Validate[Schema and scope validation]
  Validate --> Authorize[Authorize each target]
  Authorize --> Patch[Canonical session patch]
  Patch --> Outcomes[Ordered batch outcomes]
  Outcomes --> Refresh[Sidebar refresh]
Loading

Before merge

  • Resolve merge risk (P2) - The public Gateway rename spans web, Android, and shared native protocol clients; refresh exact-head integration evidence on current main to confirm the serial fallback remains available after the merge result.
  • Resolve merge risk (P1) - The bulk path batches session-state mutations and dynamically derives write versus admin scope, so the existing target authorization and outcome-order tests remain merge-critical.
  • Complete next step (P2) - No mechanical repair is indicated; this protected maintainer PR needs exact-current-main integration review before merge.
Agent review details

Security

None.

PR surface

Source +179, Tests +411, Docs +1, Other +152. Total +743 across 35 files.

View PR surface stats
Area Files Added Removed Net
Source 21 481 302 +179
Tests 11 483 72 +411
Docs 1 1 0 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 2 161 9 +152
Total 35 1126 383 +743

Review metrics

Metric Value Why it matters
Production versus test LOC production +523/-249 (net +274); tests +603/-134 (net +469) The production growth is justified by one shared public protocol contract, generated native models, and its authorization owner; regression coverage is larger than the implementation delta.
Gateway protocol transition 1 archive-only RPC removed; 1 bounded shared patch RPC added The transition crosses web, Android, and shared native protocol surfaces, so client fallback remains important before merge.

Stored data model

Persistent data-model change detected: serialized state: packages/gateway-protocol/src/schema/sessions-archive-many.ts, serialized state: packages/gateway-protocol/src/schema/sessions-patch.ts, serialized state: packages/gateway-protocol/src/schema/sessions.ts, serialized state: src/gateway/server-methods/sessions-mutations.ts, serialized state: src/gateway/session-sharing-store-cache.test.ts, serialized state: src/gateway/session-sharing.ts, and 19 more. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Refresh current-main integration evidence (recommended)
    Update the branch or merge-queue result and confirm exact-head checks cover the renamed protocol contract and serial fallback before merging.
  2. Pause for a narrower release-transition review
    Hold the PR if maintainers need additional confirmation for post-release native clients before replacing the main-only method name.

Technical review

Best possible solution:

Keep one shared bulk patch contract that delegates to canonical singular patches, with no alias for the unshipped archive-only RPC, after current-main integration confirms native/client fallback behavior.

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

Not applicable: this is a refactor PR, not a report of a failing user path; its Gateway and UI behavior is covered by focused source and test inspection.

Is this the best way to solve the issue?

Yes. A single bounded bulk envelope reusing canonical singular session patches avoids retaining two mutation-policy owners; an archive-only alias would preserve duplicate behavior without a shipped compatibility need.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 909509a5db8d.

Labels

Label justifications:

  • P1: The PR changes authorization-sensitive multi-session organization behavior used by interactive clients.
  • merge-risk: 🚨 compatibility: Replacing a Gateway method requires the reviewed older-Gateway serial fallback to survive the final merge result.
  • merge-risk: 🚨 session-state: The generalized path updates archive, unread, and category state across multiple selected sessions.
  • merge-risk: 🚨 security-boundary: The method derives operator scope from mutation fields and performs per-target authorization checks before commit.
  • 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: This maintainer-authored PR is outside the external-contributor proof gate; its reported browser and real-Gateway evidence is supportive but was not needed to classify the gate.

Evidence

What I checked:

Likely related people:

  • steipete: History attributes the current-main archive predecessor and all four commits in this generalized replacement to the same contributor. (role: introduced and recently evolved the bulk session path; confidence: high; commits: 82f6280fa86a, a7198afeca6c, b0dba49a3584; files: src/gateway/server-methods/sessions-mutations.ts, src/gateway/session-sharing.ts, ui/src/components/session-organizer-batch-mutations.ts)

Rank-up moves

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

  • Refresh exact-head current-main integration checks for the renamed method and legacy serial fallback.

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 (4 earlier review cycles)
  • reviewed 2026-08-08T16:39:57.838Z sha 526015b :: found issues before merge. :: [P1] Normalize target identity before the local authorization fence
  • reviewed 2026-08-08T16:45:38.913Z sha 526015b :: needs changes before merge. :: [P1] Normalize target identity before the local authorization fence
  • reviewed 2026-08-08T17:48:21.748Z sha 5c16ba2 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-08T21:40:14.657Z sha b4d828d :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. label Aug 8, 2026
@steipete

steipete commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot removed the rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. label Aug 8, 2026
@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. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 8, 2026
@steipete
steipete force-pushed the steipete/sessions-patch-many branch from 5c16ba2 to bcfb4f1 Compare August 8, 2026 21:06
@steipete

steipete commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@steipete

steipete commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

Land-ready proof for exact head b4d828d8595605e7264c23174c74f88ef28de586:

  • Exact pull-request CI is green: https://github.com/openclaw/openclaw/actions/runs/31278801941 (openclaw/ci-gate success; 0 pending). The first rebased run exposed one stale UI wording expectation after 8,466 passing UI tests; commit b4d828d85956 aligned it with current-main terminology, and the focused file then passed 12/12 before this clean rerun.
  • Exact-head ClawSweeper found no actionable defect and no security finding: refactor(gateway): generalize bulk session patches #120629 (comment). Fresh branch autoreview is also clean with no accepted/actionable finding.
  • Rebase integration proof: pnpm protocol:check, git diff --check, bounded archiveMany search, targeted formatting, and pnpm build passed. Earlier focused proof remains: protocol/scope/list 241, Gateway/plugin 35, UI/sidebar/mock 298, final Gateway/UI 24, and browser E2E 8. The padded-identity replacement regression passed 8/8 and Gateway authorization passed 12/12; the post-rebase UI assertion rerun passed 12/12.
  • Native proof: exact-head native-i18n, ios-build, and all selected Android test/build/ktlint jobs passed. macos-swift was manifest-skipped by design because the only Apple source change is generated apps/shared/OpenClawKit/Sources/OpenClawProtocol/**, which NATIVE_PROTOCOL_GEN_RE deliberately excludes from run_macos; ios-build still compiles the shared generated client. Local SwiftLint remains unavailable because SourceKitten could not load sourcekitdInProc.framework and exited 133; this does not represent a source diagnostic.
  • LOC: production +522/-249 (net +273), tests/test helpers +603/-134 (net +469), package protocol changelog +1/-0. Production growth is the bounded public protocol/client and authorization-owner capability; regression proof is larger than the implementation delta.
  • Architecture: singular sessions.patch remains the policy and commit owner; unshipped sessions.archiveMany is removed outright; sessions.patchMany is only bounded orchestration with all-target initial authorization, target-local commit fencing, ordered partial outcomes, and direct serial sessions.patch fallback for older Gateways.

ClawSweeper rank-up moves are satisfied by the current-main rebase, protocol/client build, exact-head CI, and this exact-head review. Main advanced again after the frozen rebase; repository landing policy treats behind-main drift as advisory when live mergeability remains true, while the native prepare/merge guard validates the actual merge result. No additional drift-only rebase is being introduced.

@steipete
steipete merged commit 5194449 into main Aug 8, 2026
128 checks passed
@steipete
steipete deleted the steipete/sessions-patch-many branch August 8, 2026 22:00
@steipete

steipete commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 9, 2026
* refactor(gateway): generalize bulk session patches

* fix(gateway): normalize bulk session fences

* refactor(gateway): simplify normalized target fence

* test(ui): align disconnected session wording
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: android App: android app: web-ui App: web-ui gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL 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