Fix task runner liveness, workspace, and cancellation reliability#497
Fix task runner liveness, workspace, and cancellation reliability#497jugol wants to merge 5 commits into
Conversation
- Detect orphaned running jobs: status reads verify recorded PIDs and persist unexplained process exits as failed jobs - Document and validate the task --cwd/-C workspace override - Make cancellation shell-safe (taskkill via argument array, shell:false) and queue-safe (cancellation persisted before termination; late workers exit cleanly on cancelled or missing records) - Docs: default long rescue tasks to --background and require explicit --cwd All four defects were hit in real-world use of v1.0.6 on Windows 11. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f168a47c88
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Backslash now escapes only quotes, whitespace, or another backslash; any other sequence (e.g. C:\Users\me\repo) keeps its backslashes, so Windows --cwd paths survive raw-argument tokenization. Addresses the automated review finding on the --cwd guidance. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f1c04d889a
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Cancellation is still persisted before termination to keep the queued-worker race closed, but if termination fails and the process is verified alive, the job record is restored to its previous active state with a retry note so /codex:status shows the live job and /codex:cancel can be retried. A failed termination against an already-dead process still settles as cancelled.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7fc8eff531
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…backslash - task-resume-candidate now accepts --cwd/-C with the same validated resolution as task, and the rescue preflight guidance forwards the requested workspace so the continue/new-thread question is scoped to the right repo - In the raw-argument splitter, a backslash before a closing quote is treated as a literal path separator when the quote is followed by whitespace or end-of-input, so quoted Windows paths like "C:\Program Files\Repo\" tokenize correctly while embedded escaped quotes elsewhere keep their existing behavior
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c6159deab6
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
A backslash before a closing quote is inherently ambiguous between an
escaped quote ("say \"hello\" now") and a literal trailing path
separator ("C:\Program Files\Repo\"). Local lookahead cannot
distinguish them, so parse in two deterministic passes: pass 1 prefers
escaped quotes and is accepted when all quoted regions close; if it
ends with an open quote (the trailing-separator signature), pass 2
treats backslashes before the active closing quote as literal.
The whitespace/EOI lookahead special case is removed as subsumed.
Summary
This fixes four task-runner reliability issues encountered in real-world use of plugin v1.0.6 with codex-cli 0.144.1 on Windows 11.
Changes
Detect orphaned running jobs
When a background worker was killed externally (e.g., a caller's shell-tool timeout killing the process tree), its persisted job stayed
runningindefinitely — we observed a job reported as running for 45+ minutes after its process had died. Status reads now verify recorded PIDs, persist an unexplained process exit as a failed job (Process exited without reporting.), and make that effective state available to status and resume-candidate selection.Allow callers to pin the task workspace
Tasks launched from an unrelated caller directory could start Codex against the wrong workspace and waste the run (Codex correctly refuses to write outside its workspace root, so the whole task ends with no changes). The existing
--cwd/-Ctask parsing is now documented in help text and validates that the requested path is a directory before starting Codex.Make cancellation shell-safe and queue-safe
On Windows under Git Bash/MSYS, shell path conversion could rewrite
taskkill /PIDintotaskkill 'C:/Program Files/Git/PID'and prevent cancellation. Separately, cancelling a still-queued job removed its record, and when the queued worker later started it crashed within seconds.taskkillnow runs with an argument array andshell: false, cancellation is persisted before termination, and late workers exit cleanly for cancelled or missing records.Prefer durable background rescue tasks
Foreground rescue tasks could be killed when the calling shell tool reached its timeout, producing the orphaned-job condition above. The rescue command and agent guidance now default work expected to exceed a few minutes to task background mode and require an explicit workspace root.
Tests
npm test: 98/98 passed (full suite run in WSL; the repo's raw native-Windows run has pre-existing POSIX-path assumptions unrelated to this change)🤖 Generated with Claude Code