Skip to content

fix(gateway): retire ownerless requested placements - #124609

Merged
steipete merged 2 commits into
mainfrom
steipete/fix-ownerless-placement-retirement
Aug 16, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/fix-ownerless-placement-retirement

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Periodic placement retirement skipped requested placement rows forever when their session was absent and they had neither a turn claim nor an environment assignment. Those ownerless rows could therefore remain in the placement store indefinitely.

Why This Change Was Made

The canonical retirement path now retires no-environment ownerless records. The placement store allowlist admits only requested placements plus the existing safe terminal and local states, preserving environment teardown requirements and the exact compare-and-swap checks on state and generation.

User Impact

Stale requested placements whose sessions have disappeared are now cleaned up by periodic reconciliation instead of accumulating indefinitely. Placements with live environment ownership continue through the existing teardown path.

Evidence

  • Focused and sibling proof: 24/24 tests passed.
  • Production LOC: +19/-21 (net -2); tests: +54/-1.
  • Fresh autoreview completed with no actionable findings.
  • Diff check is clean.

@clawsweeper

clawsweeper Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete
steipete marked this pull request as ready for review August 16, 2026 13:43
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S maintainer Maintainer-authored PR labels Aug 16, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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. labels Aug 16, 2026
@clawsweeper

clawsweeper Bot commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 16, 2026, 10:03 AM ET / 14:03 UTC.

ClawSweeper review

What this changes

The PR lets Gateway reconciliation delete a requested worker-placement record when its session is gone and the record has neither environment ownership nor a turn claim.

Merge readiness

✅ Ready for maintainer review

Keep open. The PR is a focused, source-proven Gateway cleanup that current main does not contain; no blocking correctness or security finding was identified. Its protected maintainer label and incomplete exact-head CI leave it for normal maintainer review.

Priority: P2
Reviewed head: 2f62521111efc28c8394ef09ed6ad125a5d0f4ff

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-boundary repair with credible regression coverage and no identified blocking defect.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-owned internal Gateway lifecycle repair is outside the external-contributor real-behavior-proof gate; the branch includes focused SQLite-backed regression coverage.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-owned internal Gateway lifecycle repair is outside the external-contributor real-behavior-proof gate; the branch includes focused SQLite-backed regression coverage.
Evidence reviewed 7 items Current main still has the defect: Current main retires only local, reclaimed, or safe failed placements; requested is absent from the allowlist and from the retirement decision.
PR-head retirement guard: The changed decision rejects turn claims, preserves environment-owned records for existing lifecycle handling, and separately excludes provisioning before issuing the exact state-and-generation retirement.
Store CAS remains the owner boundary: Retirement deletes only the supplied state and generation when every turn-claim field is null, so a concurrent claim or requested-to-provisioning transition fails closed.
Findings None None.
Security None None.

How this fits together

Gateway persists worker-placement lifecycle records for sessions and periodically reconciles rows whose session evidence is absent. This path either safely retires an ownerless record or preserves it for the dispatch and environment-teardown lifecycle.

flowchart LR
  A[Persisted session placement] --> B[Session evidence lookup]
  B --> C{Session absent?}
  C -->|no| D[Keep placement]
  C -->|yes| E{No claim or environment owner?}
  E -->|yes| F[Exact guarded retirement]
  E -->|no| G[Dispatch or teardown lifecycle]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -2, Tests +53. Total +51 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 2 19 21 -2
Tests 1 54 1 +53
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 73 22 +51

Review metrics

Metric Value Why it matters
Production versus regression-test delta production +19/-21 (net -2); tests +54/-1 The repair absorbs the new state into the existing retirement flow while adding focused SQLite-backed regression coverage.

Stored data model

Persistent data-model change detected: durable storage schema: src/gateway/worker-environments/placement-session-retirement.test.ts, durable storage schema: src/gateway/worker-environments/placement-session-retirement.ts, unknown-data-model-change: src/gateway/worker-environments/placement-session-retirement.test.ts. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Retain the single retirement path: permit only absent-session requested records with no ownership to reach the store’s existing exact compare-and-swap deletion guard.

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

Yes, source-reproducible: an absent-session record created by startDispatch is requested with no environment, and current main’s retirement allowlist rejects that exact state.

Is this the best way to solve the issue?

Yes. Extending the canonical store allowlist and retirement decision preserves the existing claim, generation, provisioning, and environment-teardown ownership boundaries instead of adding a cleanup side path.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 7f842da4bd45.

Labels

Label justifications:

  • P2: This fixes bounded internal Gateway placement-state accumulation without evidence of an active user-facing outage.
  • 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-owned internal Gateway lifecycle repair is outside the external-contributor real-behavior-proof gate; the branch includes focused SQLite-backed regression coverage.

Evidence

What I checked:

Likely related people:

  • steipete: Peter Steinberger authored the PR’s implementation commits and the recent merged Gateway session-evidence work on which the retirement path depends. (role: recent area contributor and repair author; confidence: high; commits: 96cacfdf7450, dc2b5c98e1bb, 2f62521111ef; files: src/gateway/worker-environments/placement-session-retirement.ts, src/gateway/worker-environments/placement-store.ts, src/gateway/server-worker-placement-session-evidence.ts)

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 (1 earlier review cycle)
  • reviewed 2026-08-16T13:49:09.668Z sha dc2b5c9 :: needs maintainer review before merge. :: none

@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready proof: absent-session requested rows were outside both the reconciliation decision and store retirement allowlist, so ownerless rows could persist indefinitely. The fix stays in the placement-retirement owner and routes that state through the existing exact state/generation/claim CAS; provisioning and environment-owned rows retain their lifecycle owners.

Production: +19/-21 (net -2). Tests: +54/-1. node scripts/run-vitest.mjs src/gateway/worker-environments/placement-session-retirement.test.ts passed 5/5; git diff --check 605dece17105e2287969a632d7d785f8355ba76f...2f62521111efc28c8394ef09ed6ad125a5d0f4ff passed. Fresh autoreview is clean. Exact-head CI run 31951305919 is green. ClawSweeper reviewed exact head with no findings and no remaining before-merge actions. No proof gaps remain.

@steipete
steipete merged commit 1b34939 into main Aug 16, 2026
236 checks passed
@steipete
steipete deleted the steipete/fix-ownerless-placement-retirement branch August 16, 2026 14:09
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 17, 2026
* fix(gateway): retire ownerless requested placements

* fix(gateway): bind placement retirement test methods
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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