From 49a6001dde72622df9410b738322e9a23e68ddee Mon Sep 17 00:00:00 2001 From: t Date: Fri, 21 Aug 2026 11:26:48 -0600 Subject: Add workflow cancellation controls --- subagents/jobs.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'subagents/jobs.lua') diff --git a/subagents/jobs.lua b/subagents/jobs.lua index 9fe5c93..dc166a7 100644 --- a/subagents/jobs.lua +++ b/subagents/jobs.lua @@ -280,6 +280,21 @@ function handle_mt:cancel() end end +-- Cancel one known handle and wake parked awaiters. `handle:cancel()` remains +-- the narrow primitive; workflow records use this helper because cancelling a +-- queued child settles it synchronously. +function M.cancel(handle) + if getmetatable(handle) ~= handle_mt then + error("jobs.cancel expects a job handle", 2) + end + if handle.settled ~= nil then + return false + end + handle:cancel() + wake() + return true +end + -- start(startspec) -> handle | nil, err -- -- startspec = { -- cgit v1.3