Skip to content

fix(heartbeat): reject ambiguous identifiers - #1379

Merged
steipete merged 2 commits into
mainfrom
steipete/fix-1368-heartbeat-args
Aug 17, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/fix-1368-heartbeat-args

Conversation

@steipete

@steipete steipete commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • reject heartbeat --id <lease> <extra> and other ambiguous identifier forms before loading configuration or resolving a provider
  • preserve the supported single positional-ID and --id-only forms
  • prove invalid syntax causes zero coordinator, backend, resolve, touch, or claim mutations

Closes #1368

Verification

  • focused heartbeat/status/claim race tests
  • loopback coordinator and fake backend zero-side-effect regression matrix
  • built-CLI source-blind argument proof
  • go vet ./..., docs validation, gofmt, and git diff --check
  • P1 autoreview clean

Built-CLI behavior proof

Source-blind proof was run from exact head 0c5efc2123221729fbf403ad3023a3f99b4e3f4e. The temporary binary was built with go build -trimpath -o "$PROOF_DIR/crabbox" ./cmd/crabbox and had SHA-256 509b3d096a0da3072d2dd5062ea79aa51b4a537afcb7ce6f2ce991419490d22f.

Each invocation used a new private temporary HOME/XDG tree plus deliberately invalid YAML, with the inherited environment removed:

printf '%s\n' 'provider: [' > "$PROOF_DIR/invalid.yaml"
env -i \
  PATH="/usr/bin:/bin:/usr/sbin:/sbin:/opt/homebrew/bin" \
  HOME="$PROOF_DIR/home" \
  XDG_CONFIG_HOME="$PROOF_DIR/home/config" \
  XDG_STATE_HOME="$PROOF_DIR/home/state" \
  XDG_CACHE_HOME="$PROOF_DIR/home/cache" \
  CRABBOX_CONFIG="$PROOF_DIR/invalid.yaml" \
  CRABBOX_COORDINATOR="http://127.0.0.1:1" \
  LC_ALL=C \
  "$PROOF_DIR/crabbox" heartbeat <case arguments>

Inspected, path-redacted transcript:

--id lease-a extra                 exit=2  usage: crabbox heartbeat --id <lease-id-or-slug> [--provider <provider>] [--idle-timeout <duration>] [--json]
--id lease-a --id lease-b          exit=2  usage: crabbox heartbeat --id <lease-id-or-slug> [--provider <provider>] [--idle-timeout <duration>] [--json]
--id=lease-a --id=lease-b          exit=2  usage: crabbox heartbeat --id <lease-id-or-slug> [--provider <provider>] [--idle-timeout <duration>] [--json]
lease-a lease-b                     exit=2  usage: crabbox heartbeat --id <lease-id-or-slug> [--provider <provider>] [--idle-timeout <duration>] [--json]
<no identifier>                    exit=2  usage: crabbox heartbeat --id <lease-id-or-slug> [--provider <provider>] [--idle-timeout <duration>] [--json]
--id ''                             exit=2  usage: crabbox heartbeat --id <lease-id-or-slug> [--provider <provider>] [--idle-timeout <duration>] [--json]
--id lease-a                        exit=2  parse config $PROOF_DIR/invalid.yaml: yaml: line 1: did not find expected node content

All six malformed identifier forms returned the same usage error without exposing the invalid-config diagnostic. The valid single-ID control crossed the syntax boundary and failed on that deliberately invalid configuration, proving malformed input is rejected first.

Maintainer disposition

The P3 suggestion to remove the Unreleased changelog entry is intentionally rejected. Repository standing policy requires changelog coverage for user-visible fixes, so the existing credited entry remains.

@clawsweeper

clawsweeper Bot commented Aug 17, 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 17, 2026
@clawsweeper

clawsweeper Bot commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 17, 2026, 6:07 AM ET / 10:07 UTC.

ClawSweeper review

What this changes

The PR makes crabbox heartbeat reject duplicate, empty, or combined positional and --id lease identifiers before configuration or provider handling.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

This PR remains necessary: current main still accepts the reported ambiguous form, while the branch rejects it before configuration or lease handling. Direct review found no actionable patch defect; the supplied built-CLI transcript is sufficient real-behavior proof.

Priority: P2
Reviewed head: 0c5efc2123221729fbf403ad3023a3f99b4e3f4e

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused implementation with strong regression coverage and credible exact-head CLI proof is ready for normal merge gating.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The exact-head, source-blind built-CLI transcript directly shows malformed forms stopping at usage before deliberately invalid configuration is parsed, with a valid control crossing that boundary.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The exact-head, source-blind built-CLI transcript directly shows malformed forms stopping at usage before deliberately invalid configuration is parsed, with a valid control crossing that boundary.
Evidence reviewed 6 items Current-main gap: The base implementation stores one --id, fills it from a positional argument only when empty, and rejects only more than one positional argument; therefore an explicit identifier plus one positional value can pass validation.
Narrow validation repair: The branch counts --id occurrences and rejects blank IDs, repeated flags, multiple positional values, and the mixed flag-plus-positional form before loadLeaseTargetConfig runs.
Regression coverage: The table-driven test covers both supported identifier forms plus repeated --id, mixed forms, multiple positionals, and a missing identifier; rejected cases assert no backend configuration, resolution, touch, coordinator request, or claim-state mutation.
Findings None None.
Security None None.

How this fits together

The heartbeat CLI command accepts one lease identifier, resolves its configuration and provider, then refreshes lease liveness. The changed validation boundary prevents malformed commands from reaching those downstream operations.

flowchart LR
  A[CLI arguments] --> B[Heartbeat command]
  B --> C[Identifier validation]
  C -->|one valid identifier| D[Configuration and provider resolution]
  C -->|missing or ambiguous| E[Usage error]
  D --> F[Coordinator or provider heartbeat]
  F --> G[Updated lease state]
Loading

Before merge

  • Complete next step (P2) - No repair-lane work is needed: direct review found no actionable defect, and the contributor supplied sufficient real behavior proof; normal merge checks can gate the exact head.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Focused change surface 4 files: CLI +9/-2, tests +99/-2, docs/release text +5/-1 The production behavior change is small and paired with a broader zero-side-effect regression matrix.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #1368
Summary: This PR is the focused candidate fix for the reported heartbeat identifier-validation defect.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Land this narrow validation and regression-test change once the normal required checks finish, preserving one unambiguous heartbeat lease identifier.

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

Yes—source inspection of current main proves that one positional argument can remain after an explicit --id, and the PR supplies a built-CLI before/after boundary transcript.

Is this the best way to solve the issue?

Yes—the repair follows existing command validation conventions, rejects ambiguity before configuration loading, and keeps both documented single-identifier forms.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The exact-head, source-blind built-CLI transcript directly shows malformed forms stopping at usage before deliberately invalid configuration is parsed, with a valid control crossing that boundary.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The exact-head, source-blind built-CLI transcript directly shows malformed forms stopping at usage before deliberately invalid configuration is parsed, with a valid control crossing that boundary.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This is a bounded CLI validation bug that can let malformed heartbeat commands proceed into lease handling.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The exact-head, source-blind built-CLI transcript directly shows malformed forms stopping at usage before deliberately invalid configuration is parsed, with a valid control crossing that boundary.
  • proof: sufficient: Contributor real behavior proof is sufficient. The exact-head, source-blind built-CLI transcript directly shows malformed forms stopping at usage before deliberately invalid configuration is parsed, with a valid control crossing that boundary.

Evidence

What I checked:

  • Current-main gap: The base implementation stores one --id, fills it from a positional argument only when empty, and rejects only more than one positional argument; therefore an explicit identifier plus one positional value can pass validation. (internal/cli/heartbeat.go:32, 055dde3111b1)
  • Narrow validation repair: The branch counts --id occurrences and rejects blank IDs, repeated flags, multiple positional values, and the mixed flag-plus-positional form before loadLeaseTargetConfig runs. (internal/cli/heartbeat.go:32, 0c5efc212322)
  • Regression coverage: The table-driven test covers both supported identifier forms plus repeated --id, mixed forms, multiple positionals, and a missing identifier; rejected cases assert no backend configuration, resolution, touch, coordinator request, or claim-state mutation. (internal/cli/heartbeat_test.go:20, 0c5efc212322)
  • Real CLI proof: The PR body records a source-blind binary run at the exact head: six malformed forms exit 2 with usage despite deliberately invalid configuration, while the valid control reaches configuration parsing. (0c5efc212322)
  • Feature-history provenance: Current main’s immediately preceding heartbeat work is commit 055dde3 by Peter Steinberger; the proposed two commits continue that same command surface. (internal/cli/heartbeat.go:24, 055dde3111b1)
  • Supplemental review limitation: The repository’s structured autoreview helper could not run locally because TruffleHog is unavailable; direct source, test, diff, history, and supplied proof inspection were completed instead. (bfc2a2e2f56e)

Likely related people:

  • steipete: Authored the current-main heartbeat lifecycle change and both commits in this focused follow-up. (role: recent heartbeat-area contributor; confidence: high; commits: 055dde3111b1, bfc2a2e2f56e, 0c5efc212322; files: internal/cli/heartbeat.go, internal/cli/heartbeat_test.go)
  • coygeek: Is credited as co-author on the proposed repair and on the immediately preceding current-main heartbeat lifecycle work. (role: recent heartbeat contributor; confidence: medium; commits: 055dde3111b1, bfc2a2e2f56e; files: internal/cli/heartbeat.go, internal/cli/heartbeat_test.go)

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 (3 earlier review cycles)
  • reviewed 2026-08-17T04:44:03.105Z sha 5afcb16 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-17T09:39:11.352Z sha 0028b5c :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-17T09:49:30.302Z sha 0c5efc2 :: needs real behavior proof before merge. :: [P3] Remove the release-owned changelog entry

@steipete
steipete force-pushed the steipete/fix-1368-heartbeat-args branch from 5afcb16 to 0028b5c Compare August 17, 2026 08:53
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 17, 2026
@steipete
steipete force-pushed the steipete/fix-1368-heartbeat-args branch from 0028b5c to 0c5efc2 Compare August 17, 2026 09:44
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 17, 2026
@steipete
steipete merged commit 808764a into main Aug 17, 2026
26 checks passed
@steipete
steipete deleted the steipete/fix-1368-heartbeat-args branch August 17, 2026 10:09
steipete added a commit to openclaw/clawsweeper that referenced this pull request Aug 17, 2026
…nal driver (#1186)

The first production terminal recording (openclaw/crabbox#1379, run
32017763576) failed because ffmpeg launched against the xvfb display
before it accepted connections and died silently inside its detached
tmux session. The driver now polls xdpyinfo for display readiness,
waits for the recorder output to exist and grow, waits for the recorder
to exit after finalize, and attaches capture-pane diagnostics from all
three sessions to any failure. Also registers the batch-publish dispatch
lane's setup-state site in the state-writer audits, which were red on
main since #1185.
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. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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.

fix(heartbeat): reject an extra positional argument with --id

1 participant