Skip to content

fix(ci): stop leaked Testbox SSH sessions and guard lease reuse - #160052

Merged
vincentkoc merged 1 commit into
mainfrom
fix/testbox-lifecycle-20260928
Sep 28, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
fix/testbox-lifecycle-20260928

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Sep 28, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Older native Crabbox clients can leave SSH connections active after commands return, extending Testbox lifetime. The wrapper also allowed retained leases to be reused without allocation provenance tied to the caller and checkout.

User Impact

Testbox selects Crabbox 0.67.0 or newer. Other providers retain their supported 0.56.0 floor, including offline installations stored only in the previous managed cache. Doctor detection and execution share the same read-only cache selector; new managed downloads target 0.67.0.

Retained Testboxes require the allocating task and matching checkout, HEAD/base, dependencies, environment and workflow inputs. The wrapper rechecks the original admission after asynchronous preparation, immediately before native delegation. Missing, foreign or old-schema receipts require stopping the lease and allocating again. One-shot runs and successful conditional-retention runs still stop normally.

Why This Change Was Made

The native SSH repair is already released in Crabbox. Its managed-binary owner selects that repair only where needed. The wrapper records retained allocation facts and hashed caller attribution without raw session identifiers, checkout paths or command payloads. Native claims continue to own remote authorization; these receipts constrain task reuse.

Operator-retained runs require a task label; session-owned warmup remains supported. TTL is a recorded request because the delegated provider does not enforce it. Labels and attribution remain local. Both proof guides document these boundaries.

Maintainer migration decision: retire schema-1 ephemeral lease receipts through explicit stop and fresh allocation. Schema 1 shipped in v2026.9.6 (tag commit eb377ac59e6c9fd6c7705028034812becf00271b, receipt-writer blob ac963572bad0ef1c9c69f3e1fe0526f240b30484). This deliberate retirement is covered by the maintainer landing request and the live compatibility probe below. It is not an npm or installed-fleet migration claim.

Evidence

Current signed head: bd03d69ad247f545dde061a9e1d22a753b9e7d01, rebased onto immutable main 4902e4ae49a669702b92a1df3aeb01b167ec6715 after a real merge conflict with the now-main-owned fixture repair below. All four production files and all four Testbox test files remain byte-identical to live-proof head 09994f04a56b9aaf2f37a9143f0f92421c707625. The two guides retain the lease contract and incorporate main-owned capacity and witness-recovery guidance. The release-owned changelog and already-landed planner fixture correction are absent from this ten-file diff. The bounded Vitest fixture correction has also been dropped because main now owns it. All ten retained file blobs are unchanged from the previously reviewed candidate; independent review verified the Testbox identities and upstream fixture ownership.

The real wrapper ran from a qualified native PR checkout with existing local authentication, checksum-verified Crabbox 0.67.0 and Blacksmith 0.4.61. A transparent audit launcher executed the unchanged Blacksmith client and recorded only native lifecycle operation identity. No mock, bundled wrapper, borrowed loader, credential forwarding or fleet upgrade was used.

  • Allowed schema-2 reuse completed and left the allocation receipt hash unchanged.
  • A distinct supported CODEX_THREAD_ID, with the same checkout, HEAD and options, was refused with zero native Testbox calls.
  • After the wrapper emitted admission, the task-owned receipt was deleted during preparation. Final admission refused the command with zero native Testbox calls.
  • After a successful native command on the real lease, the exact released writer produced schema 1. The current wrapper refused it with zero native Testbox calls. Native stop succeeded; a new, distinct lease was allocated through the wrapper with schema 2, reused successfully and stopped.
  • Both remote capsule receivers verified source 09994f04a56b9aaf2f37a9143f0f92421c707625 and tree 16d4d0d416a34d92338aea5cc850009205ce01b4 with frozen dependency reconciliation. Independent review verified the script, unchanged-client forwarding, receipt identities, audit and terminal cleanup.

Public lifecycle receipts: original lease, replacement lease. SSH cleanup succeeded at 04:27:04 and 04:30:37 UTC; jobs ended at 04:27:09 and 04:30:43 UTC. Cancelled conclusions are expected after explicit native stop. No task lease remains active.

Validation:

  • Fresh scoped P0–P2 autoreview on b8e311d found no actionable findings; source verification passed before and after review. Independent owner review cleared the unchanged production source and inspected the real lifecycle proof.
  • All 36 freshness regressions passed in 8.41 seconds through native review-tests on the qualified checkout. On 09994f, test types and managed-binary/doctor tests passed. Prior wrapper proof covers byte-identical wrapper production and tests.
  • A broader six-file run with one Vitest worker on a 16-vCPU Linux Testbox (Node 24.19.0, pnpm 12.5.1) took 237.995 seconds: 915 passed, two subsequently corrected fixture assertions failed, one skipped. This reports actual run conditions, not matched before/after savings.
  • Earlier test-only typing and inherited harness/planner failures were repaired and verified. Their now-main-owned fixture changes have been removed from this PR. The held 2e85de0 CI run then failed inherited placement-fence/teardown assertions twice; retention assertions failed in attempt 1 and were cancelled by fail-fast in attempt 2. No unchanged retry is being used as proof.
  • Main now owns the fixes: placement boundary observation and joined teardown, native callback GC scheduling, and retired-instance closure release. All are included in frozen base 741c9cb. No gateway or plugin-runtime repair is added by this PR.
  • After a frozen dependency refresh in the task-owned native PR checkout (Node 26.7.0, pnpm 12.5.1, Vitest 5.0.1), all 10 runtime-retention tests passed in 43.98 seconds. Both focused placement lifecycle files also passed (67 tests); the complete two-shard run passed 77 tests in 124.92 seconds. This local proof does not replace Linux hosted CI. Fresh exact-head CI and ClawSweeper review remain required landing gates.
  • The superseded b8e311d CI run exposed inherited AI-declaration fixture drift. A focused before-run reproduced both extra-build failures; the corrected fixture and canonical prebuilt-AI sibling passed 48/48, with targeted lint, formatting, autoreview and independent review. Then exact 63bfaebe55b91a359f1a6c7f0eeeafa8ea8abdc1 full CI and security completion passed, and ClawSweeper found no remaining action. Native merge stopped before submission when main landed the canonical fixture fix. This branch takes that main fixture wholesale and drops its equivalent fixture commit; main also moved missing-declaration repair to the CI shard owner. Fresh current-head CI and review are required: the earlier green run is not claimed as exact-head qualification.
  • Personally inspected Crabbox 0da3c21c1ca531ce64f36757059e93a5d7e54522 for SSH/SCP and retention contracts, and Codex 414782450952a196bbb64b1605a458c2531c47b6: codex-rs/protocol/src/shell_environment.rs:104, codex-rs/core/src/unified_exec/process_manager.rs:1096, codex-rs/core/src/tools/runtimes/mod.rs:289 for session propagation.

Review Follow-through

The provider-floor, documentation and release-owned changelog findings are addressed. Real final-effect refusal and schema-1 stop/reallocation proof now close the previously reported live gaps. Maintainer acceptance is the explicit ephemeral-receipt retirement described above. No new schema or runtime bypass was added to obtain proof.

The earlier 2e85de0 Node plan fell back broadly with unresolved changed-path owner: "docs/reference/test/remote-proof.md". That is a named planner-ownership follow-up, not a claimed fanout reduction. The current ten-file diff contains only the Testbox owner, regressions and proof guides. All inherited harness, planner and AI-build fixture repairs are main-owned.

Production: +309/-62 (net +247), owning allocation provenance, final admission and provider-specific binary selection. Tests: +564/-108 (net +456). Docs: +55/-23 (net +32).

Named follow-ups: existing native claim-restoration fencing; direct-caller Crabbox rollout; remote-proof docs planner ownership; and SQLite cleanup fixture isolation from automatic maintenance during setup. No speculative production repairs or fleet changes are included.

@vincentkoc vincentkoc self-assigned this Sep 28, 2026
@clawsweeper

clawsweeper Bot commented Sep 28, 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 scripts Repository scripts extensions: crabbox size: L labels Sep 28, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review September 28, 2026 02:46
@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: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 28, 2026
@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 28, 2026, 12:14 PM ET / 16:14 UTC (Revision 7).

ClawSweeper review

What this changes

For remote Testbox proof, the branch selects Crabbox 0.67.0, binds retained leases to caller and checkout receipts, rechecks them before native commands, and updates Doctor, tests, and guides.

Merge readiness

✅ Ready for maintainer review

Keep open. Current main still has the older Testbox client selection and schema-1 lease receipts. This PR supplies a distinct repair with credible real-client proof, and the review found no introduced blocker.

Priority: P2
Reviewed head: bd03d69ad247f545dde061a9e1d22a753b9e7d01

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The coherent repair has focused regressions and convincing real-client lifecycle evidence, with no established correctness or security blocker.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): The changed wrapper and receipt-owner blobs match the earlier live-proof head. The PR records real wrapper and Crabbox 0.67.0 runs through Blacksmith Testbox showing allowed reuse, foreign-session and withdrawn-receipt refusal before native calls, and stop plus fresh allocation from a released schema-1 receipt; that transition also supports stored-data compatibility.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The changed wrapper and receipt-owner blobs match the earlier live-proof head. The PR records real wrapper and Crabbox 0.67.0 runs through Blacksmith Testbox showing allowed reuse, foreign-session and withdrawn-receipt refusal before native calls, and stop plus fresh allocation from a released schema-1 receipt; that transition also supports stored-data compatibility.
Evidence reviewed 11 items Current main still needs the repair: Current main uses schema-1 receipts with fewer reuse checks; its managed Crabbox release remains 0.56.0.
Final lease admission: After asynchronous preparation, the wrapper checks the original receipt and fingerprint before spawning the native client.
Receipt ownership and version: Schema 2 binds reuse to a task key, physical checkout, HEAD, base, dependencies, and preparation inputs; missing or older receipts are refused.
Findings None None.
Security None None.

How this fits together

OpenClaw’s Crabbox wrapper sends checkout proof commands through a native client to Blacksmith Testboxes. It selects the client and checks local lease state before delegation; Doctor checks cloud-worker binary availability.

flowchart LR
  A[Checkout and caller] --> B[Crabbox client selection]
  B --> C[Lease receipt]
  C --> D[Final admission check]
  D --> E[Native Crabbox command]
  E --> F[Blacksmith Testbox]
  F --> G[Result and cleanup]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +46, Tests +465, Docs +23, Other +201. Total +735 across 10 files.

View PR surface stats
Area Files Added Removed Net
Source 2 62 16 +46
Tests 5 584 119 +465
Docs 1 35 12 +23
Config 0 0 0 0
Generated 0 0 0 0
Other 2 247 46 +201
Total 10 928 193 +735

Review metrics

Metric Value Why it matters
Production and test growth production net +247; tests net +456 The production growth implements lease provenance, final admission, and client selection; the tests exercise those transitions.
Receipt transition 1 shipped schema retired; version 1 → 2 Previously retained leases require the documented stop-and-reallocate path.

Stored data model

Persistent data-model change detected: migration/backfill/repair: extensions/crabbox/src/doctor.ts, unknown-data-model-change: scripts/testbox-lease-freshness.mts. Migration or upgrade compatibility proof is recorded; maintainers should verify it before merge.

Technical review

Best possible solution:

Keep one wrapper-owned lease admission path, retain the documented stop-and-reallocate transition for schema-1 receipts, and preserve supported offline binaries for non-Testbox providers.

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

Yes, source establishes the current-main path: it selects the older managed client and permits reuse without allocation-bound schema-2 receipts. This read-only review did not execute a failing current-main run.

Is this the best way to solve the issue?

Yes. The existing wrapper owns lease admission, and the existing binary manager scopes the newer native client to Testbox while preserving the supported floor for other providers.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This addresses a bounded Testbox reliability and lease-reuse problem without evidence of a broad user-facing outage.
  • merge-risk: 🚨 compatibility: The shipped schema-1 receipt cannot be reused; the PR records and exercises stop followed by fresh allocation.
  • merge-risk: 🚨 security-boundary: The patch changes which caller sessions and checkouts may reach native Testbox reuse, with reported final-effect refusals.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The changed wrapper and receipt-owner blobs match the earlier live-proof head. The PR records real wrapper and Crabbox 0.67.0 runs through Blacksmith Testbox showing allowed reuse, foreign-session and withdrawn-receipt refusal before native calls, and stop plus fresh allocation from a released schema-1 receipt; that transition also supports stored-data compatibility.
  • proof: sufficient: Contributor real behavior proof is sufficient. The changed wrapper and receipt-owner blobs match the earlier live-proof head. The PR records real wrapper and Crabbox 0.67.0 runs through Blacksmith Testbox showing allowed reuse, foreign-session and withdrawn-receipt refusal before native calls, and stop plus fresh allocation from a released schema-1 receipt; that transition also supports stored-data compatibility.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • vincentkoc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (6 earlier review cycles)
  • reviewed 2026-09-28T02:55:06.780Z sha 66a977269adb2c543189905eaa65531b20ebd0af :: needs real behavior proof before merge. :: [P1] Scope the 0.67.0 minimum to Testbox runs | [P2] Update the existing guide for the new label gate
  • reviewed 2026-09-28T04:00:11.452Z sha 49996a7866f572ae39f4d25f5e419669972b17e5 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-28T04:10:02.675Z sha 09994f04a56b9aaf2f37a9143f0f92421c707625 :: needs real behavior proof before merge. :: [P2] Remove the release-owned changelog entry
  • reviewed 2026-09-28T04:44:03.081Z sha 2e85de0 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-28T15:14:00.366Z sha b8e311d :: needs changes before merge. :: none
  • reviewed 2026-09-28T15:51:00.527Z sha 63bfaebe55b91a359f1a6c7f0eeeafa8ea8abdc1 :: needs maintainer review before merge. :: none

@vincentkoc
vincentkoc marked this pull request as draft September 28, 2026 03:20
@vincentkoc
vincentkoc force-pushed the fix/testbox-lifecycle-20260928 branch from 66a9772 to 9f6d349 Compare September 28, 2026 03:20
@vincentkoc
vincentkoc force-pushed the fix/testbox-lifecycle-20260928 branch from 9f6d349 to d0ef542 Compare September 28, 2026 03:25
@vincentkoc
vincentkoc marked this pull request as ready for review September 28, 2026 03:25
@vincentkoc
vincentkoc force-pushed the fix/testbox-lifecycle-20260928 branch 2 times, most recently from 7d09af1 to c6ebc81 Compare September 28, 2026 03:41
@vincentkoc
vincentkoc force-pushed the fix/testbox-lifecycle-20260928 branch 4 times, most recently from df20153 to 2e85de0 Compare September 28, 2026 04:35
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 28, 2026
@clawsweeper clawsweeper Bot added the status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. label Sep 28, 2026
@vincentkoc
vincentkoc marked this pull request as draft September 28, 2026 15:05
@vincentkoc
vincentkoc force-pushed the fix/testbox-lifecycle-20260928 branch from 2e85de0 to b8e311d Compare September 28, 2026 15:05
@vincentkoc
vincentkoc marked this pull request as ready for review September 28, 2026 15:10
Select Crabbox 0.67.0 for native Testbox SSH teardown while preserving supported offline binaries and managed caches for other providers. Keep doctor and execution on one cache selector. Record retained allocation provenance and revalidate the original caller, checkout and receipt immediately before delegation.

Retire schema1 ephemeral lease receipts through explicit stop and reallocation. Update local and remote proof guidance. Release-owned changelog content is untouched.

Real wrapper/native 0.67 proof at 09994f preserved allowed-reuse receipts, refused a different supported session and post-admission receipt withdrawal before any native Testbox call, and exercised the exact v2026.9.6 schema1 writer followed by refusal, stop, fresh schema2 allocation, reuse and terminal SSH cleanup. The four production and four Testbox test blobs remain identical after integrating main741c9cb. Freshness36/36 and the earlier scoped hosted checks passed; final exact-head proof and review remain required.

The prior CI blocker repeated an inherited one-second placement polling failure and left reconciliation unjoined during teardown. Main-owned e4ea649 observes the real admission boundary and always joins recovery; c136ec6 and 958de2c repair plugin retention lifecycle proof and disposal capture. Integrate those upstream repairs instead of adding unrelated runtime changes. Main also owns the equivalent planner fixture filter, so it is absent from this PR.

Production net +247 owns allocation provenance, final admission and provider-specific binary selection; tests net +456, docs net +32. Follow-ups: existing claim-restoration fencing, direct-caller rollout, remote-proof docs planner ownership and SQLite fixture maintenance isolation. No fleet upgrade.
@vincentkoc
vincentkoc force-pushed the fix/testbox-lifecycle-20260928 branch from 63bfaeb to bd03d69 Compare September 28, 2026 16:06
@vincentkoc
vincentkoc merged commit 517cbd9 into main Sep 28, 2026
166 checks passed
@vincentkoc
vincentkoc deleted the fix/testbox-lifecycle-20260928 branch September 28, 2026 16:22
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

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

Select Crabbox 0.67.0 for native Testbox SSH teardown while preserving supported offline binaries and managed caches for other providers. Keep doctor and execution on one cache selector. Record retained allocation provenance and revalidate the original caller, checkout and receipt immediately before delegation.

Retire schema1 ephemeral lease receipts through explicit stop and reallocation. Update local and remote proof guidance. Release-owned changelog content is untouched.

Real wrapper/native 0.67 proof at 09994f preserved allowed-reuse receipts, refused a different supported session and post-admission receipt withdrawal before any native Testbox call, and exercised the exact v2026.9.6 schema1 writer followed by refusal, stop, fresh schema2 allocation, reuse and terminal SSH cleanup. The four production and four Testbox test blobs remain identical after integrating main741c9cb. Freshness36/36 and the earlier scoped hosted checks passed; final exact-head proof and review remain required.

The prior CI blocker repeated an inherited one-second placement polling failure and left reconciliation unjoined during teardown. Main-owned d3c3c5e observes the real admission boundary and always joins recovery; a863476 and f4bb141 repair plugin retention lifecycle proof and disposal capture. Integrate those upstream repairs instead of adding unrelated runtime changes. Main also owns the equivalent planner fixture filter, so it is absent from this PR.

Production net +247 owns allocation provenance, final admission and provider-specific binary selection; tests net +456, docs net +32. Follow-ups: existing claim-restoration fencing, direct-caller rollout, remote-proof docs planner ownership and SQLite fixture maintenance isolation. No fleet upgrade.

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

Labels

docs Improvements or additions to documentation extensions: crabbox 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. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: XL 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