@juicesharp/rpiv-workflow 1.19.1 → 2.0.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-ctx.ts +103 -0
- package/audit-rows.ts +154 -0
- package/audit.ts +158 -190
- package/built-ins.ts +40 -45
- package/chain-state.ts +220 -0
- package/command-run.ts +64 -31
- package/command.ts +123 -21
- package/docs/workflow-authoring.md +356 -63
- package/{lifecycle.ts → events.ts} +161 -37
- package/execution-host.ts +75 -0
- package/host.ts +149 -64
- package/index.ts +25 -81
- package/internal-utils.ts +171 -71
- package/internal.ts +22 -1
- package/judge.ts +241 -0
- package/layers.ts +10 -15
- package/load/alias.ts +6 -12
- package/load/cache.ts +9 -6
- package/load/index.ts +27 -106
- package/load/issues.ts +31 -0
- package/load/legacy.ts +102 -0
- package/load/merge.ts +2 -2
- package/load/resolve-default.ts +3 -4
- package/load/shape-guards.ts +3 -6
- package/load/skill-contract-phase.ts +94 -0
- package/loop-constructors.ts +24 -0
- package/loop-def.ts +285 -0
- package/loop-kinds.ts +750 -0
- package/loop-parallel.ts +250 -0
- package/loop-waves.ts +99 -0
- package/loop.ts +330 -0
- package/loops/constructors.ts +334 -0
- package/loops/derivations.ts +65 -0
- package/loops/introspection.ts +184 -0
- package/loops/panel.ts +196 -0
- package/loops/verify.ts +99 -0
- package/messages.ts +249 -156
- package/outcomes/collectors/directory-path.ts +7 -3
- package/outcomes/collectors/index.ts +1 -0
- package/outcomes/collectors/require-opt.ts +11 -0
- package/outcomes/collectors/text-scan.ts +47 -0
- package/outcomes/collectors/tool-call.ts +8 -3
- package/outcomes/collectors/transcript-path.ts +4 -18
- package/outcomes/collectors/union.ts +30 -10
- package/outcomes/collectors/url.ts +9 -14
- package/outcomes/collectors/workspace-diff.ts +21 -14
- package/outcomes/exec.ts +17 -0
- package/outcomes/git-commit.ts +190 -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 +98 -20
- package/package.json +27 -11
- package/predicates.ts +11 -8
- package/preview.ts +81 -21
- package/registration.ts +117 -36
- package/routing-dsl.ts +322 -0
- package/routing.ts +48 -2
- package/runner/by-name.ts +2 -1
- package/runner/by-run-id.ts +2 -1
- package/runner/chain-advance.ts +84 -56
- package/runner/errors.ts +10 -0
- package/runner/failure.ts +163 -0
- package/runner/index.ts +7 -13
- package/runner/input-validation.ts +16 -23
- package/runner/preflight.ts +169 -0
- package/runner/resolve-stage.ts +68 -0
- package/runner/resume-entry.ts +121 -0
- package/runner/resume-loop.ts +131 -0
- package/runner/resume.ts +368 -262
- package/runner/run-context.ts +165 -0
- package/runner/run-stage.ts +490 -0
- package/runner/runner.ts +202 -449
- package/runner/script-stage.ts +104 -112
- package/schema-compat.ts +12 -1
- package/semaphore.ts +55 -0
- package/sessions/extraction.ts +146 -81
- package/sessions/halt-routing.ts +195 -0
- package/sessions/index.ts +3 -1
- package/sessions/locate.ts +141 -0
- package/sessions/reattach.ts +71 -0
- package/sessions/sessions.ts +114 -199
- package/sessions/spawn.ts +132 -119
- package/sessions/success-persist.ts +89 -0
- package/skill-contract.ts +22 -25
- package/skill-contracts/composition.ts +86 -37
- package/skill-contracts/{registries.ts → extension-points.ts} +45 -12
- package/skill-contracts/harvest.ts +4 -4
- package/skill-contracts/index.ts +15 -8
- package/skill-contracts/registry.ts +33 -50
- package/stage-def.ts +595 -0
- package/stage-errors.ts +84 -0
- package/stage-identity.ts +56 -0
- package/startup.ts +4 -1
- package/state/index.ts +8 -1
- package/state/names.ts +91 -65
- package/state/paths.ts +20 -0
- package/state/raw.ts +77 -0
- package/state/reads.ts +103 -85
- package/state/resolve.ts +73 -0
- package/state/state.ts +135 -15
- package/state/writes.ts +29 -12
- package/transcript.ts +24 -0
- package/triggers.ts +11 -3
- package/types.ts +290 -78
- package/validate/contract-compat.ts +198 -0
- package/validate/graph.ts +134 -0
- package/validate/issue.ts +328 -0
- package/validate/stage-rules.ts +499 -0
- package/validate-output.ts +82 -7
- package/validate-workflow.ts +57 -759
- package/validation-bounds.ts +35 -0
- package/control-flow.ts +0 -135
- package/fanout.ts +0 -102
- package/iterate.ts +0 -155
- package/load/cache.test.ts +0 -82
- package/load/shape-guards.test.ts +0 -74
- package/outcomes/collectors/directory-path.test.ts +0 -64
- package/outcomes/collectors/tool-call.test.ts +0 -110
- package/outcomes/collectors/transcript-path.test.ts +0 -70
- package/outcomes/collectors/union.test.ts +0 -59
- package/outcomes/collectors/url.test.ts +0 -67
- package/outcomes/collectors/workspace-diff.test.ts +0 -107
- package/outcomes/git-commit.test.ts +0 -194
- package/outcomes/parsers/json-body.test.ts +0 -80
- package/runner/by-name.test.ts +0 -95
- package/runner/by-run-id.test.ts +0 -115
- 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/resume.test.ts +0 -1130
- package/runner/stage-lifecycle.ts +0 -500
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Extension points — composition comparator and outcome deriver registries.
|
|
3
3
|
*
|
|
4
4
|
* Per-channel `CompositionComparator` and `OutcomeDeriverFn` registries,
|
|
5
5
|
* both anchored on `Symbol.for` global slots (same pattern as `registry.ts`).
|
|
@@ -11,9 +11,10 @@ import type { CompositionComparator, SkillContractMap } from "../skill-contract.
|
|
|
11
11
|
|
|
12
12
|
const COMPARATORS_KEY = Symbol.for("@juicesharp/rpiv-workflow:composition-comparators");
|
|
13
13
|
const DERIVERS_KEY = Symbol.for("@juicesharp/rpiv-workflow:outcome-derivers");
|
|
14
|
+
const BUCKETS_KEY = Symbol.for("@juicesharp/rpiv-workflow:bucket-kind-mappings");
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
|
-
* A callback that derives `
|
|
17
|
+
* A callback that derives `Outcome` outcomes for `produces` stages from the
|
|
17
18
|
* skill contract registry. Registered by a consumer (e.g. rpiv-pi) that owns
|
|
18
19
|
* the ontology (the `artifactKind → bucket` normalization table). The loader
|
|
19
20
|
* invokes drained derivers after `buildEffectiveContracts` and before the
|
|
@@ -28,11 +29,16 @@ const DERIVERS_KEY = Symbol.for("@juicesharp/rpiv-workflow:outcome-derivers");
|
|
|
28
29
|
* missing artifactKind). The callback maps directly to `acc.issues.push(...)`;
|
|
29
30
|
* the deriver only populates `message` and `severity` — the loader sets `kind`
|
|
30
31
|
* and `layer`.
|
|
32
|
+
*
|
|
33
|
+
* `bucketKindMappings` is the consumer-registered `artifactKind → bucket`
|
|
34
|
+
* extension table (see `registerBucketKindMapping`), passed by the loader so
|
|
35
|
+
* derivers stay pure functions of their arguments.
|
|
31
36
|
*/
|
|
32
37
|
export type OutcomeDeriverFn = (
|
|
33
38
|
workflows: Iterable<Workflow>,
|
|
34
39
|
skillContracts: SkillContractMap,
|
|
35
40
|
onIssue: (message: string, severity: "error" | "warning") => void,
|
|
41
|
+
bucketKindMappings: ReadonlyMap<string, string>,
|
|
36
42
|
) => void;
|
|
37
43
|
|
|
38
44
|
/** channel name → consumer-supplied composition comparator. */
|
|
@@ -40,8 +46,9 @@ export const getCompositionComparators = globalSlot(COMPARATORS_KEY, () => new M
|
|
|
40
46
|
|
|
41
47
|
/**
|
|
42
48
|
* Register a per-channel composition comparator. The framework invokes the
|
|
43
|
-
* comparator
|
|
44
|
-
* `consumes.reads[channelName]
|
|
49
|
+
* comparator through the ONE shared `adjudicateChannel` rule (composition.ts)
|
|
50
|
+
* for any consumer that declares `consumes.reads[channelName]` with a `meta`
|
|
51
|
+
* requirement, but never interprets the `meta` it compares —
|
|
45
52
|
* the channel's ontology is the consumer's. Per-channel
|
|
46
53
|
* (not a single global comparator) so different consumers own different channels
|
|
47
54
|
* without collision. Idempotent on channel name (re-register replaces). Anchored
|
|
@@ -55,7 +62,7 @@ export function registerCompositionComparator(channelName: string, comparator: C
|
|
|
55
62
|
const getDerivers = globalSlot(DERIVERS_KEY, () => [] as OutcomeDeriverFn[]);
|
|
56
63
|
|
|
57
64
|
/**
|
|
58
|
-
* Register an outcome deriver — a callback that auto-wires `
|
|
65
|
+
* Register an outcome deriver — a callback that auto-wires `Outcome`
|
|
59
66
|
* outcomes onto `produces` stages from the skill contract registry. The
|
|
60
67
|
* loader drains and invokes all registered derivers after
|
|
61
68
|
* `buildEffectiveContracts` and before the validation loop. Register before
|
|
@@ -72,10 +79,11 @@ export function registerOutcomeDeriver(deriver: OutcomeDeriverFn): void {
|
|
|
72
79
|
/**
|
|
73
80
|
* Peek at registered outcome derivers (non-draining). `loadWorkflows` calls
|
|
74
81
|
* this on every load after `buildEffectiveContracts` and invokes each deriver
|
|
75
|
-
* with the merged workflow map and effective skill contracts.
|
|
76
|
-
*
|
|
77
|
-
* on per-load
|
|
78
|
-
*
|
|
82
|
+
* with the merged workflow map and effective skill contracts. The loader
|
|
83
|
+
* shallow-copies every workflow's stage records BEFORE invoking derivers, so
|
|
84
|
+
* deriver mutations land on per-load copies — never on shared built-ins or
|
|
85
|
+
* mtime-cached overlay objects — and a contract change between loads always
|
|
86
|
+
* re-derives. The deriver is idempotent (`if (stage.outcome) continue`), so
|
|
79
87
|
* re-running on already-derived stages is safe. Internal — not on the public
|
|
80
88
|
* barrel.
|
|
81
89
|
*/
|
|
@@ -83,11 +91,36 @@ export function getOutcomeDerivers(): OutcomeDeriverFn[] {
|
|
|
83
91
|
return getDerivers();
|
|
84
92
|
}
|
|
85
93
|
|
|
94
|
+
/** Live registry slot — module-private; all mutation goes through the registrars below. */
|
|
95
|
+
const getLiveBucketKindMappings = globalSlot(BUCKETS_KEY, () => new Map<string, string>());
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* artifactKind → bucket name mappings registered by consumers. Returns a
|
|
99
|
+
* defensive copy (same posture as `getSkillContracts`) — mutating the result
|
|
100
|
+
* does not touch the registry; use `registerBucketKindMapping`.
|
|
101
|
+
*/
|
|
102
|
+
export function getBucketKindMappings(): Map<string, string> {
|
|
103
|
+
return new Map(getLiveBucketKindMappings());
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Register a mapping from an artifactKind to a bucket name for outcome
|
|
108
|
+
* derivation. Extends the hardcoded BUCKET_BY_KIND table — user-installed
|
|
109
|
+
* skills with novel artifactKind values can register their own mappings.
|
|
110
|
+
* Idempotent on artifactKind (re-register replaces). Anchored on a
|
|
111
|
+
* `Symbol.for` slot like the rest of the registry, so it survives Pi's
|
|
112
|
+
* double module-load.
|
|
113
|
+
*/
|
|
114
|
+
export function registerBucketKindMapping(artifactKind: string, bucket: string): void {
|
|
115
|
+
getLiveBucketKindMappings().set(artifactKind, bucket);
|
|
116
|
+
}
|
|
117
|
+
|
|
86
118
|
/**
|
|
87
|
-
* Partial reset (comparator + deriver registries). The barrel's
|
|
88
|
-
* `__resetSkillContracts` calls `
|
|
119
|
+
* Partial reset (comparator + deriver + bucket-kind registries). The barrel's
|
|
120
|
+
* `__resetSkillContracts` calls `__resetContractRegistry` plus this.
|
|
89
121
|
*/
|
|
90
|
-
export function
|
|
122
|
+
export function __resetExtensionPoints(): void {
|
|
91
123
|
getCompositionComparators().clear();
|
|
92
124
|
getDerivers().length = 0;
|
|
125
|
+
getLiveBucketKindMappings().clear();
|
|
93
126
|
}
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import type { Workflow } from "../api.js";
|
|
12
|
-
import { resolveSkill } from "../internal-utils.js";
|
|
13
12
|
import { extractJsonSchema } from "../json-schema.js";
|
|
14
|
-
import { isDispatchingStage } from "../load/alias.js";
|
|
15
13
|
import type { ConsumesSpec, ProducesSpec, SkillContract } from "../skill-contract.js";
|
|
14
|
+
import { readName } from "../stage-def.js";
|
|
15
|
+
import { isDispatchingStage, resolveSkill } from "../stage-identity.js";
|
|
16
16
|
import { getSkillContracts } from "./registry.js";
|
|
17
17
|
|
|
18
18
|
/**
|
|
@@ -44,7 +44,7 @@ export function harvestStageContracts(workflows: readonly Workflow[]): Map<strin
|
|
|
44
44
|
const skill = resolveSkill(stage, stageName);
|
|
45
45
|
const producesData = extractJsonSchema(stage.outputSchema);
|
|
46
46
|
const consumesData = extractJsonSchema(stage.inputSchema);
|
|
47
|
-
const reads = stage.reads?.length ? Object.fromEntries(stage.reads.map((r) => [r, {}])) : undefined;
|
|
47
|
+
const reads = stage.reads?.length ? Object.fromEntries(stage.reads.map((r) => [readName(r), {}])) : undefined;
|
|
48
48
|
const produces: ProducesSpec | undefined =
|
|
49
49
|
stage.kind === "produces" || producesData
|
|
50
50
|
? { kind: stage.kind, ...(producesData ? { data: producesData } : {}) } // real StageKind ("produces" | "side-effect")
|
|
@@ -66,7 +66,7 @@ export function harvestStageContracts(workflows: readonly Workflow[]): Map<strin
|
|
|
66
66
|
|
|
67
67
|
/**
|
|
68
68
|
* Build the effective registry the loader hands to validation + the runner:
|
|
69
|
-
* `harvested` gap-fill first, then `declared
|
|
69
|
+
* `harvested` gap-fill first, then registered (`declared`-source) contracts override per
|
|
70
70
|
* skill (declared outranks harvested). Returns a NEW map — never mutates the
|
|
71
71
|
* shared global registry returned by `getSkillContracts()`. Co-located with
|
|
72
72
|
* `harvestStageContracts` because the merge precedence is contract-domain logic,
|
package/skill-contracts/index.ts
CHANGED
|
@@ -4,16 +4,23 @@
|
|
|
4
4
|
* re-exports only the symbols the rest of the package consumes.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
export { canCompose, legalNextSkills } from "./composition.js";
|
|
8
|
-
|
|
9
|
-
export { buildEffectiveContracts, harvestStageContracts } from "./harvest.js";
|
|
10
7
|
export {
|
|
8
|
+
adjudicateChannel,
|
|
9
|
+
type ChannelAdjudication,
|
|
10
|
+
canCompose,
|
|
11
|
+
compareDataChannel,
|
|
12
|
+
legalNextSkills,
|
|
13
|
+
} from "./composition.js";
|
|
14
|
+
export {
|
|
15
|
+
getBucketKindMappings,
|
|
11
16
|
getCompositionComparators,
|
|
12
17
|
getOutcomeDerivers,
|
|
13
18
|
type OutcomeDeriverFn,
|
|
19
|
+
registerBucketKindMapping,
|
|
14
20
|
registerCompositionComparator,
|
|
15
21
|
registerOutcomeDeriver,
|
|
16
|
-
} from "./
|
|
22
|
+
} from "./extension-points.js";
|
|
23
|
+
export { buildEffectiveContracts, harvestStageContracts } from "./harvest.js";
|
|
17
24
|
export {
|
|
18
25
|
drainSkillContractCollisions,
|
|
19
26
|
drainSkillContractProviderErrors,
|
|
@@ -23,8 +30,8 @@ export {
|
|
|
23
30
|
registerSkillContractsProvider,
|
|
24
31
|
} from "./registry.js";
|
|
25
32
|
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
33
|
+
import { __resetExtensionPoints } from "./extension-points.js";
|
|
34
|
+
import { __resetContractRegistry } from "./registry.js";
|
|
28
35
|
|
|
29
36
|
/**
|
|
30
37
|
* Test reset (wired into repo-wide setup). Clears the registry, pending lazy
|
|
@@ -32,6 +39,6 @@ import { __resetRegistry } from "./registry.js";
|
|
|
32
39
|
* registries, and the flush latch so the next case starts clean.
|
|
33
40
|
*/
|
|
34
41
|
export function __resetSkillContracts(): void {
|
|
35
|
-
|
|
36
|
-
|
|
42
|
+
__resetContractRegistry();
|
|
43
|
+
__resetExtensionPoints();
|
|
37
44
|
}
|
|
@@ -9,37 +9,36 @@
|
|
|
9
9
|
* Companion modules:
|
|
10
10
|
* - harvest.ts — harvestStageContracts + buildEffectiveContracts.
|
|
11
11
|
* - composition.ts — canCompose + legalNextSkills.
|
|
12
|
-
* -
|
|
12
|
+
* - extension-points.ts — CompositionComparator + OutcomeDeriver registries (consumer extension points).
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import { deepEqual, globalSlot } from "../internal-utils.js";
|
|
15
|
+
import { deepEqual, globalSlot, lazyProviderRegistry } from "../internal-utils.js";
|
|
16
16
|
import type { SkillContract, SkillContractMap } from "../skill-contract.js";
|
|
17
17
|
|
|
18
18
|
const REGISTRY_KEY = Symbol.for("@juicesharp/rpiv-workflow:skill-contracts");
|
|
19
|
-
const PROVIDERS_KEY = Symbol.for("@juicesharp/rpiv-workflow:skill-contract-providers");
|
|
20
|
-
const FLUSH_KEY = Symbol.for("@juicesharp/rpiv-workflow:skill-contract-flush");
|
|
21
19
|
const FAILURES_KEY = Symbol.for("@juicesharp/rpiv-workflow:skill-contract-failures");
|
|
22
20
|
const COLLISIONS_KEY = Symbol.for("@juicesharp/rpiv-workflow:skill-contract-collisions");
|
|
23
21
|
const OWNERS_KEY = Symbol.for("@juicesharp/rpiv-workflow:skill-contract-owners");
|
|
24
22
|
|
|
25
|
-
/** A lazy contributor of skill contracts — run once by `flushSkillContractProviders`. */
|
|
26
|
-
type SkillContractsProvider = () => void | Promise<void>;
|
|
27
|
-
|
|
28
23
|
const getRegistry = globalSlot(REGISTRY_KEY, () => new Map<string, SkillContract>());
|
|
29
|
-
const getProviders = globalSlot(PROVIDERS_KEY, () => [] as SkillContractsProvider[]);
|
|
30
24
|
/** name → owner label of whoever last registered it (for prune-on-reload + collision detection). */
|
|
31
25
|
const getOwners = globalSlot(OWNERS_KEY, () => new Map<string, string>());
|
|
32
26
|
const getCollisions = globalSlot(COLLISIONS_KEY, () => [] as string[]);
|
|
33
27
|
const getFailures = globalSlot(FAILURES_KEY, () => [] as unknown[]);
|
|
34
28
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
29
|
+
// Provider lifecycle via the shared `lazyProviderRegistry`. DELIBERATE
|
|
30
|
+
// divergence from the built-ins registry: `onError` RECORDS each provider
|
|
31
|
+
// throw (drained by `drainSkillContractProviderErrors`) instead of
|
|
32
|
+
// propagating. Contract providers read the filesystem / parse frontmatter
|
|
33
|
+
// (failure-prone), and `loadWorkflows` must honor its never-throws contract —
|
|
34
|
+
// a malformed source degrades to a partial/empty registry instead of crashing
|
|
35
|
+
// `/wf`, but the error is NOT swallowed silently: `loadWorkflows` surfaces it
|
|
36
|
+
// as a LoadIssue so a buggy provider is debuggable.
|
|
37
|
+
const providers = lazyProviderRegistry("@juicesharp/rpiv-workflow:skill-contract-providers", {
|
|
38
|
+
onError: (err) => {
|
|
39
|
+
getFailures().push(err);
|
|
40
|
+
},
|
|
41
|
+
});
|
|
43
42
|
|
|
44
43
|
/**
|
|
45
44
|
* Register one or more skill contracts, keyed by RESOLVED skill name — a flat
|
|
@@ -85,42 +84,27 @@ export function registerSkillContracts(contracts: Iterable<readonly [string, Ski
|
|
|
85
84
|
}
|
|
86
85
|
|
|
87
86
|
/**
|
|
88
|
-
* Register a LAZY contract provider. The thunk runs once on the
|
|
89
|
-
* `flushSkillContractProviders()` (which `loadWorkflows` awaits
|
|
90
|
-
* sibling defer reading skill frontmatter off
|
|
91
|
-
*
|
|
87
|
+
* Register a LAZY contract provider. The thunk runs once, on the next
|
|
88
|
+
* `flushSkillContractProviders()` (which `loadWorkflows` awaits before every
|
|
89
|
+
* registry read), letting a sibling defer reading skill frontmatter off
|
|
90
|
+
* startup and onto first `/wf`. Re-registration after `/reload` (Pi re-runs
|
|
91
|
+
* extension entries; these slots survive on `globalThis`) is the supported
|
|
92
|
+
* refresh path — the next load flushes the new provider, whose owner-scoped
|
|
93
|
+
* `registerSkillContracts` call then prunes contracts for skills the owner
|
|
94
|
+
* dropped since.
|
|
92
95
|
*/
|
|
93
|
-
export function registerSkillContractsProvider(provider:
|
|
94
|
-
|
|
96
|
+
export function registerSkillContractsProvider(provider: () => void | Promise<void>): void {
|
|
97
|
+
providers.register(provider);
|
|
95
98
|
}
|
|
96
99
|
|
|
97
100
|
/**
|
|
98
|
-
* Run
|
|
99
|
-
* the
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
* the filesystem / parse frontmatter (failure-prone), and `loadWorkflows` must
|
|
103
|
-
* honor its never-throws contract — a malformed source degrades to a
|
|
104
|
-
* partial/empty registry instead of crashing `/wf`, but the error is NOT
|
|
105
|
-
* swallowed silently: `loadWorkflows` surfaces it as a `LoadIssue` so a buggy
|
|
106
|
-
* provider is debuggable. Built-in providers are trusted in-process code and so
|
|
107
|
-
* don't need the guard.
|
|
101
|
+
* Run every not-yet-run provider (each runs at most once; providers
|
|
102
|
+
* registered after a flush run on the next one — see `lazyProviderRegistry`).
|
|
103
|
+
* Concurrency-safe (callers await the same promise). Error posture:
|
|
104
|
+
* recorded, not propagated — see the construction comment above.
|
|
108
105
|
*/
|
|
109
106
|
export function flushSkillContractProviders(): Promise<void> {
|
|
110
|
-
|
|
111
|
-
if (existing) return existing;
|
|
112
|
-
const pending = getProviders().splice(0);
|
|
113
|
-
const flush = Promise.all(
|
|
114
|
-
pending.map((p) =>
|
|
115
|
-
Promise.resolve()
|
|
116
|
-
.then(p)
|
|
117
|
-
.catch((err) => {
|
|
118
|
-
getFailures().push(err);
|
|
119
|
-
}),
|
|
120
|
-
),
|
|
121
|
-
).then(() => undefined);
|
|
122
|
-
setFlushLatch(flush);
|
|
123
|
-
return flush;
|
|
107
|
+
return providers.flush();
|
|
124
108
|
}
|
|
125
109
|
|
|
126
110
|
/**
|
|
@@ -152,13 +136,12 @@ export function getSkillContracts(): SkillContractMap {
|
|
|
152
136
|
|
|
153
137
|
/**
|
|
154
138
|
* Partial reset (registry + providers + collision state). The barrel's
|
|
155
|
-
* `__resetSkillContracts` calls this plus `
|
|
139
|
+
* `__resetSkillContracts` calls this plus `extension-points.__resetExtensionPoints`.
|
|
156
140
|
*/
|
|
157
|
-
export function
|
|
141
|
+
export function __resetContractRegistry(): void {
|
|
158
142
|
getRegistry().clear();
|
|
159
|
-
|
|
143
|
+
providers.reset();
|
|
160
144
|
getFailures().length = 0;
|
|
161
145
|
getCollisions().length = 0;
|
|
162
146
|
getOwners().clear();
|
|
163
|
-
setFlushLatch(undefined);
|
|
164
147
|
}
|