Repository navigation
fix(gateway): new sessions fail with "Worker placement inventory changed" while other local turns start or finish - #165984
Conversation
Classify local placement publications before settlement so local claim acquisition and release do not invalidate maintenance's non-local inventory. Preserve per-session authority and worker inventory fencing, including remote-exec local claims and dispatch after an empty scan. Convert the maintenance characterization to success regressions, cover publication settlement, and document the boundary. Retain durable local claims and their dispatch, workspace, and recovery contracts.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
|
Codex review: needs maintainer review before merge. Reviewed October 6, 2026, 3:59 AM ET / 07:59 UTC (Revision 2). ClawSweeper reviewWhat this changesThe PR prevents unrelated local turn claims from interrupting session maintenance while preserving fences for worker placements and non-local transitions. Merge readiness✅ Ready for maintainer review Keep open: current main still has the reported invalidation mechanism, and the updated patch preserves non-local and per-session fences. No actionable introduced defect was found. Priority: P1 Review scores
Verification
How this fits togetherThe Gateway records where sessions execute and retains observations of those placements during session maintenance. Placement publications determine whether maintenance can safely use its prepared preservation inventory. flowchart TD
A[Concurrent session turns] --> B[Placement writer]
B --> C[Prior and new placement state]
C --> D[Placement observation owner]
D --> E[Local-only inventory remains valid]
D --> F[Worker or session observation fenced]
E --> G[Session maintenance commit]
F --> H[Fresh preparation required]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +6, Tests +189, Docs +7. Total +202 across 10 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep placement publication classification in the existing authority owner, preserving durable local claims and all non-local, per-session, and stale-claim safeguards. Do we have a high-confidence way to reproduce the issue? Yes: current-main source exposes the invalidation mechanism, and the captured live comparison reproduces it through concurrent sessions.create first turns. This reviewer did not execute a reproduction. Is this the best way to solve the issue? Yes: classifying publications against transaction-held prior state repairs the preservation fence at its owner without removing durable claims or weakening per-session authority. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d6bd730e10bc. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
Capture prior placement state in the existing writer transaction before classifying claim publications. Preserve maintenance inventory observations only for known local or absent prior and staged placements; unknown and non-local transitions remain fenced through invalidation. Cover native and worker transitions, committed and uncertain publications, local claim clearing, and local retirement. Keep per-session authority and remote-exec fencing unchanged. No schema, public config, SDK, or update migration is required.
|
Merged via squash.
|
…ged" while other local turns start or finish (openclaw#165984) * fix(gateway): preserve maintenance fences across local turns Classify local placement publications before settlement so local claim acquisition and release do not invalidate maintenance's non-local inventory. Preserve per-session authority and worker inventory fencing, including remote-exec local claims and dispatch after an empty scan. Convert the maintenance characterization to success regressions, cover publication settlement, and document the boundary. Retain durable local claims and their dispatch, workspace, and recovery contracts. * fix(gateway): fence non-local placement transitions to local Capture prior placement state in the existing writer transaction before classifying claim publications. Preserve maintenance inventory observations only for known local or absent prior and staged placements; unknown and non-local transitions remain fenced through invalidation. Cover native and worker transitions, committed and uncertain publications, local claim clearing, and local retirement. Keep per-session authority and remote-exec fencing unchanged. No schema, public config, SDK, or update migration is required.
What Problem This Solves
Fixes: a new session's first turn fails with
Worker placement inventory changedwhen other local turns start or finish at the same moment. It needs no workers to be configured; ordinary local use under concurrency is enough.User Impact
User impact: under concurrent use (several sessions or channel messages at once), new turns no longer fail with
Worker placement inventory changed. Nothing changes for deployments that use workers: a worker placement published during session maintenance still fences that maintenance and forces fresh preparation.Why This Change Was Made
Session maintenance prepares preservation with an inventory-wide placement observation, then commits. Ordinary local turns acquire and release durable placement claims even with no workers configured, and every such publication revoked all inventory-wide observations. That rejected the maintenance commit of an unrelated new session, even though maintenance's preservation scan excludes local placements.
placement-turn-authority.tsnow decides once, at publication, whether a change affects an observation. Inventory-wide observations ignore local claim publications. Per-session observations, non-local placements, unknown publications, and remote-exec placements whose turn claim has a local owner stay fenced. Only local claim churn is exempt: a publication whose prior placement is local or provably absent and whose new placement is local or absent (acquire, release, clear). Native and worker publishers supply the transaction-held prior state when they stage the change. A transition into or out of a non-local placement, or one whose prior state is unknown, still revokes inventory-wide observations, including when the outcome is uncertain or invalidated. (A review of the first commit found that classifying by the new state alone also exempted worker-to-local transitions; the second commit narrows it.) The change also removes a duplicate publication-sequence write and merges two equivalent authority checks. Production lines net to zero.Ordinary local turns still publish durable claims. Removing those writes would change lifecycle, exclusion, and persisted-state behavior, so that stays a separate follow-up.
Evidence
Live (dev Gateway, OpenAI-backed agents on the built-in and Codex runtimes; agents warmed first, then 2 x (4 rounds x 15 concurrent
sessions.createwith a short first turn)):Worker placement inventory changedf986a7aaf15bFailed to observe plugin state entry ... Session entry facts changed during their mutation check2983dfcfb319, one burstThe plugin-state mutation-check failure reproduces at the same rate on main and does not involve this code; it is tracked separately.
Deterministic proof: the startup-maintenance characterization tests now require immediate success for local claim acquisition and release. Restoring only the production owner to main makes exactly those three local cases fail with
Worker placement inventory changed, while the worker-dispatch and remote-exec controls still pass.pnpm tsgo:core, targeted oxlint and oxfmt, the docs MDX check, andgit diff --checkpass. Autoreview of the final branch was scoped-clean with no P0-P2 findings.Both commits: production +61/-55, tests +220/-31, docs +8/-1. The second commit adds 6 owner regressions (worker/unknown -> local transitions, invalidated transitions) that fail on the first commit; 62 tests pass across the four placement suites.