Skip to content

feat: let delegated providers keep a lease alive - #1707

Open
zozo123 wants to merge 1 commit into
openclaw:mainfrom
zozo123:feat/delegated-heartbeat
Open

feat: let delegated providers keep a lease alive#1707
zozo123 wants to merge 1 commit into
openclaw:mainfrom
zozo123:feat/delegated-heartbeat

Conversation

@zozo123

@zozo123 zozo123 commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Problem

crabbox heartbeat only worked for SSH-lease backends — internal/cli/heartbeat.go asserted
backend.(SSHLeaseBackend) and otherwise exited 2. A delegated provider had no way to keep its lease alive even
when its API can do so cheaply. For islo specifically, Touch only rewrote a local label, so a "heartbeat" never
reached the provider and an idle lease paused anyway.

Change

Adds a provider-neutral optional LeaseHeartbeatBackend capability plus a FeatureHeartbeat feature so it is
discoverable via crabbox providers. The request carries only the lease ID — there is nothing generic to negotiate,
and a smaller contract is easier for the next delegated provider to implement. Backends that do not implement it
fall through to the untouched SSH assertion with the same message and exit code.

--idle-timeout is refused on this path rather than silently ignored: no lifecycle-update operation exists, so
a delegated heartbeat cannot change an idle window.

islo is the first consumer. There is no dedicated heartbeat endpoint, so a heartbeat is one true exec — exits 0
immediately, mutates nothing, safe to replay. Streams are discarded so success is silent, and both the read and the
exec get a bounded context. The reported idle window is read from the live sandbox, not from Crabbox config.

A paused sandbox is refused rather than exec'd: an exec against a paused sandbox resumes it, and the resume is
billed, so a heartbeat must never be the thing that starts billing compute.

Evidence

go test ./internal/providers/islo/ ./internal/providers/all/   # ok, ok
go test ./internal/cli/ -run "TestHeartbeat|Feature"           # ok

Tests were mutation-checked — 12 mutations, each confirmed to fail, including reverting the gate to the config-only
condition and swapping the discarded streams for real writers.

Live behaviour — a controlled A/B against a real sandbox with pause_after_idle = 60s (created and deleted for the
test):

PHASE A  heartbeat every 30s
  t+32s  running    t+62s  running    t+93s  running
  t+124s running    t+154s running          <- 2.5x the idle window, no pause

PHASE B  heartbeats stopped
  t+205s running    t+246s running    t+266s paused

Control, same 60s policy with no execs, paused at t+90s. So the exec measurably defers the pause, and the pause
still arrives once heartbeats stop.

Separately, on a tenant with no credit the same exec-against-paused returns
402 BILLING_NOT_ALLOWED — "Insufficient credit balance to resume a sandbox", which is why a paused sandbox is
refused here.

`crabbox heartbeat` only worked for SSH-lease backends: internal/cli/heartbeat.go
asserted backend.(SSHLeaseBackend) and otherwise exited 2. A provider that
delegates execution had no way to keep its lease alive even when its API can do
so cheaply, and the islo adapter's Touch only rewrote a local label, so it never
reached the provider at all.

Add a provider-neutral optional capability, `LeaseHeartbeatBackend`, plus a
`FeatureHeartbeat` feature so the capability is advertised and discoverable
through `crabbox providers`. The request carries only the lease ID: there is
nothing generic to negotiate, and a smaller contract is easier for the next
delegated provider to implement. Backends that do not implement the capability
fall through to the untouched SSH assertion with the same message and the same
exit code, so existing behaviour is unchanged. The gate is a spec condition
rather than a global config check, so a provider that can never hold a
coordinator-registered lease is not excluded by an unrelated broker setting.

`--idle-timeout` is refused on this path rather than silently ignored: neither
plane exposes a lifecycle update, so a delegated heartbeat cannot change an idle
window, and accepting the flag would have reported a number that was not in
force.

Implement it for islo as the first consumer. There is no dedicated heartbeat
endpoint, so a heartbeat is one `true` exec, which exits 0 immediately and
mutates nothing, making it safe to replay. Streams are discarded so a successful
heartbeat is silent. Both the read and the exec are given a bounded context so a
hung control plane cannot stall a heartbeat loop.

The reported idle window is read from the live sandbox rather than from Crabbox
config, because the provider echoes the sandbox's own lifecycle policy and that
is the only idle number describing this lease; when the sandbox carries no such
policy the result reports no idle timeout and warns, rather than printing an
unrelated config default.

A paused sandbox is refused rather than exec'd. An exec against a paused sandbox
resumes it and the resume is billed: on a tenant with no credit the same call is
rejected with HTTP 402 BILLING_NOT_ALLOWED, "Insufficient credit balance to
resume a sandbox". Refusing means a heartbeat can never be the thing that starts
billing compute. This path issues no create and no lifecycle write of any kind,
so it cannot affect an absolute deletion deadline.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@clawsweeper

clawsweeper Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. 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 Aug 31, 2026
@clawsweeper

clawsweeper Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed September 1, 2026, 4:31 PM ET / 20:31 UTC.

ClawSweeper review

What this changes

The branch adds a provider-owned lease-heartbeat capability so delegated providers, initially Islo, can record lease activity without a Crabbox-managed SSH lease.

Merge readiness

Blocked until stronger real behavior proof is added - 3 items remain

Keep this PR open: the implementation is coherent and current main still lacks the delegated heartbeat path, but the supplied live A/B output does not demonstrate the new CLI command succeeding against a claimed running Islo sandbox.

Priority: P2
Reviewed head: c71c348455927cb4d148988448186810d846fb36

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch and focused coverage are solid, but merge readiness is capped until the claimed live behavior is tied to the actual CLI entrypoint.
Proof confidence 🦐 gold shrimp (3/6) Needs stronger real behavior proof before merge: The changed production owner is Islo’s Heartbeat method, reached by crabbox heartbeat; the PR body provides real-sandbox A/B state output, but it does not show an after-fix CLI invocation against a claimed running sandbox or its observed command result. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: The changed production owner is Islo’s Heartbeat method, reached by crabbox heartbeat; the PR body provides real-sandbox A/B state output, but it does not show an after-fix CLI invocation against a claimed running sandbox or its observed command result. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 5 items Current main still lacks the requested behavior: The fetched main version reaches the SSHLeaseBackend assertion after coordinator handling, so a delegated Islo backend still returns the unsupported-heartbeat error.
Claim and state checks precede the provider side effect: The Islo adapter resolves and requires an exact local Islo claim before its sandbox lookup, then rejects terminal and non-running states before the no-op exec.
Focused mock coverage covers the command contract: Tests cover the delegated capability route, registered-broker exception, unsupported providers, idle-timeout rejection, exact claims, state rejection, and exec failures; these are supplemental to live proof.
Findings None None.
Security None None.

How this fits together

Crabbox’s heartbeat command refreshes lease activity through either a coordinator, direct SSH provider, or provider adapter. This change sends delegated-provider identifiers to an adapter-owned activity call and renders the adapter’s reported lease state.

flowchart LR
A[CLI heartbeat request] --> B[Provider selection]
B --> C{Coordinator lease possible?}
C -->|Yes| D[Coordinator heartbeat]
C -->|No| E[Delegated provider heartbeat]
E --> F[Islo sandbox API]
D --> G[Heartbeat result]
F --> G
Loading

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: The changed production owner is Islo’s Heartbeat method, reached by crabbox heartbeat; the PR body provides real-sandbox A/B state output, but it does not show an after-fix CLI invocation against a claimed running sandbox or its observed command result. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve merge risk (P1) - The user-facing after-fix path remains unverified: the provided live output does not show crabbox heartbeat --provider islo succeeding for a claimed running sandbox.
  • Complete next step (P2) - A contributor-supplied real-path trace is required before normal maintainer merge review can complete.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production and test delta production +240/-22, tests +581/-1, docs +100/-3 The feature adds a new core/provider capability with substantially more focused regression coverage than production code.
Affected surface 15 files affected The change spans CLI routing, the Islo adapter, capability conformance tests, and operator documentation.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Retain the provider-neutral capability and add a redacted terminal transcript or runtime log that connects the real claimed Islo sandbox, CLI heartbeat invocation, successful result, and observed lifecycle effect.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Retain the provider-neutral capability and add a redacted terminal transcript or runtime log that connects the real claimed Islo sandbox, CLI heartbeat invocation, successful result, and observed lifecycle effect.

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

Yes. Current main’s command path only accepts an SSH lease backend, while the branch adds the Islo adapter path; the supplied live A/B describes the provider activity scenario but has not shown the actual CLI result.

Is this the best way to solve the issue?

Yes, subject to real-path proof. The optional provider-neutral capability follows the repository’s provider boundary and keeps Islo-specific lifecycle behavior in its adapter.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.

Label justifications:

  • P2: This is a bounded new delegated-provider capability with limited blast radius and no demonstrated current outage.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The changed production owner is Islo’s Heartbeat method, reached by crabbox heartbeat; the PR body provides real-sandbox A/B state output, but it does not show an after-fix CLI invocation against a claimed running sandbox or its observed command result. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

  • Current main still lacks the requested behavior: The fetched main version reaches the SSHLeaseBackend assertion after coordinator handling, so a delegated Islo backend still returns the unsupported-heartbeat error. (internal/cli/heartbeat.go:84, 200089463ff5)
  • Claim and state checks precede the provider side effect: The Islo adapter resolves and requires an exact local Islo claim before its sandbox lookup, then rejects terminal and non-running states before the no-op exec. (internal/providers/islo/heartbeat.go:55, c71c34845592)
  • Focused mock coverage covers the command contract: Tests cover the delegated capability route, registered-broker exception, unsupported providers, idle-timeout rejection, exact claims, state rejection, and exec failures; these are supplemental to live proof. (internal/providers/islo/heartbeat_test.go:28, c71c34845592)
  • The earlier proof request remains unmet: The prior completed review requested a redacted successful CLI trace for a claimed running sandbox. The supplied A/B output describes sandbox state over time but does not show the CLI invocation, claimed target, or command result. (c71c34845592)
  • Release check: No release tag contains the unmerged branch head; the requested behavior is neither in the stated latest release nor on fetched current main. (c71c34845592)

Likely related people:

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

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add a redacted terminal transcript or runtime log of crabbox heartbeat --provider islo succeeding for a claimed running sandbox and showing the observed lifecycle effect.

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 (2 earlier review cycles)
  • reviewed 2026-08-31T18:09:51.086Z sha c71c348 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-01T20:26:48.917Z sha c71c348 :: needs real behavior proof before merge. :: none

@zozo123

zozo123 commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Blocking findings addressed and the PR body updated with the fixes plus live behaviour proof.

@clawsweeper

clawsweeper Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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