@llblab/pi-actors 0.26.1 → 0.26.2

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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.26.2: Terminal Progress Hotfix
6
+
7
+ - `[Async Runs]` Keep `progress.json` aligned with terminal kill/cancel handling by writing `phase=killed` or `phase=cancelled` and clearing active subagent counts when a run is stopped by runtime control.
8
+ - `[Inspector]` Prevent killed runs from showing contradictory `status=killed` with `progress.phase=running`, preserving compact operator status trust after `control.kill`.
9
+
5
10
  ## 0.26.1: Coordinator Empty-Synthesis Hotfix
6
11
 
7
12
  - `[Coordinator]` Treat all-failed participant rounds and empty synthesis as a failed coordinator run instead of a clean success, preserving operator trust when swarm branches all exit non-zero.
@@ -565,6 +565,10 @@ export function readRunStateIndex(stateRoot = DEFAULT_STATE_ROOT) {
565
565
  });
566
566
  if (valid.some((entry) => !existsSync(join(entry.state_dir, "run.json"))))
567
567
  return undefined;
568
+ const indexedDirs = new Set(valid.map((entry) => resolve(entry.state_dir)));
569
+ const stateDirs = listRunStateDirs(stateRoot).map((stateDir) => resolve(stateDir));
570
+ if (stateDirs.some((stateDir) => !indexedDirs.has(stateDir)))
571
+ return undefined;
568
572
  return valid;
569
573
  }
570
574
  export function listRuns(stateRoot = DEFAULT_STATE_ROOT, statusFilter) {
@@ -1010,6 +1014,20 @@ function markTerminalHandled(stateDir, details) {
1010
1014
  ts: new Date().toISOString(),
1011
1015
  });
1012
1016
  }
1017
+ function markTerminalProgress(stateDir, phase) {
1018
+ const existing = readJson(join(stateDir, "progress.json"));
1019
+ const progress = existing && typeof existing === "object" && !Array.isArray(existing)
1020
+ ? existing
1021
+ : {};
1022
+ const { activeSubagents: _activeSubagents, ...rest } = progress;
1023
+ writeJsonAtomic(join(stateDir, "progress.json"), {
1024
+ ...rest,
1025
+ completed: typeof progress.completed === "number" ? progress.completed : 0,
1026
+ failures: Array.isArray(progress.failures) ? progress.failures : [],
1027
+ phase,
1028
+ updatedAt: new Date().toISOString(),
1029
+ });
1030
+ }
1013
1031
  function stopRun(runOrDir, signal, event) {
1014
1032
  const status = getRunStatus(runOrDir);
1015
1033
  const pid = Number(status.pid || 0);
@@ -1024,6 +1042,10 @@ function stopRun(runOrDir, signal, event) {
1024
1042
  const signalResult = signalOwnedRunProcess(pid, signal);
1025
1043
  writeFileSync(join(stateDir, "events.jsonl"), `${JSON.stringify({ event, pid, signal, ...signalResult, ts: new Date().toISOString() })}\n`, { flag: "a" });
1026
1044
  markTerminalHandled(stateDir, { event, signal });
1045
+ if (event === "run.kill")
1046
+ markTerminalProgress(stateDir, "killed");
1047
+ if (event === "run.cancel")
1048
+ markTerminalProgress(stateDir, "cancelled");
1027
1049
  return { stopped: true, pid, signal, ...signalResult, state_dir: stateDir };
1028
1050
  }
1029
1051
  export function cancelRun(runOrDir) {
@@ -2,7 +2,7 @@
2
2
  name: actors
3
3
  description: Highest-density practical guide for pi-actors. Read this skill whenever prompt and tools are not enough for spawn, message, inspect, actor runs, tools, recipes, command templates, async lifecycle, mailboxes, artifacts, and local orchestration mechanics.
4
4
  metadata:
5
- version: 0.26.1
5
+ version: 0.26.2
6
6
  ---
7
7
 
8
8
  # Actors (pi-actors)
@@ -2,7 +2,7 @@
2
2
  name: swarm
3
3
  description: Subagent orchestration with scoped locks and quorum consensus. Use for multi-model review, parallel scoped work, delegated audit, and coordinated subagent execution.
4
4
  metadata:
5
- version: 0.26.1
5
+ version: 0.26.2
6
6
  ---
7
7
 
8
8
  # Swarm
package/lib/async-runs.ts CHANGED
@@ -805,6 +805,9 @@ export function readRunStateIndex(
805
805
  });
806
806
  if (valid.some((entry) => !existsSync(join(entry.state_dir, "run.json"))))
807
807
  return undefined;
808
+ const indexedDirs = new Set(valid.map((entry) => resolve(entry.state_dir)));
809
+ const stateDirs = listRunStateDirs(stateRoot).map((stateDir) => resolve(stateDir));
810
+ if (stateDirs.some((stateDir) => !indexedDirs.has(stateDir))) return undefined;
808
811
  return valid;
809
812
  }
810
813
 
@@ -1403,6 +1406,25 @@ function markTerminalHandled(
1403
1406
  });
1404
1407
  }
1405
1408
 
1409
+ function markTerminalProgress(
1410
+ stateDir: string,
1411
+ phase: "cancelled" | "killed",
1412
+ ): void {
1413
+ const existing = readJson(join(stateDir, "progress.json"));
1414
+ const progress =
1415
+ existing && typeof existing === "object" && !Array.isArray(existing)
1416
+ ? (existing as Record<string, unknown>)
1417
+ : {};
1418
+ const { activeSubagents: _activeSubagents, ...rest } = progress;
1419
+ writeJsonAtomic(join(stateDir, "progress.json"), {
1420
+ ...rest,
1421
+ completed: typeof progress.completed === "number" ? progress.completed : 0,
1422
+ failures: Array.isArray(progress.failures) ? progress.failures : [],
1423
+ phase,
1424
+ updatedAt: new Date().toISOString(),
1425
+ });
1426
+ }
1427
+
1406
1428
  function stopRun(
1407
1429
  runOrDir: string,
1408
1430
  signal: NodeJS.Signals,
@@ -1425,6 +1447,8 @@ function stopRun(
1425
1447
  { flag: "a" },
1426
1448
  );
1427
1449
  markTerminalHandled(stateDir, { event, signal });
1450
+ if (event === "run.kill") markTerminalProgress(stateDir, "killed");
1451
+ if (event === "run.cancel") markTerminalProgress(stateDir, "cancelled");
1428
1452
  return { stopped: true, pid, signal, ...signalResult, state_dir: stateDir };
1429
1453
  }
1430
1454
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@llblab/pi-actors",
3
- "version": "0.26.1",
3
+ "version": "0.26.2",
4
4
  "private": false,
5
5
  "description": "Local Actor Kernel for Pi",
6
6
  "keywords": [
@@ -2,7 +2,7 @@
2
2
  name: actors
3
3
  description: Highest-density practical guide for pi-actors. Read this skill whenever prompt and tools are not enough for spawn, message, inspect, actor runs, tools, recipes, command templates, async lifecycle, mailboxes, artifacts, and local orchestration mechanics.
4
4
  metadata:
5
- version: 0.26.1
5
+ version: 0.26.2
6
6
  ---
7
7
 
8
8
  # Actors (pi-actors)
@@ -2,7 +2,7 @@
2
2
  name: swarm
3
3
  description: Subagent orchestration with scoped locks and quorum consensus. Use for multi-model review, parallel scoped work, delegated audit, and coordinated subagent execution.
4
4
  metadata:
5
- version: 0.26.1
5
+ version: 0.26.2
6
6
  ---
7
7
 
8
8
  # Swarm