Go to file
Paul Trowbridge 4f83e8d991 feat: cancel an in-flight module run
Adds run cancellation, which had no implementation despite `cancelled`
being a declared run status.

Mechanism: API/web/scheduler runs execute as background tasks in the
service process, so `running_pid`'s PID is the service itself — killing it
is not an option. Instead, engine/cancel.py keeps an in-process registry of
run_id -> live jrunner Popen. The cancel handler (same process) terminates
that subprocess; migrate then fails and the engine records the run as
`cancelled` (not `error`) and releases the lock in its finally. Checkpoints
before migrate and before merge honor a cancel flag set between phases.

- engine/cancel.py: registry (arm/register/unregister/is_cancelled/request_cancel) + RunCancelled
- jrunner.migrate: optional proc_hook to expose the live Popen (no engine dependency)
- runner: arm, register via proc_hook, two checkpoints, classify cancelled, unregister
- POST /api/modules/{id}/cancel (extracts run_id from the lock) and POST /runs/{id}/cancel (web)
- cancel button on run detail + live fragment, shown while running
- api/app lifespan: clear stale locks (dead PID / >24h) at startup via the existing
  repo.clear_stale_locks, so a hard service kill no longer wedges `running=1`

Verified: real subprocess terminate -> status=cancelled, lock released;
endpoints return 409 (not running) / 404 (unknown) / 200 (fragment).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-10 04:06:24 -04:00
.archive/pre-rewrite Initial commit: Pipekit rewrite. 2026-04-22 00:38:26 -04:00
bin bin/pipekit auto-detects venv; stop rewriting it in deploy.sh. 2026-04-23 00:34:32 -04:00
pipekit feat: cancel an in-flight module run 2026-07-10 04:06:24 -04:00
systemd Add scheduling, harden deploy, and update docs 2026-06-03 21:18:13 -04:00
.gitignore drivers: make staging DDL dialect-aware; stop tracking pipekit.db 2026-06-10 23:33:36 -04:00
CLAUDE.md jrunner: use bulk copy (-b) for Postgres dests too (COPY) 2026-06-18 23:14:15 -04:00
config.yaml web: add session-cookie login for web UI 2026-06-04 13:21:50 -04:00
deploy.sh deploy/cli: fix /etc/pipekit permissions so non-root group members can write secrets 2026-06-04 13:35:06 -04:00
requirements.txt web: add session-cookie login for web UI 2026-06-04 13:21:50 -04:00
SPEC.md Add scheduling, harden deploy, and update docs 2026-06-03 21:18:13 -04:00