@juicesharp/rpiv-workflow 1.19.1 → 1.20.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/README.md +81 -8
- package/api.ts +18 -703
- package/audit-rows.ts +136 -0
- package/audit.ts +139 -126
- package/built-ins.ts +20 -45
- package/chain-state.ts +169 -0
- package/command-run.ts +31 -3
- package/command.ts +116 -20
- package/docs/workflow-authoring.md +322 -61
- package/{lifecycle.ts → events.ts} +119 -35
- package/host.ts +30 -0
- package/index.ts +25 -81
- package/internal-utils.ts +92 -78
- package/internal.ts +21 -1
- package/judge.ts +229 -0
- package/layers.ts +10 -15
- package/load/alias.ts +6 -12
- package/load/cache.ts +9 -6
- package/load/index.ts +16 -109
- package/load/issues.ts +31 -0
- package/load/legacy.ts +102 -0
- package/load/merge.ts +2 -2
- package/load/shape-guards.test.ts +4 -1
- package/load/shape-guards.ts +3 -6
- package/load/skill-contract-phase.ts +94 -0
- package/loop-constructors.ts +623 -0
- package/loop-def.ts +240 -0
- package/loop-kinds.ts +493 -0
- package/loop.ts +304 -0
- package/messages.ts +225 -157
- package/outcomes/collectors/directory-path.ts +7 -3
- package/outcomes/collectors/require-opt.ts +11 -0
- package/outcomes/collectors/tool-call.test.ts +3 -1
- package/outcomes/collectors/tool-call.ts +8 -3
- package/outcomes/collectors/transcript-path.ts +2 -3
- package/outcomes/collectors/union.test.ts +54 -0
- package/outcomes/collectors/union.ts +28 -9
- package/outcomes/collectors/url.ts +7 -0
- package/outcomes/collectors/workspace-diff.test.ts +13 -0
- package/outcomes/collectors/workspace-diff.ts +21 -14
- package/outcomes/exec.ts +17 -0
- package/outcomes/git-commit.test.ts +76 -30
- package/outcomes/git-commit.ts +139 -100
- package/outcomes/index.ts +1 -0
- package/outcomes/parsers/json-body.ts +2 -2
- package/outcomes/side-effect.ts +3 -3
- package/output-spec.ts +36 -10
- package/output.ts +40 -20
- package/package.json +13 -7
- package/predicates.ts +11 -8
- package/preview.ts +77 -17
- package/registration.ts +109 -35
- package/routing-dsl.ts +310 -0
- package/routing.ts +2 -2
- package/runner/by-name.ts +2 -1
- package/runner/by-run-id.ts +2 -1
- package/runner/chain-advance.ts +59 -44
- package/runner/errors.ts +33 -0
- package/runner/failure.ts +109 -0
- package/runner/header-write-failure.test.ts +64 -0
- package/runner/index.ts +7 -13
- package/runner/input-validation.ts +11 -21
- package/runner/preflight.ts +173 -0
- package/runner/resolve-stage.ts +68 -0
- package/runner/resume-entry.ts +101 -0
- package/runner/resume-loop.test.ts +1410 -0
- package/runner/resume-loop.ts +110 -0
- package/runner/resume-session.test.ts +400 -0
- package/runner/resume.test.ts +881 -206
- package/runner/resume.ts +281 -261
- package/runner/run-context.ts +161 -0
- package/runner/run-stage.ts +456 -0
- package/runner/runner.ts +59 -400
- package/runner/script-stage.ts +103 -105
- package/schema-compat.ts +13 -1
- package/sessions/extraction.ts +53 -31
- package/sessions/index.ts +3 -1
- package/sessions/locate.test.ts +77 -0
- package/sessions/locate.ts +90 -0
- package/sessions/reattach.ts +63 -0
- package/sessions/sessions.ts +130 -127
- package/skill-contract.ts +22 -25
- package/skill-contracts/composition.ts +88 -37
- package/skill-contracts/{registries.ts → extension-points.ts} +45 -12
- package/skill-contracts/harvest.ts +2 -3
- package/skill-contracts/index.ts +15 -8
- package/skill-contracts/registry.ts +33 -50
- package/stage-def.ts +527 -0
- package/startup.ts +3 -1
- package/state/index.ts +8 -1
- package/state/names.ts +91 -65
- package/state/paths.ts +12 -0
- package/state/raw.ts +78 -0
- package/state/reads.ts +103 -85
- package/state/resolve.ts +73 -0
- package/state/state.ts +112 -15
- package/state/writes.ts +29 -12
- package/transcript.ts +24 -0
- package/triggers.ts +11 -3
- package/types.ts +202 -44
- package/validate/contract-compat.ts +193 -0
- package/validate/graph.ts +125 -0
- package/validate/issue.ts +314 -0
- package/validate/stage-rules.ts +420 -0
- package/validate-output.ts +69 -1
- package/validate-workflow.ts +55 -759
- package/control-flow.ts +0 -135
- package/fanout.ts +0 -102
- package/iterate.ts +0 -155
- package/runner/resume-fanout.test.ts +0 -331
- package/runner/resume-fanout.ts +0 -136
- package/runner/resume-iterate.test.ts +0 -444
- package/runner/resume-iterate.ts +0 -111
- package/runner/stage-lifecycle.ts +0 -500
|
@@ -6,10 +6,13 @@
|
|
|
6
6
|
* (`normalizeDefaultExport` handles Arrays before reaching `describe`;
|
|
7
7
|
* jiti's `default: true` extraction rewrites `null` / `undefined`
|
|
8
8
|
* defaults). These tests pin the contract at the unit level.
|
|
9
|
+
* (`formatError` now lives in `../internal-utils.ts` but is pinned here
|
|
10
|
+
* alongside its original siblings.)
|
|
9
11
|
*/
|
|
10
12
|
|
|
11
13
|
import { describe, expect, it } from "vitest";
|
|
12
|
-
import {
|
|
14
|
+
import { formatError } from "../internal-utils.js";
|
|
15
|
+
import { describe as describeValue, isEnvelope, isWorkflow } from "./shape-guards.js";
|
|
13
16
|
|
|
14
17
|
describe("describe", () => {
|
|
15
18
|
it("returns 'null' for null", () => {
|
package/load/shape-guards.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Runtime shape guards + small formatting helpers used during default-export
|
|
3
3
|
* normalisation. `isWorkflow` / `isEnvelope` narrow `unknown` default exports
|
|
4
|
-
* to the structural shapes `normalizeDefaultExport` accepts; `describe`
|
|
5
|
-
*
|
|
4
|
+
* to the structural shapes `normalizeDefaultExport` accepts; `describe`
|
|
5
|
+
* synthesizes human-readable strings for load-issue messages. (`formatError`
|
|
6
|
+
* lives in `../internal-utils.ts` — it's package-wide, not loader-specific.)
|
|
6
7
|
*/
|
|
7
8
|
|
|
8
9
|
import type { Workflow } from "../api.js";
|
|
@@ -42,7 +43,3 @@ export function describe(v: unknown): string {
|
|
|
42
43
|
if (Array.isArray(v)) return "an array";
|
|
43
44
|
return typeof v;
|
|
44
45
|
}
|
|
45
|
-
|
|
46
|
-
export function formatError(e: unknown): string {
|
|
47
|
-
return e instanceof Error ? e.message : String(e);
|
|
48
|
-
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The loader's skill-contract phase — everything between "workflows are
|
|
3
|
+
* merged + aliased" and "validation runs": flush the lazy contract
|
|
4
|
+
* providers, surface their recorded failures and cross-owner collisions,
|
|
5
|
+
* build the effective registry (declared ⊕ harvested), and invoke the
|
|
6
|
+
* registered outcome derivers against per-load stage copies.
|
|
7
|
+
*
|
|
8
|
+
* Extracted from `loadWorkflows` so the orchestrator reads as a
|
|
9
|
+
* sequence of phases. Every issue this phase emits is attributed to
|
|
10
|
+
* `"framework"` — these are failures of provider/deriver machinery, not of
|
|
11
|
+
* any config file (the old `layer: "built-in"` attribution was a lie).
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { formatError } from "../internal-utils.js";
|
|
15
|
+
import type { SkillContractMap } from "../skill-contract.js";
|
|
16
|
+
import {
|
|
17
|
+
buildEffectiveContracts,
|
|
18
|
+
drainSkillContractCollisions,
|
|
19
|
+
drainSkillContractProviderErrors,
|
|
20
|
+
flushSkillContractProviders,
|
|
21
|
+
getBucketKindMappings,
|
|
22
|
+
getOutcomeDerivers,
|
|
23
|
+
} from "../skill-contracts/index.js";
|
|
24
|
+
import type { LoadAccumulator } from "./merge.js";
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Run the phase against the merged accumulator. Mutates `acc` (issues +
|
|
28
|
+
* per-load stage copies when derivers will run) and returns the effective
|
|
29
|
+
* contract registry the validation loop and the runner consume.
|
|
30
|
+
*
|
|
31
|
+
* Must run BEFORE the validation loop: `checkEdgeSchemaCompat` needs the
|
|
32
|
+
* registry, and derivers must have wired `outcome`s before the
|
|
33
|
+
* produces-without-outcome rule fires.
|
|
34
|
+
*/
|
|
35
|
+
export async function applySkillContractPhase(acc: LoadAccumulator): Promise<SkillContractMap> {
|
|
36
|
+
// Flush lazy contract providers before reading the registry. Each provider
|
|
37
|
+
// throw was RECORDED (not propagated) — drain and surface as issues so the
|
|
38
|
+
// loader keeps its never-throws contract without swallowing the failure.
|
|
39
|
+
await flushSkillContractProviders();
|
|
40
|
+
for (const err of drainSkillContractProviderErrors()) {
|
|
41
|
+
acc.issues.push({
|
|
42
|
+
kind: "load",
|
|
43
|
+
layer: "framework",
|
|
44
|
+
message: `skill-contract provider failed: ${formatError(err)}`,
|
|
45
|
+
severity: "warning",
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
// Cross-owner contract collisions — last-writer still wins, but the
|
|
49
|
+
// divergence is no longer silent.
|
|
50
|
+
for (const message of drainSkillContractCollisions()) {
|
|
51
|
+
acc.issues.push({ kind: "load", layer: "framework", message, severity: "warning" });
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Effective registry: a NEW map (harvested gap-fill first, declared
|
|
55
|
+
// overriding per skill) — never mutates the shared global registry.
|
|
56
|
+
const skillContracts = buildEffectiveContracts([...acc.workflowMap.values()]);
|
|
57
|
+
|
|
58
|
+
// Deriver mutations (`stage.outcome = ...`) must land on PER-LOAD copies,
|
|
59
|
+
// never on shared sources: built-ins live in a process-global registry and
|
|
60
|
+
// unchanged overlay files come back BY REFERENCE from the mtime cache, so an
|
|
61
|
+
// in-place mutation would pin this load's derived outcome onto every future
|
|
62
|
+
// load — the deriver's `if (stage.outcome) continue` idempotency guard would
|
|
63
|
+
// then skip re-derivation even after a contract change. Shallow-copy each
|
|
64
|
+
// workflow's stage records first (same `{...stage}` copy `aliasSkills` uses).
|
|
65
|
+
if (getOutcomeDerivers().length > 0) {
|
|
66
|
+
for (const [name, w] of acc.workflowMap) {
|
|
67
|
+
acc.workflowMap.set(name, {
|
|
68
|
+
...w,
|
|
69
|
+
stages: Object.fromEntries(Object.entries(w.stages).map(([k, s]) => [k, { ...s }])),
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
for (const deriver of getOutcomeDerivers()) {
|
|
74
|
+
try {
|
|
75
|
+
deriver(
|
|
76
|
+
acc.workflowMap.values(),
|
|
77
|
+
skillContracts,
|
|
78
|
+
(message, severity) => {
|
|
79
|
+
acc.issues.push({ kind: "load", layer: "framework", severity, message });
|
|
80
|
+
},
|
|
81
|
+
getBucketKindMappings(),
|
|
82
|
+
);
|
|
83
|
+
} catch (err) {
|
|
84
|
+
acc.issues.push({
|
|
85
|
+
kind: "load",
|
|
86
|
+
layer: "framework",
|
|
87
|
+
severity: "error",
|
|
88
|
+
message: `outcome deriver failed: ${formatError(err)}`,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return skillContracts;
|
|
94
|
+
}
|