@juicesharp/rpiv-pi 2.14.2 → 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.
|
@@ -2,11 +2,9 @@
|
|
|
2
2
|
* lane-progress — bridges rpiv-workflow's lifecycle bus into the run-lane
|
|
3
3
|
* registry so the ambient overlay shows LIVE stage progress.
|
|
4
4
|
*
|
|
5
|
-
* The
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* rpiv-pi widget" marking stage progress by runId. So this bridge is a cheap,
|
|
9
|
-
* clean-install-safe increment — no host plumbing.
|
|
5
|
+
* The report path is rpiv-workflow's public `registerLifecycle` bus, which
|
|
6
|
+
* carries every stage/loop/unit event keyed by runId — so the bridge needs no
|
|
7
|
+
* runner→host plumbing and stays clean-install-safe.
|
|
10
8
|
*
|
|
11
9
|
* Each lifecycle event maps to `setLaneProgress(ctx.runId, …)`:
|
|
12
10
|
* - onStageStart → clear the prior stage's fan-out unit sub-rows (every stage kind; it fires
|
|
@@ -39,11 +37,10 @@ import { shortFailureReason } from "./lane-failure.ts";
|
|
|
39
37
|
import { isLaneRelayUiContext } from "./lane-relay-ui.ts";
|
|
40
38
|
import {
|
|
41
39
|
clearUnitLanes,
|
|
42
|
-
foldStageUsage,
|
|
43
40
|
getLane,
|
|
44
41
|
markUnitDone,
|
|
45
42
|
retireRun,
|
|
46
|
-
|
|
43
|
+
seedUnits,
|
|
47
44
|
setLaneProgress,
|
|
48
45
|
setRecap,
|
|
49
46
|
setUnitStarted,
|
|
@@ -99,6 +96,12 @@ const fanoutRuns = new Set<string>();
|
|
|
99
96
|
*/
|
|
100
97
|
const activeInstances = new Map<string, object>();
|
|
101
98
|
|
|
99
|
+
/** A seeded unit's status from its `info.settled` entry: undefined (not replayed) → pending. */
|
|
100
|
+
function replayedStatus(failed: boolean | undefined): "pending" | "done" | "failed" {
|
|
101
|
+
if (failed === undefined) return "pending";
|
|
102
|
+
return failed ? "failed" : "done";
|
|
103
|
+
}
|
|
104
|
+
|
|
102
105
|
/**
|
|
103
106
|
* Wire the lifecycle→registry bridge to the ROOT launcher's session_start.
|
|
104
107
|
* Skipped for a detached foreground child (branded relay ui) and any non-UI
|
|
@@ -141,21 +144,19 @@ export async function registerLaneProgress(): Promise<void> {
|
|
|
141
144
|
activeInstances.set(ctx.runId, ctx.state);
|
|
142
145
|
},
|
|
143
146
|
// onStageStart fires for EVERY stage kind — a plain sequential stage (the single-stage
|
|
144
|
-
// entry announcement
|
|
145
|
-
//
|
|
146
|
-
//
|
|
147
|
-
// stage
|
|
148
|
-
// loop's onLoopStart only drops the gate, it never cleared the prior generation).
|
|
147
|
+
// entry announcement) AND every loop stage, where it fires BEFORE onLoopStart
|
|
148
|
+
// (`announceLoopStart`). So the prior stage's fan-out unit sub-rows retire HERE, which
|
|
149
|
+
// covers both follow-ups that have no fanout onLoopStart to clear them: a plain
|
|
150
|
+
// sequential stage, and a non-fanout loop (whose onLoopStart only drops the gate).
|
|
149
151
|
// clearUnitLanes is a no-op on an empty map, so the first stage of a run pays nothing.
|
|
150
152
|
onStageStart: (stage, ctx) => {
|
|
151
|
-
foldStageUsage(ctx.runId);
|
|
152
153
|
clearUnitLanes(ctx.runId);
|
|
153
154
|
setLaneProgress(ctx.runId, { stageName: stage.name, phase: "running" });
|
|
154
155
|
},
|
|
155
156
|
onStageRetry: (stage, attempt, ctx) =>
|
|
156
157
|
setLaneProgress(ctx.runId, { stageName: stage.name, phase: "retry", attempt }),
|
|
157
158
|
// Carry the stage's failure cause so the dock row can surface WHY
|
|
158
|
-
// it failed before the run retires
|
|
159
|
+
// it failed before the run retires.
|
|
159
160
|
onStageError: (stage, error, ctx) => {
|
|
160
161
|
// Orphan sweep (the asymmetric onUnitStart…onUnitEnd bracket): a fail-fast
|
|
161
162
|
// halt fired onUnitStart for the halting unit (+ in-flight siblings) with no
|
|
@@ -170,19 +171,22 @@ export async function registerLaneProgress(): Promise<void> {
|
|
|
170
171
|
// generation. A non-fan-out loop (iterate/assess/verify) drops the gate so its
|
|
171
172
|
// sequential units never materialize sub-rows.
|
|
172
173
|
if (info.kind === "fanout") {
|
|
173
|
-
foldStageUsage(ctx.runId);
|
|
174
174
|
clearUnitLanes(ctx.runId);
|
|
175
175
|
fanoutRuns.add(ctx.runId);
|
|
176
|
-
// Fan out the generation's unit sub-rows
|
|
177
|
-
//
|
|
176
|
+
// Fan out the generation's unit sub-rows the instant onLoopStart fires — BEFORE
|
|
177
|
+
// any onUnitStart. Fanout precomputes its unit list; pull loops
|
|
178
178
|
// (iterate/assess/verify) carry none, so they seed nothing (the guard mirrors
|
|
179
179
|
// the `units: info.units ?` seed below). The key is the declared array position,
|
|
180
|
-
// which matches onUnitStart's unit.index
|
|
181
|
-
|
|
182
|
-
|
|
180
|
+
// which matches onUnitStart's unit.index. A resumed
|
|
181
|
+
// generation's replayed units (`info.settled`) fire no unit events, so they are
|
|
182
|
+
// seeded terminal; every other unit starts pending.
|
|
183
|
+
if (info.units) {
|
|
184
|
+
const replayed = new Map((info.settled ?? []).map((s) => [s.index, s.failed]));
|
|
185
|
+
seedUnits(
|
|
183
186
|
ctx.runId,
|
|
184
|
-
info.units.map((u, i) => ({ index: i, label: u.label })),
|
|
187
|
+
info.units.map((u, i) => ({ index: i, label: u.label, status: replayedStatus(replayed.get(i)) })),
|
|
185
188
|
);
|
|
189
|
+
}
|
|
186
190
|
} else {
|
|
187
191
|
fanoutRuns.delete(ctx.runId);
|
|
188
192
|
}
|
|
@@ -190,8 +194,9 @@ export async function registerLaneProgress(): Promise<void> {
|
|
|
190
194
|
stageName: stage.name,
|
|
191
195
|
phase: "running",
|
|
192
196
|
// Fanout precomputes its unit list; pull loops (iterate/assess) discover
|
|
193
|
-
// units one at a time, so seed total only when the list is known.
|
|
194
|
-
|
|
197
|
+
// units one at a time, so seed total only when the list is known. `done` starts
|
|
198
|
+
// at the replayed count — those units are already complete.
|
|
199
|
+
units: info.units ? { done: info.settled?.length ?? 0, total: info.units.length } : undefined,
|
|
195
200
|
});
|
|
196
201
|
},
|
|
197
202
|
// Materialize a per-unit
|
|
@@ -223,8 +228,8 @@ export async function registerLaneProgress(): Promise<void> {
|
|
|
223
228
|
// seeds `units: undefined` for them, so `units` stays undefined here and the
|
|
224
229
|
// dock omits the `· units x/y` segment (fanout-only sub-progress). The
|
|
225
230
|
// `prev?.total ?? unit.index + 1` seed is thus unreachable on the pull-loop
|
|
226
|
-
// path: a pull loop never has a seeded `prev.total`, so
|
|
227
|
-
// "1/1 → 2/1 → 3/1" (total frozen at unit.index+1 while done
|
|
231
|
+
// path: a pull loop never has a seeded `prev.total`, so its counter can never
|
|
232
|
+
// read "1/1 → 2/1 → 3/1" (total frozen at unit.index+1 while done climbs).
|
|
228
233
|
let units: { done: number; total: number } | undefined;
|
|
229
234
|
if (isFanout) {
|
|
230
235
|
const prev = getLane(ctx.runId)?.progress?.units;
|
|
@@ -158,7 +158,7 @@ export function recordRun(runId: string, name: string, meta?: { workflow?: strin
|
|
|
158
158
|
existing.workflow = meta?.workflow ?? existing.workflow;
|
|
159
159
|
existing.input = meta?.input ?? existing.input;
|
|
160
160
|
existing.status = "running"; // reactivate a retained terminal lane (resume)
|
|
161
|
-
existing
|
|
161
|
+
dropUnitLanes(runId, existing); // bank the prior run's unit tokens, drop its sessions + snapshots
|
|
162
162
|
existing.error = undefined; // clear the prior run's terminal failure reason
|
|
163
163
|
existing.lastArtifact = undefined; // clear the prior run's primary artifact path
|
|
164
164
|
existing.recap = undefined; // clear the prior run's end-of-run summary
|
|
@@ -432,16 +432,27 @@ export function sweepRunningUnits(runId: string, status: "done" | "failed"): voi
|
|
|
432
432
|
if (changed) notify();
|
|
433
433
|
}
|
|
434
434
|
|
|
435
|
-
/**
|
|
436
|
-
*
|
|
437
|
-
*
|
|
438
|
-
*
|
|
439
|
-
*
|
|
435
|
+
/** Empty a lane's per-unit map WITHOUT losing its tokens: the outgoing units' usage is
|
|
436
|
+
* folded into their stage's `stageUsage` bucket first, so `units` and `stageUsage` never
|
|
437
|
+
* overlap and nothing is dropped uncounted. The one place units are discarded — shared by
|
|
438
|
+
* `clearUnitLanes` (stage / generation transition) and `recordRun` (resume reactivation).
|
|
439
|
+
* Reads `progress.stageName`, so it runs BEFORE any caller resets `progress`. */
|
|
440
|
+
function dropUnitLanes(runId: string, entry: LaneEntry): void {
|
|
441
|
+
foldStageUsage(runId);
|
|
442
|
+
entry.units.clear();
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/** Clear the per-unit map at a stage or fan-out generation transition (bridge
|
|
446
|
+
* `onStageStart`/`onLoopStart`): the engine resets `cursor.slots` per loop, so the
|
|
447
|
+
* registry shows only the CURRENT generation's units (a run may fan out several times,
|
|
448
|
+
* reusing indices 0..N). The outgoing units' tokens are banked into `stageUsage` (see
|
|
449
|
+
* `dropUnitLanes`). Settles any dangling `pendingInput` so a child never hangs, and resets
|
|
450
|
+
* the lane clock. No-op on an empty map (the single-stage / first-generation path). */
|
|
440
451
|
export function clearUnitLanes(runId: string): void {
|
|
441
452
|
const entry = state().lanes.get(runId);
|
|
442
453
|
if (!entry || entry.units.size === 0) return;
|
|
443
454
|
settleAndEmitCleared(runId, entry, () => {
|
|
444
|
-
entry
|
|
455
|
+
dropUnitLanes(runId, entry);
|
|
445
456
|
entry.needsInputSince = undefined;
|
|
446
457
|
});
|
|
447
458
|
}
|
|
@@ -449,8 +460,8 @@ export function clearUnitLanes(runId: string): void {
|
|
|
449
460
|
/** Pairwise-accumulate one stage's usage into the `stageUsage` bucket for `runId` +
|
|
450
461
|
* `stageName` via `addLaneUsage` (so a re-folded stage SUMS, never overwrites). No-op
|
|
451
462
|
* on undefined usage / missing lane / undefined stageName — a pre-first-stage fold, or a
|
|
452
|
-
* lane with no live progress, records nothing. Does NOT notify (the
|
|
453
|
-
*
|
|
463
|
+
* lane with no live progress, records nothing. Does NOT notify (the caller's
|
|
464
|
+
* own notify covers it). */
|
|
454
465
|
export function addStageUsage(runId: string, stageName: string | undefined, usage: LaneUsage | undefined): void {
|
|
455
466
|
if (usage === undefined || stageName === undefined) return;
|
|
456
467
|
const entry = state().lanes.get(runId);
|
|
@@ -460,11 +471,12 @@ export function addStageUsage(runId: string, stageName: string | undefined, usag
|
|
|
460
471
|
}
|
|
461
472
|
|
|
462
473
|
/** Fold the CURRENT stage's per-unit orchestrator tokens into its `stageUsage` bucket.
|
|
463
|
-
* Reads the OUTGOING stage name off `progress.stageName` (
|
|
464
|
-
*
|
|
465
|
-
* then folds each unit's effective `unitUsage` (teardown snapshot else live child)
|
|
466
|
-
* that stage's bucket via `addStageUsage`.
|
|
467
|
-
*
|
|
474
|
+
* Reads the OUTGOING stage name off `progress.stageName` (`dropUnitLanes` runs it BEFORE
|
|
475
|
+
* the units are emptied, and the bridge clears BEFORE `setLaneProgress` flips to the next
|
|
476
|
+
* name), then folds each unit's effective `unitUsage` (teardown snapshot else live child)
|
|
477
|
+
* into that stage's bucket via `addStageUsage`. Does NOT clear `units` — calling it alone
|
|
478
|
+
* and then `dropUnitLanes` counts the same units twice. No-op when the stage name is unset
|
|
479
|
+
* or `units` is empty. Does NOT notify — the enclosing caller does. */
|
|
468
480
|
export function foldStageUsage(runId: string): void {
|
|
469
481
|
const lane = state().lanes.get(runId);
|
|
470
482
|
const stageName = lane?.progress?.stageName;
|
|
@@ -472,21 +484,25 @@ export function foldStageUsage(runId: string): void {
|
|
|
472
484
|
for (const unit of lane.units.values()) addStageUsage(runId, stageName, unitUsage(unit));
|
|
473
485
|
}
|
|
474
486
|
|
|
475
|
-
/** Seed the CURRENT fan-out generation's unit sub-rows
|
|
476
|
-
*
|
|
477
|
-
*
|
|
478
|
-
*
|
|
479
|
-
*
|
|
480
|
-
*
|
|
481
|
-
*
|
|
482
|
-
|
|
487
|
+
/** Seed the CURRENT fan-out generation's unit sub-rows (bridge `onLoopStart` for a
|
|
488
|
+
* fanout): each declared unit's sub-lane is created FRESH keyed by its declared array
|
|
489
|
+
* `index`, so the dock fans out the generation the instant onLoopStart fires — BEFORE any
|
|
490
|
+
* onUnitStart flips a unit running. `status` defaults to "pending"; a resumed generation
|
|
491
|
+
* seeds its replayed units terminal ("done"/"failed") because they fire no unit events.
|
|
492
|
+
* Does NOT go through `upsertUnit` (the host's live-session lifecycle seeds "running");
|
|
493
|
+
* the pending→running flip is `setUnitStarted` (`onUnitStart`) on the SAME map key.
|
|
494
|
+
* One notify per seed. Best-effort: a missing run is a no-op, mirroring every sibling mutator. */
|
|
495
|
+
export function seedUnits(
|
|
496
|
+
runId: string,
|
|
497
|
+
units: ReadonlyArray<{ index: number; label: string; status?: "pending" | "done" | "failed" }>,
|
|
498
|
+
): void {
|
|
483
499
|
const entry = state().lanes.get(runId);
|
|
484
500
|
if (!entry) return;
|
|
485
501
|
for (const u of units) {
|
|
486
502
|
entry.units.set(u.index, {
|
|
487
503
|
index: u.index,
|
|
488
504
|
label: u.label,
|
|
489
|
-
status: "pending",
|
|
505
|
+
status: u.status ?? "pending",
|
|
490
506
|
currentSession: undefined,
|
|
491
507
|
pendingInput: [],
|
|
492
508
|
});
|
|
@@ -95,9 +95,10 @@ export interface UnitLane {
|
|
|
95
95
|
* until `setUnitStarted` fires — the host may publish a live session first. */
|
|
96
96
|
label?: string;
|
|
97
97
|
/** Per-unit lifecycle status — drives the sub-row glyph and the orphan sweep.
|
|
98
|
-
* "pending" is seeded by `
|
|
98
|
+
* "pending" is seeded by `seedUnits` (a fanout `onLoopStart`) and flipped to
|
|
99
99
|
* "running" by `setUnitStarted` (`onUnitStart`); "running" until `markUnitDone`/
|
|
100
|
-
* `sweepRunningUnits`/`retireRun` flips it terminal.
|
|
100
|
+
* `sweepRunningUnits`/`retireRun` flips it terminal. A resumed generation's replayed
|
|
101
|
+
* units are seeded terminal directly — they fire no unit events. */
|
|
101
102
|
status: "running" | "pending" | "done" | "failed";
|
|
102
103
|
/** This unit's currently-live child session (the viewer/preview source);
|
|
103
104
|
* undefined before the child spawns, between stages, or after teardown. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juicesharp/rpiv-pi",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.16.0",
|
|
4
4
|
"description": "A skill-based development workflow for Pi Agent. 30 contract-carrying skills (discover → research → design → plan → implement → validate → code-review → commit, and more), the 15 named subagents they dispatch, and four built-in /wf workflows that chain them end to end in detached parallel runs.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
]
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@juicesharp/rpiv-config": "^2.
|
|
55
|
+
"@juicesharp/rpiv-config": "^2.16.0"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"@earendil-works/pi-ai": "*",
|