@juicesharp/rpiv-workflow 2.2.0 → 2.3.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.
Files changed (49) hide show
  1. package/audit-ctx.ts +7 -7
  2. package/audit.ts +29 -29
  3. package/chain-state.ts +14 -3
  4. package/death-scene.ts +9 -9
  5. package/docs/workflow-authoring.md +2 -2
  6. package/events.ts +1 -1
  7. package/failure-memos.ts +4 -4
  8. package/handle.ts +16 -1
  9. package/host.ts +1 -1
  10. package/loop-def.ts +1 -1
  11. package/loop-kinds.ts +12 -12
  12. package/loop-parallel.ts +15 -15
  13. package/loop-waves.ts +3 -3
  14. package/loop.ts +32 -30
  15. package/messages.ts +30 -17
  16. package/outcomes/collectors/workspace-diff.ts +3 -3
  17. package/outcomes/git-commit.ts +11 -4
  18. package/output-spec.ts +7 -7
  19. package/package.json +2 -2
  20. package/preview.ts +8 -1
  21. package/registration.ts +3 -3
  22. package/routing.ts +1 -1
  23. package/runner/chain-advance.ts +49 -25
  24. package/runner/errors.ts +1 -1
  25. package/runner/failure.ts +22 -23
  26. package/runner/preflight.ts +3 -6
  27. package/runner/resolve-stage.ts +3 -3
  28. package/runner/resume-entry.ts +5 -5
  29. package/runner/resume-loop.ts +5 -5
  30. package/runner/resume.ts +1 -1
  31. package/runner/run-stage.ts +69 -64
  32. package/runner/runner.ts +4 -4
  33. package/runner/script-stage.ts +17 -17
  34. package/sessions/bash-strikes.ts +9 -9
  35. package/sessions/extraction.ts +19 -12
  36. package/sessions/halt-routing.ts +14 -14
  37. package/sessions/index.ts +1 -1
  38. package/sessions/reattach.ts +10 -10
  39. package/sessions/sessions.ts +29 -23
  40. package/sessions/spawn.ts +5 -5
  41. package/sessions/success-persist.ts +3 -3
  42. package/stage-def.ts +2 -2
  43. package/stage-errors.ts +1 -1
  44. package/state/index.ts +1 -1
  45. package/state/names.ts +1 -1
  46. package/state/reads.ts +1 -1
  47. package/state/state.ts +4 -4
  48. package/state/writes.ts +2 -2
  49. package/types.ts +16 -16
package/types.ts CHANGED
@@ -16,7 +16,7 @@
16
16
  *
17
17
  * Per-stage / per-phase sessions extend a shared `SessionContext` base
18
18
  * (cwd, runId, state, prompt, skill). The audit layer pins its dependency
19
- * on this base structurally via `AuditCtx = Pick<SessionContext, ...>`.
19
+ * on this base structurally via `AuditContext = Pick<SessionContext, ...>`.
20
20
  *
21
21
  * Lives apart from runner.ts / sessions.ts so both can reference the same
22
22
  * shapes without a runtime import cycle (type-only refs back via this
@@ -239,13 +239,13 @@ export interface RunWorkflowOptions {
239
239
  signal?: AbortSignal;
240
240
  /**
241
241
  * Per-stage model-override resolver, injected by the embedder. Threaded onto
242
- * `RunContext.resolveModel` → every `StageSession.model`; the host applies it
242
+ * `RunContext.resolveModel` → every `StageSessionContext.model`; the host applies it
243
243
  * at child-session creation. Undefined ⇒ host default for every stage.
244
244
  */
245
245
  resolveModel?: (id: { stage: string; skill: string }) => ModelSelection | undefined;
246
246
  /**
247
247
  * Worktree-digest override for the validation-retry gate — threaded
248
- * onto `RunContext.worktreeDigest` → every `StageSession.worktreeDigest`.
248
+ * onto `RunContext.worktreeDigest` → every `StageSessionContext.worktreeDigest`.
249
249
  * Undefined ⇒ the built-in `computeWorktreeDigest` (git + artifacts).
250
250
  */
251
251
  worktreeDigest?: (cwd: string) => string | undefined;
@@ -361,7 +361,7 @@ export interface RunContext {
361
361
  * lacks a stage `inputSchema` (a harvested `consumes.data` is the
362
362
  * stage's own `inputSchema` re-derived, already covered by
363
363
  * `ensureInputValid`);
364
- * - `effectiveOutputSchema` (threaded onto `StageSession`) sources a
364
+ * - `effectiveOutputSchema` (threaded onto `StageSessionContext`) sources a
365
365
  * declared `produces.data` as the output schema when the stage carries
366
366
  * no `outputSchema` of its own.
367
367
  * Fail-soft: both degrade (no validation, never throw) when absent.
@@ -370,7 +370,7 @@ export interface RunContext {
370
370
  /**
371
371
  * Resolve a per-stage model override, injected by the embedder (rpiv-pi maps
372
372
  * each `{ stage, skill }` to its model/effort override). The runner threads
373
- * the result onto every `StageSession.model`; the host applies it at child
373
+ * the result onto every `StageSessionContext.model`; the host applies it at child
374
374
  * creation (NOT via global mutation). Undefined ⇒ host default.
375
375
  */
376
376
  resolveModel?: (id: { stage: string; skill: string }) => ModelSelection | undefined;
@@ -381,13 +381,13 @@ export interface RunContext {
381
381
  * writer at failure time (death-scene.ts) — the ONLY reader. Undefined for
382
382
  * programmatic embedders / no provider, in which case the writer degrades
383
383
  * silently (no artifact, no warning). Threaded provider → executor →
384
- * `RunContext` → `SessionContext` → `AuditCtx` → `auditFor`.
384
+ * `RunContext` → `SessionContext` → `AuditContext` → `auditFor`.
385
385
  */
386
386
  readSessionBranch?: (file: string) => BranchEntry[] | undefined;
387
387
  /**
388
388
  * Worktree-digest resolver injected by the embedder (tests / programmatic
389
389
  * embedders that want to stub the filesystem). Threaded onto every
390
- * `StageSession.worktreeDigest` and read by the validation-retry gate
390
+ * `StageSessionContext.worktreeDigest` and read by the validation-retry gate
391
391
  * (`packages/rpiv-workflow/sessions/extraction.ts` mechanism-1 +
392
392
  * `packages/rpiv-workflow/runner/run-stage.ts` mechanism-2) via
393
393
  * `resolveDigest` (`worktree-digest.ts`). Undefined ⇒ the built-in
@@ -409,7 +409,7 @@ export interface RunContext {
409
409
  lifecycle: LifecycleDispatcher;
410
410
  /**
411
411
  * Optional cooperative-cancellation signal from `RunWorkflowOptions.signal`.
412
- * Checked at the between-stage seam (top of `runStageOrRecordFailure`, before
412
+ * Checked at the between-stage seam (top of `dispatchStageOrRecordFailure`, before
413
413
  * the start stage and before every routed next stage). An aborted signal
414
414
  * records an `"aborted"` terminal row and unwinds — it does NOT interrupt a
415
415
  * stage already streaming (Pi owns the live session).
@@ -418,9 +418,9 @@ export interface RunContext {
418
418
  }
419
419
 
420
420
  /**
421
- * Per-stage / per-unit common base. Extended by `StageSession` (loop units
422
- * thread their identity through `StageSession.unit`); consumed in pick form by
423
- * `AuditCtx` (audit.ts) so the audit layer pins its dependency on this shape
421
+ * Per-stage / per-unit common base. Extended by `StageSessionContext` (loop units
422
+ * thread their identity through `StageSessionContext.unit`); consumed in pick form by
423
+ * `AuditContext` (audit.ts) so the audit layer pins its dependency on this shape
424
424
  * structurally instead of duplicating the field list.
425
425
  *
426
426
  * `stageName` is the workflow stage's record key — the value that lands
@@ -464,10 +464,10 @@ export interface SessionContext {
464
464
  /**
465
465
  * Host-injected persisted-session branch reader, threaded from
466
466
  * `RunContext.readSessionBranch`. Read by the death-scene artifact writer
467
- * (`writeDeathSceneArtifact`) via `AuditCtx`; absent for programmatic
467
+ * (`writeDeathSceneArtifact`) via `AuditContext`; absent for programmatic
468
468
  * embedders (the writer degrades silently). Travels FURTHER than
469
- * `resolveModel` — into `SessionContext` → `AuditCtx` → `auditFor` —
470
- * because the writer reads it from `AuditCtx` at failure time.
469
+ * `resolveModel` — into `SessionContext` → `AuditContext` → `auditFor` —
470
+ * because the writer reads it from `AuditContext` at failure time.
471
471
  */
472
472
  readSessionBranch?: (file: string) => BranchEntry[] | undefined;
473
473
  }
@@ -490,7 +490,7 @@ export interface UnitRef {
490
490
  label: string;
491
491
  }
492
492
 
493
- export interface StageSession extends SessionContext {
493
+ export interface StageSessionContext extends SessionContext {
494
494
  stage: StageDef;
495
495
  /**
496
496
  * Registered skill-contract registry, threaded from
@@ -549,7 +549,7 @@ export interface StageSession extends SessionContext {
549
549
  * `undefined` ⇒ the `BASH_TIMEOUT_STRIKES` module default. Pin to `0` in a
550
550
  * watchdog-contract test to force immediate exhaustion; pin to `N` to drive
551
551
  * a multi-strike recovery without mutating env. Now the SOLE strike surface
552
- * on `StageSession`: the mutable accounting (used counter + reasons
552
+ * on `StageSessionContext`: the mutable accounting (used counter + reasons
553
553
  * accumulator) lives in the private `StrikeBudget` value object held in
554
554
  * `sessions/bash-strikes.ts`, keyed off this session (read once at first
555
555
  * consume to resolve the budget's ceiling). Immutable per-activation.