@tokenfactory/acc-runner 0.40.10 → 0.40.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Runner-side file-lock lifecycle helpers.
3
+ *
4
+ * Two seams the runner needs but that live outside task-runner.ts's single
5
+ * per-task try/finally:
6
+ *
7
+ * - releaseHeldLocks: the SIGINT/SIGTERM graceful-shutdown (watch.ts
8
+ * gracefulShutdown) cancels in-flight tasks and deregisters WITHOUT failing
9
+ * them, deliberately issuing no transition — it relies on the server
10
+ * zombie-recovery sweep to requeue + release. When that sweep is delayed or
11
+ * the process dies before it runs, the lock LEAKS (the incident). Calling
12
+ * this on shutdown frees every still-held lock immediately, so a requeued
13
+ * task never carries a stale lock into the queue. Idempotent + best-effort:
14
+ * acc.release_task_locks is a no-op on a missing lock and one task's failure
15
+ * never blocks the rest of shutdown.
16
+ *
17
+ * - readLiveAllowedGlobs: re-reads the task's CURRENT file scope from the live
18
+ * row so operator narrowing of a QUEUED task takes effect (AC4). The claim
19
+ * RPC already snapshots the live acc.tasks.allowed column FOR UPDATE at
20
+ * claim time; this helper exposes the same live read for pre-claim
21
+ * evaluation/telemetry and prefers the structured allowed_globs when set.
22
+ */
23
+ import type { RunnerSupabaseClient } from "../supabase.js";
24
+ /**
25
+ * Read a task's current file scope from the live row. Prefers the structured
26
+ * acc.tasks.allowed_globs; falls back to the human-facing allowed[] when the
27
+ * structured column is empty. Returns [] when neither is set.
28
+ */
29
+ export declare function readLiveAllowedGlobs(supabase: RunnerSupabaseClient, taskId: string): Promise<string[]>;
30
+ /**
31
+ * Release the file locks for every task id supplied — the graceful-shutdown
32
+ * deregister path. Best-effort and idempotent: logs and continues on a per-task
33
+ * failure, returns the ids actually released.
34
+ */
35
+ export declare function releaseHeldLocks(supabase: RunnerSupabaseClient, taskIds: Iterable<string>): Promise<string[]>;
36
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/locks/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAE3D;;;;GAIG;AACH,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,oBAAoB,EAC9B,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,MAAM,EAAE,CAAC,CAYnB;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,oBAAoB,EAC9B,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,GACxB,OAAO,CAAC,MAAM,EAAE,CAAC,CAanB"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Read a task's current file scope from the live row. Prefers the structured
3
+ * acc.tasks.allowed_globs; falls back to the human-facing allowed[] when the
4
+ * structured column is empty. Returns [] when neither is set.
5
+ */
6
+ export async function readLiveAllowedGlobs(supabase, taskId) {
7
+ const { data, error } = await supabase
8
+ .from("tasks")
9
+ .select("allowed, allowed_globs")
10
+ .eq("id", taskId)
11
+ .maybeSingle();
12
+ if (error) {
13
+ throw new Error(`readLiveAllowedGlobs(${taskId}): ${error.message}`);
14
+ }
15
+ const row = (data ?? {});
16
+ const globs = row.allowed_globs && row.allowed_globs.length > 0 ? row.allowed_globs : row.allowed;
17
+ return globs ?? [];
18
+ }
19
+ /**
20
+ * Release the file locks for every task id supplied — the graceful-shutdown
21
+ * deregister path. Best-effort and idempotent: logs and continues on a per-task
22
+ * failure, returns the ids actually released.
23
+ */
24
+ export async function releaseHeldLocks(supabase, taskIds) {
25
+ const released = [];
26
+ for (const taskId of taskIds) {
27
+ const { error } = await supabase.rpc("release_task_locks", { p_task_id: taskId });
28
+ if (error) {
29
+ process.stderr.write(`[acc-runner] release_task_locks(${taskId}) failed on shutdown: ${error.message}\n`);
30
+ continue;
31
+ }
32
+ released.push(taskId);
33
+ }
34
+ return released;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AC;QACD,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACxB,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tokenfactory/acc-runner",
3
- "version": "0.40.10",
3
+ "version": "0.40.11",
4
4
  "description": "Agent Control Center local runner. Spawns Claude Code sessions assigned via ACC.",
5
5
  "license": "UNLICENSED",
6
6
  "private": false,