Repository navigation
feat(gateway): carry machine class through session moves - #125292
Conversation
Profile move targets accept an optional machineClass with new-session parity: validated in the protocol, persisted on the durable move intent (bare nullable column, lazy same-version ALTER), replayed exactly by restart recovery, and selectable from the Control UI move dialog. Moving to the current profile with a different class resizes the session's worker.
|
Codex review: found issues before merge. Reviewed August 17, 2026, 4:22 PM ET / 20:22 UTC. ClawSweeper reviewWhat this changesThe PR adds optional cloud-worker machine-class selection to session moves, persists it across recovery, adds a Control UI picker, and keeps placement data in chat responses. Merge readiness⛔ Blocked by patch quality or review findings - 5 items remain Keep open: the prior P1 schema-compatibility blocker remains on the current head. An existing v9 database containing the previously shipped optional move table but not the new column is rejected during Gateway startup before the feature-local lazy migration can run. Priority: P1 Review scores
Verification
How this fits togetherA Control UI session move becomes a Gateway request that records durable move intent, drains the source worker, and dispatches the destination. Chat responses project that durable placement state back into the client store so the move control remains available. flowchart LR
A[Control UI move dialog] --> B[Gateway move request]
B --> C[Durable move intent]
C --> D[Drain and recovery lifecycle]
D --> E[Worker dispatch]
E --> F[Placement projection]
F --> G[Chat client store]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +119, Tests +274, Docs 0, Generated +1, Other +6. Total +400 across 19 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: Register target_machine_class as a startup additive column and add a preflight regression that starts from the old move-table shape, reports startup-repairable, then verifies the writable open adds the column. Do we have a high-confidence way to reproduce the issue? Yes—source establishes a focused current-head path: retain the v9 move table from the already-merged move feature without target_machine_class, then start Gateway; preflight rejects it before the feature-local ensure can run. The read-only review environment did not run that test. Is this the best way to solve the issue? No—the feature-local ensure is appropriate after startup, but it cannot repair an existing table that startup preflight refuses first; the shared startup additive-column owner is the required repair location. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 248966d30081. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles)
|
|
🦞👀 Pull request received. I will update this pull request when review starts. |
chat.startup and chat.history built sessionInfo without the placement projection sessions.list applies, so clients merging that row erased a live worker placement and its move intent — the Runs on Cloud chip disappeared after any turn until a full reload. Reuse the canonical ensureColumn helper for the move table's additive column instead of a hand-rolled PRAGMA read.
|
Merged via squash.
|
…5292) * feat(gateway): carry machine class through session moves Profile move targets accept an optional machineClass with new-session parity: validated in the protocol, persisted on the durable move intent (bare nullable column, lazy same-version ALTER), replayed exactly by restart recovery, and selectable from the Control UI move dialog. Moving to the current profile with a different class resizes the session's worker. * fix(gateway): project placement facts on chat startup chat.startup and chat.history built sessionInfo without the placement projection sessions.list applies, so clients merging that row erased a live worker placement and its move intent — the Runs on Cloud chip disappeared after any turn until a full reload. Reuse the canonical ensureColumn helper for the move table's additive column instead of a hand-rolled PRAGMA read.
What Problem This Solves
PR #125036 added
sessions.move, and PR #124864 added per-dispatch machine selection for cloud worker profiles — but the two never met: a profile move target carried onlyprofileId, so moving a session to a cloud profile always landed on the profile's configured default class. A session dispatched with afastoverride, reclaimed, and moved back silently downgraded tostandard, and there was no way to resize a running cloud session.Live testing this surfaced a second, larger defect:
chat.startupandchat.historybuiltsessionInfowithout the placement projection thatsessions.listapplies. Clients merge that row into the same store, so opening a chat erased a live worker placement and its move intent — the Runs on Cloud chip disappeared until a full page reload, making the move flow unreachable in normal use.AI-assisted implementation; I reviewed the architecture, durable-intent persistence, recovery fencing, and live proof.
Why This Change Was Made
Profile move targets now accept an optional
machineClasswith exact new-session parity: validated in the protocol, persisted on the durable move intent as a bare nullabletarget_machine_classcolumn (same-version additive via the canonicalensureColumnhelper; reads stay no-create), CAS-matched by every exact-target completion/deletion statement, and replayed exactly by restart recovery — a recovered move dispatches the class the operator chose, never the profile default. The Control UI move dialog shows the machine picker under the selected profile, reusing the new-session menu components; choosing the default omits the override.Moving a session to the profile it already runs on with a different class is the resize workflow: the normal drain → reconcile → dispatch lifecycle replaces the worker with one of the chosen size.
The placement fix applies the same projection at the
chat.startup/chat.historyproducer, so every path that feeds the client store carries the recorded placement fact. The schema-ensure also gained a per-database-handle memo so the sessions read projection never runs DDL orPRAGMAper read.User Impact
Operators moving a session to a cloud profile can pick the machine class in the move dialog (or pass
machineClassinsessions.move), the choice survives Gateway restart mid-move, and resizing a cloud session is one move away. The placement chip no longer vanishes after opening a chat. No schema-version bump, no protocol version bump, no new config surface.Evidence
Live proof — isolated dev Gateway (own
OPENCLAW_STATE_DIR, port 19457), real Crabbox AWS worker profile, managed-worktree session:CLOUD-TURN-OK ip-172-31-47-53.active).Cloud · aws, then Fast, and submitted.move:v1:DRBKfklX… | profile | aws | fast, placementdraining, chip showing Moving session….provisioning → syncing → active; the new environment recordsmachineClass = fastwhile the profile default staysstandard, and the old environment isdestroyed.MOVED-TURN-OK ip-172-31-45-32 64(different host, 64 cores).Machine picker under the selected profile:
Non-default class selected (default checkmark moves off Standard):
Session after the move, both turns in one transcript on two different machines:
Automated: protocol schema (34), move schema/store (29 — persistence, exact-target join/conflict, invalid-row, restart recovery replaying the class), sessions dispatch (21), dispatch/recovery/reclaim (72), projection (31), Control UI move dialog unit + mocked-gateway E2E (13), plus a new
chat.startup/chat.historyplacement regression that fails pre-fix. Typecheck lanes green (core, ui, core-test shards); Swift/Kotlin protocol generation checks; Kysely generated types verified; native schema-version guard unchanged (v9); assertion-safety ratchet green; oxfmt;git diff --check. Autoreview (Codexgpt-5.6-sol, high): clean, no actionable findings.Production LOC: +141/−26 for the machine class (justified by durable class persistence + picker) plus a net-negative-shaped placement fix that reuses existing helpers; tests +236/−16 plus the new regression; docs updated (
docs/gateway/cloud-workers.md,docs/web/control-ui.md).