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

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 (199) hide show
  1. package/CHANGELOG.md +183 -0
  2. package/LICENSE +21 -0
  3. package/README.md +228 -2
  4. package/dist/cjs/CachePolicy.d.ts +131 -0
  5. package/dist/cjs/CachePolicy.d.ts.map +1 -0
  6. package/dist/cjs/CachePolicy.js +50 -0
  7. package/dist/cjs/CachePolicy.js.map +7 -0
  8. package/dist/cjs/Effects.d.ts +240 -0
  9. package/dist/cjs/Effects.d.ts.map +1 -0
  10. package/dist/cjs/Effects.js +76 -0
  11. package/dist/cjs/Effects.js.map +7 -0
  12. package/dist/cjs/FileSet.d.ts +288 -0
  13. package/dist/cjs/FileSet.d.ts.map +1 -0
  14. package/dist/cjs/FileSet.js +191 -0
  15. package/dist/cjs/FileSet.js.map +7 -0
  16. package/dist/cjs/GraphBuildError.d.ts +122 -0
  17. package/dist/cjs/GraphBuildError.d.ts.map +1 -0
  18. package/dist/cjs/GraphBuildError.js +71 -0
  19. package/dist/cjs/GraphBuildError.js.map +7 -0
  20. package/dist/cjs/KeyMaterial.d.ts +102 -0
  21. package/dist/cjs/KeyMaterial.d.ts.map +1 -0
  22. package/dist/cjs/KeyMaterial.js +64 -0
  23. package/dist/cjs/KeyMaterial.js.map +7 -0
  24. package/dist/cjs/Node.d.ts +606 -0
  25. package/dist/cjs/Node.d.ts.map +1 -0
  26. package/dist/cjs/Node.js +207 -0
  27. package/dist/cjs/Node.js.map +7 -0
  28. package/dist/cjs/Placement.d.ts +117 -0
  29. package/dist/cjs/Placement.d.ts.map +1 -0
  30. package/dist/cjs/Placement.js +46 -0
  31. package/dist/cjs/Placement.js.map +7 -0
  32. package/dist/cjs/Plan.d.ts +440 -0
  33. package/dist/cjs/Plan.d.ts.map +1 -0
  34. package/dist/cjs/Plan.js +508 -0
  35. package/dist/cjs/Plan.js.map +7 -0
  36. package/dist/cjs/PlanDiff.d.ts +58 -0
  37. package/dist/cjs/PlanDiff.d.ts.map +1 -0
  38. package/dist/cjs/PlanDiff.js +124 -0
  39. package/dist/cjs/PlanDiff.js.map +7 -0
  40. package/dist/cjs/Planned.d.ts +121 -0
  41. package/dist/cjs/Planned.d.ts.map +1 -0
  42. package/dist/cjs/Planned.js +72 -0
  43. package/dist/cjs/Planned.js.map +7 -0
  44. package/dist/cjs/Repetition.d.ts +31 -0
  45. package/dist/cjs/Repetition.d.ts.map +1 -0
  46. package/dist/cjs/Repetition.js +36 -0
  47. package/dist/cjs/Repetition.js.map +7 -0
  48. package/dist/cjs/Scheduling.d.ts +89 -0
  49. package/dist/cjs/Scheduling.d.ts.map +1 -0
  50. package/dist/cjs/Scheduling.js +76 -0
  51. package/dist/cjs/Scheduling.js.map +7 -0
  52. package/dist/cjs/StepKey.d.ts +333 -0
  53. package/dist/cjs/StepKey.d.ts.map +1 -0
  54. package/dist/cjs/StepKey.js +311 -0
  55. package/dist/cjs/StepKey.js.map +7 -0
  56. package/dist/cjs/index.d.ts +91 -0
  57. package/dist/cjs/index.d.ts.map +1 -0
  58. package/dist/cjs/index.js +59 -0
  59. package/dist/cjs/index.js.map +7 -0
  60. package/dist/cjs/internal/ConflictAnnotation.d.ts +59 -0
  61. package/dist/cjs/internal/ConflictAnnotation.d.ts.map +1 -0
  62. package/dist/cjs/internal/ConflictAnnotation.js +247 -0
  63. package/dist/cjs/internal/ConflictAnnotation.js.map +7 -0
  64. package/dist/cjs/internal/EffectCandidates.d.ts +19 -0
  65. package/dist/cjs/internal/EffectCandidates.d.ts.map +1 -0
  66. package/dist/cjs/internal/EffectCandidates.js +92 -0
  67. package/dist/cjs/internal/EffectCandidates.js.map +7 -0
  68. package/dist/cjs/internal/JsonMirror.d.ts +34 -0
  69. package/dist/cjs/internal/JsonMirror.d.ts.map +1 -0
  70. package/dist/cjs/internal/JsonMirror.js +195 -0
  71. package/dist/cjs/internal/JsonMirror.js.map +7 -0
  72. package/dist/cjs/internal/effects.d.ts +245 -0
  73. package/dist/cjs/internal/effects.d.ts.map +1 -0
  74. package/dist/cjs/internal/effects.js +290 -0
  75. package/dist/cjs/internal/effects.js.map +7 -0
  76. package/dist/cjs/internal/node.d.ts +526 -0
  77. package/dist/cjs/internal/node.d.ts.map +1 -0
  78. package/dist/cjs/internal/node.js +312 -0
  79. package/dist/cjs/internal/node.js.map +7 -0
  80. package/dist/cjs/package.json +1 -0
  81. package/dist/cjs/test/PlanFixtures.d.ts +127 -0
  82. package/dist/cjs/test/PlanFixtures.d.ts.map +1 -0
  83. package/dist/cjs/test/PlanFixtures.js +59 -0
  84. package/dist/cjs/test/PlanFixtures.js.map +7 -0
  85. package/dist/esm/CachePolicy.d.ts +131 -0
  86. package/dist/esm/CachePolicy.d.ts.map +1 -0
  87. package/dist/esm/CachePolicy.js +117 -0
  88. package/dist/esm/CachePolicy.js.map +1 -0
  89. package/dist/esm/Effects.d.ts +240 -0
  90. package/dist/esm/Effects.d.ts.map +1 -0
  91. package/dist/esm/Effects.js +167 -0
  92. package/dist/esm/Effects.js.map +1 -0
  93. package/dist/esm/FileSet.d.ts +288 -0
  94. package/dist/esm/FileSet.d.ts.map +1 -0
  95. package/dist/esm/FileSet.js +324 -0
  96. package/dist/esm/FileSet.js.map +1 -0
  97. package/dist/esm/GraphBuildError.d.ts +122 -0
  98. package/dist/esm/GraphBuildError.d.ts.map +1 -0
  99. package/dist/esm/GraphBuildError.js +146 -0
  100. package/dist/esm/GraphBuildError.js.map +1 -0
  101. package/dist/esm/KeyMaterial.d.ts +102 -0
  102. package/dist/esm/KeyMaterial.d.ts.map +1 -0
  103. package/dist/esm/KeyMaterial.js +85 -0
  104. package/dist/esm/KeyMaterial.js.map +1 -0
  105. package/dist/esm/Node.d.ts +606 -0
  106. package/dist/esm/Node.d.ts.map +1 -0
  107. package/dist/esm/Node.js +521 -0
  108. package/dist/esm/Node.js.map +1 -0
  109. package/dist/esm/Placement.d.ts +117 -0
  110. package/dist/esm/Placement.d.ts.map +1 -0
  111. package/dist/esm/Placement.js +65 -0
  112. package/dist/esm/Placement.js.map +1 -0
  113. package/dist/esm/Plan.d.ts +440 -0
  114. package/dist/esm/Plan.d.ts.map +1 -0
  115. package/dist/esm/Plan.js +673 -0
  116. package/dist/esm/Plan.js.map +1 -0
  117. package/dist/esm/PlanDiff.d.ts +58 -0
  118. package/dist/esm/PlanDiff.d.ts.map +1 -0
  119. package/dist/esm/PlanDiff.js +159 -0
  120. package/dist/esm/PlanDiff.js.map +1 -0
  121. package/dist/esm/Planned.d.ts +121 -0
  122. package/dist/esm/Planned.d.ts.map +1 -0
  123. package/dist/esm/Planned.js +147 -0
  124. package/dist/esm/Planned.js.map +1 -0
  125. package/dist/esm/Repetition.d.ts +31 -0
  126. package/dist/esm/Repetition.d.ts.map +1 -0
  127. package/dist/esm/Repetition.js +24 -0
  128. package/dist/esm/Repetition.js.map +1 -0
  129. package/dist/esm/Scheduling.d.ts +89 -0
  130. package/dist/esm/Scheduling.d.ts.map +1 -0
  131. package/dist/esm/Scheduling.js +82 -0
  132. package/dist/esm/Scheduling.js.map +1 -0
  133. package/dist/esm/StepKey.d.ts +333 -0
  134. package/dist/esm/StepKey.d.ts.map +1 -0
  135. package/dist/esm/StepKey.js +478 -0
  136. package/dist/esm/StepKey.js.map +1 -0
  137. package/dist/esm/index.d.ts +91 -0
  138. package/dist/esm/index.d.ts.map +1 -0
  139. package/dist/esm/index.js +91 -0
  140. package/dist/esm/index.js.map +1 -0
  141. package/dist/esm/internal/ConflictAnnotation.d.ts +59 -0
  142. package/dist/esm/internal/ConflictAnnotation.d.ts.map +1 -0
  143. package/dist/esm/internal/ConflictAnnotation.js +332 -0
  144. package/dist/esm/internal/ConflictAnnotation.js.map +1 -0
  145. package/dist/esm/internal/EffectCandidates.d.ts +19 -0
  146. package/dist/esm/internal/EffectCandidates.d.ts.map +1 -0
  147. package/dist/esm/internal/EffectCandidates.js +86 -0
  148. package/dist/esm/internal/EffectCandidates.js.map +1 -0
  149. package/dist/esm/internal/JsonMirror.d.ts +34 -0
  150. package/dist/esm/internal/JsonMirror.d.ts.map +1 -0
  151. package/dist/esm/internal/JsonMirror.js +204 -0
  152. package/dist/esm/internal/JsonMirror.js.map +1 -0
  153. package/dist/esm/internal/effects.d.ts +245 -0
  154. package/dist/esm/internal/effects.d.ts.map +1 -0
  155. package/dist/esm/internal/effects.js +459 -0
  156. package/dist/esm/internal/effects.js.map +1 -0
  157. package/dist/esm/internal/node.d.ts +526 -0
  158. package/dist/esm/internal/node.d.ts.map +1 -0
  159. package/dist/esm/internal/node.js +564 -0
  160. package/dist/esm/internal/node.js.map +1 -0
  161. package/dist/esm/test/PlanFixtures.d.ts +127 -0
  162. package/dist/esm/test/PlanFixtures.d.ts.map +1 -0
  163. package/dist/esm/test/PlanFixtures.js +60 -0
  164. package/dist/esm/test/PlanFixtures.js.map +1 -0
  165. package/docs/README.md +165 -0
  166. package/docs/api.md +1475 -0
  167. package/docs/concepts/authoring-ast.md +203 -0
  168. package/docs/concepts/effects-and-conflicts.md +135 -0
  169. package/docs/concepts/plan-value.md +168 -0
  170. package/docs/concepts/step-keys.md +179 -0
  171. package/docs/guides/author-a-node-graph.md +182 -0
  172. package/docs/guides/compile-a-plan.md +146 -0
  173. package/docs/guides/declare-file-effects.md +143 -0
  174. package/docs/guides/diff-two-plans.md +101 -0
  175. package/docs/installation.md +71 -0
  176. package/docs/quickstart.md +128 -0
  177. package/docs/testing.md +73 -0
  178. package/docs/troubleshooting.md +314 -0
  179. package/package.json +254 -3
  180. package/src/CachePolicy.ts +143 -0
  181. package/src/Effects.ts +284 -0
  182. package/src/FileSet.ts +411 -0
  183. package/src/GraphBuildError.ts +158 -0
  184. package/src/KeyMaterial.ts +106 -0
  185. package/src/Node.ts +871 -0
  186. package/src/Placement.ts +99 -0
  187. package/src/Plan.ts +868 -0
  188. package/src/PlanDiff.ts +199 -0
  189. package/src/Planned.ts +208 -0
  190. package/src/Repetition.ts +33 -0
  191. package/src/Scheduling.ts +154 -0
  192. package/src/StepKey.ts +710 -0
  193. package/src/index.ts +103 -0
  194. package/src/internal/ConflictAnnotation.ts +374 -0
  195. package/src/internal/EffectCandidates.ts +89 -0
  196. package/src/internal/JsonMirror.ts +255 -0
  197. package/src/internal/effects.ts +543 -0
  198. package/src/internal/node.ts +858 -0
  199. package/src/test/PlanFixtures.ts +76 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Plan.js","sourceRoot":"","sources":["../../src/Plan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAEpD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,WAAW,MAAM,oBAAoB,CAAA;AACjD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,KAAK,SAAS,MAAM,kCAAkC,CAAA;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACrD,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAA;AAC/C,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AAEvC;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC;IACvC,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,eAAe,CAAC;IAC5C,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC;IACzC;;;;OAIG;IACH,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACvD,YAAY,EAAE,OAAO,CAAC,YAAY;CACnC,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AC1D,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CACvB,OAAO,CAAC,gFAAgF,CAAC,CAC1F,CAAA;IACH,CAAC;IACD,OAAO,UAAU,CAAC,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,CAAC,CAAA;AAC1C,CAAC,CAAC,CAAA;AAEJ;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAAU,EAA2B,EAAE,CACrE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,KAAK,IAAI,CAAC,UAAU,CAAC,CAAA;AAElE;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAc,EAAiB,EAAE,CAC1D,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,WAAW,CAAC,GAAG,CAAC,KAAa,CAAC,CAAA;AAE/E;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,IAAU,EACoF,EAAE,CAChG,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAA","sourcesContent":["/**\n * The plan: a node graph with every step key computed, inert until run.\n *\n * The way a plan is produced is a law: **planning performs no I/O**.\n * Everything in this module is therefore a pure function of declarations plus\n * the injected `Crypto` service: no filesystem, no clock, no network. A node's\n * key is a function of what it consumes, so an edited declaration re-keys that\n * node and everything downstream of it, and nothing else. That is the entire\n * invalidation mechanism. Invalidation is re-keying, which **rejects**\n * Skyframe's reverse-dependency index and invalidating node visitor outright\n * because content addressing subsumes them. Key invalidation never retains a\n * reverse-dependency index; annotation uses only a temporary reachability cache.\n *\n * Growth is append-only: {@link append} adds a pre-keyed subgraph to the same\n * plan and never rewrites a node already in it.\n *\n * @since 0.1.0\n */\n\nimport { DerivedKey, StoredKey } from \"@smthrs/keys\"\nimport type * as Crypto from \"effect/Crypto\"\nimport * as Effect from \"effect/Effect\"\nimport * as Inspectable from \"effect/Inspectable\"\nimport * as Schema from \"effect/Schema\"\nimport * as Effects from \"./Effects.ts\"\nimport * as FileSet from \"./FileSet.ts\"\nimport { GraphBuildError } from \"./GraphBuildError.ts\"\nimport * as Conflicts from \"./internal/ConflictAnnotation.ts\"\nimport { jsonMirror } from \"./internal/JsonMirror.ts\"\nimport * as KeyMaterial from \"./KeyMaterial.ts\"\nimport * as StepKey from \"./StepKey.ts\"\n\n/**\n * What a node does to the world, declared. Paths only — measuring them is\n * run-time work, so a digest here would break the no-I/O law.\n *\n * @since 0.1.0\n * @category schemas\n * @slop\n */\nexport const NodeEffects = Schema.Struct({\n reads: Schema.Array(FileSet.ReadDeclaration),\n writes: Schema.Array(FileSet.Declaration),\n /**\n * Paths the node declares it will DELETE. A removal mutates the world exactly\n * as a write does, so {@link produces} folds the two together and both the\n * conflict pass and the reader-after-writer pass see them as one set.\n */\n removes: Schema.optional(Schema.Array(FileSet.Pattern)),\n boundaryMode: FileSet.BoundaryMode\n})\n\n/**\n * The value form of {@link NodeEffects}.\n *\n * @since 0.1.0\n * @category models\n * @slop\n */\nexport type NodeEffects = typeof NodeEffects.Type\n\n/**\n * The plan-time write-conflict strategies of the effect taxonomy.\n *\n * @since 0.1.0\n * @category schemas\n * @slop\n */\nexport const PairStrategy = Effects.ConflictStrategy\n\n/**\n * The value form of {@link PairStrategy}.\n *\n * @since 0.1.0\n * @category models\n * @slop\n */\nexport type PairStrategy = typeof PairStrategy.Type\n\n/**\n * The runtime half of a conflict annotation: what the scheduler\n * does when the overlap the plan predicted actually bites, or when a\n * scheduled node's inputs are invalidated under it.\n *\n * @since 0.1.0\n * @category schemas\n * @slop\n */\nexport const RuntimeStrategy = Schema.Literals([\"delay-rebase\", \"stop-merge\"])\n\n/**\n * The value form of {@link RuntimeStrategy}.\n *\n * @since 0.1.0\n * @category models\n * @slop\n */\nexport type RuntimeStrategy = typeof RuntimeStrategy.Type\n\n/** @private */\nconst NodeKind = Schema.Literals([\"step\", \"agent\", \"merge\"])\n\n/**\n * One resolved overlap between two writers that no dependency path already\n * orders. Conflict is a property of the PAIR, not of one declaration.\n *\n * @since 0.1.0\n * @category schemas\n * @slop\n */\nexport const ConflictAnnotation = Schema.Struct({\n with: Schema.NonEmptyString,\n paths: Schema.Array(Schema.String),\n strategy: PairStrategy,\n runtime: RuntimeStrategy\n})\n\n/**\n * The value form of {@link ConflictAnnotation}.\n *\n * @since 0.1.0\n * @category models\n * @slop\n */\nexport type ConflictAnnotation = typeof ConflictAnnotation.Type\n\n/**\n * A keyed node of the plan.\n *\n * `dependsOn` is the *edge* set: material references, any ordering edge a\n * `serialize` verdict added, and the reader-after-writer edges that put a\n * node behind whoever produces the paths it reads. Ordering edges are\n * deliberately NOT part of the key — a node ordered behind another still\n * computes the same result, so re-keying it would throw away a legitimate\n * cache hit.\n *\n * `strategy` and `runtime` are this declaration's own preferences, recorded so\n * a later elaboration can resolve a pair against them without re-reading the\n * flow source.\n *\n * @since 0.1.0\n * @category schemas\n * @slop\n */\nexport const PlanNode = Schema.Struct({\n id: Schema.NonEmptyString,\n kind: NodeKind,\n key: StoredKey,\n material: KeyMaterial.KeyMaterial,\n effects: NodeEffects,\n dependsOn: Schema.Array(Schema.NonEmptyString),\n conflicts: Schema.Array(ConflictAnnotation),\n strategy: PairStrategy,\n runtime: RuntimeStrategy,\n priority: Schema.Int,\n generation: Schema.Int\n})\n\n/**\n * The value form of {@link PlanNode}.\n *\n * @since 0.1.0\n * @category models\n * @slop\n */\nexport type PlanNode = typeof PlanNode.Type\n\n/**\n * A plan: the whole keyed graph plus the digest an approval binds to.\n *\n * `nodes` follows material-dependency order within each generation. Inferred\n * edges can point to later entries; schedule from the complete `dependsOn`\n * graph, never by iterating the array alone.\n *\n * `baseDigest` is the digest at generation 0: what a human approved and what\n * a `RUNNING` run pins. `digest` advances with every appended elaboration.\n *\n * @since 0.1.0\n * @category schemas\n * @slop\n */\nexport const Plan = Schema.Struct({\n planId: Schema.NonEmptyString,\n flow: Schema.NonEmptyString,\n generation: Schema.Int,\n baseDigest: StoredKey,\n digest: StoredKey,\n nodes: Schema.Array(PlanNode)\n})\n\n/**\n * The value form of {@link Plan}.\n *\n * @since 0.1.0\n * @category models\n * @slop\n */\nexport type Plan = typeof Plan.Type\n\n/**\n * What a planner hands {@link compile}: a node without its key.\n *\n * @since 0.1.0\n * @category models\n * @slop\n */\nexport interface NodeDraft {\n readonly id: string\n readonly material: KeyMaterial.KeyMaterial\n readonly effects: NodeEffects\n readonly kind?: PlanNode[\"kind\"] | undefined\n readonly priority?: number | undefined\n /** This declaration's preferred plan-time verdict for a detected overlap. */\n readonly conflictStrategy?: PairStrategy | undefined\n /** This declaration's preferred runtime response. */\n readonly runtimeStrategy?: RuntimeStrategy | undefined\n}\n\n/**\n * A graph the compiler refuses.\n *\n * @since 0.1.0\n * @category errors\n * @slop\n */\nexport class PlanError extends Schema.TaggedError<PlanError>()(\"@smthrs/plan/PlanError\", {\n code: Schema.Literals([\n \"cycle\",\n \"unknown_dependency\",\n \"duplicate_node\",\n \"overlap_forbidden\",\n \"invalid_effects\",\n \"invalid_node\",\n \"invalid_plan\",\n \"graph_too_large\"\n ]),\n message: Schema.String\n}) {}\n\n/**\n * Maximum number of nodes retained by one compiled plan.\n *\n * Effect analysis also has a yielding work budget, since a node ceiling alone\n * does not bound dense conflicts to practical work.\n *\n * @since 1.0.0\n * @category limits\n * @slop\n */\nexport const maximumPlanNodes = 10_000\n\n/** @private */\nconst graphSizeError = (size: number): PlanError =>\n new PlanError({\n code: \"graph_too_large\",\n message: `A plan may contain at most ${maximumPlanNodes} nodes, received ${size}`\n })\n\n/** @private */\ntype Ordered =\n | { readonly ok: true; readonly drafts: ReadonlyArray<NodeDraft> }\n | { readonly ok: false; readonly error: PlanError }\n\n/**\n * Topologically orders drafts by their MATERIAL dependencies — the only edges\n * that exist before keys do.\n *\n * @private\n */\nconst topological = (drafts: ReadonlyArray<NodeDraft>, known: ReadonlySet<string>): Ordered => {\n const byId = new Map(drafts.map((draft) => [draft.id, draft]))\n const ordered: Array<NodeDraft> = []\n const state = new Map<string, \"visiting\" | \"done\">()\n interface Frame {\n readonly draft: NodeDraft\n readonly dependencies: ReadonlyArray<string>\n next: number\n }\n for (const draft of drafts) {\n if (state.get(draft.id) === \"done\") continue\n state.set(draft.id, \"visiting\")\n const stack: Array<Frame> = [{ draft, dependencies: KeyMaterial.dependencies(draft.material), next: 0 }]\n while (stack.length > 0) {\n const frame = stack[stack.length - 1]!\n if (frame.next === frame.dependencies.length) {\n state.set(frame.draft.id, \"done\")\n ordered.push(frame.draft)\n stack.pop()\n continue\n }\n const dependency = frame.dependencies[frame.next++]!\n if (known.has(dependency)) continue\n const next = byId.get(dependency)\n if (next === undefined) {\n return {\n ok: false,\n error: new PlanError({\n code: \"unknown_dependency\",\n message: `Node ${frame.draft.id} depends on unknown node ${dependency}`\n })\n }\n }\n const mark = state.get(next.id)\n if (mark === \"done\") continue\n if (mark === \"visiting\") {\n return {\n ok: false,\n error: new PlanError({ code: \"cycle\", message: `Plan cycle through node ${next.id}` })\n }\n }\n state.set(next.id, \"visiting\")\n stack.push({ draft: next, dependencies: KeyMaterial.dependencies(next.material), next: 0 })\n }\n }\n return { ok: true, drafts: ordered }\n}\n\n/**\n * Runs the conflict and reader-after-writer passes and records what they found\n * on every node outside `frozen`, whose rows an append never rewrites. A\n * refused graph fails as a `PlanError` carrying the pass's code and message.\n *\n * @private\n */\nconst annotate = (\n nodes: ReadonlyArray<PlanNode>,\n frozen: ReadonlySet<string>,\n replayGenerations = false\n): Effect.Effect<ReadonlyArray<PlanNode>, PlanError> =>\n Conflicts.annotate(nodes, frozen.size, replayGenerations).pipe(\n Effect.mapError((refusal) => new PlanError(refusal)),\n Effect.map(({ conflicts, ordering }) =>\n nodes.map((node) => {\n if (frozen.has(node.id)) return node\n const added = ordering.get(node.id) ?? []\n return freezeNode({\n ...node,\n conflicts: conflicts.get(node.id) ?? [],\n dependsOn: added.length === 0 ? node.dependsOn : [...node.dependsOn, ...added]\n })\n })\n )\n )\n\n/**\n * The single approval projection. Its node list is the complete reviewable and\n * behavior-bearing contract: id, kind, key, edges, conflict annotations,\n * declared effects, conflict strategy, runtime strategy, and priority.\n *\n * @private\n */\nconst approvalPayload = (\n planId: string,\n flow: string,\n nodes: ReadonlyArray<PlanNode>\n) => ({\n body: { kind: \"plan\", planId, flow },\n inputs: {\n nodes: nodes.map((node) => ({\n id: node.id,\n kind: node.kind,\n key: node.key,\n dependsOn: node.dependsOn,\n conflicts: node.conflicts,\n effects: node.effects,\n strategy: node.strategy,\n runtime: node.runtime,\n priority: node.priority\n }))\n },\n layers: [],\n capabilities: {}\n})\n\n/**\n * The plan's digest: what an approval binds to. Deriving it only from\n * {@link approvalPayload} keeps the approved field list in one place.\n *\n * @private\n */\nconst digestOf = (\n planId: string,\n flow: string,\n nodes: ReadonlyArray<PlanNode>\n): Effect.Effect<StepKey.StepKey, StepKey.KeyMaterialError | Schema.SchemaError, Crypto.Crypto> =>\n StepKey.content(approvalPayload(planId, flow, nodes))\n\n/** @private */\nconst maximumDescriptionLength = 256\n\n/** @private */\nconst describeValue = (value: unknown): string => {\n const rendered = typeof value === \"string\" ? JSON.stringify(value) : Inspectable.toStringUnknown(value, 0)\n return rendered.length > maximumDescriptionLength\n ? `${rendered.slice(0, maximumDescriptionLength - 3)}...`\n : rendered\n}\n\n/** @private */\nconst describeNodeId = (id: string): string => id.length > maximumDescriptionLength ? describeValue(id) : id\n\n/** @private */\nconst validateIdentity = (planId: unknown, flow: unknown): PlanError | undefined => {\n if (typeof planId !== \"string\" || planId.length === 0) {\n return new PlanError({\n code: \"invalid_node\",\n message: `Plan option planId must be a non-empty string, received ${describeValue(planId)}`\n })\n }\n if (typeof flow !== \"string\" || flow.length === 0) {\n return new PlanError({\n code: \"invalid_node\",\n message: `Plan option flow must be a non-empty string, received ${describeValue(flow)}`\n })\n }\n return undefined\n}\n\n/** Whether `value` is a container this module may safely copy. */\nconst isSnapshotContainer = (value: unknown): value is object => {\n if (typeof value !== \"object\" || value === null) return false\n if (Array.isArray(value)) return true\n const prototype = Object.getPrototypeOf(value)\n return prototype === Object.prototype || prototype === null\n}\n\n/** Creates an empty container with the source container's supported prototype. */\nconst emptySnapshot = (source: object): object =>\n Array.isArray(source) ? [] : Object.create(Object.getPrototypeOf(source)) as object\n\n/**\n * Copies and freezes plain structural containers without interpreting them as\n * JSON. Shared references and cycles point at one cloned container through\n * `memo`; every other value passes through by reference and remains unfrozen.\n * In particular, this does not probe a `Planned` proxy. `validateDrafts`\n * creates the inert material mirror inside the Effect while retaining that\n * proxy, so the canonical serializer still reaches and refuses it.\n */\nconst snapshot = <A extends object>(value: A): A => {\n const root = emptySnapshot(value)\n const memo = new WeakMap<object, object>([[value, root]])\n const pending: Array<{ readonly source: object; readonly target: object }> = [{ source: value, target: root }]\n const created = [root]\n\n while (pending.length > 0) {\n const { source, target } = pending.pop()!\n for (const key of Reflect.ownKeys(source)) {\n const descriptor = Object.getOwnPropertyDescriptor(source, key)!\n if (\"value\" in descriptor && isSnapshotContainer(descriptor.value)) {\n let child = memo.get(descriptor.value)\n if (child === undefined) {\n child = emptySnapshot(descriptor.value)\n memo.set(descriptor.value, child)\n pending.push({ source: descriptor.value, target: child })\n created.push(child)\n }\n descriptor.value = child\n }\n Object.defineProperty(target, key, descriptor)\n }\n }\n\n for (const container of created) Object.freeze(container)\n return root as A\n}\n\n/** Freezes one node built by this module while retaining its material snapshot. */\nconst freezeNode = (node: PlanNode): PlanNode =>\n Object.freeze({\n ...node,\n dependsOn: Object.freeze([...node.dependsOn]),\n conflicts: Object.freeze(\n node.conflicts.map((conflict) => Object.freeze({ ...conflict, paths: Object.freeze([...conflict.paths]) }))\n )\n })\n\n/** Plans whose complete immutable snapshot was created by this module. */\nconst frozenPlans = new WeakSet<Plan>()\n\n/** Freezes the plan envelope and its newly built node list. */\nconst freezePlan = (plan: Plan): Plan => {\n const frozen = Object.freeze({ ...plan, nodes: Object.freeze([...plan.nodes]) })\n frozenPlans.add(frozen)\n return frozen\n}\n\n/**\n * Validates the runtime-only parts of `NodeDraft` without replacing effect\n * admission. Effect 4 Struct decoding strips excess properties and copies its\n * schema arrays. The decoded effect declaration replaces any caller-supplied\n * `material.effects`, and every accepted draft receives one deeply frozen JSON\n * mirror for both storage and hashing.\n *\n * @private\n */\nconst validateDrafts = (\n drafts: ReadonlyArray<NodeDraft>\n): Effect.Effect<ReadonlyArray<NodeDraft>, PlanError> =>\n Effect.forEach(drafts, (draft) =>\n Effect.gen(function*() {\n if (typeof draft.id !== \"string\" || draft.id.length === 0) {\n return yield* Effect.fail(\n new PlanError({\n code: \"invalid_node\",\n message: `Node id must be a non-empty string, received ${describeValue(draft.id)}`\n })\n )\n }\n const nodeId = describeNodeId(draft.id)\n if (draft.priority !== undefined && !Number.isSafeInteger(draft.priority)) {\n return yield* Effect.fail(\n new PlanError({\n code: \"invalid_node\",\n message: `Node ${nodeId} priority must be a safe integer, received ${describeValue(draft.priority)}`\n })\n )\n }\n if (draft.kind !== undefined && !Schema.is(NodeKind)(draft.kind)) {\n return yield* Effect.fail(\n new PlanError({\n code: \"invalid_node\",\n message: `Node ${nodeId} kind must be step, agent, or merge, received ${describeValue(draft.kind)}`\n })\n )\n }\n if (draft.conflictStrategy !== undefined && !Schema.is(PairStrategy)(draft.conflictStrategy)) {\n return yield* Effect.fail(\n new PlanError({\n code: \"invalid_node\",\n message: `Node ${nodeId} conflictStrategy must be serialize, lane, or fail, received ${\n describeValue(draft.conflictStrategy)\n }`\n })\n )\n }\n if (draft.runtimeStrategy !== undefined && !Schema.is(RuntimeStrategy)(draft.runtimeStrategy)) {\n return yield* Effect.fail(\n new PlanError({\n code: \"invalid_node\",\n message: `Node ${nodeId} runtimeStrategy must be delay-rebase or stop-merge, received ${\n describeValue(draft.runtimeStrategy)\n }`\n })\n )\n }\n const decodedMaterial = yield* Schema.decodeUnknownEffect(KeyMaterial.KeyMaterial)(draft.material).pipe(\n Effect.mapError((cause) =>\n new PlanError({\n code: \"invalid_node\",\n message: `Node ${nodeId} has invalid material: ${cause.message}`\n })\n )\n )\n const decodedEffects = yield* Schema.decodeUnknownEffect(NodeEffects)(draft.effects).pipe(\n Effect.mapError((cause) =>\n new PlanError({\n code: \"invalid_node\",\n message: `Node ${nodeId} has invalid effects: ${cause.message}`\n })\n )\n )\n let material: KeyMaterial.KeyMaterial\n try {\n material = snapshot(\n jsonMirror({ ...decodedMaterial, effects: decodedEffects }, (planned) => planned) as KeyMaterial.KeyMaterial\n )\n } catch (cause) {\n const path = cause instanceof GraphBuildError ? cause.path : []\n return yield* Effect.fail(\n new PlanError({\n code: \"invalid_node\",\n message: `Node ${nodeId} has invalid material payload at ${[\"$\", ...path].join(\".\")}`\n })\n )\n }\n return Object.freeze({\n ...draft,\n material,\n effects: material.effects as NodeEffects\n })\n }))\n\n/**\n * The effects schema admits each individual declaration in `validateDrafts`.\n * This pass enforces the cross-field invariant that one path cannot be both a\n * write and a removal.\n *\n * @private\n */\nconst validateEffects = (id: string, effects: NodeEffects): PlanError | undefined => {\n const removes = effects.removes ?? []\n const writes = FileSet.expand(effects.writes)\n for (const removal of removes) {\n if (writes.some((entry) => FileSet.overlaps(entry, removal))) {\n return new PlanError({\n code: \"invalid_effects\",\n message: `Node ${id} declares ${removal} as both a write and a removal`\n })\n }\n }\n return undefined\n}\n\n/** @private */\nconst keyNodes = (\n drafts: ReadonlyArray<NodeDraft>,\n existing: ReadonlyArray<PlanNode>,\n generation: number\n): Effect.Effect<\n ReadonlyArray<PlanNode>,\n PlanError | StepKey.KeyMaterialError | Schema.SchemaError,\n Crypto.Crypto\n> =>\n Effect.gen(function*() {\n const digests: Record<string, string> = Object.create(null) as Record<string, string>\n const known = new Set<string>()\n for (const node of existing) {\n Object.defineProperty(digests, node.id, {\n configurable: true,\n enumerable: true,\n value: node.key,\n writable: true\n })\n known.add(node.id)\n }\n for (const draft of drafts) {\n if (known.has(draft.id)) {\n return yield* Effect.fail(\n new PlanError({ code: \"duplicate_node\", message: `Node ${draft.id} is already in the plan` })\n )\n }\n known.add(draft.id)\n }\n const sorted = topological(drafts, new Set(existing.map((node) => node.id)))\n if (!sorted.ok) return yield* Effect.fail(sorted.error)\n const keyed: Array<PlanNode> = []\n for (const draft of sorted.drafts) {\n const invalid = validateEffects(draft.id, draft.effects)\n if (invalid !== undefined) return yield* Effect.fail(invalid)\n const key = yield* StepKey.planIdentity(draft.material, digests)\n Object.defineProperty(digests, draft.id, {\n configurable: true,\n enumerable: true,\n value: key,\n writable: true\n })\n keyed.push(freezeNode({\n id: draft.id,\n kind: draft.kind ?? \"step\",\n key,\n material: draft.material,\n effects: draft.effects,\n dependsOn: KeyMaterial.dependencies(draft.material),\n conflicts: [],\n strategy: draft.conflictStrategy ?? \"serialize\",\n runtime: draft.runtimeStrategy ?? \"delay-rebase\",\n priority: draft.priority ?? 0,\n generation\n }))\n }\n return keyed\n })\n\n/**\n * Compiles drafts into a plan: material-dependency order, dependency-digest\n * substitution, overlap annotation, and the plan digest. No I/O.\n * Inferred edges extend `dependsOn` without reordering the node array.\n *\n * Traversal uses explicit stacks. Because the conflict and reader/writer\n * passes consider a quadratic number of node pairs, plans are bounded by\n * {@link maximumPlanNodes} and fail with `graph_too_large` above that limit\n * or the effect-analysis work budget. Analysis yields periodically.\n *\n * @since 0.1.0\n * @category constructors\n * @slop\n */\nexport const compile = (options: {\n readonly planId: string\n readonly flow: string\n readonly nodes: ReadonlyArray<NodeDraft>\n}): Effect.Effect<Plan, PlanError | StepKey.KeyMaterialError | Schema.SchemaError, Crypto.Crypto> => {\n const captured = snapshot(options)\n return Effect.gen(function*() {\n const invalidIdentity = validateIdentity(captured.planId, captured.flow)\n if (invalidIdentity !== undefined) return yield* Effect.fail(invalidIdentity)\n if (captured.nodes.length > maximumPlanNodes) return yield* Effect.fail(graphSizeError(captured.nodes.length))\n const drafts = yield* validateDrafts(captured.nodes)\n const keyed = yield* keyNodes(drafts, [], 0)\n const nodes = yield* annotate(keyed, new Set())\n const digest = yield* digestOf(captured.planId, captured.flow, nodes)\n return freezePlan({\n planId: captured.planId,\n flow: captured.flow,\n generation: 0,\n baseDigest: digest,\n digest,\n nodes\n })\n })\n}\n\n/**\n * Appends an elaborated subgraph to an existing plan.\n *\n * The plan GROWS; it is never invalidated. Nodes already in it keep their id,\n * key, edges, and generation byte for byte, and the new nodes arrive pre-keyed\n * against them, so a `hit` shows instantly. New nodes retain their material\n * dependency order; scheduling must honor their complete `dependsOn` graph.\n * Re-ordering after a reconciliation happens by re-keying *future* steps,\n * never by rewriting history.\n *\n * @since 0.1.0\n * @category constructors\n * @slop\n */\nexport const append = (\n plan: Plan,\n drafts: ReadonlyArray<NodeDraft>\n): Effect.Effect<Plan, PlanError | StepKey.KeyMaterialError | Schema.SchemaError, Crypto.Crypto> => {\n const candidate = frozenPlans.has(plan) ? plan : snapshot(plan)\n const capturedDrafts = snapshot(drafts)\n return Effect.gen(function*() {\n const invalidIdentity = validateIdentity(candidate.planId, candidate.flow)\n if (invalidIdentity !== undefined) return yield* Effect.fail(invalidIdentity)\n const capturedPlan = yield* verify(candidate)\n const nextSize = capturedPlan.nodes.length + capturedDrafts.length\n if (nextSize > maximumPlanNodes) return yield* Effect.fail(graphSizeError(nextSize))\n const validated = yield* validateDrafts(capturedDrafts)\n if (validated.length === 0) {\n return yield* Effect.fail(\n new PlanError({\n code: \"invalid_node\",\n message: `Plan ${capturedPlan.planId} append requires at least one draft`\n })\n )\n }\n const generation = capturedPlan.generation + 1\n const keyed = yield* keyNodes(validated, capturedPlan.nodes, generation)\n const nodes = yield* annotate(\n [...capturedPlan.nodes, ...keyed],\n new Set(capturedPlan.nodes.map((node) => node.id))\n )\n const digest = yield* digestOf(capturedPlan.planId, capturedPlan.flow, nodes)\n return freezePlan({ ...capturedPlan, generation, digest, nodes })\n })\n}\n\n/**\n * Verifies an imported plan against the same key and topology rules as the\n * compiler. Valid compiler-owned immutable values need no second compilation.\n *\n * Generation boundaries are replayed when reconstructing conflict annotations:\n * an append may annotate new nodes, but cannot rewrite an earlier generation.\n * Recorded material-dependency order is verified without sorting inferred edges.\n * Keys and approval digests retain their existing format. The returned snapshot\n * is immutable; later caller mutation cannot change the verified value.\n *\n * @since 1.0.0\n * @category validation\n */\nexport const verify = (\n input: unknown\n): Effect.Effect<Plan, PlanError | StepKey.KeyMaterialError | Schema.SchemaError, Crypto.Crypto> =>\n Effect.gen(function*() {\n if (typeof input === \"object\" && input !== null && frozenPlans.has(input as Plan)) return input as Plan\n // Check the array ceiling before schema decoding copies its members.\n if (typeof input === \"object\" && input !== null && \"nodes\" in input && Array.isArray(input.nodes)) {\n if (input.nodes.length > maximumPlanNodes) return yield* Effect.fail(graphSizeError(input.nodes.length))\n }\n const decoded = yield* Schema.decodeUnknownEffect(Plan)(input)\n const invalid = (message: string) => new PlanError({ code: \"invalid_plan\", message })\n if (\n !Number.isSafeInteger(decoded.generation) || decoded.generation < 0 || decoded.generation > decoded.nodes.length\n ) {\n return yield* Effect.fail(\n invalid(\"Plan generation must be a non-negative safe integer with a nonempty appended generation\")\n )\n }\n const generations = new Map<string, number>()\n let previous = 0\n for (const node of decoded.nodes) {\n if (!Number.isSafeInteger(node.generation) || node.generation < previous || node.generation > previous + 1) {\n return yield* Effect.fail(invalid(`Node ${node.id} has an invalid or out-of-order generation`))\n }\n generations.set(node.id, node.generation)\n previous = node.generation\n }\n if (previous !== decoded.generation) {\n return yield* Effect.fail(invalid(\"Plan generation does not match its newest nodes\"))\n }\n for (const node of decoded.nodes) {\n for (const dependency of KeyMaterial.dependencies(node.material)) {\n const generation = generations.get(dependency)\n if (generation !== undefined && generation > node.generation) {\n return yield* Effect.fail(invalid(`Node ${node.id} refers to a future generation`))\n }\n }\n }\n const drafts = yield* validateDrafts(decoded.nodes.map((node) => ({\n id: node.id,\n kind: node.kind,\n material: node.material,\n effects: node.effects,\n conflictStrategy: node.strategy,\n runtimeStrategy: node.runtime,\n priority: node.priority\n })))\n const keyed = (yield* keyNodes(drafts, [], 0)).map((node) =>\n freezeNode({ ...node, generation: generations.get(node.id)! })\n )\n // Replay boundaries within one annotation pass, retaining its expansion\n // map, candidate trie, inferred graph and reachability cache throughout.\n const nodes = yield* annotate(keyed, new Set(), true)\n const baseDigest = yield* digestOf(decoded.planId, decoded.flow, nodes.filter((node) => node.generation === 0))\n const digest = decoded.generation === 0 ? baseDigest : yield* digestOf(decoded.planId, decoded.flow, nodes)\n if (decoded.baseDigest !== baseDigest || decoded.digest !== digest) {\n return yield* Effect.fail(invalid(\"Plan approval digest does not match its compiled content\"))\n }\n // Compare the complete node contract, including material and generation,\n // rather than trusting the claimed keys or the approval projection alone.\n const hash = Schema.decodeUnknownEffect(DerivedKey)\n if ((yield* hash(decoded.nodes)) !== (yield* hash(nodes))) {\n return yield* Effect.fail(\n invalid(\"Plan nodes do not match their compiled keys, effects, ordering, or generations\")\n )\n }\n return freezePlan({ ...decoded, nodes })\n })\n\n/**\n * The nodes added by the newest generation: what {@link module:PlanStore}\n * appends and what the `subgraph-appended` journal record names.\n *\n * @since 0.1.0\n * @category accessors\n * @slop\n */\nexport const generationNodes = (plan: Plan): ReadonlyArray<PlanNode> =>\n plan.nodes.filter((node) => node.generation === plan.generation)\n\n/**\n * Whether `input` is a compiler-owned immutable snapshot that already passed\n * {@link verify}: such values take verify's trusted fast path and need no\n * second schema validation.\n *\n * @since 1.0.0\n * @category guards\n * @slop\n */\nexport const isVerified = (input: unknown): input is Plan =>\n typeof input === \"object\" && input !== null && frozenPlans.has(input as Plan)\n\n/**\n * The approval digest of every generation before the newest: the digest this\n * plan carried before its last append. {@link module:PlanStore}'s append\n * matches it against the stored envelope, so an append proves the recorded\n * plan's integrity from the already-verified prefix instead of decoding and\n * re-verifying every stored row.\n *\n * @since 1.0.0\n * @category accessors\n * @slop\n */\nexport const prefixDigest = (\n plan: Plan\n): Effect.Effect<StepKey.StepKey, StepKey.KeyMaterialError | Schema.SchemaError, Crypto.Crypto> =>\n digestOf(plan.planId, plan.flow, plan.nodes.filter((node) => node.generation < plan.generation))\n"]}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * A plan comparison, as a value.
3
+ *
4
+ * A plan diff answers "which steps changed key (and _which input_
5
+ * changed them), what entered the envelope, what joined the release set —
6
+ * 'what is different about this run' is a set comparison, not archaeology."
7
+ * This module is the set comparison.
8
+ *
9
+ * The **verdict** is the key: two nodes with the same id and the same key are
10
+ * the same step and nothing else needs saying. The **attribution** —
11
+ * `changed: ["input[1]"]` — is a report for a human, derived by comparing the
12
+ * declarations field by field. It is deliberately not part of any digest.
13
+ *
14
+ * @since 0.1.0
15
+ */
16
+ import type * as Plan from "./Plan.ts";
17
+ /**
18
+ * A node whose key moved, with the fields that moved it.
19
+ *
20
+ * @since 0.1.0
21
+ * @category models
22
+ * @slop
23
+ */
24
+ export interface Rekeyed {
25
+ readonly id: string;
26
+ readonly from: string;
27
+ readonly to: string;
28
+ /**
29
+ * Field labels such as `"kind"`, `"body"`, `"layers"`, `"capabilities"`,
30
+ * `"effects"`, and `"input[0]"` whose declaration differs. `"kind"` is the
31
+ * effect tier (`sealed`, `compensable`, or `irreversible`). A
32
+ * `Pending`-referenced upstream re-key is attributed to that input position
33
+ * too. `changed` is empty only when none of the compared fields moved.
34
+ */
35
+ readonly changed: ReadonlyArray<string>;
36
+ }
37
+ /**
38
+ * What changed between two plans of the same flow.
39
+ *
40
+ * @since 0.1.0
41
+ * @category models
42
+ * @slop
43
+ */
44
+ export interface PlanDiff {
45
+ readonly added: ReadonlyArray<string>;
46
+ readonly removed: ReadonlyArray<string>;
47
+ readonly rekeyed: ReadonlyArray<Rekeyed>;
48
+ readonly unchanged: ReadonlyArray<string>;
49
+ }
50
+ /**
51
+ * Compares a plan against the last plan for the same flow.
52
+ *
53
+ * @since 0.1.0
54
+ * @category constructors
55
+ * @slop
56
+ */
57
+ export declare const diff: (previous: Plan.Plan, next: Plan.Plan) => PlanDiff;
58
+ //# sourceMappingURL=PlanDiff.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlanDiff.d.ts","sourceRoot":"","sources":["../../src/PlanDiff.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,KAAK,IAAI,MAAM,WAAW,CAAA;AAGtC;;;;;;GAMG;AACH,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB;;;;;;OAMG;IACH,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;CACxC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;IACrC,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;IACvC,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC,CAAA;IACxC,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;CAC1C;AAuGD;;;;;;GAMG;AACH,eAAO,MAAM,IAAI,GAAI,UAAU,IAAI,CAAC,IAAI,EAAE,MAAM,IAAI,CAAC,IAAI,KAAG,QAmC3D,CAAA"}
@@ -0,0 +1,159 @@
1
+ /**
2
+ * A plan comparison, as a value.
3
+ *
4
+ * A plan diff answers "which steps changed key (and _which input_
5
+ * changed them), what entered the envelope, what joined the release set —
6
+ * 'what is different about this run' is a set comparison, not archaeology."
7
+ * This module is the set comparison.
8
+ *
9
+ * The **verdict** is the key: two nodes with the same id and the same key are
10
+ * the same step and nothing else needs saying. The **attribution** —
11
+ * `changed: ["input[1]"]` — is a report for a human, derived by comparing the
12
+ * declarations field by field. It is deliberately not part of any digest.
13
+ *
14
+ * @since 0.1.0
15
+ */
16
+ import { jsonMirror } from "./internal/JsonMirror.js";
17
+ /**
18
+ * Order-insensitive structural comparison for the attribution report only.
19
+ * Digests go through RFC 8785 canonical JSON; this does not have to, and
20
+ * saying so keeps the two from being confused.
21
+ *
22
+ * @private
23
+ */
24
+ const stable = (value) => {
25
+ if (typeof value === "bigint")
26
+ return `${value}n`;
27
+ if (value === null || typeof value !== "object")
28
+ return JSON.stringify(value) ?? "undefined";
29
+ if (Array.isArray(value))
30
+ return `[${value.map(stable).join(",")}]`;
31
+ const entries = Object.entries(value).sort(([left], [right]) => left < right ? -1 : 1);
32
+ return `{${entries.map(([name, entry]) => `${JSON.stringify(name)}:${stable(entry)}`).join(",")}}`;
33
+ };
34
+ /**
35
+ * A planned value compares as the reference an AST stores for it, so the same
36
+ * reference at the same place is unchanged.
37
+ *
38
+ * @private
39
+ */
40
+ const plannedReference = (_value, reference) => ({
41
+ _tag: "PlannedReference",
42
+ node: reference.node,
43
+ path: reference.path
44
+ });
45
+ /**
46
+ * Projects compared fields through the key's JSON semantics. A refused value
47
+ * receives an identity token scoped to its node and field, so the same value
48
+ * remains equal to itself without equating two distinct refused values.
49
+ *
50
+ * @private
51
+ */
52
+ const fieldComparison = () => {
53
+ const refused = new Map();
54
+ const token = (input, nodeId, field) => {
55
+ try {
56
+ return stable(jsonMirror(input, plannedReference));
57
+ }
58
+ catch {
59
+ const address = JSON.stringify([nodeId, field]);
60
+ let fields = refused.get(input);
61
+ if (fields === undefined) {
62
+ fields = new Map();
63
+ refused.set(input, fields);
64
+ }
65
+ let sentinel = fields.get(address);
66
+ if (sentinel === undefined) {
67
+ sentinel = Symbol(address);
68
+ fields.set(address, sentinel);
69
+ }
70
+ return sentinel;
71
+ }
72
+ };
73
+ return (previous, next, nodeId, field) => token(previous, nodeId, field) === token(next, nodeId, field);
74
+ };
75
+ /** @private */
76
+ const changedFields = (previous, next, rekeyedDependencies, sameField) => {
77
+ const changed = [];
78
+ // StepKey.materialBody is the identity list this attribution must mirror.
79
+ // Inputs, layers, and capabilities complete fromKeyMaterial's hashed value,
80
+ // and material.kind selects the key namespace (content versus tier-bearing
81
+ // plan declaration), so a tier-only move still re-keys and is blamed here.
82
+ if (!sameField(previous.material.version, next.material.version, next.id, "version"))
83
+ changed.push("version");
84
+ if (previous.material.kind !== next.material.kind)
85
+ changed.push("kind");
86
+ if (!sameField(previous.material.body, next.material.body, next.id, "body"))
87
+ changed.push("body");
88
+ if (!sameField(previous.material.nondeterministic, next.material.nondeterministic, next.id, "nondeterministic")) {
89
+ changed.push("nondeterministic");
90
+ }
91
+ if (!sameField(previous.material.effects, next.material.effects, next.id, "effects"))
92
+ changed.push("effects");
93
+ if (!sameField(previous.material.placement, next.material.placement, next.id, "placement")) {
94
+ changed.push("placement");
95
+ }
96
+ const width = Math.max(previous.material.inputs.length, next.material.inputs.length);
97
+ for (let index = 0; index < width; index++) {
98
+ const before = previous.material.inputs[index];
99
+ const after = next.material.inputs[index];
100
+ const field = `input[${index}]`;
101
+ if (before === undefined || after === undefined || !sameField(before, after, next.id, field)) {
102
+ changed.push(field);
103
+ continue;
104
+ }
105
+ if (after._tag !== "Literal" && rekeyedDependencies.has(after.from))
106
+ changed.push(field);
107
+ }
108
+ if (!sameField(previous.material.layers, next.material.layers, next.id, "layers"))
109
+ changed.push("layers");
110
+ if (!sameField(previous.material.capabilities, next.material.capabilities, next.id, "capabilities")) {
111
+ changed.push("capabilities");
112
+ }
113
+ return changed;
114
+ };
115
+ /**
116
+ * Compares a plan against the last plan for the same flow.
117
+ *
118
+ * @since 0.1.0
119
+ * @category constructors
120
+ * @slop
121
+ */
122
+ export const diff = (previous, next) => {
123
+ const before = new Map(previous.nodes.map((node) => [node.id, node]));
124
+ const after = new Map(next.nodes.map((node) => [node.id, node]));
125
+ const rekeyedIds = new Set();
126
+ for (const node of next.nodes) {
127
+ const original = before.get(node.id);
128
+ if (original !== undefined && original.key !== node.key)
129
+ rekeyedIds.add(node.id);
130
+ }
131
+ const added = [];
132
+ const rekeyed = [];
133
+ const unchanged = [];
134
+ const sameField = fieldComparison();
135
+ for (const node of next.nodes) {
136
+ const original = before.get(node.id);
137
+ if (original === undefined) {
138
+ added.push(node.id);
139
+ continue;
140
+ }
141
+ if (original.key === node.key) {
142
+ unchanged.push(node.id);
143
+ continue;
144
+ }
145
+ rekeyed.push({
146
+ id: node.id,
147
+ from: original.key,
148
+ to: node.key,
149
+ changed: changedFields(original, node, rekeyedIds, sameField)
150
+ });
151
+ }
152
+ return {
153
+ added,
154
+ removed: previous.nodes.filter((node) => !after.has(node.id)).map((node) => node.id),
155
+ rekeyed,
156
+ unchanged
157
+ };
158
+ };
159
+ //# sourceMappingURL=PlanDiff.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlanDiff.js","sourceRoot":"","sources":["../../src/PlanDiff.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAuCrD;;;;;;GAMG;AACH,MAAM,MAAM,GAAG,CAAC,KAAc,EAAU,EAAE;IACxC,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,GAAG,KAAK,GAAG,CAAA;IACjD,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,WAAW,CAAA;IAC5F,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAA;IACnE,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,KAAgC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,IAAI,GAAG,KAAK,CAAC,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*\n * A plan diff answers \"which steps changed key (and _which input_\n * changed them), what entered the envelope, what joined the release set —\n * 'what is different about this run' is a set comparison, not archaeology.\"\n * This module is the set comparison.\n *\n * The **verdict** is the key: two nodes with the same id and the same key are\n * the same step and nothing else needs saying. The **attribution** —\n * `changed: [\"input[1]\"]` — is a report for a human, derived by comparing the\n * declarations field by field. It is deliberately not part of any digest.\n *\n * @since 0.1.0\n */\n\nimport { jsonMirror } from \"./internal/JsonMirror.ts\"\nimport type * as Plan from \"./Plan.ts\"\nimport type * as Planned from \"./Planned.ts\"\n\n/**\n * A node whose key moved, with the fields that moved it.\n *\n * @since 0.1.0\n * @category models\n * @slop\n */\nexport interface Rekeyed {\n readonly id: string\n readonly from: string\n readonly to: string\n /**\n * Field labels such as `\"kind\"`, `\"body\"`, `\"layers\"`, `\"capabilities\"`,\n * `\"effects\"`, and `\"input[0]\"` whose declaration differs. `\"kind\"` is the\n * effect tier (`sealed`, `compensable`, or `irreversible`). A\n * `Pending`-referenced upstream re-key is attributed to that input position\n * too. `changed` is empty only when none of the compared fields moved.\n */\n readonly changed: ReadonlyArray<string>\n}\n\n/**\n * What changed between two plans of the same flow.\n *\n * @since 0.1.0\n * @category models\n * @slop\n */\nexport interface PlanDiff {\n readonly added: ReadonlyArray<string>\n readonly removed: ReadonlyArray<string>\n readonly rekeyed: ReadonlyArray<Rekeyed>\n readonly unchanged: ReadonlyArray<string>\n}\n\n/**\n * Order-insensitive structural comparison for the attribution report only.\n * Digests go through RFC 8785 canonical JSON; this does not have to, and\n * saying so keeps the two from being confused.\n *\n * @private\n */\nconst stable = (value: unknown): string => {\n if (typeof value === \"bigint\") return `${value}n`\n if (value === null || typeof value !== \"object\") return JSON.stringify(value) ?? \"undefined\"\n if (Array.isArray(value)) return `[${value.map(stable).join(\",\")}]`\n const entries = Object.entries(value as Record<string, unknown>).sort(([left], [right]) => left < right ? -1 : 1)\n return `{${entries.map(([name, entry]) => `${JSON.stringify(name)}:${stable(entry)}`).join(\",\")}}`\n}\n\n/**\n * A planned value compares as the reference an AST stores for it, so the same\n * reference at the same place is unchanged.\n *\n * @private\n */\nconst plannedReference = (_value: unknown, reference: Planned.Reference) => ({\n _tag: \"PlannedReference\",\n node: reference.node,\n path: reference.path\n})\n\n/** @private */\ntype ComparisonToken = string | symbol\n\n/**\n * Projects compared fields through the key's JSON semantics. A refused value\n * receives an identity token scoped to its node and field, so the same value\n * remains equal to itself without equating two distinct refused values.\n *\n * @private\n */\nconst fieldComparison = () => {\n const refused = new Map<unknown, Map<string, symbol>>()\n const token = (input: unknown, nodeId: string, field: string): ComparisonToken => {\n try {\n return stable(jsonMirror(input, plannedReference))\n } catch {\n const address = JSON.stringify([nodeId, field])\n let fields = refused.get(input)\n if (fields === undefined) {\n fields = new Map()\n refused.set(input, fields)\n }\n let sentinel = fields.get(address)\n if (sentinel === undefined) {\n sentinel = Symbol(address)\n fields.set(address, sentinel)\n }\n return sentinel\n }\n }\n return (previous: unknown, next: unknown, nodeId: string, field: string): boolean =>\n token(previous, nodeId, field) === token(next, nodeId, field)\n}\n\n/** @private */\nconst changedFields = (\n previous: Plan.PlanNode,\n next: Plan.PlanNode,\n rekeyedDependencies: ReadonlySet<string>,\n sameField: ReturnType<typeof fieldComparison>\n): ReadonlyArray<string> => {\n const changed: Array<string> = []\n // StepKey.materialBody is the identity list this attribution must mirror.\n // Inputs, layers, and capabilities complete fromKeyMaterial's hashed value,\n // and material.kind selects the key namespace (content versus tier-bearing\n // plan declaration), so a tier-only move still re-keys and is blamed here.\n if (!sameField(previous.material.version, next.material.version, next.id, \"version\")) changed.push(\"version\")\n if (previous.material.kind !== next.material.kind) changed.push(\"kind\")\n if (!sameField(previous.material.body, next.material.body, next.id, \"body\")) changed.push(\"body\")\n if (!sameField(previous.material.nondeterministic, next.material.nondeterministic, next.id, \"nondeterministic\")) {\n changed.push(\"nondeterministic\")\n }\n if (!sameField(previous.material.effects, next.material.effects, next.id, \"effects\")) changed.push(\"effects\")\n if (!sameField(previous.material.placement, next.material.placement, next.id, \"placement\")) {\n changed.push(\"placement\")\n }\n const width = Math.max(previous.material.inputs.length, next.material.inputs.length)\n for (let index = 0; index < width; index++) {\n const before = previous.material.inputs[index]\n const after = next.material.inputs[index]\n const field = `input[${index}]`\n if (before === undefined || after === undefined || !sameField(before, after, next.id, field)) {\n changed.push(field)\n continue\n }\n if (after._tag !== \"Literal\" && rekeyedDependencies.has(after.from)) changed.push(field)\n }\n if (!sameField(previous.material.layers, next.material.layers, next.id, \"layers\")) changed.push(\"layers\")\n if (!sameField(previous.material.capabilities, next.material.capabilities, next.id, \"capabilities\")) {\n changed.push(\"capabilities\")\n }\n return changed\n}\n\n/**\n * Compares a plan against the last plan for the same flow.\n *\n * @since 0.1.0\n * @category constructors\n * @slop\n */\nexport const diff = (previous: Plan.Plan, next: Plan.Plan): PlanDiff => {\n const before = new Map(previous.nodes.map((node) => [node.id, node]))\n const after = new Map(next.nodes.map((node) => [node.id, node]))\n const rekeyedIds = new Set<string>()\n for (const node of next.nodes) {\n const original = before.get(node.id)\n if (original !== undefined && original.key !== node.key) rekeyedIds.add(node.id)\n }\n const added: Array<string> = []\n const rekeyed: Array<Rekeyed> = []\n const unchanged: Array<string> = []\n const sameField = fieldComparison()\n for (const node of next.nodes) {\n const original = before.get(node.id)\n if (original === undefined) {\n added.push(node.id)\n continue\n }\n if (original.key === node.key) {\n unchanged.push(node.id)\n continue\n }\n rekeyed.push({\n id: node.id,\n from: original.key,\n to: node.key,\n changed: changedFields(original, node, rekeyedIds, sameField)\n })\n }\n return {\n added,\n removed: previous.nodes.filter((node) => !after.has(node.id)).map((node) => node.id),\n rekeyed,\n unchanged\n }\n}\n"]}
@@ -0,0 +1,121 @@
1
+ /**
2
+ * The placeholder a body sees where a step result will be.
3
+ *
4
+ * A flow body runs at PLAN time, so its
5
+ * own payload is real data while every step result is a value that does not
6
+ * exist yet. That value has a name and one rule: a planned value may be **passed** — into a payload field,
7
+ * into a branch, into a map — and field access is allowed, because it records a
8
+ * reference path. It may never be **computed on**.
9
+ *
10
+ * {@link Planned} is branded, so arithmetic is a compile error.
11
+ * {@link make} returns a strict proxy
12
+ * whose `Symbol.toPrimitive`, `valueOf`, `toString`, `toJSON`, and call traps
13
+ * throw {@link module:GraphBuildError.GraphBuildError} rather than let a plan be
14
+ * built around `NaN` or `"[object Object]"`. The lenient proxy this adapts
15
+ * (`@smthrs/core`'s `Graph.plannedValue`) answered `toPrimitive` with a
16
+ * readable string, which is exactly the silent-wrong-plan path this module
17
+ * exists to close.
18
+ *
19
+ * JavaScript does not expose traps for `Boolean(value)` or strict identity
20
+ * (`value === other`), so those operations cannot be refused at run time.
21
+ * They reveal only proxy truthiness or identity and never the planned result;
22
+ * authors must use {@link module:Node.branch} for decisions on real values.
23
+ * Type-aware ESLint `@typescript-eslint/strict-boolean-expressions` rejects
24
+ * planned conditions, but does not reject explicit Boolean coercion or all
25
+ * reference comparisons. Those still require review.
26
+ *
27
+ * @since 0.1.0
28
+ */
29
+ import type * as Types from "effect/Types";
30
+ /**
31
+ * The brand carried by every planned value, and the key its reference is read
32
+ * from. Interned with `Symbol.for` so a value that crossed a module boundary is
33
+ * still recognised. The interned symbol is a recognition aid, not a
34
+ * capability, so {@link reference} validates the value stored under it.
35
+ *
36
+ * @since 0.1.0
37
+ * @category symbols
38
+ * @slop
39
+ */
40
+ export declare const TypeId: unique symbol;
41
+ /**
42
+ * The type-level form of {@link TypeId}.
43
+ *
44
+ * @since 0.1.0
45
+ * @category symbols
46
+ * @slop
47
+ */
48
+ export type TypeId = typeof TypeId;
49
+ /**
50
+ * What a planned value points at: the node that will produce the result, and
51
+ * the property path read from it. `path` is empty for the result itself.
52
+ *
53
+ * @since 0.1.0
54
+ * @category models
55
+ * @slop
56
+ */
57
+ export interface Reference {
58
+ readonly node: string;
59
+ readonly path: ReadonlyArray<string>;
60
+ }
61
+ /**
62
+ * A {@link Reference} plus the phantom type of the value it stands for, so
63
+ * `Planned<string>` and `Planned<number>` are not interchangeable.
64
+ *
65
+ * @since 0.1.0
66
+ * @category models
67
+ * @slop
68
+ */
69
+ export interface Identity<out T> extends Reference {
70
+ readonly _T: Types.Covariant<T>;
71
+ }
72
+ /**
73
+ * A step result that has not been produced yet.
74
+ *
75
+ * The brand rejects arithmetic and ordinary value arguments. The mapped half keeps field
76
+ * access typed — `result.files` is a `Planned` of the field, which is what
77
+ * makes "pass it on, never compute on it" expressible rather than merely
78
+ * documented.
79
+ *
80
+ * @since 0.1.0
81
+ * @category models
82
+ * @slop
83
+ */
84
+ export type Planned<T> = {
85
+ readonly [TypeId]: Identity<T>;
86
+ } & ([T] extends [object] ? {
87
+ readonly [K in keyof T]: Planned<T[K]>;
88
+ } : unknown);
89
+ /**
90
+ * Creates the strict placeholder standing for a node's result.
91
+ *
92
+ * Planning hands one of these to every builder that consumes an upstream
93
+ * value — a branch arm, a continuation — and reads the {@link Reference} back
94
+ * off whatever the builder passed it into.
95
+ *
96
+ * @since 0.1.0
97
+ * @category constructors
98
+ * @slop
99
+ */
100
+ export declare const make: <T>(node: string) => Planned<T>;
101
+ /**
102
+ * Reads the reference a planned value records, or `undefined` for anything
103
+ * else. An interned symbol is a recognition aid rather than a capability, so a
104
+ * forged carrier is accepted only when its node and path have the complete
105
+ * reference shape. This is how a payload is scanned for the upstream results
106
+ * it consumes.
107
+ *
108
+ * @since 0.1.0
109
+ * @category accessors
110
+ * @slop
111
+ */
112
+ export declare const reference: (value: unknown) => Reference | undefined;
113
+ /**
114
+ * Checks whether a value is a planned placeholder.
115
+ *
116
+ * @since 0.1.0
117
+ * @category guards
118
+ * @slop
119
+ */
120
+ export declare const isPlanned: (value: unknown) => value is Planned<unknown>;
121
+ //# sourceMappingURL=Planned.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Planned.d.ts","sourceRoot":"","sources":["../../src/Planned.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAA;AAG1C;;;;;;;;;GASG;AACH,eAAO,MAAM,MAAM,EAAE,OAAO,MAA2C,CAAA;AAEvE;;;;;;GAMG;AACH,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAA;AAElC;;;;;;;GAOG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;CACrC;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAE,SAAQ,SAAS;IAChD,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;CAChC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,IACjB;IAAE,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAA;CAAE,GAClC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG;IAAE,QAAQ,EAAE,CAAC,IAAI,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GAAG,OAAO,CAAC,CAAA;AAmEjF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,IAAI,GAAI,CAAC,EAAE,MAAM,MAAM,KAAG,OAAO,CAAC,CAAC,CAAkD,CAAA;AAalG;;;;;;;;;;GAUG;AACH,eAAO,MAAM,SAAS,GAAI,OAAO,OAAO,KAAG,SAAS,GAAG,SAItD,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,OAAO,CAAC,OAAO,CAAmC,CAAA"}
@@ -0,0 +1,147 @@
1
+ /**
2
+ * The placeholder a body sees where a step result will be.
3
+ *
4
+ * A flow body runs at PLAN time, so its
5
+ * own payload is real data while every step result is a value that does not
6
+ * exist yet. That value has a name and one rule: a planned value may be **passed** — into a payload field,
7
+ * into a branch, into a map — and field access is allowed, because it records a
8
+ * reference path. It may never be **computed on**.
9
+ *
10
+ * {@link Planned} is branded, so arithmetic is a compile error.
11
+ * {@link make} returns a strict proxy
12
+ * whose `Symbol.toPrimitive`, `valueOf`, `toString`, `toJSON`, and call traps
13
+ * throw {@link module:GraphBuildError.GraphBuildError} rather than let a plan be
14
+ * built around `NaN` or `"[object Object]"`. The lenient proxy this adapts
15
+ * (`@smthrs/core`'s `Graph.plannedValue`) answered `toPrimitive` with a
16
+ * readable string, which is exactly the silent-wrong-plan path this module
17
+ * exists to close.
18
+ *
19
+ * JavaScript does not expose traps for `Boolean(value)` or strict identity
20
+ * (`value === other`), so those operations cannot be refused at run time.
21
+ * They reveal only proxy truthiness or identity and never the planned result;
22
+ * authors must use {@link module:Node.branch} for decisions on real values.
23
+ * Type-aware ESLint `@typescript-eslint/strict-boolean-expressions` rejects
24
+ * planned conditions, but does not reject explicit Boolean coercion or all
25
+ * reference comparisons. Those still require review.
26
+ *
27
+ * @since 0.1.0
28
+ */
29
+ import { GraphBuildError } from "./GraphBuildError.js";
30
+ /**
31
+ * The brand carried by every planned value, and the key its reference is read
32
+ * from. Interned with `Symbol.for` so a value that crossed a module boundary is
33
+ * still recognised. The interned symbol is a recognition aid, not a
34
+ * capability, so {@link reference} validates the value stored under it.
35
+ *
36
+ * @since 0.1.0
37
+ * @category symbols
38
+ * @slop
39
+ */
40
+ export const TypeId = Symbol.for("@smthrs/plan/Planned");
41
+ /**
42
+ * The operations that are computation rather than reference, keyed by the
43
+ * property that performs them. `toJSON` is here because `JSON.stringify` reads
44
+ * it, and a plan that serialized a placeholder would look correct.
45
+ *
46
+ * @private
47
+ */
48
+ const refusals = new Map([
49
+ [Symbol.toPrimitive, "Symbol.toPrimitive"],
50
+ ["valueOf", "valueOf"],
51
+ ["toString", "toString"],
52
+ ["toJSON", "toJSON"]
53
+ ]);
54
+ /** @private */
55
+ const describe = (reference) => reference.path.length === 0 ? reference.node : `${reference.node}.${reference.path.join(".")}`;
56
+ /**
57
+ * The one refusal this module raises. The guidance is spelled out rather than
58
+ * linked because the author reading it is inside a body and needs the
59
+ * correction on the spot.
60
+ *
61
+ * @private
62
+ */
63
+ const refuse = (reference, operation) => new GraphBuildError({
64
+ code: "planned_value_computed",
65
+ node: reference.node,
66
+ path: reference.path,
67
+ message: `Planned value ${describe(reference)} was computed at plan time by ${operation}. ` +
68
+ "Use Node.map to compute, Node.branch to decide, or pass the value into a payload."
69
+ });
70
+ /**
71
+ * The proxy itself. `_T` of {@link Identity} is a phantom and never exists at
72
+ * run time, so the trap carries the plain {@link Reference}.
73
+ *
74
+ * @private
75
+ */
76
+ const placeholder = (reference) => {
77
+ /* v8 ignore next -- a Proxy application always enters the `apply` trap below, so the callable target is unreachable by construction */
78
+ const target = () => undefined;
79
+ return new Proxy(target, {
80
+ get: (_target, key) => {
81
+ if (key === TypeId)
82
+ return reference;
83
+ const refusal = refusals.get(key);
84
+ if (refusal !== undefined)
85
+ throw refuse(reference, refusal);
86
+ // Not a thenable: a body that returns a planned value inside a promise
87
+ // must resolve to the placeholder, not hang awaiting a proxy.
88
+ if (key === "then")
89
+ return undefined;
90
+ return placeholder({ node: reference.node, path: [...reference.path, String(key)] });
91
+ },
92
+ apply: () => {
93
+ throw refuse(reference, "function application");
94
+ },
95
+ has: () => {
96
+ throw refuse(reference, "property existence (`in`)");
97
+ },
98
+ ownKeys: () => {
99
+ throw refuse(reference, "property enumeration");
100
+ }
101
+ });
102
+ };
103
+ /**
104
+ * Creates the strict placeholder standing for a node's result.
105
+ *
106
+ * Planning hands one of these to every builder that consumes an upstream
107
+ * value — a branch arm, a continuation — and reads the {@link Reference} back
108
+ * off whatever the builder passed it into.
109
+ *
110
+ * @since 0.1.0
111
+ * @category constructors
112
+ * @slop
113
+ */
114
+ export const make = (node) => placeholder({ node, path: [] });
115
+ /** @private */
116
+ const carrier = (value) => (typeof value === "object" && value !== null) || typeof value === "function";
117
+ /** @private */
118
+ const validReference = (value) => typeof value === "object" && value !== null &&
119
+ typeof value.node === "string" && value.node.length > 0 &&
120
+ Array.isArray(value.path) &&
121
+ Array.from(value.path).every((segment) => typeof segment === "string");
122
+ /**
123
+ * Reads the reference a planned value records, or `undefined` for anything
124
+ * else. An interned symbol is a recognition aid rather than a capability, so a
125
+ * forged carrier is accepted only when its node and path have the complete
126
+ * reference shape. This is how a payload is scanned for the upstream results
127
+ * it consumes.
128
+ *
129
+ * @since 0.1.0
130
+ * @category accessors
131
+ * @slop
132
+ */
133
+ export const reference = (value) => {
134
+ if (!carrier(value))
135
+ return undefined;
136
+ const candidate = value[TypeId];
137
+ return validReference(candidate) ? candidate : undefined;
138
+ };
139
+ /**
140
+ * Checks whether a value is a planned placeholder.
141
+ *
142
+ * @since 0.1.0
143
+ * @category guards
144
+ * @slop
145
+ */
146
+ export const isPlanned = (value) => reference(value) !== undefined;
147
+ //# sourceMappingURL=Planned.js.map