Skip to content

fix: retain runner cleanup ownership after registration cancellation - #3045

Merged
vincentkoc merged 2 commits into
mainfrom
fix/actions-runner-cancel-registration-20261105
Nov 5, 2026
Merged

vincentkoc merged 2 commits into
mainfrom
fix/actions-runner-cancel-registration-20261105

Conversation

@vincentkoc

Copy link
Copy Markdown
Member

What Problem This Solves

Canceling Actions runner registration after the guest has configured itself can leave an offline GitHub runner without its matching local cleanup receipt.

User Impact

Crabbox retains the verified runner identity for actions unregister, leaves its listener stopped, and returns cancellation to the caller.

Why This Change Was Made

Recover the guest identity and verify the exact GitHub object with a bounded 30-second settlement context under the existing claim lock. Listener startup still uses the caller context. Existing exact-ID rollback remains in place if receipt persistence fails.

The change uses the existing receipt and cleanup owners; it adds no flags, credentials, storage schema, or provider policy.

Evidence

  • The new CLI lifecycle regression fails on the base in both repository and organization mode: the newly configured GitHub runner exists while the local receipt still identifies the previous runner.
  • With the fix, the race-enabled lifecycle test passes. It cancels during guest configuration and during GitHub identity verification, then proves the receipt matches, the listener remains stopped, cancellation is returned, and cleanup performs one exact API deletion without SSH.
  • The existing runner installer, transport, labels, and capability tests pass with the race detector (TestGitHubActionsRunner* and TestValidateActionsRunner*).
  • go vet ./internal/cli, command documentation checks, internal documentation links, formatting, and git diff --check pass.
  • Existing lifecycle coverage also exercises lost acknowledgements, changed ownership, consumed runners, and persistence-failure rollback.
  • Independent review found no actionable P0–P2 findings. The patch adds 14 production lines and removes 10; test and documentation growth supports the cancellation regression.

This is local CLI/transport-fixture proof; live organization registration remains a separate migration qualification.

@clawsweeper

clawsweeper Bot commented Nov 5, 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.

@vincentkoc
vincentkoc marked this pull request as ready for review November 5, 2026 13:03
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal priority bug or improvement 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. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 5, 2026
@clawsweeper

clawsweeper Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR retains a verified runner cleanup receipt after cancellation while leaving the listener stopped and returning cancellation.

Example: Registration creates runner 43 for repos/example-org/my-app, then the caller cancels during verification.

  • Before: Verification uses the canceled context, leaving the local receipt pointing to the previous runner.
  • After: Bounded settlement verifies runner 43 and saves its receipt; actions unregister can delete it without SSH.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, source-supported lifecycle repair with meaningful fixture coverage and no actionable finding; real transport behavior remains unverified.
Proof confidence 🦐 gold shrimp (3/6) The ordinary proof gate is exempt for this maintainer-authored PR; supplied validation exercises App.Run and generated guest scripts with stand-in SSH, GitHub, and runner commands rather than a live registration.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Canceling registration after guest configuration can leave an offline GitHub runner without the local identity needed for exact cleanup.
Reason: The maintainer-authored change restores the established durable-before-start lifecycle with a narrow repair.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: current main can lose cleanup ownership after registration cancellation, and this focused fix preserves the existing ownership checks without an actionable introduced defect.

Priority: P2
Reviewed head: fd4778c92c09af4269d500e3af463f961a712edf

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: A shipped CLI run against real SSH and GitHub showing cancellation, retained identity, stopped listener, and subsequent unregister is not supplied.
Agent review details

How this fits together

The Go Actions CLI coordinates guest configuration over SSH, verifies the exact GitHub runner, and persists its identity in the locked local lease claim before listener activation.

flowchart TD
A[Actions register] --> B[Locked lease claim]
B --> C[Guest configuration over SSH]
C --> D[Bounded identity settlement]
D --> E[GitHub runner verification]
E --> F[Durable cleanup receipt]
F --> G[Caller context listener activation]
F --> H[Exact runner unregister]
Loading

Technical review

Best possible solution:

Keep cancellation settlement in the existing locked registration owner, persist only the verified identity, and preserve caller-controlled listener activation.

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

Current-main source shows recovery and GitHub verification using the canceled caller context before receipt persistence; the PR reports base-failing lifecycle cases, but no reproduction was executed during this read-only review.

Is this the best way to solve the issue?

The patch directly repairs lifecycle settlement using the existing lock, verifier, receipt, and rollback path, with no parallel owner or configuration expansion.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Pinned patch and current-main defect: The introduced diff replaces canceled-context identity recovery with bounded settlement and checks caller cancellation before activation; current main still uses the caller context for recovery and verification. (internal/cli/actions_runner.go:167, fd4778c92c09)
  • Cancellation lifecycle coverage: The added lifecycle cases cancel during configuration and verification in repository and organization modes, checking matching persisted identity, cancellation, no listener activation, and one exact API deletion without SSH; these use stand-in transport commands. (internal/cli/actions_runner_test.go:307, fd4778c92c09)
  • Existing authorization and persistence owners: Settlement remains inside the durable claim lock; runner verification checks ID, name, lease label, and requested labels, and deletion rechecks identity using current GitHub credentials. The receipt schema and durable writer are unchanged. (internal/cli/actions_runner.go:212, fd4778c92c09)
  • Original lifecycle contract: feat: register Actions runners in organization groups #3028 established durable ownership before listener startup, exact deregistration, legacy adoption, and lost-acknowledgement recovery; this PR repairs cancellation within that contract. (internal/cli/actions_runner.go:166, 3bc35d7553b3)
  • Discussion and dependent work: The full body and comments provide fixture-based validation claims, with no additional runtime artifact; feat: support runner cleanup from a fresh machine #3046 explicitly depends on this cancellation settlement and adds separate portable-receipt behavior.
  • Repository policy and inspection limits: The complete root AGENTS.md was applied; no nested policies, maintainer-notes directory, or pr-simplify skill were found. Earlier actions.go content needed for extended history was unavailable locally; the changed runner file and its current-main provenance were readable. No tests were run, and the checkout remains clean. (AGENTS.md:1, fd4778c92c09)

Likely related people:

  • Vincent Koc: Raw commit 3bc35d7 adds internal/cli/actions_runner.go:163 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 3bc35d7553b3; files: internal/cli/actions_runner.go)
  • Peter Steinberger: Raw commit fd90dd9 adds docs/commands/actions.md:14 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: fd90dd91605d; files: docs/commands/actions.md)

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Patch scope Production +15/-9; tests +51/-1; documentation +4/-0 A small lifecycle repair reuses existing owners; added coverage exercises two distinct cancellation stages in both scopes.

Labels

Label changes:

  • add P2: Cancellation can leave an offline runner without its matching cleanup receipt, affecting a limited Actions registration workflow.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: Cancellation can leave an offline runner without its matching cleanup receipt, affecting a limited Actions registration workflow.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

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

  • Strengthen confidence with a redacted real CLI cancellation and exact-unregister trace.

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 execution lanes are retired.

Reviewed November 5, 2026, 8:18 AM ET / 13:18 UTC.

@vincentkoc
vincentkoc merged commit 2748b47 into main Nov 5, 2026
56 checks passed
@vincentkoc
vincentkoc deleted the fix/actions-runner-cancel-registration-20261105 branch November 5, 2026 13:23
paulcam206 added a commit to paulcam206/crabbox-upstream that referenced this pull request Nov 6, 2026
Reconciles the split-lock registration with the cancellation custody of
openclaw#3045 and the portable cleanup
receipt of openclaw#3046.

After the unlocked guest install, the identity read, GitHub check and
claim recheck run on a cancellation-independent budget. If the lease still
owns the reservation, the runner receipt and any portable receipt are
recorded even when the operation was canceled, and the listener starts
only when it was not; `actions unregister` can then clean up, as on main.
If the lease changed hands or started retiring during the install, the
exact configured runner is deleted instead of recorded. The reuse path
also writes the portable receipt before starting the listener.

Hydration keeps a cause-carrying registration error intact so its cleanup
detail is not replaced by the bare cancellation cause.
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: 👀 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