Repository navigation
fix(heartbeat): persist dynamic local-container claims - #1385
Conversation
Delegate runtime-derived exact claim authorization to providers while preserving generic static-scope validation, and persist local-container heartbeat lifecycle changes through claim compare-and-swap. Refs #1367 Co-authored-by: Coy Geek <[email protected]>
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 17, 2026, 5:07 AM ET / 09:07 UTC. ClawSweeper reviewWhat this changesThe PR delegates runtime-derived lease-claim authorization to provider backends and makes local-container heartbeat updates durable across fresh CLI processes. Regression provenancePossible regression — probable (reproduction; reviewed change; known regression link). No predecessor PR is attributed. Merge readinessKeep this PR open as the focused fix for the linked local-container heartbeat failure. The provider-neutral hook preserves core’s static validation while the local-container backend revalidates the exact runtime claim and persists lifecycle state with compare-and-swap semantics; no actionable patch defect was found. Priority: P2 Review scores
Verification
How this fits togetherCrabbox heartbeat refreshes retained leases directly through an SSH-capable provider when no coordinator owns the lease. Before updating expiry state, the provider must verify the exact local ownership claim and then return the refreshed lease state to the CLI. flowchart LR
A[Heartbeat command] --> B[Resolve retained lease]
B --> C[Read exact ownership claim]
C --> D{Static or runtime scope}
D -->|Static| E[Core validates scope and resource]
D -->|Runtime| F[Provider validates recorded runtime and container]
E --> G[Compare-and-swap lifecycle claim]
F --> G
G --> H[Refreshed lease state]
Before merge
Agent review detailsSecurityNone. Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Merge the narrow provider-owned authorization path so valid retained local-container leases can heartbeat while changed, missing, or replaced claims remain unable to mutate lifecycle state. Do we have a high-confidence way to reproduce the issue? Yes — current-main source compares the stored claim to a static provider scope, while the linked report supplies a concrete Docker reproduction using a dynamic local-container runtime scope. Is this the best way to solve the issue? Yes — a narrow provider-owned authorizer keeps core provider-neutral while preserving static-provider validation and requiring local-container to validate its runtime identity before mutation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against bb8370aa3bdf. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
Summary
Thanks @coygeek for the precise report and Docker reproduction.
Fixes #1367
Verification
gofmton changed Go filesgit diff --checkgo test -race -count=1 -timeout=4m ./internal/cli -run 'Test(StatusWaitRequestsReadyProbe|StatusLeaseExactClaimAuthorizerOwnsDynamicScopeValidation|HeartbeatDirectProviderUsesTouchForExactClaim|HeartbeatDirectProviderOmitsIdleTimeoutOverrideIntent|HeartbeatDirectProviderRejectsClaimlessLease)$'go test -race -count=1 -timeout=5m ./internal/providers/localcontainer -run 'Test(AuthorizeStatusTouchClaimHydratesDynamicRuntimeScope|LocalContainerTouchPersistsExactClaimLifecycle|LocalContainerTouchRejectsUnownedOrChangedClaimWithoutMutation)$'go test -race -count=1 -p 1 -timeout=12m ./internal/providers/localcontainergo test -race -count=1 -p 1 -timeout=6m ./internal/cli -run '^(TestHeartbeat|TestStatus)'go vet -p 2 ./...scripts/check-docs.shA repository-wide macOS
internal/clirace run was also attempted; unrelated browser-opener and listener-helper tests failed before the package later timed out. The complete heartbeat/status race slice and full local-container race suite above pass, and required CI will provide the isolated full-suite result.Live local-container proof
Provider:
local-containeron Docker-compatible OrbStack. Proof leasecbx_96f08273aabawas removed after verification.lastTouchedAt=2026-08-17T08:59:32Z,idleTimeout=11m0s, andexpiresAt=2026-08-17T09:10:32Zstopremoved the exact container, claim, per-lease SSH key directory, and bootstrap directoryclaims list --jsonreturned an empty claim setConfiguration and secrets
No new configuration, dependency, credential, or secret handling is introduced.