Skip to content

feat(workers): bind cleanup to recorded cloud resources - #189019

Merged
roboclaw-bot merged 14 commits into
mainfrom
openclaw/s4-retained-session-disk
Oct 31, 2026
Merged

roboclaw-bot merged 14 commits into
mainfrom
openclaw/s4-retained-session-disk

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #188796

What Problem This Solves

Cloud worker recovery and cleanup need a durable binding to the original provider resource, rather than relying only on a reusable lease handle after a lost reply or restart.

Original work and design by @galiniliev; extracted and reimplemented at the contributor's request.

Work sessions

User Impact

New Crabbox Azure Sandbox workers record exact resource identity before setup/enrollment. Restart recovery refuses replacement identities, unavailable observations preserve ownership, and Stop remains pending until exact-resource deletion is confirmed.

This is a prerequisite, not retained-disk activation. Gateway checkpoints, existing idle suspension, and workspace authority remain unchanged. It enables neither retained allocation nor pause/resume nor disk-authoritative workspaces. Legacy environments without receipts keep their fixed-lease cleanup contract and are not silently rebound. Dependent lifecycle implementation is separately published in #189346, above authority #189106.

Shared-state schema 36 → 37 preserves old rows with a null receipt and fences older binaries. Rollback requires settling new environments and pending cleanup, then restoring the matching pre-upgrade backup with its binary; a package-only downgrade is unsafe. PostgreSQL migration and generated predecessor descriptors are included.

Why This Change Was Made

An optional generic provider receipt contract feeds the existing environment writer, provisioning, inspection, and teardown owners. Crabbox alone interprets Azure-specific identity and CLI flags. Receipt custody commits before subsequent setup effects; retries retain the original allocation and immutable identity. No separate manager, timer, queue, or state file is introduced. SSH bootstrap and Crabbox teardown phases are extracted without changing ownership to keep modules bounded. The 781-line regression allocation is task-specific; the shared scalar is unchanged.

Evidence

  • Initial provider/recovery proof: 56 tests across 5 files; real-worker store/migration proof: 10 tests, repeated after main integration. Existing store/projection coverage also passed 25 cases.
  • CI repairs fixed receipt-column omissions, PostgreSQL physical column ordering, enrollment/teardown owner handling, predecessor schema composition, optional-fragment foreign keys in historical fixtures, and confirmed teardown settlement during Gateway drain.
  • Repair proof included 110 placement/provisioning consumer tests across 6 files, 13 tooling tests, 24 lifecycle tests, and 29 migration/descriptor/provider tests.
  • Later qualified 37 real PostgreSQL integration tests across 2 files on CI's pinned pgvector image with its extensions and lock setting. This supersedes the earlier skipped PostgreSQL execution. The task container was stopped and reconciled absent.
  • 37 migration/credential/cleanup consumer tests across 6 files, 2 strengthened drain tests, and 18 affected receipt/image-intent/drain/migration tests across 4 files passed. Ten unchanged Doctor tests also passed locally; that replay alone was not claimed as a repair of the earlier merge-only failure.
  • Targeted production/test typing, type-aware lint, formatting, canonical generation, native schema parity, regression-budget/line-cap checks, and pre-commit passed. Initial committed SDK comparison acknowledgment: 4a99ee35.
  • Fresh independent P0–P3 autoreview covered the original change and subsequent repairs, with source verification and no remaining actionable findings. Generated catalog review was partition-limited; regeneration, complete schema-owner context, and migration tests provide cross-catalog evidence.
  • A local fixture CLI exercised the actual stop boundary: baseline deleted a simulated replacement; the fixed implementation refused the replacement and preserved it.

Current conflict repair and CI

Published head: f4255b1; tested tree: 17b921cb2e20123acfc0fb2a6e430d0fdd728923. The publisher's attributed marker commit preserves that complete tested tree.

History-preserving main integration at ef60dd0 resolved the sole conflict by regenerating the canonical SQLite catalog. Shared-state remains37; authority38 and retained lifecycle39 are excluded. Hosted readback confirms the conflict is cleared, with this PR still open and unmerged.

On the merged source:

  • Canonical schema generation/verification and Kysely freshness passed; generator and catalog-equivalence suites passed.
  • Receipt store/migration/provider boundary: 15 tests across three files passed. Crabbox receipt/stop siblings: 14 tests across two files passed.
  • 56 update tests across four files passed, including the previously failing Node-prefix, incompatible-service-runtime, writable-launcher, and target-schema cases. Main already contains owner fixture repair 20ab8ec (fix(ci): restore updater runtime contract coverage #189226); this PR does not independently weaken those assertions. The old candidate-admission suite was reorganized upstream and was not separately selected in this focused replay.
  • Script typing and whitespace checks passed. Simplification retained the existing design; no new production mechanism was needed for the merge.
  • Fresh three-pass P0–P3 autoreview against ef60dd0 completed. One reported Azure stop-recovery finding was rejected after source verification: receipts are produced/parsed only for azure-sandbox, and provisioning/destruction reject a differing provider before stop, so the azure-only legacy recovery branch cannot receive a valid receipt. Generated-catalog review remains partition-limited, covered by canonical regeneration and equivalence tests.

Current-head CI run 41208499615, attempt1, completed failed: 152 passed, 2 failed, 19 skipped. All update-runtime shards, types/lint, all PostgreSQL shards, and iOS evidence passed. One memory-core assertion failed; the second failure is the aggregate gate. The executed synthetic merge was f37eefb03c0a51b459e1c59acda6799458005a91 (base88b56eea, headf4255b1d). Complete attached-check inventory at finalization: 186 success, 44 skipped, 3 failure, 1 neutral; none pending. The third attached failure is the separate protected aggregate publisher 41210377330, not another product-test failure.

The remaining failure is manager-publication-admission.test.ts:349, expecting a parent-process PRAGMA integrity_check observation after an unclean reopen. Its test and observer helper are unchanged from main; the admission owner blob is identical at pinned ef60dd0, CI base88b56eea, and this head. Upstream84bfd8a4 (#189247) moved required scans into the integrity worker and changed lease-less unclean reopening to bounded admission. The old helper only wraps its own process DatabaseSync, so its integrityChecked:false result does not establish a skipped required worker scan. This is a source-attributed inherited assertion mismatch, not an observed exact-base replay. A focused local attempt timed out during runtime compilation before a test verdict; no assertion or safety guard was weakened. Failed CI is retained. The finalizer fetched the actual executed merge object, reproduced its tree from ordered base/head parents, and verified all ten determining sources are identical at the actual CI baseline, tested merge and PR head. Any landing uses the native inherited-failure evidence route, with review, security and live writer gates still enforced.

Prior-head failure evidence

Head8042bdde run41188657688 failed: 149 passed, 5 failed, 19 skipped. Four runtime shards contained five update assertions; the fifth failure was the aggregate gate. They reproduced locally (5 failed/54 passed), with determining sources byte-identical to pinned main64daa256. The newer main integration includes the upstream fixture correction; it does not relabel that failed run as passing. PostgreSQL and iOS screenshots passed on the old run; that iOS pass did not establish a fix for the earlier missing Mermaid accessibility assertion.

Exact installed-upgrade qualification

Native run 41243053820 passed the installed receipt cell in 282.359s, command/wrapper exit 0 and settled. Actual installed and serving identities changed from published stable 8b18b5578f66eab1501cba4cef2310d88bfb9a41 to exact candidate f4255b1d506b4bbe135f05c93ede950632172d06; the assertion checks build IDs, not the equal version label. Candidate package SHA256: 4ac4bad3141cfa0b2c8aed2953d2f667a1e9297b928c479ef9c560913f067971, from Package Acceptance 41236419893. Durable update 53387e26-d48b-40c9-8063-8b4321ba26b6 succeeded and finished.

  • Existing SQLite/session invariants and a valid synthetic legacy failed/no-lease environment row survived update, stop and repeated maintenance, including Unicode/NUL data. The new receipt column is nullable TEXT/default NULL; no legacy identity was fabricated.
  • A synthetic installed provider exercised the real core receipt callback and writer through public environments.create: identical replay succeeded, changed identity produced the specific resource receipt is immutable refusal, and the receipt persisted before an intentional provisioning error.
  • Public destroy received the exact recorded receipt. A real service stop/start with PID replacement, public status and store reads preserved it; same-key terminal replay made no second provision. Observed: one provision, one exact destruction. No live cloud resource was allocated.
  • Public scoped-backup recovery migrated an agent fixture 39→26 while preserving two outbox rows and an unrelated later write. This is agent-scoped recovery, not shared receipt-table rollback or retained-disk restore; shared-state migration/rollback coverage remains the separately recorded owner tests.
  • Final service stop succeeded; Docker inventories had no added containers/volumes; independent native lease status was completed/no host. The finalizer verified all 13 supplied evidence-file hashes and reconstructed the exact executed driver from hash-verified stock tooling plus its bounded fixture patch. No product/candidate files or runtime safeguards were patched. Earlier setup/fixture failures remain non-passes.

Remaining qualification gaps

No live provider allocation, authenticated controller readiness, or real-model disk-mode Gateway flow is claimed. The earlier isolated wire-E2E runner refused preparation because separation from managed Gateway artifacts could not be verified; no guard was bypassed. Crabbox 0.80.0 capability/help/source inspection is protocol evidence, not cold-boot reconnect or release-readiness proof. Exact f425 installed receipt qualification above does not automatically qualify later S5–S9 behavior, retained-disk activation, or controller release/adoption.

Worked on by

roboclaw-bot and others added 2 commits October 31, 2026 03:44
Persist immutable provider receipts through the existing environment writer before setup and enrollment. Reuse them for recovery, inspection, and confirmed exact-resource teardown. Retained allocation, pause/resume, and disk-authoritative workspaces remain inactive. Related: #188796.

Co-authored-by: galiniliev <[email protected]>
Worked on by:
- @galiniliev

Co-authored-by: galiniliev <[email protected]>
OpenClaw-Publication: 79a28e77-6a76-4cd6-bd81-e44cc99064b5
@clawsweeper

clawsweeper Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime extensions: crabbox size: XL labels Oct 31, 2026
@clawsweeper clawsweeper Bot added the clawsweeper:intake:feature Preliminary submission classification; full source review pending. label Oct 31, 2026
roboclaw-bot and others added 2 commits October 31, 2026 04:12
Resolve the package metadata conflict by preserving this prerequisite state schema 37 and current main agent schema 39. Receipt behavior is unchanged; canonical schema generators and all 10 receipt store/migration tests pass after integration.

Co-authored-by: galiniliev <[email protected]>
Worked on by:
- @galiniliev

Co-authored-by: galiniliev <[email protected]>
OpenClaw-Publication: fea66917-e69b-4777-b127-03eb548d7c89
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Oct 31, 2026
roboclaw-bot and others added 2 commits October 31, 2026 04:18
Keep the historical migration expectation values unchanged while satisfying no-shadow.

Co-authored-by: galiniliev <[email protected]>
Worked on by:
- @galiniliev

Co-authored-by: galiniliev <[email protected]>
OpenClaw-Publication: 147bd311-a32a-4cc1-a4c2-116b71affb91
roboclaw-bot and others added 2 commits October 31, 2026 05:17
Preserve receipt custody through provisioning failure, select the complete placement row, align PostgreSQL additive column positions, and update schema-bound consumers and regression fixtures.

Co-authored-by: galiniliev <[email protected]>
Worked on by:
- @galiniliev

Co-authored-by: galiniliev <[email protected]>
OpenClaw-Publication: aa6ef0fc-2c5f-4e21-94bc-6ead8b0adea2
@openclaw-barnacle openclaw-barnacle Bot added channel: voice-call Channel integration: voice-call scripts Repository scripts labels Oct 31, 2026
roboclaw-bot and others added 4 commits October 31, 2026 09:15
Compose legacy schema transformations in canonical order, preserve installed PostgreSQL foreign keys in historical fixtures, and settle confirmed deletion after shutdown aborts new effects.

Co-authored-by: galiniliev <[email protected]>
Worked on by:
- @galiniliev

Co-authored-by: galiniliev <[email protected]>
OpenClaw-Publication: 1cb5a42a-b4a8-43a9-8242-1e75244865d8
Integrate main 64daa25 to repair the actual provider-lifecycle conflict. Keep the receipt-owned SSH bootstrap extraction and the incoming destructured clock default. Shared-state schema remains 37. Affected receipt, image-intent, teardown-drain, and migration tests: 18 passed; targeted Gateway typing and lifecycle lint passed.

Co-authored-by: galiniliev <[email protected]>
Worked on by:
- @galiniliev

Co-authored-by: galiniliev <[email protected]>
OpenClaw-Publication: c1df24cc-0977-428a-bfbc-8ba8a983218b
Merge main ef60dd0 without rewriting receipt work. Regenerate canonical catalogs while retaining shared-state37.

Independent P0-P3 review: rejected the reported Azure fixed-lease recovery gap as unreachable for receipts: receipt producer/identity parser only accept azure-sandbox; provisioning and destruction reject a differing provider before stop. The azure recovery branch remains receipt-less.

Co-authored-by: galiniliev <[email protected]>
Worked on by:
- @galiniliev

Co-authored-by: galiniliev <[email protected]>
OpenClaw-Publication: aad1f458-d629-42e3-b44e-a1a2c937d658
@roboclaw-bot
roboclaw-bot merged commit ff3ab23 into main Oct 31, 2026
268 of 271 checks passed
@roboclaw-bot
roboclaw-bot deleted the openclaw/s4-retained-session-disk branch October 31, 2026 21:46
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 1, 2026
)

* feat(workers): bind cleanup to recorded cloud resources

Persist immutable provider receipts through the existing environment writer before setup and enrollment. Reuse them for recovery, inspection, and confirmed exact-resource teardown. Retained allocation, pause/resume, and disk-authoritative workspaces remain inactive. Related: openclaw#188796.

Co-authored-by: galiniliev <[email protected]>

* feat(workers): bind cleanup to recorded cloud resources

Worked on by:
- @galiniliev

Co-authored-by: galiniliev <[email protected]>
OpenClaw-Publication: 79a28e77-6a76-4cd6-bd81-e44cc99064b5

* Publish openclaw/s4-retained-session-disk

Worked on by:
- @galiniliev

Co-authored-by: galiniliev <[email protected]>
OpenClaw-Publication: fea66917-e69b-4777-b127-03eb548d7c89

* test(state): avoid shadowing the migration fixture path import

Keep the historical migration expectation values unchanged while satisfying no-shadow.

Co-authored-by: galiniliev <[email protected]>

* Publish openclaw/s4-retained-session-disk

Worked on by:
- @galiniliev

Co-authored-by: galiniliev <[email protected]>
OpenClaw-Publication: 147bd311-a32a-4cc1-a4c2-116b71affb91

* fix(workers): complete resource receipt consumers and migration parity

Preserve receipt custody through provisioning failure, select the complete placement row, align PostgreSQL additive column positions, and update schema-bound consumers and regression fixtures.

Co-authored-by: galiniliev <[email protected]>

* Publish openclaw/s4-retained-session-disk

Worked on by:
- @galiniliev

Co-authored-by: galiniliev <[email protected]>
OpenClaw-Publication: aa6ef0fc-2c5f-4e21-94bc-6ead8b0adea2

* fix(workers): retain teardown settlement and predecessor contracts

Compose legacy schema transformations in canonical order, preserve installed PostgreSQL foreign keys in historical fixtures, and settle confirmed deletion after shutdown aborts new effects.

Co-authored-by: galiniliev <[email protected]>

* Publish openclaw/s4-retained-session-disk

Worked on by:
- @galiniliev

Co-authored-by: galiniliev <[email protected]>
OpenClaw-Publication: 1cb5a42a-b4a8-43a9-8242-1e75244865d8

* Publish openclaw/s4-retained-session-disk

Worked on by:
- @galiniliev

Co-authored-by: galiniliev <[email protected]>
OpenClaw-Publication: c1df24cc-0977-428a-bfbc-8ba8a983218b

* Publish openclaw/s4-retained-session-disk

Worked on by:
- @galiniliev

Co-authored-by: galiniliev <[email protected]>
OpenClaw-Publication: aad1f458-d629-42e3-b44e-a1a2c937d658

---------

Co-authored-by: galiniliev <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: voice-call Channel integration: voice-call docs Improvements or additions to documentation extensions: crabbox gateway Gateway runtime 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. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. scripts Repository scripts size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant