@juicesharp/rpiv-workflow 2.15.0 → 2.16.0

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/events.ts CHANGED
@@ -70,10 +70,25 @@ export type StageRef =
70
70
  * `kind: "verify"` is a verify-bearing stage (a desugared attempt→verify
71
71
  * loop) — verified stages follow loop semantics: observe units, not
72
72
  * `onStageEnd`.
73
+ *
74
+ * `settled` is present only on a RESUMED fanout re-announce: the slots the
75
+ * fold already filled from the trail (`failed` = a collected soft-halt
76
+ * sentinel). Those units are replayed, never re-dispatched, so they fire no
77
+ * `onUnitStart`/`onUnitEnd` — a listener tracking per-unit state reads their
78
+ * terminal status here instead. Absent on a live entry (nothing is settled).
73
79
  */
74
80
  export interface LoopStartInfo {
75
81
  kind: "fanout" | "iterate" | "assess" | "verify";
76
82
  units?: readonly Unit[];
83
+ settled?: readonly SettledUnit[];
84
+ }
85
+
86
+ /** One already-filled fanout slot on a resume re-announce (see `LoopStartInfo.settled`). */
87
+ export interface SettledUnit {
88
+ /** Declared unit index — the same key `onUnitStart`'s `unit.index` uses. */
89
+ index: number;
90
+ /** The slot holds a collected soft-halt sentinel, not a real output. */
91
+ failed: boolean;
77
92
  }
78
93
 
79
94
  /**
package/loop.ts CHANGED
@@ -38,7 +38,7 @@
38
38
 
39
39
  import type { AssessLoop, LoopDef } from "./api.ts";
40
40
  import { applyCompletedStage } from "./chain-state.ts";
41
- import { lifecycleCtxFor, skillStageRef } from "./events.ts";
41
+ import { lifecycleCtxFor, type SettledUnit, skillStageRef } from "./events.ts";
42
42
  import { nowIso } from "./internal-utils.ts";
43
43
  import { type AnyJudge, isPanel, type PanelJudge } from "./judge.ts";
44
44
  import { panelVerdictChannel, panelVerdictDef } from "./loop-constructors.ts";
@@ -58,6 +58,7 @@ import {
58
58
  } from "./loop-kinds.ts";
59
59
  import { runFanoutGeneration } from "./loop-parallel.ts";
60
60
  import { MSG_LOOP_CAP_ADVANCE, MSG_LOOP_ZERO_UNITS } from "./messages.ts";
61
+ import { isFailedOutput } from "./output.ts";
61
62
  import { appendLoopCap } from "./state/index.ts";
62
63
  import type { RunContext, WorkflowHostContext } from "./types.ts";
63
64
 
@@ -72,6 +73,7 @@ export async function announceLoopStart(
72
73
  hostCtx: WorkflowHostContext,
73
74
  run: RunContext,
74
75
  e: Pick<LoopEntry, "stageIdx" | "name" | "skill" | "def" | "loop" | "units">,
76
+ settled?: readonly SettledUnit[],
75
77
  ): Promise<void> {
76
78
  const ref = skillStageRef(e.name, e.stageIdx + 1, e.skill);
77
79
  await run.lifecycle.fire(hostCtx, "onStageStart", ref, lifecycleCtxFor(run));
@@ -79,7 +81,11 @@ export async function announceLoopStart(
79
81
  hostCtx,
80
82
  "onLoopStart",
81
83
  ref,
82
- { kind: presentedKindOf(e.def, e.loop), ...(e.units ? { units: e.units } : {}) },
84
+ {
85
+ kind: presentedKindOf(e.def, e.loop),
86
+ ...(e.units ? { units: e.units } : {}),
87
+ ...(settled?.length ? { settled } : {}),
88
+ },
83
89
  lifecycleCtxFor(run),
84
90
  );
85
91
  }
@@ -157,6 +163,18 @@ export function pendingFanoutIndices(cursor: LoopCursor, total: number): number[
157
163
  return out;
158
164
  }
159
165
 
166
+ /** The complement of `pendingFanoutIndices` — slots the fold already filled, with
167
+ * whether each holds a collected soft-halt sentinel. Carried on the resume
168
+ * re-announce so listeners can show replayed units terminal (they fire no unit events). */
169
+ export function settledFanoutSlots(cursor: LoopCursor, total: number): SettledUnit[] {
170
+ const out: SettledUnit[] = [];
171
+ for (let i = 0; i < total; i++) {
172
+ const slot = cursor.slots?.[i];
173
+ if (slot !== undefined) out.push({ index: i, failed: isFailedOutput(slot) });
174
+ }
175
+ return out;
176
+ }
177
+
160
178
  /** Resume re-dispatch — thin wrapper over `runFanoutGeneration`. Runs the still-pending
161
179
  * fanout units, each gated on its own deps, folding each at its declared index (so
162
180
  * completed slots keep their position), and always finishes (the live run already
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juicesharp/rpiv-workflow",
3
- "version": "2.15.0",
3
+ "version": "2.16.0",
4
4
  "description": "Pi extension. Chain skills into typed multi-stage workflows with audited JSONL state, predicate routing, and per-stage output validation. Skill-agnostic — bring your own skills.",
5
5
  "keywords": [
6
6
  "pi-package",
@@ -112,7 +112,7 @@
112
112
  ]
113
113
  },
114
114
  "dependencies": {
115
- "@juicesharp/rpiv-config": "^2.15.0",
115
+ "@juicesharp/rpiv-config": "^2.16.0",
116
116
  "jiti": "^2.7.0"
117
117
  },
118
118
  "peerDependencies": {
package/registration.ts CHANGED
@@ -73,6 +73,7 @@ export {
73
73
  type LoopCapInfo,
74
74
  type LoopStartInfo,
75
75
  registerLifecycle,
76
+ type SettledUnit,
76
77
  type StageRef,
77
78
  type UnitEvent,
78
79
  } from "./events.ts";
@@ -19,7 +19,7 @@
19
19
 
20
20
  import { auditCtxFor, failedArgs, recordFatalFailure } from "../audit.ts";
21
21
  import { resolveSkill } from "../chain-state.ts";
22
- import { announceLoopStart, pendingFanoutIndices, runFanoutResume, runLoop } from "../loop.ts";
22
+ import { announceLoopStart, pendingFanoutIndices, runFanoutResume, runLoop, settledFanoutSlots } from "../loop.ts";
23
23
  import { effectiveLoopOf, freezesEntryArgsOf } from "../loop-constructors.ts";
24
24
  import { buildLoopEntry, type LoopDeps, sequentialStrategyOf } from "../loop-kinds.ts";
25
25
  import { ensureUnitDeps } from "../loop-waves.ts";
@@ -75,7 +75,8 @@ export async function resumeLoopStage(
75
75
  // otherwise reach the dispatcher. guardResumeEntry catches this throw → clean failure.
76
76
  ensureUnitDeps(point.units!, point.parent);
77
77
  const pending = pendingFanoutIndices(point.cursor, point.units!.length); // slots === undefined
78
- if (pending.length > 0) await announceLoopStart(ctx, run, entry);
78
+ if (pending.length > 0)
79
+ await announceLoopStart(ctx, run, entry, settledFanoutSlots(point.cursor, point.units!.length));
79
80
  await runFanoutResume(ctx, entry, point.cursor, run, deps, pending);
80
81
  return;
81
82
  }