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

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 +189 -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 +685 -0
  26. package/dist/cjs/Node.d.ts.map +1 -0
  27. package/dist/cjs/Node.js +230 -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 +685 -0
  111. package/dist/esm/Node.d.ts.map +1 -0
  112. package/dist/esm/Node.js +591 -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 +974 -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,145 @@
1
+ /**
2
+ * The refusals a plan-time build raises instead of producing a wrong plan.
3
+ *
4
+ * Every one of these fails LOUDLY at build time: a planned value that was computed on must not
5
+ * bake `NaN` into a plan, an arm that returned something other than a node must
6
+ * not silently vanish from the topology, and a recursive `.call()` must direct
7
+ * the author to `.to()` or `.child()` rather than expanding forever. Each
8
+ * failure therefore names the site (`node` plus the recorded property `path`)
9
+ * and states the fix in `message`, because the author reading it is mid-body
10
+ * and needs the correction, not a classification.
11
+ *
12
+ * The codes are a closed schema literal so a caller can switch on them, and so
13
+ * a new refusal is a deliberate addition rather than a new free-form string.
14
+ *
15
+ * @since 0.1.0
16
+ */
17
+ import * as Schema from "effect/Schema";
18
+ /**
19
+ * The stable code of a build refusal.
20
+ *
21
+ * `planned_value_computed` is a body computing on a step result;
22
+ * `invalid_all_member` is a non-node handed to {@link module:Node.all};
23
+ * `invalid_join` is a race, any, or quorum with a non-node member, no members,
24
+ * or a quorum count its members cannot reach;
25
+ * `invalid_continuation` is a branch arm or continuation that did not return a
26
+ * node; `recursion_requires_boundary` is a flow calling itself inline, which
27
+ * has to become a trampoline handoff or an explicit child boundary;
28
+ * `placement_requires_boundary` is an inline call whose callee declares a
29
+ * placement the enclosing flow cannot satisfy, which has to become that same
30
+ * explicit child boundary; `cyclic_payload` is a payload that contains itself,
31
+ * which no plan could serialize or hash; `payload_too_deep` is a payload
32
+ * nested past the build bound, which has to be flattened into shallower data;
33
+ * `graph_too_deep` is authored topology nested past the build bound, which
34
+ * has to be split with `.child()` boundaries or trampoline handoffs;
35
+ * `duplicate_node` is two structural graph addresses resolving to one durable
36
+ * node id;
37
+ * `invalid_priority` is a scheduling priority that is not a safe integer,
38
+ * which no ordering could compare; `invalid_payload` is a payload member that
39
+ * cannot be captured as inert JSON without executing author code or losing
40
+ * identity; `unstable_callback` is a function with process-local identity in a
41
+ * graph that requires stable callbacks. Declare its complete inert captures
42
+ * with `Node.capture`, including semantic implementation versions. The two
43
+ * depth refusals exist because graph building walks with an explicit stack
44
+ * and refuses at a bound, rather than recursing until the native stack
45
+ * overflows without a typed error.
46
+ *
47
+ * The four effect-authority refusals are raised when a declaration claims more
48
+ * than the declaration enclosing it granted:
49
+ * `effect_outside_envelope` is a read or write path the envelope does not
50
+ * cover, and it names those paths in `path`; `effect_mode_widening` is an
51
+ * `expected` declaration inside a `hermetic` envelope; `effect_tier_widening`
52
+ * is a tier less reversible than the envelope's; and
53
+ * `capability_outside_grant` is a called flow or action requiring a capability
54
+ * the caller does not hold, which names the dropped capabilities in `path`. The
55
+ * first three are fatal by {@link isFatalDiagnostic}; the fourth is advisory,
56
+ * because dropping a capability narrows authority rather than widening it.
57
+ *
58
+ * The last six are raised by `@smthrs/core`'s graph builder, which uses this
59
+ * one error rather than a second class of its own. `write_conflict` is two work
60
+ * nodes overlapping under `onConflict: "fail"`, and `node` names the first of
61
+ * the pair while `Graph.conflicts` carries both; `missing_key_material` is a
62
+ * node that reached key compilation without any; `dependency_cycle` is a
63
+ * dependency set that cannot be ordered, and `node` names a node in the cycle;
64
+ * `plan_too_large` is a node, edge, conflict, or effect-path limit crossed, and
65
+ * `node` names the node whose admission crossed it; `payload_too_large` is a
66
+ * plan value with more members than the bound, and `path` names the offending
67
+ * value path; `invalid_node` is a malformed node AST. All six are fatal.
68
+ *
69
+ * @since 0.1.0
70
+ * @category schemas
71
+ */
72
+ export const GraphBuildErrorCode = Schema.Literals([
73
+ "planned_value_computed",
74
+ "invalid_all_member",
75
+ "invalid_join",
76
+ "invalid_continuation",
77
+ "recursion_requires_boundary",
78
+ "placement_requires_boundary",
79
+ "cyclic_payload",
80
+ "payload_too_deep",
81
+ "graph_too_deep",
82
+ "duplicate_node",
83
+ "invalid_priority",
84
+ "invalid_payload",
85
+ "unstable_callback",
86
+ "effect_outside_envelope",
87
+ "effect_mode_widening",
88
+ "effect_tier_widening",
89
+ "capability_outside_grant",
90
+ "write_conflict",
91
+ "missing_key_material",
92
+ "dependency_cycle",
93
+ "plan_too_large",
94
+ "payload_too_large",
95
+ "invalid_node"
96
+ ]);
97
+ /**
98
+ * A build the planner refuses, naming the site and the fix.
99
+ *
100
+ * `node` is the node reference the failure belongs to — a planned value's
101
+ * origin node, an `all` member name, a branch arm, or the node whose admission
102
+ * crossed a bound. `path` is the property path recorded on a planned value
103
+ * before it was misused, the effect paths an over-claiming declaration named,
104
+ * the capabilities a call lost, or the value path of an oversized payload; it
105
+ * is empty for every other code.
106
+ *
107
+ * This is the ONE build refusal. `@smthrs/core`'s graph builder raised a second
108
+ * `GraphBuildError` of its own, with `paths`, `nodeId` and `nodes` in place of
109
+ * these fields, and the two code sets diverged instead of merging. A conflict's
110
+ * second node is read from `Graph.conflicts`, which carries the pair.
111
+ *
112
+ * @since 0.1.0
113
+ * @category errors
114
+ */
115
+ export class GraphBuildError extends Schema.TaggedError()("@smthrs/plan/GraphBuildError", {
116
+ code: GraphBuildErrorCode,
117
+ node: Schema.String,
118
+ path: Schema.Array(Schema.String),
119
+ message: Schema.String
120
+ }) {
121
+ }
122
+ /**
123
+ * The one advisory code. Everything else a build records blocks the drafts.
124
+ *
125
+ * A capability the caller does not grant is DROPPED, not granted: the callee
126
+ * runs with less authority than it asked for, which is the safe direction. The
127
+ * author still needs to know, because a flow that silently loses a capability
128
+ * fails later at the action that needed it, so the build records the refusal
129
+ * and lets the graph compile.
130
+ */
131
+ const advisoryCodes = new Set(["capability_outside_grant"]);
132
+ /**
133
+ * Whether a recorded refusal blocks the drafts a plan is compiled from.
134
+ *
135
+ * A fatal refusal means the graph describes something no plan could execute as
136
+ * written, so the drafts are withheld. An advisory one reports a narrowing the
137
+ * author should see while the graph still compiles.
138
+ *
139
+ * @param diagnostic - A recorded refusal.
140
+ * @returns `false` only for an advisory code (`capability_outside_grant`).
141
+ * @since 0.1.0
142
+ * @category predicates
143
+ */
144
+ export const isFatalDiagnostic = (diagnostic) => !advisoryCodes.has(diagnostic.code);
145
+ //# sourceMappingURL=GraphBuildError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GraphBuildError.js","sourceRoot":"","sources":["../../src/GraphBuildError.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC,QAAQ,CAAC;IACjD,wBAAwB;IACxB,oBAAoB;IACpB,cAAc;IACd,sBAAsB;IACtB,6BAA6B;IAC7B,6BAA6B;IAC7B,gBAAgB;IAChB,kBAAkB;IAClB,gBAAgB;IAChB,gBAAgB;IAChB,kBAAkB;IAClB,iBAAiB;IACjB,mBAAmB;IACnB,yBAAyB;IACzB,sBAAsB;IACtB,sBAAsB;IACtB,0BAA0B;IAC1B,gBAAgB;IAChB,sBAAsB;IACtB,kBAAkB;IAClB,gBAAgB;IAChB,mBAAmB;IACnB,cAAc;CACf,CAAC,CAAA;AAUF;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAO,eAAgB,SAAQ,MAAM,CAAC,WAAW,EAAmB,CAAC,8BAA8B,EAAE;IACzG,IAAI,EAAE,mBAAmB;IACzB,IAAI,EAAE,MAAM,CAAC,MAAM;IACnB,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC;IACjC,OAAO,EAAE,MAAM,CAAC,MAAM;CACvB,CAAC;CAAG;AAEL;;;;;;;;GAQG;AACH,MAAM,aAAa,GAAqC,IAAI,GAAG,CAAsB,CAAC,0BAA0B,CAAC,CAAC,CAAA;AAElH;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,UAA2B,EAAW,EAAE,CAAC,CAAC,aAAa,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA","sourcesContent":["/**\n * The refusals a plan-time build raises instead of producing a wrong plan.\n *\n * Every one of these fails LOUDLY at build time: a planned value that was computed on must not\n * bake `NaN` into a plan, an arm that returned something other than a node must\n * not silently vanish from the topology, and a recursive `.call()` must direct\n * the author to `.to()` or `.child()` rather than expanding forever. Each\n * failure therefore names the site (`node` plus the recorded property `path`)\n * and states the fix in `message`, because the author reading it is mid-body\n * and needs the correction, not a classification.\n *\n * The codes are a closed schema literal so a caller can switch on them, and so\n * a new refusal is a deliberate addition rather than a new free-form string.\n *\n * @since 0.1.0\n */\n\nimport * as Schema from \"effect/Schema\"\n\n/**\n * The stable code of a build refusal.\n *\n * `planned_value_computed` is a body computing on a step result;\n * `invalid_all_member` is a non-node handed to {@link module:Node.all};\n * `invalid_join` is a race, any, or quorum with a non-node member, no members,\n * or a quorum count its members cannot reach;\n * `invalid_continuation` is a branch arm or continuation that did not return a\n * node; `recursion_requires_boundary` is a flow calling itself inline, which\n * has to become a trampoline handoff or an explicit child boundary;\n * `placement_requires_boundary` is an inline call whose callee declares a\n * placement the enclosing flow cannot satisfy, which has to become that same\n * explicit child boundary; `cyclic_payload` is a payload that contains itself,\n * which no plan could serialize or hash; `payload_too_deep` is a payload\n * nested past the build bound, which has to be flattened into shallower data;\n * `graph_too_deep` is authored topology nested past the build bound, which\n * has to be split with `.child()` boundaries or trampoline handoffs;\n * `duplicate_node` is two structural graph addresses resolving to one durable\n * node id;\n * `invalid_priority` is a scheduling priority that is not a safe integer,\n * which no ordering could compare; `invalid_payload` is a payload member that\n * cannot be captured as inert JSON without executing author code or losing\n * identity; `unstable_callback` is a function with process-local identity in a\n * graph that requires stable callbacks. Declare its complete inert captures\n * with `Node.capture`, including semantic implementation versions. The two\n * depth refusals exist because graph building walks with an explicit stack\n * and refuses at a bound, rather than recursing until the native stack\n * overflows without a typed error.\n *\n * The four effect-authority refusals are raised when a declaration claims more\n * than the declaration enclosing it granted:\n * `effect_outside_envelope` is a read or write path the envelope does not\n * cover, and it names those paths in `path`; `effect_mode_widening` is an\n * `expected` declaration inside a `hermetic` envelope; `effect_tier_widening`\n * is a tier less reversible than the envelope's; and\n * `capability_outside_grant` is a called flow or action requiring a capability\n * the caller does not hold, which names the dropped capabilities in `path`. The\n * first three are fatal by {@link isFatalDiagnostic}; the fourth is advisory,\n * because dropping a capability narrows authority rather than widening it.\n *\n * The last six are raised by `@smthrs/core`'s graph builder, which uses this\n * one error rather than a second class of its own. `write_conflict` is two work\n * nodes overlapping under `onConflict: \"fail\"`, and `node` names the first of\n * the pair while `Graph.conflicts` carries both; `missing_key_material` is a\n * node that reached key compilation without any; `dependency_cycle` is a\n * dependency set that cannot be ordered, and `node` names a node in the cycle;\n * `plan_too_large` is a node, edge, conflict, or effect-path limit crossed, and\n * `node` names the node whose admission crossed it; `payload_too_large` is a\n * plan value with more members than the bound, and `path` names the offending\n * value path; `invalid_node` is a malformed node AST. All six are fatal.\n *\n * @since 0.1.0\n * @category schemas\n */\nexport const GraphBuildErrorCode = Schema.Literals([\n \"planned_value_computed\",\n \"invalid_all_member\",\n \"invalid_join\",\n \"invalid_continuation\",\n \"recursion_requires_boundary\",\n \"placement_requires_boundary\",\n \"cyclic_payload\",\n \"payload_too_deep\",\n \"graph_too_deep\",\n \"duplicate_node\",\n \"invalid_priority\",\n \"invalid_payload\",\n \"unstable_callback\",\n \"effect_outside_envelope\",\n \"effect_mode_widening\",\n \"effect_tier_widening\",\n \"capability_outside_grant\",\n \"write_conflict\",\n \"missing_key_material\",\n \"dependency_cycle\",\n \"plan_too_large\",\n \"payload_too_large\",\n \"invalid_node\"\n])\n\n/**\n * The value form of {@link GraphBuildErrorCode}.\n *\n * @since 0.1.0\n * @category models\n */\nexport type GraphBuildErrorCode = typeof GraphBuildErrorCode.Type\n\n/**\n * A build the planner refuses, naming the site and the fix.\n *\n * `node` is the node reference the failure belongs to — a planned value's\n * origin node, an `all` member name, a branch arm, or the node whose admission\n * crossed a bound. `path` is the property path recorded on a planned value\n * before it was misused, the effect paths an over-claiming declaration named,\n * the capabilities a call lost, or the value path of an oversized payload; it\n * is empty for every other code.\n *\n * This is the ONE build refusal. `@smthrs/core`'s graph builder raised a second\n * `GraphBuildError` of its own, with `paths`, `nodeId` and `nodes` in place of\n * these fields, and the two code sets diverged instead of merging. A conflict's\n * second node is read from `Graph.conflicts`, which carries the pair.\n *\n * @since 0.1.0\n * @category errors\n */\nexport class GraphBuildError extends Schema.TaggedError<GraphBuildError>()(\"@smthrs/plan/GraphBuildError\", {\n code: GraphBuildErrorCode,\n node: Schema.String,\n path: Schema.Array(Schema.String),\n message: Schema.String\n}) {}\n\n/**\n * The one advisory code. Everything else a build records blocks the drafts.\n *\n * A capability the caller does not grant is DROPPED, not granted: the callee\n * runs with less authority than it asked for, which is the safe direction. The\n * author still needs to know, because a flow that silently loses a capability\n * fails later at the action that needed it, so the build records the refusal\n * and lets the graph compile.\n */\nconst advisoryCodes: ReadonlySet<GraphBuildErrorCode> = new Set<GraphBuildErrorCode>([\"capability_outside_grant\"])\n\n/**\n * Whether a recorded refusal blocks the drafts a plan is compiled from.\n *\n * A fatal refusal means the graph describes something no plan could execute as\n * written, so the drafts are withheld. An advisory one reports a narrowing the\n * author should see while the graph still compiles.\n *\n * @param diagnostic - A recorded refusal.\n * @returns `false` only for an advisory code (`capability_outside_grant`).\n * @since 0.1.0\n * @category predicates\n */\nexport const isFatalDiagnostic = (diagnostic: GraphBuildError): boolean => !advisoryCodes.has(diagnostic.code)\n"]}
@@ -0,0 +1,107 @@
1
+ /**
2
+ * The key-material contract: what a planner hands the step-key compiler.
3
+ *
4
+ * Revived from the deleted `packages/smithers/flows/keys/src/KeyMaterial.ts`.
5
+ * It does NOT return to `@smthrs/keys`: that package owns generic derivation
6
+ * and stored-key validation, while material is a *plan-shaped* concept. It
7
+ * lives here, above `@smthrs/keys`, so the key package stays a leaf.
8
+ *
9
+ * Governing contract: the step-key rules at
10
+ * https://github.com/smithersai/smithers/blob/main/packages/smithers/flows/plan/docs/concepts/step-keys.md. Material is computed with no I/O,
11
+ * and two hardening rules shape it: the nominal, never shape-sniffed
12
+ * `InputRef` and the hashed `version`.
13
+ *
14
+ * @since 0.1.0
15
+ */
16
+ import * as Schema from "effect/Schema";
17
+ /**
18
+ * A reference to one declared input of a node: a value hashed inline, or the
19
+ * key of an upstream node whose result this node consumes.
20
+ *
21
+ * The three variants are tagged, and the tag is hashed, so `Pending{from}` and
22
+ * `Ref{from, path: []}` — which resolve to the same dependency digest — can
23
+ * never collide.
24
+ *
25
+ * - `Literal` hashes `value` inline.
26
+ * - `Ref` consumes the value at `path` inside node `from`'s result.
27
+ * - `Pending` consumes node `from`'s whole result.
28
+ *
29
+ * @since 0.1.0
30
+ * @category schemas
31
+ */
32
+ export declare const InputRef: Schema.Union<readonly [Schema.TaggedStruct<"Literal", {
33
+ readonly value: Schema.Unknown;
34
+ }>, Schema.TaggedStruct<"Ref", {
35
+ readonly from: Schema.NonEmptyString;
36
+ readonly path: Schema.$Array<Schema.String>;
37
+ }>, Schema.TaggedStruct<"Pending", {
38
+ readonly from: Schema.NonEmptyString;
39
+ }>]>;
40
+ /**
41
+ * The value form of {@link InputRef}.
42
+ *
43
+ * @since 0.1.0
44
+ * @category models
45
+ */
46
+ export type InputRef = typeof InputRef.Type;
47
+ /**
48
+ * The material version. Folded into every hashed body so a bump re-keys every
49
+ * node derived from it — the original's second collision fix, kept.
50
+ *
51
+ * @since 0.1.0
52
+ * @category constants
53
+ */
54
+ export declare const version = "flows/key-material/v2";
55
+ /**
56
+ * Everything that can change a node's result, handed to the digest.
57
+ *
58
+ * `effects` and `placement` are opaque: canonically serialized, never
59
+ * interpreted, which is what keeps the compiler independent of whatever the
60
+ * flow builder decides an effect declaration looks like.
61
+ *
62
+ * `version` must equal {@link version}. `kind` is the effect tier. `inputs`
63
+ * are hashed in order; `layers` and `capabilities` name what the node runs
64
+ * with.
65
+ *
66
+ * @since 0.1.0
67
+ * @category schemas
68
+ */
69
+ export declare const KeyMaterial: Schema.Struct<{
70
+ readonly version: Schema.Literal<"flows/key-material/v2">;
71
+ readonly kind: Schema.Literals<readonly ["sealed", "compensable", "irreversible"]>;
72
+ readonly nondeterministic: Schema.optional<Schema.Literal<true>>;
73
+ readonly body: Schema.Unknown;
74
+ readonly inputs: Schema.$Array<Schema.Union<readonly [Schema.TaggedStruct<"Literal", {
75
+ readonly value: Schema.Unknown;
76
+ }>, Schema.TaggedStruct<"Ref", {
77
+ readonly from: Schema.NonEmptyString;
78
+ readonly path: Schema.$Array<Schema.String>;
79
+ }>, Schema.TaggedStruct<"Pending", {
80
+ readonly from: Schema.NonEmptyString;
81
+ }>]>>;
82
+ readonly layers: Schema.$Array<Schema.String>;
83
+ readonly capabilities: Schema.$Array<Schema.String>;
84
+ readonly effects: Schema.optional<Schema.Unknown>;
85
+ readonly placement: Schema.optional<Schema.Unknown>;
86
+ }>;
87
+ /**
88
+ * The value form of {@link KeyMaterial}.
89
+ *
90
+ * @since 0.1.0
91
+ * @category models
92
+ */
93
+ export type KeyMaterial = typeof KeyMaterial.Type;
94
+ /**
95
+ * The graph-local dependencies a material names, in declaration order and
96
+ * without duplicates. The compiler resolves exactly these before hashing, and
97
+ * {@link module:Plan} uses them as the edge set — one derivation, so an edge
98
+ * and a hashed reference can never disagree.
99
+ *
100
+ * @param material - The node's key material.
101
+ * @returns The `from` of every `Ref` and `Pending` input, first occurrence
102
+ * order, deduplicated.
103
+ * @since 0.1.0
104
+ * @category accessors
105
+ */
106
+ export declare const dependencies: (material: KeyMaterial) => ReadonlyArray<string>;
107
+ //# sourceMappingURL=KeyMaterial.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KeyMaterial.d.ts","sourceRoot":"","sources":["../../src/KeyMaterial.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAGvC;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,QAAQ;;;;;;;IAInB,CAAA;AAEF;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC,IAAI,CAAA;AAE3C;;;;;;GAMG;AACH,eAAO,MAAM,OAAO,0BAA0B,CAAA;AAE9C;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;EAWtB,CAAA;AAEF;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GAAG,OAAO,WAAW,CAAC,IAAI,CAAA;AAEjD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,YAAY,GAAI,UAAU,WAAW,KAAG,aAAa,CAAC,MAAM,CAMxE,CAAA"}
@@ -0,0 +1,92 @@
1
+ /**
2
+ * The key-material contract: what a planner hands the step-key compiler.
3
+ *
4
+ * Revived from the deleted `packages/smithers/flows/keys/src/KeyMaterial.ts`.
5
+ * It does NOT return to `@smthrs/keys`: that package owns generic derivation
6
+ * and stored-key validation, while material is a *plan-shaped* concept. It
7
+ * lives here, above `@smthrs/keys`, so the key package stays a leaf.
8
+ *
9
+ * Governing contract: the step-key rules at
10
+ * https://github.com/smithersai/smithers/blob/main/packages/smithers/flows/plan/docs/concepts/step-keys.md. Material is computed with no I/O,
11
+ * and two hardening rules shape it: the nominal, never shape-sniffed
12
+ * `InputRef` and the hashed `version`.
13
+ *
14
+ * @since 0.1.0
15
+ */
16
+ import * as Schema from "effect/Schema";
17
+ import * as Effects from "./Effects.js";
18
+ /**
19
+ * A reference to one declared input of a node: a value hashed inline, or the
20
+ * key of an upstream node whose result this node consumes.
21
+ *
22
+ * The three variants are tagged, and the tag is hashed, so `Pending{from}` and
23
+ * `Ref{from, path: []}` — which resolve to the same dependency digest — can
24
+ * never collide.
25
+ *
26
+ * - `Literal` hashes `value` inline.
27
+ * - `Ref` consumes the value at `path` inside node `from`'s result.
28
+ * - `Pending` consumes node `from`'s whole result.
29
+ *
30
+ * @since 0.1.0
31
+ * @category schemas
32
+ */
33
+ export const InputRef = Schema.Union([
34
+ Schema.TaggedStruct("Literal", { value: Schema.Unknown }),
35
+ Schema.TaggedStruct("Ref", { from: Schema.NonEmptyString, path: Schema.Array(Schema.String) }),
36
+ Schema.TaggedStruct("Pending", { from: Schema.NonEmptyString })
37
+ ]);
38
+ /**
39
+ * The material version. Folded into every hashed body so a bump re-keys every
40
+ * node derived from it — the original's second collision fix, kept.
41
+ *
42
+ * @since 0.1.0
43
+ * @category constants
44
+ */
45
+ export const version = "flows/key-material/v2";
46
+ /**
47
+ * Everything that can change a node's result, handed to the digest.
48
+ *
49
+ * `effects` and `placement` are opaque: canonically serialized, never
50
+ * interpreted, which is what keeps the compiler independent of whatever the
51
+ * flow builder decides an effect declaration looks like.
52
+ *
53
+ * `version` must equal {@link version}. `kind` is the effect tier. `inputs`
54
+ * are hashed in order; `layers` and `capabilities` name what the node runs
55
+ * with.
56
+ *
57
+ * @since 0.1.0
58
+ * @category schemas
59
+ */
60
+ export const KeyMaterial = Schema.Struct({
61
+ version: Schema.Literal(version),
62
+ kind: Effects.Tier,
63
+ // Absence claims determinism; only the explicit declaration changes identity.
64
+ nondeterministic: Schema.optional(Schema.Literal(true)),
65
+ body: Schema.Unknown,
66
+ inputs: Schema.Array(InputRef),
67
+ layers: Schema.Array(Schema.String),
68
+ capabilities: Schema.Array(Schema.String),
69
+ effects: Schema.optional(Schema.Unknown),
70
+ placement: Schema.optional(Schema.Unknown)
71
+ });
72
+ /**
73
+ * The graph-local dependencies a material names, in declaration order and
74
+ * without duplicates. The compiler resolves exactly these before hashing, and
75
+ * {@link module:Plan} uses them as the edge set — one derivation, so an edge
76
+ * and a hashed reference can never disagree.
77
+ *
78
+ * @param material - The node's key material.
79
+ * @returns The `from` of every `Ref` and `Pending` input, first occurrence
80
+ * order, deduplicated.
81
+ * @since 0.1.0
82
+ * @category accessors
83
+ */
84
+ export const dependencies = (material) => {
85
+ const seen = new Set();
86
+ for (const input of material.inputs) {
87
+ if (input._tag !== "Literal")
88
+ seen.add(input.from);
89
+ }
90
+ return [...seen];
91
+ };
92
+ //# sourceMappingURL=KeyMaterial.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KeyMaterial.js","sourceRoot":"","sources":["../../src/KeyMaterial.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AAEvC;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC;IACnC,MAAM,CAAC,YAAY,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC;IACzD,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,cAAc,EAAE,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;IAC9F,MAAM,CAAC,YAAY,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,cAAc,EAAE,CAAC;CAChE,CAAC,CAAA;AAUF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,uBAAuB,CAAA;AAE9C;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC;IACvC,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;IAChC,IAAI,EAAE,OAAO,CAAC,IAAI;IAClB,8EAA8E;IAC9E,gBAAgB,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACvD,IAAI,EAAE,MAAM,CAAC,OAAO;IACpB,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC;IAC9B,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC;IACnC,YAAY,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC;IACzC,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC;IACxC,SAAS,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC;CAC3C,CAAC,CAAA;AAUF;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,QAAqB,EAAyB,EAAE;IAC3E,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAA;IAC9B,KAAK,MAAM,KAAK,IAAI,QAAQ,CAAC,MAAM,EAAE,CAAC;QACpC,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS;YAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IACpD,CAAC;IACD,OAAO,CAAC,GAAG,IAAI,CAAC,CAAA;AAClB,CAAC,CAAA","sourcesContent":["/**\n * The key-material contract: what a planner hands the step-key compiler.\n *\n * Revived from the deleted `packages/smithers/flows/keys/src/KeyMaterial.ts`.\n * It does NOT return to `@smthrs/keys`: that package owns generic derivation\n * and stored-key validation, while material is a *plan-shaped* concept. It\n * lives here, above `@smthrs/keys`, so the key package stays a leaf.\n *\n * Governing contract: the step-key rules at\n * https://github.com/smithersai/smithers/blob/main/packages/smithers/flows/plan/docs/concepts/step-keys.md. Material is computed with no I/O,\n * and two hardening rules shape it: the nominal, never shape-sniffed\n * `InputRef` and the hashed `version`.\n *\n * @since 0.1.0\n */\n\nimport * as Schema from \"effect/Schema\"\nimport * as Effects from \"./Effects.ts\"\n\n/**\n * A reference to one declared input of a node: a value hashed inline, or the\n * key of an upstream node whose result this node consumes.\n *\n * The three variants are tagged, and the tag is hashed, so `Pending{from}` and\n * `Ref{from, path: []}` — which resolve to the same dependency digest — can\n * never collide.\n *\n * - `Literal` hashes `value` inline.\n * - `Ref` consumes the value at `path` inside node `from`'s result.\n * - `Pending` consumes node `from`'s whole result.\n *\n * @since 0.1.0\n * @category schemas\n */\nexport const InputRef = Schema.Union([\n Schema.TaggedStruct(\"Literal\", { value: Schema.Unknown }),\n Schema.TaggedStruct(\"Ref\", { from: Schema.NonEmptyString, path: Schema.Array(Schema.String) }),\n Schema.TaggedStruct(\"Pending\", { from: Schema.NonEmptyString })\n])\n\n/**\n * The value form of {@link InputRef}.\n *\n * @since 0.1.0\n * @category models\n */\nexport type InputRef = typeof InputRef.Type\n\n/**\n * The material version. Folded into every hashed body so a bump re-keys every\n * node derived from it — the original's second collision fix, kept.\n *\n * @since 0.1.0\n * @category constants\n */\nexport const version = \"flows/key-material/v2\"\n\n/**\n * Everything that can change a node's result, handed to the digest.\n *\n * `effects` and `placement` are opaque: canonically serialized, never\n * interpreted, which is what keeps the compiler independent of whatever the\n * flow builder decides an effect declaration looks like.\n *\n * `version` must equal {@link version}. `kind` is the effect tier. `inputs`\n * are hashed in order; `layers` and `capabilities` name what the node runs\n * with.\n *\n * @since 0.1.0\n * @category schemas\n */\nexport const KeyMaterial = Schema.Struct({\n version: Schema.Literal(version),\n kind: Effects.Tier,\n // Absence claims determinism; only the explicit declaration changes identity.\n nondeterministic: Schema.optional(Schema.Literal(true)),\n body: Schema.Unknown,\n inputs: Schema.Array(InputRef),\n layers: Schema.Array(Schema.String),\n capabilities: Schema.Array(Schema.String),\n effects: Schema.optional(Schema.Unknown),\n placement: Schema.optional(Schema.Unknown)\n})\n\n/**\n * The value form of {@link KeyMaterial}.\n *\n * @since 0.1.0\n * @category models\n */\nexport type KeyMaterial = typeof KeyMaterial.Type\n\n/**\n * The graph-local dependencies a material names, in declaration order and\n * without duplicates. The compiler resolves exactly these before hashing, and\n * {@link module:Plan} uses them as the edge set — one derivation, so an edge\n * and a hashed reference can never disagree.\n *\n * @param material - The node's key material.\n * @returns The `from` of every `Ref` and `Pending` input, first occurrence\n * order, deduplicated.\n * @since 0.1.0\n * @category accessors\n */\nexport const dependencies = (material: KeyMaterial): ReadonlyArray<string> => {\n const seen = new Set<string>()\n for (const input of material.inputs) {\n if (input._tag !== \"Literal\") seen.add(input.from)\n }\n return [...seen]\n}\n"]}