Skip to content

feat(kanban): add POST /runs/{run_id}/terminate endpoint (salvage #31097)#34449

Merged
teknium1 merged 2 commits into
mainfrom
salvage/kanban-terminate-31097
May 29, 2026
Merged

feat(kanban): add POST /runs/{run_id}/terminate endpoint (salvage #31097)#34449
teknium1 merged 2 commits into
mainfrom
salvage/kanban-terminate-31097

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

Salvages PR #31097 onto current main. Adds POST /api/plugins/kanban/runs/{run_id}/terminate to the Kanban dashboard plugin API — a clean operator stop primitive for live, well-behaved workers. Closes the termination-control gap left by PR #28432 (which shipped the read-only sibling endpoints /workers/active, /runs/{run_id}, /runs/{run_id}/inspect but no stop control).

Pure HTTP wrapper around the existing kanban_db.reclaim_task() flow — no new termination semantics introduced, so the SIGTERM→SIGKILL escalation, run-outcome bookkeeping, and event-log append all match POST /tasks/{task_id}/reclaim exactly.

Changes

  • plugins/kanban/dashboard/plugin_api.py: new POST /runs/{run_id}/terminate endpoint (~50 LOC, sits next to the existing inspect_run_endpoint)
  • tests/plugins/test_kanban_worker_runs.py: 5 new test cases (happy path, 404 unknown id, 409 already ended, 409 task not reclaimable, empty-body accepted)
  • scripts/release.py: AUTHOR_MAP entry for @Interstellar-code

Behavior

Status Condition
200 {ok, run_id, task_id} Worker terminated, task reset to ready
404 Unknown run_id
409 Run already ended_at, or task no longer in a reclaimable state

Auth follows the existing dashboard session-token middleware — same exposure surface as the sibling /runs/* endpoints.

Validation

Result
tests/plugins/test_kanban_worker_runs.py (16 tests, 5 new) 16/16 pass
Cherry-picked clean from PR #31097 commit 0b07d86b4
Files exist on current main (plugin_api.py @ inspect_run_endpoint line 1246)
reclaim_task / get_run signatures match

Closes #23762. Credit @Interstellar-code — original PR was clean, just needed cherry-pick onto current main + AUTHOR_MAP entry.

Infographic

kanban-terminate-endpoint

Interstellar-code and others added 2 commits May 29, 2026 00:13
Closes the termination-control gap left by PR #28432, which shipped the
read-only sibling endpoints (/workers/active, /runs/{run_id},
/runs/{run_id}/inspect) but no way to stop a misbehaving worker from
the dashboard without dropping to the CLI.

The new endpoint resolves run_id -> task_id and delegates to the
existing kanban_db.reclaim_task() flow, so the SIGTERM->SIGKILL
escalation, run-outcome bookkeeping, and event-log append all match
POST /tasks/{task_id}/reclaim exactly. No new termination semantics
introduced.

Responses:
  200 {ok, run_id, task_id} on success
  404 unknown run_id
  409 run already ended OR task no longer reclaimable

Refs: #23762
@github-actions

Copy link
Copy Markdown
Contributor

🔎 Lint report: salvage/kanban-terminate-31097 vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 9425 on HEAD, 9425 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 4891 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

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.

Public termination endpoint for kanban runs (POST /runs/{run_id}/terminate)

2 participants