@smthrs/plan 0.0.0-stage → 1.0.0-rc.12

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 (209) hide show
  1. package/CHANGELOG.md +185 -0
  2. package/LICENSE +21 -0
  3. package/README.md +230 -2
  4. package/THIRD_PARTY_NOTICES.md +48 -0
  5. package/dist/cjs/CachePolicy.d.ts +131 -0
  6. package/dist/cjs/CachePolicy.d.ts.map +1 -0
  7. package/dist/cjs/CachePolicy.js +50 -0
  8. package/dist/cjs/CachePolicy.js.map +7 -0
  9. package/dist/cjs/Effects.d.ts +258 -0
  10. package/dist/cjs/Effects.d.ts.map +1 -0
  11. package/dist/cjs/Effects.js +76 -0
  12. package/dist/cjs/Effects.js.map +7 -0
  13. package/dist/cjs/FileSet.d.ts +366 -0
  14. package/dist/cjs/FileSet.d.ts.map +1 -0
  15. package/dist/cjs/FileSet.js +196 -0
  16. package/dist/cjs/FileSet.js.map +7 -0
  17. package/dist/cjs/GraphBuildError.d.ts +120 -0
  18. package/dist/cjs/GraphBuildError.d.ts.map +1 -0
  19. package/dist/cjs/GraphBuildError.js +71 -0
  20. package/dist/cjs/GraphBuildError.js.map +7 -0
  21. package/dist/cjs/KeyMaterial.d.ts +107 -0
  22. package/dist/cjs/KeyMaterial.d.ts.map +1 -0
  23. package/dist/cjs/KeyMaterial.js +64 -0
  24. package/dist/cjs/KeyMaterial.js.map +7 -0
  25. package/dist/cjs/Node.d.ts +677 -0
  26. package/dist/cjs/Node.d.ts.map +1 -0
  27. package/dist/cjs/Node.js +229 -0
  28. package/dist/cjs/Node.js.map +7 -0
  29. package/dist/cjs/Placement.d.ts +117 -0
  30. package/dist/cjs/Placement.d.ts.map +1 -0
  31. package/dist/cjs/Placement.js +46 -0
  32. package/dist/cjs/Placement.js.map +7 -0
  33. package/dist/cjs/Plan.d.ts +489 -0
  34. package/dist/cjs/Plan.d.ts.map +1 -0
  35. package/dist/cjs/Plan.js +511 -0
  36. package/dist/cjs/Plan.js.map +7 -0
  37. package/dist/cjs/PlanDiff.d.ts +77 -0
  38. package/dist/cjs/PlanDiff.d.ts.map +1 -0
  39. package/dist/cjs/PlanDiff.js +149 -0
  40. package/dist/cjs/PlanDiff.js.map +7 -0
  41. package/dist/cjs/Planned.d.ts +121 -0
  42. package/dist/cjs/Planned.d.ts.map +1 -0
  43. package/dist/cjs/Planned.js +72 -0
  44. package/dist/cjs/Planned.js.map +7 -0
  45. package/dist/cjs/Repetition.d.ts +31 -0
  46. package/dist/cjs/Repetition.d.ts.map +1 -0
  47. package/dist/cjs/Repetition.js +36 -0
  48. package/dist/cjs/Repetition.js.map +7 -0
  49. package/dist/cjs/Scheduling.d.ts +89 -0
  50. package/dist/cjs/Scheduling.d.ts.map +1 -0
  51. package/dist/cjs/Scheduling.js +76 -0
  52. package/dist/cjs/Scheduling.js.map +7 -0
  53. package/dist/cjs/StepKey.d.ts +354 -0
  54. package/dist/cjs/StepKey.d.ts.map +1 -0
  55. package/dist/cjs/StepKey.js +313 -0
  56. package/dist/cjs/StepKey.js.map +7 -0
  57. package/dist/cjs/index.d.ts +91 -0
  58. package/dist/cjs/index.d.ts.map +1 -0
  59. package/dist/cjs/index.js +59 -0
  60. package/dist/cjs/index.js.map +7 -0
  61. package/dist/cjs/internal/ConflictAnnotation.d.ts +59 -0
  62. package/dist/cjs/internal/ConflictAnnotation.d.ts.map +1 -0
  63. package/dist/cjs/internal/ConflictAnnotation.js +247 -0
  64. package/dist/cjs/internal/ConflictAnnotation.js.map +7 -0
  65. package/dist/cjs/internal/EffectCandidates.d.ts +19 -0
  66. package/dist/cjs/internal/EffectCandidates.d.ts.map +1 -0
  67. package/dist/cjs/internal/EffectCandidates.js +92 -0
  68. package/dist/cjs/internal/EffectCandidates.js.map +7 -0
  69. package/dist/cjs/internal/JsonMirror.d.ts +34 -0
  70. package/dist/cjs/internal/JsonMirror.d.ts.map +1 -0
  71. package/dist/cjs/internal/JsonMirror.js +195 -0
  72. package/dist/cjs/internal/JsonMirror.js.map +7 -0
  73. package/dist/cjs/internal/SchemaIdentity.d.ts +140 -0
  74. package/dist/cjs/internal/SchemaIdentity.d.ts.map +1 -0
  75. package/dist/cjs/internal/SchemaIdentity.js +718 -0
  76. package/dist/cjs/internal/SchemaIdentity.js.map +7 -0
  77. package/dist/cjs/internal/effects.d.ts +245 -0
  78. package/dist/cjs/internal/effects.d.ts.map +1 -0
  79. package/dist/cjs/internal/effects.js +290 -0
  80. package/dist/cjs/internal/effects.js.map +7 -0
  81. package/dist/cjs/internal/node.d.ts +526 -0
  82. package/dist/cjs/internal/node.d.ts.map +1 -0
  83. package/dist/cjs/internal/node.js +313 -0
  84. package/dist/cjs/internal/node.js.map +7 -0
  85. package/dist/cjs/package.json +1 -0
  86. package/dist/cjs/test/PlanFixtures.d.ts +127 -0
  87. package/dist/cjs/test/PlanFixtures.d.ts.map +1 -0
  88. package/dist/cjs/test/PlanFixtures.js +59 -0
  89. package/dist/cjs/test/PlanFixtures.js.map +7 -0
  90. package/dist/esm/CachePolicy.d.ts +131 -0
  91. package/dist/esm/CachePolicy.d.ts.map +1 -0
  92. package/dist/esm/CachePolicy.js +117 -0
  93. package/dist/esm/CachePolicy.js.map +1 -0
  94. package/dist/esm/Effects.d.ts +258 -0
  95. package/dist/esm/Effects.d.ts.map +1 -0
  96. package/dist/esm/Effects.js +178 -0
  97. package/dist/esm/Effects.js.map +1 -0
  98. package/dist/esm/FileSet.d.ts +366 -0
  99. package/dist/esm/FileSet.d.ts.map +1 -0
  100. package/dist/esm/FileSet.js +398 -0
  101. package/dist/esm/FileSet.js.map +1 -0
  102. package/dist/esm/GraphBuildError.d.ts +120 -0
  103. package/dist/esm/GraphBuildError.d.ts.map +1 -0
  104. package/dist/esm/GraphBuildError.js +145 -0
  105. package/dist/esm/GraphBuildError.js.map +1 -0
  106. package/dist/esm/KeyMaterial.d.ts +107 -0
  107. package/dist/esm/KeyMaterial.d.ts.map +1 -0
  108. package/dist/esm/KeyMaterial.js +92 -0
  109. package/dist/esm/KeyMaterial.js.map +1 -0
  110. package/dist/esm/Node.d.ts +677 -0
  111. package/dist/esm/Node.d.ts.map +1 -0
  112. package/dist/esm/Node.js +586 -0
  113. package/dist/esm/Node.js.map +1 -0
  114. package/dist/esm/Placement.d.ts +117 -0
  115. package/dist/esm/Placement.d.ts.map +1 -0
  116. package/dist/esm/Placement.js +65 -0
  117. package/dist/esm/Placement.js.map +1 -0
  118. package/dist/esm/Plan.d.ts +489 -0
  119. package/dist/esm/Plan.d.ts.map +1 -0
  120. package/dist/esm/Plan.js +718 -0
  121. package/dist/esm/Plan.js.map +1 -0
  122. package/dist/esm/PlanDiff.d.ts +77 -0
  123. package/dist/esm/PlanDiff.d.ts.map +1 -0
  124. package/dist/esm/PlanDiff.js +205 -0
  125. package/dist/esm/PlanDiff.js.map +1 -0
  126. package/dist/esm/Planned.d.ts +121 -0
  127. package/dist/esm/Planned.d.ts.map +1 -0
  128. package/dist/esm/Planned.js +147 -0
  129. package/dist/esm/Planned.js.map +1 -0
  130. package/dist/esm/Repetition.d.ts +31 -0
  131. package/dist/esm/Repetition.d.ts.map +1 -0
  132. package/dist/esm/Repetition.js +24 -0
  133. package/dist/esm/Repetition.js.map +1 -0
  134. package/dist/esm/Scheduling.d.ts +89 -0
  135. package/dist/esm/Scheduling.d.ts.map +1 -0
  136. package/dist/esm/Scheduling.js +82 -0
  137. package/dist/esm/Scheduling.js.map +1 -0
  138. package/dist/esm/StepKey.d.ts +354 -0
  139. package/dist/esm/StepKey.d.ts.map +1 -0
  140. package/dist/esm/StepKey.js +503 -0
  141. package/dist/esm/StepKey.js.map +1 -0
  142. package/dist/esm/index.d.ts +91 -0
  143. package/dist/esm/index.d.ts.map +1 -0
  144. package/dist/esm/index.js +91 -0
  145. package/dist/esm/index.js.map +1 -0
  146. package/dist/esm/internal/ConflictAnnotation.d.ts +59 -0
  147. package/dist/esm/internal/ConflictAnnotation.d.ts.map +1 -0
  148. package/dist/esm/internal/ConflictAnnotation.js +332 -0
  149. package/dist/esm/internal/ConflictAnnotation.js.map +1 -0
  150. package/dist/esm/internal/EffectCandidates.d.ts +19 -0
  151. package/dist/esm/internal/EffectCandidates.d.ts.map +1 -0
  152. package/dist/esm/internal/EffectCandidates.js +86 -0
  153. package/dist/esm/internal/EffectCandidates.js.map +1 -0
  154. package/dist/esm/internal/JsonMirror.d.ts +34 -0
  155. package/dist/esm/internal/JsonMirror.d.ts.map +1 -0
  156. package/dist/esm/internal/JsonMirror.js +204 -0
  157. package/dist/esm/internal/JsonMirror.js.map +1 -0
  158. package/dist/esm/internal/SchemaIdentity.d.ts +140 -0
  159. package/dist/esm/internal/SchemaIdentity.d.ts.map +1 -0
  160. package/dist/esm/internal/SchemaIdentity.js +1002 -0
  161. package/dist/esm/internal/SchemaIdentity.js.map +1 -0
  162. package/dist/esm/internal/effects.d.ts +245 -0
  163. package/dist/esm/internal/effects.d.ts.map +1 -0
  164. package/dist/esm/internal/effects.js +459 -0
  165. package/dist/esm/internal/effects.js.map +1 -0
  166. package/dist/esm/internal/node.d.ts +526 -0
  167. package/dist/esm/internal/node.d.ts.map +1 -0
  168. package/dist/esm/internal/node.js +565 -0
  169. package/dist/esm/internal/node.js.map +1 -0
  170. package/dist/esm/test/PlanFixtures.d.ts +127 -0
  171. package/dist/esm/test/PlanFixtures.d.ts.map +1 -0
  172. package/dist/esm/test/PlanFixtures.js +60 -0
  173. package/dist/esm/test/PlanFixtures.js.map +1 -0
  174. package/docs/README.md +167 -0
  175. package/docs/api.md +1485 -0
  176. package/docs/concepts/authoring-ast.md +204 -0
  177. package/docs/concepts/effects-and-conflicts.md +135 -0
  178. package/docs/concepts/plan-value.md +168 -0
  179. package/docs/concepts/step-keys.md +179 -0
  180. package/docs/guides/author-a-node-graph.md +182 -0
  181. package/docs/guides/compile-a-plan.md +146 -0
  182. package/docs/guides/declare-file-effects.md +143 -0
  183. package/docs/guides/diff-two-plans.md +310 -0
  184. package/docs/installation.md +75 -0
  185. package/docs/quickstart.md +128 -0
  186. package/docs/testing.md +73 -0
  187. package/docs/troubleshooting.md +314 -0
  188. package/package.json +255 -3
  189. package/src/CachePolicy.ts +143 -0
  190. package/src/Effects.ts +302 -0
  191. package/src/FileSet.ts +493 -0
  192. package/src/GraphBuildError.ts +156 -0
  193. package/src/KeyMaterial.ts +111 -0
  194. package/src/Node.ts +969 -0
  195. package/src/Placement.ts +99 -0
  196. package/src/Plan.ts +911 -0
  197. package/src/PlanDiff.ts +244 -0
  198. package/src/Planned.ts +208 -0
  199. package/src/Repetition.ts +33 -0
  200. package/src/Scheduling.ts +154 -0
  201. package/src/StepKey.ts +736 -0
  202. package/src/index.ts +103 -0
  203. package/src/internal/ConflictAnnotation.ts +374 -0
  204. package/src/internal/EffectCandidates.ts +89 -0
  205. package/src/internal/JsonMirror.ts +255 -0
  206. package/src/internal/SchemaIdentity.ts +1096 -0
  207. package/src/internal/effects.ts +543 -0
  208. package/src/internal/node.ts +859 -0
  209. package/src/test/PlanFixtures.ts +76 -0
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Shared ready-work admission policy. This module decides priority, aging,
3
+ * deterministic ties, and step/agent capacity. It does not decide which nodes
4
+ * are ready, evaluate branches, launch effects, or own execution lifetimes.
5
+ * Those decisions must use the compiled graph and the caller's activation
6
+ * state before presenting candidates here.
7
+ *
8
+ * @since 1.0.0
9
+ */
10
+ import type * as Plan from "./Plan.ts";
11
+ /**
12
+ * Admission limits, independent of graph width and provider capacity.
13
+ * Omitted limits are unbounded within JavaScript's safe-integer range.
14
+ *
15
+ * @since 1.0.0
16
+ * @category models
17
+ */
18
+ export interface Concurrency {
19
+ readonly steps?: number | undefined;
20
+ readonly agents?: number | undefined;
21
+ }
22
+ /**
23
+ * Currently held permits. Every agent also holds a step permit.
24
+ *
25
+ * @since 1.0.0
26
+ * @category models
27
+ */
28
+ export interface Usage {
29
+ readonly steps: number;
30
+ readonly agents: number;
31
+ }
32
+ /**
33
+ * The part of a plan node admission reads. Declared once here so the three
34
+ * places that name it, {@link Candidate}, {@link Admission} and
35
+ * {@link Policy.admit}, cannot drift apart.
36
+ */
37
+ type Schedulable = Pick<Plan.PlanNode, "id" | "kind" | "priority">;
38
+ /**
39
+ * A ready node's scheduling state. `order` is its position in the compiled
40
+ * plan, not arrival order. `waited` counts capacity-constrained admission
41
+ * passes, not wall-clock time.
42
+ *
43
+ * @since 1.0.0
44
+ * @category models
45
+ */
46
+ export interface Candidate<N extends Schedulable = Plan.PlanNode> {
47
+ readonly node: N;
48
+ readonly order: number;
49
+ readonly waited: number;
50
+ }
51
+ /**
52
+ * One admission decision. Deferred candidates carry their incremented age;
53
+ * admitted candidates retain their age for dispatch diagnostics. No input is
54
+ * mutated and neither array owns or freezes the caller's node values.
55
+ *
56
+ * @since 1.0.0
57
+ * @category models
58
+ */
59
+ export interface Admission<N extends Schedulable = Plan.PlanNode> {
60
+ readonly admitted: ReadonlyArray<Candidate<N>>;
61
+ readonly deferred: ReadonlyArray<Candidate<N>>;
62
+ readonly agents: number;
63
+ }
64
+ /**
65
+ * Pure policy shared by execution coordinators.
66
+ *
67
+ * @since 1.0.0
68
+ * @category models
69
+ */
70
+ export interface Policy {
71
+ readonly limits: Usage;
72
+ readonly admit: <N extends Schedulable>(ready: ReadonlyArray<Candidate<N>>, active: Usage) => Admission<N>;
73
+ }
74
+ /**
75
+ * Snapshots validated limits. Admission orders by declared priority plus age,
76
+ * using exact integer arithmetic even when their sum exceeds MAX_SAFE_INTEGER.
77
+ * Ties preserve compiled plan order. An agent blocked by its subset cap does
78
+ * not prevent ordinary ready work from using spare step capacity.
79
+ *
80
+ * Invalid candidate/permit state is refused before any decision is returned.
81
+ * At MAX_SAFE_INTEGER the age saturates; a bounded plan cannot require that
82
+ * many capacity-constrained passes to drain finite work.
83
+ *
84
+ * @since 1.0.0
85
+ * @category constructors
86
+ */
87
+ export declare const make: (concurrency?: Concurrency) => Policy;
88
+ export {};
89
+ //# sourceMappingURL=Scheduling.d.ts.map
@@ -0,0 +1 @@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AW,EACpC,KAAK,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAClC,MAAM,EAAE,KAAK,KACV,SAAS,CAAC,CAAC,CAAC,CAAA;CAClB;AASD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,IAAI,GAAI,cAAa,WAAgB,KAAG,MAiDpD,CAAA"}
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var Scheduling_exports = {};
20
+ __export(Scheduling_exports, {
21
+ make: () => make
22
+ });
23
+ module.exports = __toCommonJS(Scheduling_exports);
24
+ const integer = (name, value, minimum) => {
25
+ if (!Number.isSafeInteger(value) || value < minimum) {
26
+ throw new RangeError(`${name} must be a ${minimum === 1 ? "positive" : "non-negative"} safe integer`);
27
+ }
28
+ return value;
29
+ };
30
+ const make = (concurrency = {}) => {
31
+ const limits = Object.freeze({
32
+ steps: integer("concurrency.steps", concurrency.steps ?? Number.MAX_SAFE_INTEGER, 1),
33
+ agents: integer("concurrency.agents", concurrency.agents ?? Number.MAX_SAFE_INTEGER, 1)
34
+ });
35
+ const admit = (ready, active) => {
36
+ integer("active.steps", active.steps, 0);
37
+ integer("active.agents", active.agents, 0);
38
+ if (active.agents > active.steps) throw new RangeError("active.agents cannot exceed active.steps");
39
+ const ids = /* @__PURE__ */ new Set();
40
+ const positions = /* @__PURE__ */ new Set();
41
+ const ranked = ready.map((candidate) => {
42
+ const { node, order, waited } = candidate;
43
+ integer("candidate.order", order, 0);
44
+ integer("candidate.waited", waited, 0);
45
+ if (!Number.isSafeInteger(node.priority)) throw new RangeError("candidate.priority must be a safe integer");
46
+ if (node.kind !== "step" && node.kind !== "agent" && node.kind !== "merge") {
47
+ throw new RangeError("invalid candidate kind");
48
+ }
49
+ if (typeof node.id !== "string" || node.id === "" || ids.has(node.id)) {
50
+ throw new RangeError("candidate ids must be non-empty and unique");
51
+ }
52
+ if (positions.has(order)) throw new RangeError("candidate plan positions must be unique");
53
+ ids.add(node.id);
54
+ positions.add(order);
55
+ return { candidate, priority: BigInt(node.priority) + BigInt(waited) };
56
+ });
57
+ ranked.sort(
58
+ (left, right) => left.priority === right.priority ? left.candidate.order - right.candidate.order : left.priority > right.priority ? -1 : 1
59
+ );
60
+ const admitted = [];
61
+ const deferred = [];
62
+ let agents = 0;
63
+ for (const { candidate } of ranked) {
64
+ const isAgent = candidate.node.kind === "agent";
65
+ if (admitted.length >= limits.steps - active.steps || isAgent && agents >= limits.agents - active.agents) {
66
+ deferred.push(Object.freeze({ ...candidate, waited: Math.min(Number.MAX_SAFE_INTEGER, candidate.waited + 1) }));
67
+ } else {
68
+ admitted.push(Object.freeze({ ...candidate }));
69
+ if (isAgent) agents++;
70
+ }
71
+ }
72
+ return Object.freeze({ admitted: Object.freeze(admitted), deferred: Object.freeze(deferred), agents });
73
+ };
74
+ return Object.freeze({ limits, admit });
75
+ };
76
+ //# sourceMappingURL=Scheduling.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/Scheduling.ts"],
4
+ "sourcesContent": ["/**\n * Shared ready-work admission policy. This module decides priority, aging,\n * deterministic ties, and step/agent capacity. It does not decide which nodes\n * are ready, evaluate branches, launch effects, or own execution lifetimes.\n * Those decisions must use the compiled graph and the caller's activation\n * state before presenting candidates here.\n *\n * @since 1.0.0\n */\n\nimport type * as Plan from \"./Plan.ts\"\n\n/**\n * Admission limits, independent of graph width and provider capacity.\n * Omitted limits are unbounded within JavaScript's safe-integer range.\n *\n * @since 1.0.0\n * @category models\n */\nexport interface Concurrency {\n readonly steps?: number | undefined\n readonly agents?: number | undefined\n}\n\n/**\n * Currently held permits. Every agent also holds a step permit.\n *\n * @since 1.0.0\n * @category models\n */\nexport interface Usage {\n readonly steps: number\n readonly agents: number\n}\n\n/**\n * The part of a plan node admission reads. Declared once here so the three\n * places that name it, {@link Candidate}, {@link Admission} and\n * {@link Policy.admit}, cannot drift apart.\n */\ntype Schedulable = Pick<Plan.PlanNode, \"id\" | \"kind\" | \"priority\">\n\n/**\n * A ready node's scheduling state. `order` is its position in the compiled\n * plan, not arrival order. `waited` counts capacity-constrained admission\n * passes, not wall-clock time.\n *\n * @since 1.0.0\n * @category models\n */\nexport interface Candidate<N extends Schedulable = Plan.PlanNode> {\n readonly node: N\n readonly order: number\n readonly waited: number\n}\n\n/**\n * One admission decision. Deferred candidates carry their incremented age;\n * admitted candidates retain their age for dispatch diagnostics. No input is\n * mutated and neither array owns or freezes the caller's node values.\n *\n * @since 1.0.0\n * @category models\n */\nexport interface Admission<N extends Schedulable = Plan.PlanNode> {\n readonly admitted: ReadonlyArray<Candidate<N>>\n readonly deferred: ReadonlyArray<Candidate<N>>\n readonly agents: number\n}\n\n/**\n * Pure policy shared by execution coordinators.\n *\n * @since 1.0.0\n * @category models\n */\nexport interface Policy {\n readonly limits: Usage\n readonly admit: <N extends Schedulable>(\n ready: ReadonlyArray<Candidate<N>>,\n active: Usage\n ) => Admission<N>\n}\n\nconst integer = (name: string, value: number, minimum: number): number => {\n if (!Number.isSafeInteger(value) || value < minimum) {\n throw new RangeError(`${name} must be a ${minimum === 1 ? \"positive\" : \"non-negative\"} safe integer`)\n }\n return value\n}\n\n/**\n * Snapshots validated limits. Admission orders by declared priority plus age,\n * using exact integer arithmetic even when their sum exceeds MAX_SAFE_INTEGER.\n * Ties preserve compiled plan order. An agent blocked by its subset cap does\n * not prevent ordinary ready work from using spare step capacity.\n *\n * Invalid candidate/permit state is refused before any decision is returned.\n * At MAX_SAFE_INTEGER the age saturates; a bounded plan cannot require that\n * many capacity-constrained passes to drain finite work.\n *\n * @since 1.0.0\n * @category constructors\n */\nexport const make = (concurrency: Concurrency = {}): Policy => {\n const limits = Object.freeze({\n steps: integer(\"concurrency.steps\", concurrency.steps ?? Number.MAX_SAFE_INTEGER, 1),\n agents: integer(\"concurrency.agents\", concurrency.agents ?? Number.MAX_SAFE_INTEGER, 1)\n })\n const admit: Policy[\"admit\"] = (ready, active) => {\n integer(\"active.steps\", active.steps, 0)\n integer(\"active.agents\", active.agents, 0)\n if (active.agents > active.steps) throw new RangeError(\"active.agents cannot exceed active.steps\")\n const ids = new Set<string>()\n const positions = new Set<number>()\n const ranked = ready.map((candidate) => {\n const { node, order, waited } = candidate\n integer(\"candidate.order\", order, 0)\n integer(\"candidate.waited\", waited, 0)\n if (!Number.isSafeInteger(node.priority)) throw new RangeError(\"candidate.priority must be a safe integer\")\n if (node.kind !== \"step\" && node.kind !== \"agent\" && node.kind !== \"merge\") {\n throw new RangeError(\"invalid candidate kind\")\n }\n if (typeof node.id !== \"string\" || node.id === \"\" || ids.has(node.id)) {\n throw new RangeError(\"candidate ids must be non-empty and unique\")\n }\n if (positions.has(order)) throw new RangeError(\"candidate plan positions must be unique\")\n ids.add(node.id)\n positions.add(order)\n return { candidate, priority: BigInt(node.priority) + BigInt(waited) }\n })\n ranked.sort((left, right) =>\n left.priority === right.priority\n ? left.candidate.order - right.candidate.order\n : left.priority > right.priority\n ? -1\n : 1\n )\n const admitted: Array<typeof ready[number]> = []\n const deferred: Array<typeof ready[number]> = []\n let agents = 0\n for (const { candidate } of ranked) {\n const isAgent = candidate.node.kind === \"agent\"\n if (admitted.length >= limits.steps - active.steps || (isAgent && agents >= limits.agents - active.agents)) {\n deferred.push(Object.freeze({ ...candidate, waited: Math.min(Number.MAX_SAFE_INTEGER, candidate.waited + 1) }))\n } else {\n admitted.push(Object.freeze({ ...candidate }))\n if (isAgent) agents++\n }\n }\n return Object.freeze({ admitted: Object.freeze(admitted), deferred: Object.freeze(deferred), agents })\n }\n return Object.freeze({ limits, admit })\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAoFA,MAAM,UAAU,CAAC,MAAc,OAAe,YAA4B;AACxE,MAAI,CAAC,OAAO,cAAc,KAAK,KAAK,QAAQ,SAAS;AACnD,UAAM,IAAI,WAAW,GAAG,IAAI,cAAc,YAAY,IAAI,aAAa,cAAc,eAAe;AAAA,EACtG;AACA,SAAO;AACT;AAeO,MAAM,OAAO,CAAC,cAA2B,CAAC,MAAc;AAC7D,QAAM,SAAS,OAAO,OAAO;AAAA,IAC3B,OAAO,QAAQ,qBAAqB,YAAY,SAAS,OAAO,kBAAkB,CAAC;AAAA,IACnF,QAAQ,QAAQ,sBAAsB,YAAY,UAAU,OAAO,kBAAkB,CAAC;AAAA,EACxF,CAAC;AACD,QAAM,QAAyB,CAAC,OAAO,WAAW;AAChD,YAAQ,gBAAgB,OAAO,OAAO,CAAC;AACvC,YAAQ,iBAAiB,OAAO,QAAQ,CAAC;AACzC,QAAI,OAAO,SAAS,OAAO,MAAO,OAAM,IAAI,WAAW,0CAA0C;AACjG,UAAM,MAAM,oBAAI,IAAY;AAC5B,UAAM,YAAY,oBAAI,IAAY;AAClC,UAAM,SAAS,MAAM,IAAI,CAAC,cAAc;AACtC,YAAM,EAAE,MAAM,OAAO,OAAO,IAAI;AAChC,cAAQ,mBAAmB,OAAO,CAAC;AACnC,cAAQ,oBAAoB,QAAQ,CAAC;AACrC,UAAI,CAAC,OAAO,cAAc,KAAK,QAAQ,EAAG,OAAM,IAAI,WAAW,2CAA2C;AAC1G,UAAI,KAAK,SAAS,UAAU,KAAK,SAAS,WAAW,KA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eyMaterial → step-key compiler.
3
+ *
4
+ * Revived from the deleted `packages/smithers/flows/keys/src/StepKey.ts`. Two
5
+ * deliberate deviations from the original:
6
+ *
7
+ * 1. **It lives here, not in `@smthrs/keys`.** That package owns generic
8
+ * derivation and stored-key validation; a compiler that understands plan
9
+ * material belongs above it.
10
+ * 2. **It produces `@smthrs/keys` `StoredKey` values, not a second `sk1_` digest
11
+ * format.** The original minted its own prefix over a private `Digest`
12
+ * module. The engine dispatches under `StoredKey` (`FlowEngine/ActionKey.ts`),
13
+ * so a plan whose node keys were a *different* string format could never be
14
+ * the thing the cache is consulted against, and that is the whole point of
15
+ * a `Plan`. One key format, one hashing
16
+ * chokepoint (canonical JSON + injected `Crypto`), one namespace field
17
+ * (`kind`) distinguishing content keys from ordinal ones.
18
+ *
19
+ * Everything the original earned is kept: nominally branded digest inputs (a
20
+ * literal that merely *looks* like `{digest}` hashes as a literal), set
21
+ * normalization, the separate environment namespace, per-variant tagging of
22
+ * resolved references, and the hashed `version`.
23
+ *
24
+ * Governing contract: the step-key rules at
25
+ * https://github.com/smithersai/smithers/blob/main/packages/smithers/flows/plan/docs/concepts/step-keys.md.
26
+ *
27
+ * @since 0.1.0
28
+ */
29
+ import { type StoredKey } from "@smthrs/keys";
30
+ import * as Cause from "effect/Cause";
31
+ import type * as Crypto from "effect/Crypto";
32
+ import * as Effect from "effect/Effect";
33
+ import * as Schema from "effect/Schema";
34
+ import type * as FileSet from "./FileSet.ts";
35
+ import type * as KeyMaterial from "./KeyMaterial.ts";
36
+ /**
37
+ * A computed step key. Identical in representation to any other flow key —
38
+ * `key1_` plus a SHA-256 digest of the canonical serialization of the material.
39
+ *
40
+ * @since 0.1.0
41
+ * @category models
42
+ */
43
+ export type StepKey = StoredKey;
44
+ /**
45
+ * The nominal brand carried by every {@link DigestInput}. Kept private: the
46
+ * only way to produce a value bearing it is {@link digestInput}, so a plain
47
+ * value that merely happens to look like `{ digest: "..." }` — actions pass
48
+ * content hashes around as ordinary data — can never be mistaken for a genuine
49
+ * upstream-result digest reference. This closes a step-key collision where
50
+ * shape-sniffing (`"digest" in value`) hashed the two identically.
51
+ *
52
+ * @since 0.1.0
53
+ * @category symbols
54
+ */
55
+ declare const DigestInputTypeId: unique symbol;
56
+ /**
57
+ * Which kind of graph reference a {@link DigestInput} stands for. Declared
58
+ * once here so the field on `DigestInput` and the parameter of
59
+ * {@link digestInput} name one set and cannot drift apart.
60
+ */
61
+ type GraphReference = "ref" | "pending" | "ref-projected";
62
+ /**
63
+ * A precomputed digest supplied as a step input rather than a literal value.
64
+ *
65
+ * @since 0.1.0
66
+ * @category models
67
+ */
68
+ export interface DigestInput {
69
+ readonly [DigestInputTypeId]: typeof DigestInputTypeId;
70
+ readonly digest: string;
71
+ /**
72
+ * Which kind of graph reference resolved to this digest.
73
+ *
74
+ * Carrying the discriminator on the digest input keeps `normalizeInputs` the
75
+ * single normalizer: it wraps every variant once, and the variants stay
76
+ * mutually distinct because they differ in this field rather than in a
77
+ * hand-built object a second wrap would hide.
78
+ */
79
+ readonly reference?: GraphReference;
80
+ /** The projection applied to the referenced result, for `ref-projected`. */
81
+ readonly path?: ReadonlyArray<string>;
82
+ }
83
+ /**
84
+ * Nominally tags a precomputed digest so it is hashed as a digest reference
85
+ * rather than a literal value.
86
+ *
87
+ * @param digest - The precomputed digest.
88
+ * @param reference - Which graph reference resolved to the digest, and the
89
+ * projection path for `ref-projected`. Omit for a plain digest.
90
+ * @returns The tagged digest input.
91
+ * @since 0.1.0
92
+ * @category constructors
93
+ */
94
+ export declare const digestInput: (digest: string, reference?: {
95
+ readonly reference: GraphReference;
96
+ readonly path?: ReadonlyArray<string>;
97
+ }) => DigestInput;
98
+ /**
99
+ * Type guard for values produced by {@link digestInput}. A plain object
100
+ * shaped like `{ digest: "..." }` is not one.
101
+ *
102
+ * @param value - Any value.
103
+ * @returns `true` only for a value carrying the private digest-input brand.
104
+ * @since 0.1.0
105
+ * @category guards
106
+ */
107
+ export declare const isDigestInput: (value: unknown) => value is DigestInput;
108
+ /**
109
+ * The engine-resolved execution environment a content key is computed under,
110
+ * hashed in its OWN namespace rather than merged into the caller's `layers`
111
+ * and `capabilities`.
112
+ *
113
+ * Three properties matter and none survives a merge:
114
+ *
115
+ * 1. **Non-aliasing.** Concatenating environment material onto the caller's
116
+ * made `caller{fs:["a"]} + env{fs:["b"]}` hash identically to
117
+ * `caller{fs:["a","b"]} + env{}` — a cross-run collision in the very
118
+ * material whose purpose is preventing one.
119
+ * 2. **Declared vs undeclared.** `declared: false` is not the same value as
120
+ * `declared: true` with empty sets.
121
+ * 3. **Composition order.** Environment layers retain declaration order,
122
+ * because plugin and service composition order can change behavior. The
123
+ * caller-owned `ContentIdentity.layers` stays set-normalized.
124
+ *
125
+ * `runScope` is set only when `declared` is `false`: it pins the key to one
126
+ * run, so a step whose environment identity is unknown can never serve a
127
+ * cross-run hit. The union enforces this for typed callers; both
128
+ * {@link content} and {@link dispatchIdentity} validate it at run time.
129
+ *
130
+ * @since 0.1.0
131
+ * @category models
132
+ */
133
+ export type EnvironmentIdentity = typeof EnvironmentIdentity.Type;
134
+ /**
135
+ * Validated, copyable runtime environment identity. Layer order matters;
136
+ * capability patterns are set-like. Unknown fields are not identity material.
137
+ * @since 1.0.0
138
+ * @category schemas
139
+ */
140
+ export declare const EnvironmentIdentity: Schema.Union<readonly [Schema.Struct<{
141
+ readonly declared: Schema.Literal<true>;
142
+ readonly layers: Schema.$Array<Schema.String>;
143
+ readonly capabilities: Schema.$Record<Schema.String, Schema.$Array<Schema.String>>;
144
+ readonly runScope: Schema.optionalKey<Schema.Undefined>;
145
+ }>, Schema.Struct<{
146
+ readonly declared: Schema.Literal<false>;
147
+ readonly layers: Schema.$Array<Schema.String>;
148
+ readonly capabilities: Schema.$Record<Schema.String, Schema.$Array<Schema.String>>;
149
+ readonly runScope: Schema.NonEmptyString;
150
+ }>]>;
151
+ /**
152
+ * Caller-owned memoization context for projected dependency-value digests.
153
+ *
154
+ * This is the flows counterpart of Bazel's `ActionKeyContext`: one context is
155
+ * passed through related key computations so shared input material is hashed
156
+ * once. Concurrent requests for the same projection share the in-flight
157
+ * digest. Entries are sound only while each settled `from` value is immutable;
158
+ * callers must create a fresh memo when those values can change.
159
+ *
160
+ * `digest(from, path, compute)` runs `compute` once per address and shares its
161
+ * result with concurrent callers. A failed or interrupted computation is not
162
+ * kept: the next caller recomputes, and a waiter whose leader was interrupted
163
+ * becomes the new leader instead of inheriting the interrupt.
164
+ *
165
+ * @since 0.1.0
166
+ * @category models
167
+ */
168
+ export interface DigestMemo {
169
+ readonly digest: (from: string, path: ReadonlyArray<string>, compute: Effect.Effect<StepKey, Schema.SchemaError, Crypto.Crypto>) => Effect.Effect<StepKey, Schema.SchemaError, Crypto.Crypto>;
170
+ }
171
+ /**
172
+ * Creates an empty projected-value digest memo. Projection addresses are
173
+ * JSON-encoded `[from, path]` tuples so segment boundaries are unambiguous.
174
+ *
175
+ * @returns A memo with no entries.
176
+ * @since 0.1.0
177
+ * @category constructors
178
+ */
179
+ export declare const makeDigestMemo: () => DigestMemo;
180
+ /**
181
+ * Material describing a sealed or hermetic content-addressed step.
182
+ *
183
+ * @since 0.1.0
184
+ * @category models
185
+ */
186
+ export interface ContentIdentity {
187
+ readonly body: unknown;
188
+ readonly inputs: Readonly<Record<string, unknown | DigestInput>>;
189
+ readonly layers: ReadonlyArray<string>;
190
+ readonly capabilities: Readonly<Record<string, ReadonlyArray<string>>>;
191
+ readonly environment?: EnvironmentIdentity | undefined;
192
+ readonly hermetic?: {
193
+ readonly readSet: ReadonlyArray<{
194
+ readonly path: string;
195
+ readonly digest: string;
196
+ }>;
197
+ readonly writeSet: ReadonlyArray<FileSet.Entry>;
198
+ readonly removes?: ReadonlyArray<string> | undefined;
199
+ readonly boundaryMode: FileSet.BoundaryMode;
200
+ } | undefined;
201
+ }
202
+ /**
203
+ * Material describing the run-local identity of a non-cacheable step.
204
+ *
205
+ * @since 0.1.0
206
+ * @category models
207
+ */
208
+ export interface OrdinalIdentity {
209
+ readonly runId: string;
210
+ readonly parentScope?: string | undefined;
211
+ readonly ordinal: number;
212
+ readonly tier: "compensable" | "irreversible" | "unsealed";
213
+ }
214
+ declare const KeyMaterialError_base: Schema.Class<KeyMaterialError, Schema.TaggedStruct<"@smthrs/plan/KeyMaterialError", {
215
+ readonly code: Schema.Literals<readonly ["invalid_environment", "missing_dependency", "non_content_material"]>;
216
+ readonly message: Schema.String;
217
+ }>, Cause.YieldableError>;
218
+ /**
219
+ * Stable failures while deriving a key. `code` names the rule:
220
+ *
221
+ * - `invalid_environment`: an {@link EnvironmentIdentity} that is neither
222
+ * declared nor run-scoped.
223
+ * - `missing_dependency`: a `Ref` or `Pending` input names a node with no
224
+ * recorded digest, or, at dispatch, a `Ref` names one with no settled
225
+ * result.
226
+ * - `non_content_material`: a content-key constructor received material whose
227
+ * tier is not `sealed`.
228
+ *
229
+ * @since 0.1.0
230
+ * @category errors
231
+ */
232
+ export declare class KeyMaterialError extends KeyMaterialError_base {
233
+ }
234
+ /**
235
+ * Fingerprint for binding one execution to its runtime environment, not an
236
+ * action dispatch key. Uses the same normalization as content/dispatch keys.
237
+ * An omitted environment is distinct from declared-empty and run-scoped ones.
238
+ * @since 1.0.0
239
+ * @category constructors
240
+ */
241
+ export declare const environmentIdentity: (environment?: EnvironmentIdentity) => Effect.Effect<StoredKey, KeyMaterialError | Schema.SchemaError, Crypto.Crypto>;
242
+ /**
243
+ * Produces a cross-run reusable key for a sealed or hermetic step. Set-like
244
+ * declarations are normalized before serialization; write declarations remain
245
+ * part of the identity even when the step writes nothing.
246
+ *
247
+ * @param identity - The step's content material.
248
+ * @returns The content key. Fails with `invalid_environment` for a malformed
249
+ * environment, or `SchemaError` when the material cannot be serialized.
250
+ * @since 0.1.0
251
+ * @category constructors
252
+ */
253
+ export declare const content: (identity: ContentIdentity) => Effect.Effect<StepKey, KeyMaterialError | Schema.SchemaError, Crypto.Crypto>;
254
+ /**
255
+ * Produces a run-local ordinal key for compensable, irreversible, or unsealed
256
+ * work. These keys intentionally cannot be reused across runs.
257
+ *
258
+ * @param identity - The run id, optional parent scope, ordinal, and tier.
259
+ * @returns The ordinal key.
260
+ * @since 0.1.0
261
+ * @category constructors
262
+ */
263
+ export declare const ordinal: (identity: OrdinalIdentity) => Effect.Effect<StepKey, Schema.SchemaError, Crypto.Crypto>;
264
+ /**
265
+ * Resolves graph-local references to dependency digests and constructs a
266
+ * sealed content key. Use {@link planIdentity} to compile any effect tier.
267
+ *
268
+ * This is the handoff the Flow Builder Brief describes: the planner hands over
269
+ * a topologically ordered sequence of `{ nodeId, material }`, and for each one
270
+ * the compiler substitutes every `Ref`/`Pending` with the *already computed
271
+ * key of the referenced node*. Structural node ids are lookup addresses only
272
+ * and never enter the hashed value — rename a node and nothing re-keys; change
273
+ * what a node consumes and everything downstream of it does.
274
+ *
275
+ * @param material - The node's key material; its tier must be `sealed`.
276
+ * @param dependencyDigests - The key of every node the material references,
277
+ * by node id.
278
+ * @returns The content key. Fails with `non_content_material` for a
279
+ * non-sealed tier and `missing_dependency` for an unresolved reference.
280
+ * @since 0.1.0
281
+ * @category constructors
282
+ */
283
+ export declare const fromKeyMaterial: (material: KeyMaterial.KeyMaterial, dependencyDigests: Readonly<Record<string, string>>) => Effect.Effect<StepKey, KeyMaterialError | Schema.SchemaError, Crypto.Crypto>;
284
+ /**
285
+ * Identifies a declaration in a plan, independently of whether its execution
286
+ * can be cached. Sealed material retains its existing content-key format;
287
+ * compensable and irreversible material use a distinct, tier-bearing plan
288
+ * namespace. These fingerprints bind approvals, not cross-run result reuse.
289
+ * Dispatch non-cacheable work under a run-local {@link ordinal} instead.
290
+ *
291
+ * @since 1.0.0
292
+ * @category constructors
293
+ */
294
+ export declare const planIdentity: (material: KeyMaterial.KeyMaterial, dependencyDigests: Readonly<Record<string, string>>) => Effect.Effect<StepKey, KeyMaterialError | Schema.SchemaError, Crypto.Crypto>;
295
+ /**
296
+ * Projects a settled result along a `Ref` path. Only own data properties
297
+ * resolve, so a missing, inherited, or accessor segment yields `undefined`
298
+ * without invoking a getter. This is a stable, distinct value: a projection that
299
+ * walks off the end of a result is a fact about the graph, not a failure.
300
+ * `undefined` drops out of the canonical form, so it hashes distinctly from
301
+ * every JSON value including `null`.
302
+ *
303
+ * Exported because it is the ONE projection semantics for the value channel:
304
+ * {@link dispatchIdentity} digests what this returns, so every consumer that
305
+ * resolves a `Ref` at execution time must resolve it the same way, or two
306
+ * inputs that key identically could be consumed differently — a stale-hit
307
+ * vector.
308
+ *
309
+ * @since 0.1.0
310
+ * @category utilities
311
+ */
312
+ export declare const project: (value: unknown, path: ReadonlyArray<string>) => unknown;
313
+ /**
314
+ * The key a dispatch is *cached* under, as distinct from the plan key a node
315
+ * is *identified* by.
316
+ *
317
+ * A plan key folds the resolved keys of every upstream node, transitively, so
318
+ * an edit anywhere upstream re-keys everything below it — even when the edited
319
+ * node's output value is byte for byte what it was before. Bazel does not work
320
+ * that way: `ActionCacheChecker` keys an action by the *content* of its
321
+ * inputs, so an unchanged output stops invalidation dead. The file channel in
322
+ * flows already had that property through the measured boundary digests; the
323
+ * JSON value channel did not, and this is what gives it one.
324
+ *
325
+ * The derivation folds the node's OWN material — body, version, effects,
326
+ * placement, layers, capabilities — and never an upstream key. Each material
327
+ * input contributes content instead: a `Literal` its value, a `Ref` the digest
328
+ * of the settled result of `from` projected along `path`, and a `Pending`
329
+ * nothing beyond its tag. The measured hermetic boundary is folded unchanged.
330
+ *
331
+ * `results` must hold every dependency the material names. The scheduler's
332
+ * halt rule guarantees it: a dependent of failed or skipped work never
333
+ * dispatches, so a `Ref` always resolves against a success.
334
+ *
335
+ * @param options - The material, the dependencies' settled results, the
336
+ * measured hermetic boundary, and an optional environment and memo.
337
+ * @returns The dispatch key. Fails with `non_content_material` for a
338
+ * non-sealed tier, `missing_dependency` for a `Ref` absent from `results`,
339
+ * or `invalid_environment` for a malformed environment.
340
+ * @since 0.1.0
341
+ * @category constructors
342
+ */
343
+ export declare const dispatchIdentity: (options: {
344
+ readonly material: KeyMaterial.KeyMaterial;
345
+ /** The settled output value of each dependency, by node id. */
346
+ readonly results: Readonly<Record<string, unknown>>;
347
+ readonly hermetic: NonNullable<ContentIdentity["hermetic"]>;
348
+ /** The engine-resolved execution environment this dispatch runs under. */
349
+ readonly environment?: EnvironmentIdentity | undefined;
350
+ /** Reuses projected-value digests while the corresponding settled values remain immutable. */
351
+ readonly digestMemo?: DigestMemo | undefined;
352
+ }) => Effect.Effect<StepKey, KeyMaterialError | Schema.SchemaError, Crypto.Crypto>;
353
+ export {};
354
+ //# sourceMappingURL=StepKey.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StepKey.d.ts","sourceRoot":"","sources":["../../src/StepKey.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAc,KAAK,SAAS,EAAE,MAAM,cAAc,CAAA;AACzD,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAA;AAE5C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,OAAO,MAAM,cAAc,CAAA;AAC5C,OAAO,KAAK,KAAK,WAAW,MAAM,kBAAkB,CAAA;AAEpD;;;;;;GAMG;AACH,MAAM,MAAM,OAAO,GAAG,SAAS,CAAA;AAE/B;;;;;;;;;;GAUG;AACH,QAAA,MAAM,iBAAiB,EAAE,OAAO,MAAuD,CAAA;AAEvF;;;;GAIG;AACH,KAAK,cAAc,GAAG,KAAK,GAAG,SAAS,GAAG,eAAe,CAAA;AAEzD;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,CAAC,iBAAiB,CAAC,EAAE,OAAO,iBAAiB,CAAA;IACtD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB;;;;;;;OAOG;IACH,QAAQ,CAAC,SAA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