taskflow-core 0.2.10 → 0.3.0-beta.1

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 (109) hide show
  1. package/README.md +139 -377
  2. package/dist/agents.d.ts.map +1 -1
  3. package/dist/agents.js +3 -10
  4. package/dist/agents.js.map +1 -1
  5. package/dist/atomic-rename.d.ts +14 -0
  6. package/dist/atomic-rename.d.ts.map +1 -0
  7. package/dist/atomic-rename.js +35 -0
  8. package/dist/atomic-rename.js.map +1 -0
  9. package/dist/build-info.json +2 -2
  10. package/dist/discovery-boundary.d.ts +20 -0
  11. package/dist/discovery-boundary.d.ts.map +1 -0
  12. package/dist/discovery-boundary.js +101 -0
  13. package/dist/discovery-boundary.js.map +1 -0
  14. package/dist/effects/index.d.ts +9 -0
  15. package/dist/effects/index.d.ts.map +1 -0
  16. package/dist/effects/index.js +9 -0
  17. package/dist/effects/index.js.map +1 -0
  18. package/dist/effects/runtime-apply.d.ts +66 -0
  19. package/dist/effects/runtime-apply.d.ts.map +1 -0
  20. package/dist/effects/runtime-apply.js +214 -0
  21. package/dist/effects/runtime-apply.js.map +1 -0
  22. package/dist/effects/schema.d.ts +8 -0
  23. package/dist/effects/schema.d.ts.map +1 -0
  24. package/dist/effects/schema.js +41 -0
  25. package/dist/effects/schema.js.map +1 -0
  26. package/dist/effects/types.d.ts +93 -0
  27. package/dist/effects/types.d.ts.map +1 -0
  28. package/dist/effects/types.js +37 -0
  29. package/dist/effects/types.js.map +1 -0
  30. package/dist/effects/validate.d.ts +103 -0
  31. package/dist/effects/validate.d.ts.map +1 -0
  32. package/dist/effects/validate.js +543 -0
  33. package/dist/effects/validate.js.map +1 -0
  34. package/dist/effects/why.d.ts +94 -0
  35. package/dist/effects/why.d.ts.map +1 -0
  36. package/dist/effects/why.js +365 -0
  37. package/dist/effects/why.js.map +1 -0
  38. package/dist/exec/kernel-policy.d.ts.map +1 -1
  39. package/dist/exec/kernel-policy.js +4 -0
  40. package/dist/exec/kernel-policy.js.map +1 -1
  41. package/dist/exec/step.d.ts.map +1 -1
  42. package/dist/exec/step.js +6 -0
  43. package/dist/exec/step.js.map +1 -1
  44. package/dist/flowir/canonical-hash.d.ts.map +1 -1
  45. package/dist/flowir/canonical-hash.js +6 -2
  46. package/dist/flowir/canonical-hash.js.map +1 -1
  47. package/dist/flowir/compile.d.ts.map +1 -1
  48. package/dist/flowir/compile.js +41 -2
  49. package/dist/flowir/compile.js.map +1 -1
  50. package/dist/flowir/index.js +1 -1
  51. package/dist/flowir/index.js.map +1 -1
  52. package/dist/flowir/meta.d.ts +6 -0
  53. package/dist/flowir/meta.d.ts.map +1 -1
  54. package/dist/flowir/schema.d.ts +9 -0
  55. package/dist/flowir/schema.d.ts.map +1 -1
  56. package/dist/flowir/schema.js +8 -0
  57. package/dist/flowir/schema.js.map +1 -1
  58. package/dist/flowir/translate.d.ts.map +1 -1
  59. package/dist/flowir/translate.js +32 -0
  60. package/dist/flowir/translate.js.map +1 -1
  61. package/dist/index.d.ts +1 -0
  62. package/dist/index.d.ts.map +1 -1
  63. package/dist/index.js +2 -0
  64. package/dist/index.js.map +1 -1
  65. package/dist/resources/execution.d.ts +9 -0
  66. package/dist/resources/execution.d.ts.map +1 -1
  67. package/dist/resources/execution.js +80 -0
  68. package/dist/resources/execution.js.map +1 -1
  69. package/dist/resources/file-transaction.d.ts +105 -0
  70. package/dist/resources/file-transaction.d.ts.map +1 -0
  71. package/dist/resources/file-transaction.js +781 -0
  72. package/dist/resources/file-transaction.js.map +1 -0
  73. package/dist/resources/journal.d.ts +39 -4
  74. package/dist/resources/journal.d.ts.map +1 -1
  75. package/dist/resources/journal.js +140 -11
  76. package/dist/resources/journal.js.map +1 -1
  77. package/dist/resources/types.d.ts +4 -0
  78. package/dist/resources/types.d.ts.map +1 -1
  79. package/dist/resources/types.js.map +1 -1
  80. package/dist/runtime/phases/script.d.ts +6 -0
  81. package/dist/runtime/phases/script.d.ts.map +1 -1
  82. package/dist/runtime/phases/script.js +6 -0
  83. package/dist/runtime/phases/script.js.map +1 -1
  84. package/dist/runtime.d.ts.map +1 -1
  85. package/dist/runtime.js +203 -14
  86. package/dist/runtime.js.map +1 -1
  87. package/dist/schema.d.ts +18 -0
  88. package/dist/schema.d.ts.map +1 -1
  89. package/dist/schema.js +30 -0
  90. package/dist/schema.js.map +1 -1
  91. package/dist/store.d.ts.map +1 -1
  92. package/dist/store.js +15 -37
  93. package/dist/store.js.map +1 -1
  94. package/dist/verifiers/discover.d.ts.map +1 -1
  95. package/dist/verifiers/discover.js +1 -17
  96. package/dist/verifiers/discover.js.map +1 -1
  97. package/dist/verifiers/effects-lint.d.ts +33 -0
  98. package/dist/verifiers/effects-lint.d.ts.map +1 -0
  99. package/dist/verifiers/effects-lint.js +77 -0
  100. package/dist/verifiers/effects-lint.js.map +1 -0
  101. package/dist/verifiers/index.d.ts +1 -0
  102. package/dist/verifiers/index.d.ts.map +1 -1
  103. package/dist/verifiers/index.js +3 -1
  104. package/dist/verifiers/index.js.map +1 -1
  105. package/dist/verify.d.ts +7 -1
  106. package/dist/verify.d.ts.map +1 -1
  107. package/dist/verify.js +3 -0
  108. package/dist/verify.js.map +1 -1
  109. package/package.json +1 -1
@@ -0,0 +1,41 @@
1
+ /** Closed TypeBox contract for EffectIR. Runtime authority still lives in resources/*. */
2
+ import { Type } from "typebox";
3
+ import { PathRefSchema } from "../resources/schema.js";
4
+ import { StringEnum } from "../typebox-helpers.js";
5
+ import { CONFIDENTIALITY_LABELS, EFFECT_KINDS, INTEGRITY_LABELS, } from "./types.js";
6
+ const ConfidentialitySchema = StringEnum(CONFIDENTIALITY_LABELS);
7
+ const IntegritySchema = StringEnum(INTEGRITY_LABELS);
8
+ const common = {
9
+ id: Type.String({ minLength: 1 }),
10
+ confidentiality: Type.Optional(ConfidentialitySchema),
11
+ integrity: Type.Optional(IntegritySchema),
12
+ purpose: Type.Optional(Type.String()),
13
+ };
14
+ const PathTargetSchema = Type.Object({ kind: Type.Literal("path"), path: PathRefSchema }, { additionalProperties: false });
15
+ const SecretTargetSchema = Type.Object({
16
+ kind: Type.Literal("secret"),
17
+ secret: Type.Object({
18
+ secretId: Type.String({ minLength: 1 }),
19
+ issuer: Type.Optional(Type.String({ minLength: 1 })),
20
+ }, { additionalProperties: false }),
21
+ }, { additionalProperties: false });
22
+ const ServiceTargetSchema = Type.Object({
23
+ kind: Type.Literal("service"),
24
+ service: Type.Object({
25
+ serviceId: Type.String({ minLength: 1 }),
26
+ operation: Type.Optional(Type.String({ minLength: 1 })),
27
+ }, { additionalProperties: false }),
28
+ }, { additionalProperties: false });
29
+ const fsKinds = EFFECT_KINDS.filter((kind) => kind.startsWith("fs."));
30
+ const ClosedEffectDeclSchema = Type.Union([
31
+ ...fsKinds.map((kind) => Type.Object({ ...common, kind: Type.Literal(kind), target: PathTargetSchema }, { additionalProperties: false })),
32
+ Type.Object({ ...common, kind: Type.Literal("secret.read"), target: SecretTargetSchema }, { additionalProperties: false }),
33
+ Type.Object({ ...common, kind: Type.Literal("service.call"), target: ServiceTargetSchema }, { additionalProperties: false }),
34
+ ]);
35
+ // PathRefSchema deliberately uses optional Never fields to encode XOR, which
36
+ // TypeBox validates correctly at runtime but currently infers as `never` when
37
+ // nested through a union. Preserve the closed runtime schema while exposing
38
+ // the independently reviewed EffectDecl TypeScript contract.
39
+ export const EffectDeclSchema = Type.Unsafe(ClosedEffectDeclSchema);
40
+ export const EffectIRSchema = Type.Object({ effects: Type.Array(EffectDeclSchema) }, { additionalProperties: false });
41
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/effects/schema.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAE1F,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,E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M,CAAa,sBAAsB,CAAC,CAAC;AAEhF,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,CAAC,MAAM,CACxC,EAAE,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,EAAE,EACzC,EAAE,oBAAoB,EAAE,KAAK,EAAE,CAC/B,CAAC"}
@@ -0,0 +1,93 @@
1
+ /**
2
+ * Trusted Effects (0.3 MVP) — pure type contract.
3
+ *
4
+ * EffectIR is the closed vocabulary of side effects a FlowIR node may declare.
5
+ * PathRef is reused from resources/*; SecretRef/ServiceRef are typed handles
6
+ * that fail closed until a real backend is bound (MVP: type + validation only).
7
+ *
8
+ * @see docs/internal/0.3.0-trusted-effects-mvp.md
9
+ */
10
+ import type { PathRef } from "../resources/schema.ts";
11
+ /** Confidentiality lattice (low → high). Higher may not flow to lower sinks. */
12
+ export declare const CONFIDENTIALITY_LABELS: readonly ["public", "internal", "secret"];
13
+ export type ConfidentialityLabel = (typeof CONFIDENTIALITY_LABELS)[number];
14
+ /** Integrity lattice (low → high). Lower integrity must not overwrite higher. */
15
+ export declare const INTEGRITY_LABELS: readonly ["untrusted", "project", "verified"];
16
+ export type IntegrityLabel = (typeof INTEGRITY_LABELS)[number];
17
+ export declare const CONFIDENTIALITY_RANK: Record<ConfidentialityLabel, number>;
18
+ export declare const INTEGRITY_RANK: Record<IntegrityLabel, number>;
19
+ /**
20
+ * Opaque secret handle — never carries secret material.
21
+ * MVP: validation only; no vault backend.
22
+ */
23
+ export interface SecretRef {
24
+ secretId: string;
25
+ issuer?: string;
26
+ }
27
+ /**
28
+ * External service endpoint handle — no ambient network authority from strings.
29
+ * MVP: validation only; no live adapter.
30
+ */
31
+ export interface ServiceRef {
32
+ serviceId: string;
33
+ /** Optional logical operation name (e.g. "createIssue"). */
34
+ operation?: string;
35
+ }
36
+ export type EffectTarget = {
37
+ kind: "path";
38
+ path: PathRef;
39
+ } | {
40
+ kind: "secret";
41
+ secret: SecretRef;
42
+ } | {
43
+ kind: "service";
44
+ service: ServiceRef;
45
+ };
46
+ export declare const EFFECT_KINDS: readonly ["fs.read", "fs.write", "fs.delete", "secret.read", "service.call"];
47
+ export type EffectKind = (typeof EFFECT_KINDS)[number];
48
+ /**
49
+ * One declared side effect on a FlowIR / phase node.
50
+ * `id` is stable within the flow for why-effect attribution.
51
+ */
52
+ export interface EffectDecl {
53
+ id: string;
54
+ kind: EffectKind;
55
+ target: EffectTarget;
56
+ confidentiality?: ConfidentialityLabel;
57
+ integrity?: IntegrityLabel;
58
+ /** Free-text purpose for why-* explainers (not authority). */
59
+ purpose?: string;
60
+ }
61
+ /** EffectIR: bag of effects attached to a node or whole flow. */
62
+ export interface EffectIR {
63
+ effects: EffectDecl[];
64
+ }
65
+ export interface WhyAuthorized {
66
+ effectId: string;
67
+ allowed: boolean;
68
+ principalId?: string;
69
+ capabilityBindingIds: string[];
70
+ reasons: string[];
71
+ }
72
+ export interface WhyContext {
73
+ effectId: string;
74
+ runId: string;
75
+ phaseId?: string;
76
+ confidentiality: ConfidentialityLabel;
77
+ integrity: IntegrityLabel;
78
+ workspaceRoot?: string;
79
+ reasons: string[];
80
+ }
81
+ export interface WhyEffect {
82
+ effectId: string;
83
+ kind: EffectKind;
84
+ targetSummary: string;
85
+ purpose?: string;
86
+ intentId?: string;
87
+ journalStatus?: string;
88
+ status: "declared" | "staged" | "committed" | "rejected" | "unknown" | "skipped";
89
+ reasons: string[];
90
+ authorized: WhyAuthorized;
91
+ context: WhyContext;
92
+ }
93
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/effects/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAMtD,gFAAgF;AAChF,eAAO,MAAM,sBAAsB,YAAI,QAAQ,EAAE,UAAU,EAAE,QAAQ,CAAU,CAAC;AAChF,MAAM,MAAM,oBAA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c,CAAC;IAC3B,8DAA8D;IAC9D,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,iEAAiE;AACjE,MAAM,WAAW,QAAQ;IACxB,OAAO,EAAE,UAAU,EAAE,CAAC;CACtB;AAMD,MAAM,WAAW,aAAa;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,OAAO,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,MAAM,WAAW,UAAU;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,oBAAoB,CAAC;IACtC,SAAS,EAAE,cAAc,CAAC;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,MAAM,WAAW,SAAS;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,UAAU,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,UAAU,GAAG,QAAQ,GAAG,WAAW,GAAG,UAAU,GAAG,SAAS,GAAG,SAAS,CAAC;IACjF,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,UAAU,EAAE,aAAa,CAAC;IAC1B,OAAO,EAAE,UAAU,CAAC;CACpB"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Trusted Effects (0.3 MVP) — pure type contract.
3
+ *
4
+ * EffectIR is the closed vocabulary of side effects a FlowIR node may declare.
5
+ * PathRef is reused from resources/*; SecretRef/ServiceRef are typed handles
6
+ * that fail closed until a real backend is bound (MVP: type + validation only).
7
+ *
8
+ * @see docs/internal/0.3.0-trusted-effects-mvp.md
9
+ */
10
+ // ---------------------------------------------------------------------------
11
+ // Information-flow labels (MVP fixed lattice)
12
+ // ---------------------------------------------------------------------------
13
+ /** Confidentiality lattice (low → high). Higher may not flow to lower sinks. */
14
+ export const CONFIDENTIALITY_LABELS = ["public", "internal", "secret"];
15
+ /** Integrity lattice (low → high). Lower integrity must not overwrite higher. */
16
+ export const INTEGRITY_LABELS = ["untrusted", "project", "verified"];
17
+ export const CONFIDENTIALITY_RANK = {
18
+ public: 0,
19
+ internal: 1,
20
+ secret: 2,
21
+ };
22
+ export const INTEGRITY_RANK = {
23
+ untrusted: 0,
24
+ project: 1,
25
+ verified: 2,
26
+ };
27
+ // ---------------------------------------------------------------------------
28
+ // Effect kinds (closed set for MVP)
29
+ // ---------------------------------------------------------------------------
30
+ export const EFFECT_KINDS = [
31
+ "fs.read",
32
+ "fs.write",
33
+ "fs.delete",
34
+ "secret.read",
35
+ "service.call",
36
+ ];
37
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/effects/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,8EAA8E;AAC9E,8CAA8C;AAC9C,8EAA8E;AAE9E,gFAAgF;AAChF,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,QAAQ,EAAE,UAAU,EAAE,QAAQ,CAAU,CAAC;AAGhF,iFAAiF;AACjF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,WAAW,EAAE,SAAS,EAAE,UAAU,CAAU,CAAC;AAG9E,MAAM,CAAC,MAAM,oBAAoB,GAAyC;IACzE,MAAM,EAAE,CAAC;IACT,QAAQ,EAAE,CAAC;IACX,MAAM,EAAE,CAAC;CACT,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAmC;IAC7D,SAAS,EAAE,CAAC;IACZ,OAAO,EAAE,CAAC;IACV,QAAQ,EAAE,CAAC;CACX,CAAC;AA8BF,8EAA8E;AAC9E,oCAAoC;AACpC,8EAA8E;AAE9E,MAAM,CAAC,MAAM,YAAY,GAAG;IAC3B,SAAS;IACT,UAAU;IACV,WAAW;IACX,aAAa;IACb,cAAc;CACL,CAAC"}
@@ -0,0 +1,103 @@
1
+ /**
2
+ * Static EffectIR validation: kinds, refs, labels, mutating-path overlap.
3
+ * Pure — no I/O.
4
+ */
5
+ import { type PathRef } from "../resources/schema.ts";
6
+ import { type EffectDecl, type EffectIR, type EffectKind, type SecretRef, type ServiceRef } from "./types.ts";
7
+ export interface EffectValidationIssue {
8
+ severity: "error" | "warning";
9
+ code: string;
10
+ message: string;
11
+ effectId?: string;
12
+ pathA?: string;
13
+ pathB?: string;
14
+ }
15
+ export interface EffectValidationResult {
16
+ ok: boolean;
17
+ issues: EffectValidationIssue[];
18
+ }
19
+ type ValidEffectRecord = Record<string, unknown> & {
20
+ id: string;
21
+ kind: EffectKind;
22
+ };
23
+ /** Extract portable relative path string from a PathRef for overlap checks. */
24
+ export declare function pathRefRelativeKey(pathRef: PathRef): string | undefined;
25
+ /**
26
+ * True if path A is the same as, a parent of, or a child of path B
27
+ * (portable `/` paths, no `..`).
28
+ */
29
+ export declare function pathsOverlap(a: string, b: string): boolean;
30
+ /**
31
+ * Validate an EffectIR bag: shape, labels, target/kind consistency, overlap.
32
+ */
33
+ export declare function validateEffectIR(ir: EffectIR | {
34
+ effects?: unknown;
35
+ }): EffectValidationResult;
36
+ export interface EffectFlowPhaseLike {
37
+ id?: unknown;
38
+ effects?: unknown;
39
+ dependsOn?: unknown;
40
+ from?: unknown;
41
+ type?: unknown;
42
+ def?: unknown;
43
+ use?: unknown;
44
+ final?: unknown;
45
+ }
46
+ export interface ComposedEffectFlowLike {
47
+ name?: unknown;
48
+ phases?: readonly EffectFlowPhaseLike[];
49
+ }
50
+ interface LabeledEffect {
51
+ label: string;
52
+ effect: ValidEffectRecord;
53
+ }
54
+ interface PhaseEffectSummary {
55
+ sources: LabeledEffect[];
56
+ sinks: LabeledEffect[];
57
+ }
58
+ export interface ComposedEffectFlowOptions {
59
+ resolveFlow?: (name: string) => ComposedEffectFlowLike | undefined;
60
+ /**
61
+ * Static gates (validateTaskflow / verifyTaskflow / FlowIR translate+compile)
62
+ * run without a flow store, so a `flow{use: <saved>}` child they cannot load
63
+ * degrades to the unknown-boundary summary (secret source + public sink).
64
+ * Legal saved-subflow compositions — e.g. a benign child followed by a
65
+ * declared write — then hard-fail even though the runtime, which resolves
66
+ * the name through `loadFlow`, accepts them. When this option is set, an
67
+ * unresolved `use` still emits the conservative unknown-boundary taint but
68
+ * reports it as advisory warnings (codes `unresolved-flow-use` /
69
+ * `unresolved-flow-use-taint`) instead of errors. Runtime admission (with
70
+ * `resolveFlow`) remains the authoritative fail-closed gate for real
71
+ * violations. Dynamic inline `def` boundaries are unaffected — they stay
72
+ * hard-tainted by design.
73
+ */
74
+ downgradeUnresolvedUse?: boolean;
75
+ }
76
+ /**
77
+ * Conservative DAG-wide label flow. Every source reachable through a phase's
78
+ * dependencies may influence that phase's sinks, including through unlabeled
79
+ * intermediate phases. This is a pure static check; conditional branches are
80
+ * intentionally not used to declassify data.
81
+ */
82
+ export declare function validateEffectFlow(phases: readonly EffectFlowPhaseLike[], dependencyIds?: (phase: EffectFlowPhaseLike) => readonly string[], phaseSummaries?: ReadonlyMap<string, PhaseEffectSummary>): EffectValidationResult;
83
+ /**
84
+ * Validate label flow across nested flow/expand boundaries. Child sources are
85
+ * summarized onto the parent node and child sinks receive the parent's
86
+ * dependency-reachable sources. Unresolved saved/dynamic children expose a
87
+ * maximally confidential source and public sink until runtime resolution.
88
+ * With {@link ComposedEffectFlowOptions.downgradeUnresolvedUse} set (static
89
+ * gates without a flow loader), unresolvable `flow{use}` boundaries report as
90
+ * advisory warnings instead of errors; runtime admission stays authoritative.
91
+ */
92
+ export declare function validateComposedEffectFlow(flow: ComposedEffectFlowLike, options?: ComposedEffectFlowOptions): EffectValidationResult;
93
+ /** Type guard for a well-formed SecretRef (no material). */
94
+ export declare function isSecretRef(v: unknown): v is SecretRef;
95
+ /** Type guard for ServiceRef. */
96
+ export declare function isServiceRef(v: unknown): v is ServiceRef;
97
+ /** Collect mutating path keys from effects (static literals only). */
98
+ export declare function collectMutatingPathKeys(effects: EffectDecl[]): Array<{
99
+ effectId: string;
100
+ pathKey: string;
101
+ }>;
102
+ export {};
103
+ //# sourceMappingURL=validate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/effects/validate.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAiC,KAAK,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAGrF,OAAO,EAON,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,KAAK,UAAU,EAEf,KAAK,SAAS,EACd,KAAK,UAAU,EACf,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,qBAAqB;IACrC,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,sBAAsB;IACtC,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,qBAAqB,EAAE,CAAC;CAChC;AAkBD,KAAK,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC;AAuDpF,+EAA+E;AAC/E,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CASvE;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAM1D;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