Skip to content

probing: add cancel command for stuck measurements#17

Merged
matthieugouel merged 2 commits into
mainfrom
feat/cancel-command
Jun 19, 2026
Merged

probing: add cancel command for stuck measurements#17
matthieugouel merged 2 commits into
mainfrom
feat/cancel-command

Conversation

@matthieugouel

Copy link
Copy Markdown
Member

Adds nxthdr probing cancel <id> to resolve a stuck/in-progress measurement — pairs with the gateway endpoint in saimiris-gateway#47 (POST /api/measurement/{id}/cancel). (roadmap nxthdr/roadmap#38)

Changes

  • probing cancel <id> → POSTs the cancel endpoint, reports cancelled / agents_cancelled (idempotent — a no-op with a message if already terminal).
  • Surfaces the new cancelled state everywhere: measurements (list) and measurement-status now show status cancelled (and per-agent cancelled), via a shared measurement_label(cancelled, complete) helper. New measurement_cancelled fields are #[serde(default)], so the CLI still works against a gateway that predates the cancel deploy.

Testing

cargo build + cargo clippy --all-targets clean. End-to-end test against prod once gateway #47 is deployed (cancel the real stuck cf78cc3d… measurement).

Order: merge + deploy gateway #47 before this lands, so cancel hits a gateway that has the endpoint.

🤖 Generated with Claude Code

`nxthdr probing cancel <id>` POSTs /api/measurement/{id}/cancel to resolve a stuck/in-progress measurement (e.g. an agent died mid-run). Also surfaces the new cancelled state: `measurements` and `measurement-status` now show status "cancelled" (and per-agent "cancelled") via a shared measurement_label helper.

Pairs with saimiris-gateway #47.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@matthieugouel

matthieugouel commented Jun 19, 2026

Copy link
Copy Markdown
Member Author

Claude finished @matthieugouel's task in 1m 32s —— View job


PR Review

  • Gather context and read changed files
  • Analyze diff for logic bugs, security issues, and CLAUDE.md violations
  • Post review findings

Two findings worth addressing before merge:

1. message field silently dropped in JSON/CSV mode

In cancel() (src/probing.rs:396-400), resp.message is only surfaced via output::success/output::info, which are text-only helpers. In -o json or -o csv mode the message is silently lost — a machine consumer only sees cancelled: false with no reason why.

CLAUDE.md says data must be routed through output.rs so -o json/-o csv keep working. Adding message to the kv block fixes this:

output::kv(&[
    ("id", id),
    ("cancelled", &resp.cancelled.to_string()),
    ("agents_cancelled", &resp.agents_cancelled.to_string()),
    ("message", &resp.message),   // ← add this
]);

Fix this →

2. Per-agent table header "complete" is now stale

In measurement_status() (src/probing.rs:371), the agent status column now renders three distinct values — "cancelled", "yes", or "no" — but the table header still says "complete":

output::table(&["agent", "probes sent/expected", "complete"], &rows);
//                                                ^^^^^^^^^^
// now shows "cancelled" / "yes" / "no" — header is misleading

This affects text, JSON, and CSV output (the header becomes a JSON key and a CSV column name). A header like "status" would be accurate across all three values.

Fix this →


The rest of the implementation looks solid: #[serde(default)] backward-compatibility on the new fields is correct, the measurement_label precedence (cancelled > complete > in-progress) is right, and cancel correctly uses new_saimiris(). No security issues.

- include the API 'message' in the kv block so it survives -o json/-o csv (was text-only).
- rename the per-agent table header 'complete' -> 'status' since the column now shows cancelled/yes/no (it's also the JSON key / CSV column).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@matthieugouel matthieugouel merged commit 6cea672 into main Jun 19, 2026
10 checks passed
@matthieugouel matthieugouel deleted the feat/cancel-command branch June 19, 2026 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant