testbox: approve only the warmup run that Blacksmith records for your box

Merged
LA
2mo ago
+89-33

An agent approved the deployment gate of a Testbox warmup run that another agent had dispatched (37097582012, cancelled, no harm). The approval step found "your" run by a set difference over the first page of waiting runs. That page has 30 runs by default, so a busy lane shows runs that look new but are not yours.

New: scripts/blacksmith-testbox-approve.sh <tbx> <dispatch-epoch>. The script takes the run id from Blacksmith's own record of the Testbox (the RUN URL in blacksmith testbox status --id). It then checks that run on GitHub: the warmup workflow, workflow_dispatch, ref main, status waiting, created no earlier than the dispatch, and a triggering actor that is the caller or Blacksmith's app. On any mismatch the script approves nothing and exits 3. scripts/blacksmith-testbox-demo.sh uses it. The hq skill text changes in a separate hq PR.

Verification:

  • bash -n passes on both scripts.
  • Refusal paths ran live: a stopped box gave run 37069938011 is completed, not waiting at the gate (exit 3); an unknown box gave shows no run URL (exit 3). Neither approved anything.
  • The success path was not run, because that needs a fresh warmup.

Changelog

none

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Summary by cubic

Fixes Testbox warmup approval so it approves only the run that Blacksmith recorded for your box, never one picked from the shared list of waiting runs.

  • The old script found "your" run by set difference over the first page (30 runs) of waiting runs, which can include another agent's run on a busy lane and led to approving the wrong box's run.
  • scripts/blacksmith-testbox-approve.sh <tbx> <dispatch-epoch> takes the run id from Blacksmith's own record of the box and validates it on GitHub (warmup workflow, event, ref main, status waiting, creation time, triggering actor) before approving.
  • scripts/blacksmith-testbox-demo.sh now uses the new script.
  • On any mismatch the script approves nothing and exits 3.

Summary by CodeRabbit

  • Improvements
    • Automatic approval now checks that a pending deployment belongs to the specified Testbox warmup run before approving it.
    • Approval is limited to eligible runs on the expected workflow and branch, with checks for run status, timing, and actor where available.
    • If automatic approval fails or times out, the demo directs you to approve the run shown in Testbox status.