Skip to content

fix: allow Claw removal with a running Gateway - #166889

Merged
steipete merged 1 commit into
mainfrom
deslop/heartbeat-s1-20261007
Oct 8, 2026
Merged

steipete merged 1 commit into
mainfrom
deslop/heartbeat-s1-20261007

Conversation

@steipete

@steipete steipete commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes Claw removal failing when a running Gateway already owns Cron receipt authority. The CLI tried to acquire the same custody while beginning or rolling back its deletion journal, following the owner change in 58bcc015a37.

User Impact

Claw removal can complete through the serving Gateway while preserving unrelated scheduled jobs. The CLI retains its original deletion lease and physical database identity. A lost reply preserves an uncertain outcome and prevents unsafe release or local replay.

No configuration, SQLite schema, plugin SDK, or heartbeat delivery behavior changes in this slice.

Why This Change Was Made

Only journal begin/rollback move to the existing serving Cron owner. The Gateway validates the current request, configuration, Claw installation, deletion lease, and physical database at native transaction/commit admission; it acknowledges the recorded native outcome. Existing offline callers retain their current path.

This is slice 1 of the maintainer-approved split of #164265. Immediate session events follow in slice 2; Doctor conversion and periodic heartbeat retirement land atomically in slice 3 under #134994. The original PR remains open until all slices merge.

Production grows by 724 lines (+769/−45) because this repair supplies the missing journal transport and settlement handling. Tests grow by 179 lines (+181/−2). No generated output or test support is included in the production count.

Production area Added Deleted Net
src/claws 424 22 +402
src/state 122 2 +120
src/agents 79 21 +58
src/gateway 75 0 +75
src/cli 69 0 +69

Evidence

  • Core production types, scoped lint, line-cap and SQLite worker ratchets passed. Runtime and static cycle checks both report zero; the subsequent worker-only filename correction preserves the import graph.
  • Two independent autoreviews found no actionable P0/P1 issue. The second includes the explicit worker contract; only a worker-only filename correction and removal of two unused schema exports followed it.
  • Wrapper source-closure checks passed (3 cases). The four existing runtime modules preserve their existing APIs; the landing tooling has no direct imports from them. No landing scripts, helper inventory, baseline, or lint suppression was changed.
  • Gateway journal/method tests passed (38 cases), including confirmed begin/rollback, lost reply retaining custody, stale installation and revoked request rejection.
  • Focused runtime suites: 94 passed; four existing admission cases failed. Both assertion failures and both 120-second timing failures independently reproduced on unchanged main at 5fa9edbad099. The assertion failures concern deferred startup inspection; this slice changes only deletion publication in that owner.
  • pnpm build qaRuntime passed, including 14 runtime-postbuild phases and all control-plane imports, on a source-identical isolated copy before the two unused exports were made private.
  • Exact-head AWS proof passed on 7a0ab1eb73236416f3cacd225bb7e32920d1f956: fresh remote PR checkout, independently pinned bootstrap, Node 24.21.0, runtime build 57.7s, and the selected real CLI/Gateway custody case passed in a 60.9s Vitest run. It enables Cron, creates a disabled sibling through the public API, removes the Claw through a separate CLI process, and verifies the sibling survives. Run run_a6e227b4eaf8c31fbed0058f54905a8a; lease cbx_974b2d2d83e6 stopped after proof. The three other lifecycle cases were not selected by this focused command.
  • The AWS negative control confirmed the original defect on unchanged main 5fa9edbad099 plus only this regression test: real claws remove returned monitor_cleanup_failed and a lock timeout on openclaw.sqlite.cron-authority (28.4s case, 58.2s Vitest run). The primary 7a0ab1e checkout stayed unchanged; baseline source and the sole test diff/hash were verified. Run run_5b9dee020d400905b51f78118b87d26f; its separate lease is released. Earlier local CPU-starvation and temporary-directory quota failures did not count as negative controls.
  • Exact-head CI run 37715769749, attempt 2, completed successfully. Attempt 1 failed in Android Maven dependency resolution and cancelled ten sibling jobs; the failed/cancelled jobs reran without code changes after the artifact endpoints recovered. Two cancelled auxiliary automation jobs also reran successfully. Local full declaration build was interrupted for the cycle correction; it is not claimed as passing. No test deadline was increased.

Known main failure: test/scripts/lint-suppressions.test.ts receives two additional typescript/unbound-method suppressions in src/logging/redact-pattern-runtime.ts and src/logging/redact.ts (80 versus 78). The same failure was independently reproduced on unchanged product commit 5fa9edbad099; this PR touches neither logging file nor the suppression test/baseline. No exception is claimed for missing or cancelled CI coverage.

Admission failure details: does not let an unavailable required agent hide a newer required database receives no synchronous newer-schema failure; keeps a secondary with malformed ownership isolated while required agents start receives the existing agent-database-inspection-pending refusal; the two cleaner secondary variants reach their unchanged 120-second deadline on both source versions. These remain failures, not passing coverage; hosted CI and source attribution govern landing.

@clawsweeper

clawsweeper Bot commented Oct 8, 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.

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: 7a0ab1eb73236416f3cacd225bb7e32920d1f956
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/gateway/methods/core-descriptors.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.

Carefully review these changes before merging.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime cli CLI command changes agents Agent runtime and tooling size: L labels Oct 8, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 8, 2026
@clawsweeper

clawsweeper Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 7, 2026, 10:47 PM ET / October 8, 2026, 02:47 UTC (Revision 2).

ClawSweeper review

What this changes

Routes Claw removal journal creation and rollback through the running Gateway while preserving the CLI’s deletion lease and handling uncertain replies.

Example: Remove workspace-agent while Cron is enabled in the Gateway

  • Before: Removal attempts to acquire Cron authority already held by the Gateway and fails.
  • After: Removal reports status complete and leaves the disabled retained-sibling job for main intact.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A useful, coherent repair with recorded end-to-end success and no actionable findings; baseline-control evidence remains limited.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The exact-head AWS lifecycle run exercises the shipped CLI in a separate process against a Cron-enabled Gateway, observes complete Claw removal, and verifies the unrelated disabled job survives. Real-worker harness coverage supplements this with rejected authority and lost-reply outcomes. The previous proof request is resolved; the baseline negative control remains unproven. Existing journal formats and schema are unchanged, so no migration is required.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Users cannot remove a Claw when the running Gateway already owns the scheduled-work authority needed by removal.
Reason: The repair restores the documented removal flow and preserves unrelated schedules. Prior area ownership and the maintainer-authored split establish direction for this bounded slice.

Merge readiness

✅ Ready for maintainer review

This PR remains useful and has no actionable correctness findings. The exact-head CLI/Gateway run resolves the previous proof request; ordinary CI and landing gates still apply.

Priority: P2
Reviewed head: 7a0ab1eb73236416f3cacd225bb7e32920d1f956

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: After-fix separate-process proof is recorded. The baseline control has not yet reached the custody failure, so fail-on-base/pass-on-head is not demonstrated.
Agent review details

How this fits together

Claws packages create agents and track the resources they own. Removal uses a durable deletion journal to coordinate configuration, database, scheduled-work, and resource cleanup across the CLI and Gateway.

flowchart TD
  A[CLI removal with confirmed plan] --> B[Original deletion lease]
  B --> C[Gateway journal request]
  C --> D[Current request and ownership checks]
  D --> E[Existing Cron authority owner]
  E --> F[SQLite worker commit]
  F --> G[Confirmed cleanup or retained uncertain outcome]
Loading

Technical review

Best possible solution:

Keep journal publication with the serving Cron owner, preserve native offline callers, and retain the original deletion lease whenever remote settlement is uncertain.

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

Yes, source establishes the competing Cron-custody acquisition, and the existing lifecycle scenario supplies a concrete CLI/Gateway path. A baseline failing run has not yet been established; the recorded local timeout occurred earlier.

Is this the best way to solve the issue?

Yes. Delegating journal publication to the existing serving owner preserves the intended custody boundary and avoids competing local writers or unsafe replay.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against d327a36593da.

Provenance checked

Testing

Proof path: shipped entry point. Added test files: 3.

Security

None.

Evidence

What I checked:

  • Introduced change inspected: Reviewed the pinned merge-base-to-head hunks, including the CLI transport, Gateway handler, journal worker, and retained lease settlement. Endpoint drift was excluded from PR ownership. (7a0ab1eb7323)
  • Current main still needs the repair: Fetched main retains the local Cron-authority acquisition around deletion journal mutations. The relevant existing paths have no changes between the pinned merge base and fetched main; this transport repair is not already present. (src/agents/agent-lifecycle-registry.ts, d327a36593da)
  • Exact-head real behavior evidence: The retrieved PR body records AWS run run_a6e227b4eaf8c31fbed0058f54905a8a on this exact head, Node 24.21.0, a 57.7-second runtime build, and a 60.9-second selected lifecycle run. A separate CLI removes workspace-agent with Cron enabled in the serving Gateway and verifies retained-sibling survives. This satisfies the previous rank-up request; no reviewer-side execution is claimed. (src/claws/lifecycle.e2e.test.ts:315, 7a0ab1eb7323)
  • Authority checks reach native commit: The worker verifies the original physical database and durable deletion lease, compares installation and journal digests, and requests current host authority at transaction and commit admission. The Gateway callback also checks cancellation, live client authority, configuration identity, and reload settlement. (src/claws/removal-journal.worker.ts:48, 7a0ab1eb7323)
  • Failure and revocation coverage: The new handler composition uses real journal workers and lease owners with a substituted RPC transport. It checks acknowledged begin/rollback, revoked-request and stale-install rejection with no journal remaining, and a lost post-commit reply retaining the journal and lease. The body reports these focused cases passed; this is supplemental harness evidence. (src/gateway/server-claws-removal-journal.test.ts:26, 7a0ab1eb7323)
  • Persistence and upgrade scope: The new worker reuses existing deletion-journal operations and their stored representation. No DDL, schema version, configuration default, plugin SDK contract, or migration changes are introduced. Existing local callers retain the native path. (src/claws/removal-journal.worker.ts:96, 7a0ab1eb7323)

Likely related people:

  • Peter Steinberger: Raw commit a620ab6 adds src/agents/agent-lifecycle-registry.ts:90 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: a620ab692463; files: src/agents/agent-lifecycle-registry.ts)
  • giodl73-repo: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

PR surface

Source +724, Tests +179. Total +903 across 22 files.

View PR surface stats
Area Files Added Removed Net
Source 19 769 45 +724
Tests 3 181 2 +179
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 22 950 47 +903

Review metrics

Metric Value Why it matters
Gateway mutation surface 1 new administrator-only RPC; 0 new user configuration options The added operation repairs cross-process journal ownership without introducing a new operator policy.

Labels

Label changes:

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

Label justifications:

  • P2: This repairs a bounded experimental Claw removal failure without evidence of an urgent broader runtime outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only; repair and merge need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-08T02:05:52.143Z sha 7a0ab1e :: needs changes before merge. :: none

@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: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Oct 8, 2026
@steipete
steipete merged commit fb3773d into main Oct 8, 2026
256 of 270 checks passed
@steipete
steipete deleted the deslop/heartbeat-s1-20261007 branch October 8, 2026 03:11
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 8, 2026
Route Claw deletion journal begin and rollback through the serving Gateway Cron receipt owner while retaining the CLI deletion lease and physical database identity.

Prove the original Cron custody timeout on unchanged main and successful Claw removal with sibling-job preservation on the candidate. Focused runtime proof, both cycle checks, production types, wrapper closure checks, independent review, and exact-head hosted CI completed.

Slice 1 of the approved Heartbeat to Automations split (openclaw#164265, openclaw#134994).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling cli CLI command changes gateway Gateway runtime 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. security-sensitive-changed size: L 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