Repository navigation
fix(gateway): refresh placement reads after concurrent publication - #165166
Conversation
Wait for pending placement publications and refresh superseded read-only preparation against the captured physical database. Keep returned observations, cancellation, owner replacement, and uncertain outcomes fenced; never replay writes or consumer effects. A held projection read followed by the preceding claim release fails on the base and passes with fresh facts and zero caller-thread SQL. The original initial-setup runtime preference race was already fixed by 7ecc80a; this completes the remaining pure placement-reader preparation path. Focused tests, changed checks, import boundaries, cycle checks, the database worker ratchet, and independent P2 review pass. The published-driver update cell remains a merge precondition after infrastructure failures.
|
🦞👀 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 4, 2026, 7:23 PM ET / 23:23 UTC (Revision 4). ClawSweeper reviewWhat this changesThe Gateway waits for concurrent placement publications and refreshes unfinished reads so the next message avoids a spurious placement-authority error. Merge readiness✅ Ready for maintainer review This PR remains useful: current main still rejects reads superseded during preparation. No actionable defects were found, and the recorded published-driver update acceptance resolves the previous review’s blocker. Priority: P2 Review scores
Verification
How this fits togetherThe placement reader supplies session execution-location and recovery facts to Gateway admission and worker routing. Its authority owner tracks publications so callers can reject stale facts before using them. flowchart TD
A[Incoming session turn] --> B[Placement read preparation]
C[Concurrent placement publication] --> D[Publication settlement]
D --> B
B --> E[Read original physical store]
E --> F{Facts still current?}
F -->|Refresh needed| B
F -->|Yes| G[Caller rechecks admission]
G --> H[Turn routing]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +70, Tests +104, Docs +6. Total +180 across 4 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep refresh behavior inside the existing placement authority owner while preserving strict consumer checks and exactly-once execution. Do we have a high-confidence way to reproduce the issue? Yes: holding a placement projection read while the preceding claim is released exposes the rejection in the unchanged current-main path. Source inspection and the supplied failing-base regression establish the mechanism; this reviewer did not execute it. Is this the best way to solve the issue? Yes: refreshing only unfinished reads at the existing authority owner repairs the race without replaying writes or weakening checks on facts already returned to callers. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 5837209ed1ba. 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
History |
|
Merged via squash.
|
…penclaw#165166) Wait for pending placement publications and refresh superseded read-only preparation against the captured physical database. Keep returned observations, cancellation, owner replacement, and uncertain outcomes fenced; never replay writes or consumer effects. A held projection read followed by the preceding claim release fails on the base and passes with fresh facts and zero caller-thread SQL. The original initial-setup runtime preference race was already fixed by a8487f3; this completes the remaining pure placement-reader preparation path. Focused tests, changed checks, import boundaries, cycle checks, the database worker ratchet, and independent P2 review pass. The published-driver update cell remains a merge precondition after infrastructure failures.
What Problem This Solves
Users occasionally saw a placement-authority-changed error asking them to resend their message just after the previous turn finished. A placement publication can supersede an in-flight admission read and reject the next turn with
placement authority changed, even though no execution has started. Holding the real projection read while the preceding turn releases its claim reproduces this remaining reader race on the base.The originally reported initial-setup E2E flake was already repaired on main by 7ecc80a45736, which stopped treating runtime preference selection as execution authority. This is a follow-up repair to the stricter placement reader, not a replacement for that fix.
Why This Change Was Made
The existing placement authority owner waits for pending publication settlement and refreshes superseded, unconsumed reads against their original physical store. Notifications replace polling. Confirmed rollback remains usable; unknown outcomes, cancellation, owner closure, and replacement remain fenced. Observations handed to consumers retain their existing strict checks. No writer or consumer effect is replayed.
The regression forces the interleaving with a held promise, checks fresh claim-free facts and zero caller-thread SQL, and covers settlement, cancellation, and close behavior using the existing fixture. A real-Gateway diagnostic trace locates the second preference observation before the first turn releases its claim: placement stays active at generation 5, while the claim/result owner publishes new state. The controlled failure is exposed as a terminal
UNAVAILABLEresponse and a visible chat error. The UI says the input will not run automatically and instructs the user to copy it and send again;rendererStallis null.User Impact
Ordinary placement publications no longer fail pure read preparation. Execution claims, synchronous worker transactions, FIFO settlement, current grants, schemas, retention, durability, public SDK signatures, and update behavior are unchanged. No new
OPENCLAW_*names or dependencies.Production LOC: +106 / −36 / net +70 across two files (142 changed production lines). T1: 894 → 894 globally; the placement store remains 4 → 4. No SQL operation moves in this follow-up.
Adjacent ownership work: #162433. The change stays in the existing placement reader/authority owner; broader turn and queue ownership is untouched.
Required update acceptance: passed. Published 2026.9.8 successfully updated to the exact candidate package; managed Gateway replacement, readiness, build identity, durable history preservation, and incognito restart behavior all passed. Earlier provider setup failures were infrastructure-only; no product assertion or ownership guard was bypassed.
Evidence
Base:
a0c1b065b5b25b54cd1f855881a2c13d2237f467.pnpm test src/gateway/worker-environments/placement-read-projection.worker.test.ts --maxWorkers=1, 138.31s wall.--maxWorkers=1, 734.53s wall on the loaded local host.node scripts/check-changed.mjs: passed (including production/test typechecking, lint, guards, and zero runtime import cycles).77bb005880561/1 failed (113s) → actual candidate 1/1 passed (86s), with both accepted turns launched exactly once. The trace changes observation sequence 9 → 14, withownerActive=true,sameOwner=true, no pending mutation, and placement still active at generation 5; the first claim changes to null. This is a real claim publication, not a projection refresh generation bump.7ecc80a45736, while the new held-read unit regression proves this PR's additional reader fix.v2026.9.8→f0274b804377declaration report completed locally (digesta24517d4). Placement types are SDK-reachable through Gateway request-context contracts. The generatedprepareRuntimeRefresh(sessionId: string)Promise return and all result/authority fields are byte-identical before/after; this PR changes no existing sync/async, parameter, callback, or export contract. The new helper is an internal module export, so no new compatibility shim or deprecation record is required. The full release comparison also contains inherited SDK changes outside this four-file PR.node-workspace-retain-coordinator,placement-move-schema,placement-projector) passed 43/43 with--maxWorkers=1, 115.99s wrapper wall time (101.71s Vitest). No routing expansion was needed. All new imports already belong to the compiled-wrapper dependency inventory.security-fastandopenclaw/ci-gate. The initial PR context check rejected the old heading; the body now uses the required template and run 37240916562 passed.f0274b80437744d62dc917229e5f7d2b9e3fa394: passed, cell exit 0 in 638.934s on isolated Linux. The installed driver completed the update; managed service replacement,/readyz200, running version/build identity, retained durable history, and cleared incognito state were verified. Candidate tarball SHA-256:753b4628bf45ff6ed9cabc6bacf392d5471cfedb9daafcee85ffcc47e733828d. The synthetic service shim used the supported stop/update/start path after an unsupported property query; all acceptance assertions passed. Environment prerequisite repairs were Docker, Buildx, and SSH-session group activation; no source changes were needed.Exact-head CI completed successfully in 8m36s (22:30:33–22:39:09 UTC); local focused timings above include compilation on a loaded host. The required published-driver update precondition is complete. Independent P2 autoreview and exact-head ClawSweeper found no actionable code or security findings; the latter’s outstanding proof item is resolved by this update cell.