Skip to content

feat(run): cooperative cancel through the engine contract before the process kill - #130

Merged
Sannrox merged 1 commit into
mainfrom
feat/120
Nov 12, 2026
Merged

Sannrox merged 1 commit into
mainfrom
feat/120

Conversation

@Sannrox

@Sannrox Sannrox commented Nov 12, 2026

Copy link
Copy Markdown
Owner

Closes #120

On timeout or a job-source abort, the runner writes a scratch cancel file
and waits a grace window before killing the process group. Engines that
expose cooperative cancel (mizuchi CancelToken) stop, return limit: cancelled, and the run is a typed Failure::Cancelled with that report.
The kill path still fires when the engine ignores the file; the child is
gone within five seconds. Engines without a token stay on the kill path.

Cancelled local runs write failure.txt and a receipt whose
engine_version is the engine report, with empty outputs.

Reuse decision

Reuse the existing sandbox wait/kill, mizuchi CancelToken at the worker
edge, and Failure / receipt reporting. The engine-agnostic signal is a
scratch cancel file (not SIGTERM: that killed linux_native mizuchi
before it could report). JobSource still has no execute-time cancel
hook; the sandbox accepts an abort flag for when one exists. Kill after
grace stays Failure::Limit.

Lane

  • claim branch: feat/120
  • worktree: .worktrees/issue-120
  • base SHA: 5f8aa37e8f95d77adbd603558bdeb32b45103d91
  • published SHA: 482eeb7c46ef6c4d6abf67edd30720b29009d854
  • authority: land

Verification

  • cargo fmt --all -- --check
  • cargo clippy --locked --workspace --all-targets -- -D warnings
  • cargo clippy --locked -p kako-source-sekai --features sekai-client --all-targets -- -D warnings
  • cargo test --locked --workspace
  • cargo test --locked -p kako-source-sekai --features sekai-client
  • bash scripts/validate-workflow-skills.sh
  • python3 scripts/adr-index --check

Focused: cooperative cancel returns the engine report without kill;
ignored cancel kills within five seconds; source abort uses the same
path; mizuchi timeout is typed cancelled; cancelled receipt carries the
report; exclusive cancel-file create does not follow a symlink.

Skipped: kekkai-guest userspace payload tests (helper not on PATH).
validate-behavior: skipped; the MVP and sandbox tests observe the
receipt, failure.txt, and process lifetime.

Autoreview

AUTOREVIEW_CODEX_CONFIG=model_provider=cliproxyapi "$AUTOREVIEW" --mode local --engine codex

Clean: no accepted/actionable findings.

Simplify-change

Userspace spawn uses the same PID-aware wait/kill path as in-process
backends (no watcher around kekkai's blocking deadline helper). Capture
stays a 4 MiB head drain per stream. Receipt identity reuses
engine_version rather than a schema bump.

Compatibility

  • JobSource, receipt schema, and the kekkai pin are unchanged.
  • Default CPU when unset is 2 * wall_clock + cancel grace so RLIMIT_CPU
    does not kill a cooperative engine first.
  • Successful jobs that print limit: cancelled still complete; only a
    failed worker exit with that report is typed cancelled.

…process kill

On timeout or a job-source abort, write a scratch cancel file so engines
that expose a token can stop and return a typed cancelled failure. Kill
the process group if the child ignores the file past the grace window.
@Sannrox
Sannrox marked this pull request as ready for review November 12, 2026 05:19
@Sannrox
Sannrox merged commit 85232e9 into main Nov 12, 2026
5 of 6 checks passed
@Sannrox
Sannrox deleted the feat/120 branch November 12, 2026 05:42
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.

feat(run): cooperative cancel through the engine contract before the process kill

1 participant