@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,398 @@
1
+ /**
2
+ * Static filesystem declaration vocabulary shared by planning and execution.
3
+ *
4
+ * Declared paths use `/` as their canonical separator and normalize Unicode
5
+ * to NFC. Workspace-relative paths reject C0 controls (U+0000 through U+001F)
6
+ * and DEL (U+007F), which name nothing a supported filesystem can open. C1
7
+ * controls (U+0080 through U+009F) remain accepted because those bytes are
8
+ * legal in a POSIX file name.
9
+ *
10
+ * @since 0.1.0
11
+ */
12
+ import * as Schema from "effect/Schema";
13
+ /**
14
+ * How strictly a declared file set is enforced at the boundary.
15
+ *
16
+ * `hard` rejects undeclared access. `expected` records access for validation
17
+ * after execution without requiring the sandbox to reject it immediately.
18
+ *
19
+ * This is the ONE spelling of the pair. `Plan.NodeEffects.boundaryMode` is this
20
+ * schema and so is `@smthrs/flow`'s `Action.BoundaryMode`; the literal used to
21
+ * be written out in all three places.
22
+ *
23
+ * @category schemas
24
+ * @since 1.0.0-rc.0
25
+ */
26
+ export const BoundaryMode = Schema.Literals(["hard", "expected"]);
27
+ /**
28
+ * The canonical spelling of a declared path or pattern: every separator is
29
+ * `/`, and Unicode is normalized to NFC.
30
+ *
31
+ * {@link workspaceRelative} accepts a backslash as a separator, so
32
+ * `dist\same.js` and `dist/same.js` are two spellings of ONE workspace path.
33
+ * Every exact-path comparison in this module goes through this form, because
34
+ * comparing the raw spellings would let the separator alias defeat overlap
35
+ * detection exactly as `.` segments and empty segments would.
36
+ *
37
+ * @category accessors
38
+ * @since 0.1.0
39
+ */
40
+ export const canonical = (path) => path.replaceAll("\\", "/").normalize("NFC");
41
+ /**
42
+ * The {@link canonical} spelling with letter case folded away.
43
+ *
44
+ * A case-insensitive filesystem (default macOS APFS, Windows NTFS) opens
45
+ * `src/A.ts` and `src/a.ts` as one file, so static overlap compares this form:
46
+ * two declarations that differ only in case must serialize. Folding goes
47
+ * through upper case because that mapping is context-free, so it folds each
48
+ * character alone and commutes with splitting a path into segments.
49
+ *
50
+ * @category accessors
51
+ * @since 1.0.0-rc.0
52
+ */
53
+ export const folded = (path) => canonical(path).toUpperCase().normalize("NFC");
54
+ /**
55
+ * A non-empty workspace-relative path or pattern.
56
+ *
57
+ * Decoding fails with a `SchemaError` when {@link workspaceRelative} refuses
58
+ * the string. A bare `Pattern` in a declaration names one literal path; only a
59
+ * {@link Glob} gives `*` and `**` wildcard meaning.
60
+ *
61
+ * @category schemas
62
+ * @since 0.1.0
63
+ */
64
+ export const Pattern = Schema.NonEmptyString.check(Schema.makeFilter((pattern) => workspaceRelative(pattern) || "file patterns must be workspace-relative and cannot traverse upward", { title: "workspaceRelativePattern" }));
65
+ /**
66
+ * Whether a declared path or pattern stays inside the workspace and names it
67
+ * one way only. Refuses absolute paths (POSIX and drive-letter), upward
68
+ * traversal, and the aliasing forms — `.` segments, empty segments — that
69
+ * would let two spellings of one file defeat exact-string overlap detection.
70
+ *
71
+ * C0 controls and DEL are refused as well.
72
+ *
73
+ * @category predicates
74
+ * @since 0.1.0
75
+ */
76
+ export const workspaceRelative = (pattern) => {
77
+ for (let index = 0; index < pattern.length; index++) {
78
+ const code = pattern.charCodeAt(index);
79
+ if (code <= 0x1f || code === 0x7f)
80
+ return false;
81
+ }
82
+ if (pattern.startsWith("/"))
83
+ return false;
84
+ const segments = canonical(pattern).split("/");
85
+ // `C:foo` is drive-relative on Windows, so any drive-letter prefix escapes.
86
+ if (/^[A-Za-z]:/.test(segments[0]) || segments[0].endsWith(":"))
87
+ return false;
88
+ return segments.every((segment) => segment !== ".." && segment !== "." && segment !== "");
89
+ };
90
+ /**
91
+ * A Bazel-style file glob: the paths matching any `include` pattern and no
92
+ * `exclude` pattern.
93
+ *
94
+ * In a pattern, `*` matches within one path segment and a `**` segment
95
+ * matches zero or more whole segments. A trailing `**` needs its separator,
96
+ * so `src/**` does not match `src` itself.
97
+ *
98
+ * @category schemas
99
+ * @since 0.1.0
100
+ */
101
+ export const Glob = Schema.TaggedStruct("Glob", {
102
+ include: Schema.NonEmptyArray(Pattern),
103
+ exclude: Schema.optional(Schema.Array(Pattern))
104
+ });
105
+ /**
106
+ * A directory output captured and replayed as one tree artifact.
107
+ *
108
+ * It covers `path` and every path beneath it, compared in {@link folded}
109
+ * form.
110
+ *
111
+ * @category schemas
112
+ * @since 0.1.0
113
+ */
114
+ export const TreeArtifact = Schema.TaggedStruct("TreeArtifact", {
115
+ path: Pattern
116
+ });
117
+ /**
118
+ * One leaf declaration: a literal path, a {@link Glob}, or a
119
+ * {@link TreeArtifact}. Write sets and filegroups hold entries.
120
+ *
121
+ * @category schemas
122
+ * @since 0.1.0
123
+ */
124
+ export const Entry = Schema.Union([Pattern, Glob, TreeArtifact]);
125
+ /**
126
+ * One leaf declaration valid in a read set: a literal path or a {@link Glob}.
127
+ * A read set cannot name a {@link TreeArtifact}, which is an output form.
128
+ *
129
+ * @category schemas
130
+ * @since 0.1.0
131
+ */
132
+ export const ReadEntry = Schema.Union([Pattern, Glob]);
133
+ /**
134
+ * A named, reusable list of {@link Entry} declarations.
135
+ *
136
+ * {@link expand} replaces a filegroup with its entries in place before any
137
+ * overlap check or measurement, so the name never reaches the boundary.
138
+ * Filegroups do not nest.
139
+ *
140
+ * @category schemas
141
+ * @since 0.1.0
142
+ */
143
+ export const Filegroup = Schema.TaggedStruct("Filegroup", {
144
+ name: Schema.NonEmptyString,
145
+ entries: Schema.Array(Entry)
146
+ });
147
+ /**
148
+ * A {@link Filegroup} restricted to {@link ReadEntry} declarations, for use
149
+ * in a read set. It shares the `"Filegroup"` tag.
150
+ *
151
+ * @category schemas
152
+ * @since 0.1.0
153
+ */
154
+ export const ReadFilegroup = Schema.TaggedStruct("Filegroup", {
155
+ name: Schema.NonEmptyString,
156
+ entries: Schema.Array(ReadEntry)
157
+ });
158
+ /**
159
+ * Any declaration accepted in a write set: an {@link Entry} or a
160
+ * {@link Filegroup}.
161
+ *
162
+ * @category schemas
163
+ * @since 0.1.0
164
+ */
165
+ export const Declaration = Schema.Union([Entry, Filegroup]);
166
+ /**
167
+ * Any declaration accepted in a read set: a {@link ReadEntry} or a
168
+ * {@link ReadFilegroup}.
169
+ *
170
+ * @category schemas
171
+ * @since 0.1.0
172
+ */
173
+ export const ReadDeclaration = Schema.Union([ReadEntry, ReadFilegroup]);
174
+ /**
175
+ * Creates a {@link Filegroup}. It does not validate `name` or `entries`;
176
+ * decode through {@link Filegroup} when the input is untrusted.
177
+ *
178
+ * @param name - The filegroup name.
179
+ * @param entries - The entries the filegroup expands to, in order.
180
+ * @returns The filegroup value.
181
+ * @category constructors
182
+ * @since 0.1.0
183
+ */
184
+ export const makeFilegroup = (name, entries) => ({
185
+ _tag: "Filegroup",
186
+ name,
187
+ entries
188
+ });
189
+ /**
190
+ * Replaces each {@link Filegroup} with its entries, in place, and keeps every
191
+ * other declaration as it is. Order is preserved and duplicates are kept.
192
+ *
193
+ * @param declarations - Write-set declarations, possibly holding filegroups.
194
+ * @returns The flat list of entries.
195
+ * @category accessors
196
+ * @since 0.1.0
197
+ */
198
+ export const expand = (declarations) => declarations.flatMap((declaration) => typeof declaration !== "string" && declaration._tag === "Filegroup" ? declaration.entries : [declaration]);
199
+ /**
200
+ * {@link expand} for read sets: replaces each {@link ReadFilegroup} with its
201
+ * entries, in place, preserving order and duplicates.
202
+ *
203
+ * @param declarations - Read-set declarations, possibly holding filegroups.
204
+ * @returns The flat list of read entries.
205
+ * @category accessors
206
+ * @since 0.1.0
207
+ */
208
+ export const expandReads = (declarations) => declarations.flatMap((declaration) => typeof declaration !== "string" && declaration._tag === "Filegroup" ? declaration.entries : [declaration]);
209
+ /**
210
+ * Whether a value carries the `"Glob"` tag. It checks only the tag, not the
211
+ * patterns.
212
+ *
213
+ * @param value - Any value.
214
+ * @returns `true` for an object whose `_tag` is `"Glob"`.
215
+ * @category guards
216
+ * @since 0.1.0
217
+ */
218
+ export const isGlob = (value) => typeof value === "object" && value !== null && "_tag" in value && value._tag === "Glob";
219
+ /**
220
+ * Whether a value carries the `"TreeArtifact"` tag. It checks only the tag,
221
+ * not the path.
222
+ *
223
+ * @param value - Any value.
224
+ * @returns `true` for an object whose `_tag` is `"TreeArtifact"`.
225
+ * @category guards
226
+ * @since 0.1.0
227
+ */
228
+ export const isTreeArtifact = (value) => typeof value === "object" && value !== null && "_tag" in value && value._tag === "TreeArtifact";
229
+ /** KMP searches a literal without rescanning a long near-matching prefix. */
230
+ const literalSearch = (literal) => {
231
+ const fallback = new Uint32Array(literal.length);
232
+ let matched = 0;
233
+ for (let index = 1; index < literal.length; index++) {
234
+ while (matched > 0 && literal[index] !== literal[matched])
235
+ matched = fallback[matched - 1];
236
+ if (literal[index] === literal[matched])
237
+ matched++;
238
+ fallback[index] = matched;
239
+ }
240
+ return (path, start, end) => {
241
+ let matched = 0;
242
+ for (let index = start; index < end; index++) {
243
+ while (matched > 0 && path[index] !== literal[matched])
244
+ matched = fallback[matched - 1];
245
+ if (path[index] === literal[matched])
246
+ matched++;
247
+ if (matched === literal.length)
248
+ return index + 1;
249
+ }
250
+ return -1;
251
+ };
252
+ };
253
+ /** Anchored ends and disjoint literal searches make each segment match linear. */
254
+ const segmentMatcher = (segment) => {
255
+ const chunks = segment.split(/\*+/);
256
+ const prefix = chunks.shift();
257
+ if (chunks.length === 0)
258
+ return (path) => path === prefix;
259
+ const suffix = chunks.pop();
260
+ const searches = chunks.map(literalSearch);
261
+ return (path) => {
262
+ const end = path.length - suffix.length;
263
+ if (prefix.length > end || !path.startsWith(prefix) || !path.endsWith(suffix))
264
+ return false;
265
+ let position = prefix.length;
266
+ for (const search of searches) {
267
+ position = search(path, position, end);
268
+ if (position === -1)
269
+ return false;
270
+ }
271
+ return true;
272
+ };
273
+ };
274
+ const patternMatchers = new Map();
275
+ /** Compile once per canonical spelling; recursive segments use no backtracking. */
276
+ const patternMatcher = (pattern) => {
277
+ const key = canonical(pattern);
278
+ const cached = patternMatchers.get(key);
279
+ if (cached !== undefined)
280
+ return cached;
281
+ const segments = key.split("/").map((segment) => segment === "**" ? undefined : segmentMatcher(segment));
282
+ const matcher = (path) => {
283
+ const parts = path.split("/");
284
+ // Suffix membership: next[j] says the remaining pattern matches parts[j..].
285
+ // Each pattern/path segment pair is visited once, even with repeated **.
286
+ let next = new Uint8Array(parts.length + 1);
287
+ next[parts.length] = 1;
288
+ for (let index = segments.length - 1; index >= 0; index--) {
289
+ const segment = segments[index];
290
+ const current = new Uint8Array(parts.length + 1);
291
+ for (let part = parts.length - 1; part >= 0; part--) {
292
+ current[part] = segment === undefined
293
+ // A trailing ** accepts every remaining code unit. It still needs
294
+ // the separator preceding it: src/** does not match bare src.
295
+ ? Number(index === segments.length - 1 || next[part] === 1 ||
296
+ (parts[part] !== "" && current[part + 1] === 1))
297
+ : Number(next[part + 1] === 1 && segment(parts[part]));
298
+ }
299
+ next = current;
300
+ }
301
+ return next[0] === 1;
302
+ };
303
+ patternMatchers.set(key, matcher);
304
+ return matcher;
305
+ };
306
+ /**
307
+ * Whether `path` matches `pattern` under {@link Glob} wildcard rules.
308
+ *
309
+ * The pattern is read in its {@link canonical} spelling; the path is matched
310
+ * as given, case-sensitively, with `/` as its only separator.
311
+ *
312
+ * @param pattern - A Bazel-style pattern such as `src/*.ts` or `docs/**`.
313
+ * @param path - A workspace-relative path.
314
+ * @returns `true` when the path matches.
315
+ * @category predicates
316
+ * @since 0.1.0
317
+ */
318
+ export const matchesPattern = (pattern, path) => patternMatcher(pattern)(path);
319
+ /**
320
+ * Whether `path` matches some `include` pattern of `glob` and no `exclude`
321
+ * pattern, each tested with {@link matchesPattern}. Case-sensitive.
322
+ *
323
+ * @param glob - The glob to test.
324
+ * @param path - A workspace-relative path.
325
+ * @returns `true` when the glob selects the path.
326
+ * @category predicates
327
+ * @since 0.1.0
328
+ */
329
+ export const matchesGlob = (glob, path) => glob.include.some((pattern) => matchesPattern(pattern, path)) &&
330
+ !(glob.exclude ?? []).some((pattern) => matchesPattern(pattern, path));
331
+ const beneath = (tree, path) => {
332
+ const root = folded(tree);
333
+ const inside = folded(path);
334
+ return inside === root || inside.startsWith(`${root}/`);
335
+ };
336
+ /**
337
+ * Whether a canonical path is inside a declaration, case-sensitively.
338
+ * Unlike {@link overlaps}, this predicate establishes replay authority.
339
+ *
340
+ * @category predicates
341
+ * @since 1.0.0-rc.0
342
+ */
343
+ export const contains = (entry, path) => {
344
+ const inside = canonical(path);
345
+ if (typeof entry === "string")
346
+ return canonical(entry) === inside;
347
+ if (isGlob(entry))
348
+ return matchesGlob(entry, inside);
349
+ const root = canonical(entry.path);
350
+ return inside === root || inside.startsWith(`${root}/`);
351
+ };
352
+ /** Includes fold conservatively; exclusions cannot rule out all case aliases. */
353
+ const mayMatchGlob = (glob, path) => glob.include.some((pattern) => matchesPattern(folded(pattern), folded(path)));
354
+ /**
355
+ * Conservative static overlap. `true` may over-serialize; `false` proves that
356
+ * no path can belong to both declarations.
357
+ *
358
+ * A plain string is a literal path, even when it contains `*` or `**`, as it
359
+ * is at execution (sandbox admission, capture, removal, and replay); wildcard
360
+ * matching belongs to a Glob.
361
+ *
362
+ * Exact paths and tree roots compare in their
363
+ * {@link folded} form, so separator aliases, canonically equivalent Unicode
364
+ * spellings, and spellings that differ only in letter case overlap. A Glob
365
+ * against an exact path folds its includes and ignores exclusions: an excluded
366
+ * spelling may alias an included spelling on another filesystem. {@link matchesGlob} itself stays case-sensitive and tests the path bytes it
367
+ * is handed; its property suite pins a backslash inside a path segment as
368
+ * literal text, so canonicalizing a measured path before matching is its
369
+ * caller's decision, not this module's.
370
+ *
371
+ * @category predicates
372
+ * @since 0.1.0
373
+ */
374
+ export const overlaps = (left, right) => {
375
+ if (typeof left === "string" && typeof right === "string")
376
+ return folded(left) === folded(right);
377
+ if (typeof left === "string" && isGlob(right))
378
+ return mayMatchGlob(right, left);
379
+ if (isGlob(left) && typeof right === "string")
380
+ return mayMatchGlob(left, right);
381
+ if (isGlob(left) && isGlob(right))
382
+ return true;
383
+ if (isTreeArtifact(left) && typeof right === "string")
384
+ return beneath(left.path, right);
385
+ if (typeof left === "string" && isTreeArtifact(right))
386
+ return beneath(right.path, left);
387
+ if (isTreeArtifact(left) && isTreeArtifact(right)) {
388
+ return beneath(left.path, right.path) || beneath(right.path, left.path);
389
+ }
390
+ if (isTreeArtifact(left) && isGlob(right))
391
+ return true;
392
+ /* v8 ignore else -- the closed Entry union leaves only Glob/TreeArtifact here */
393
+ if (isGlob(left) && isTreeArtifact(right))
394
+ return overlaps(right, left);
395
+ /* v8 ignore next -- Entry's closed union makes every pair return above */
396
+ return true;
397
+ };
398
+ //# sourceMappingURL=FileSet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileSet.js","sourceRoot":"","sources":["../../src/FileSet.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAA;AAUjE;;;;;;;;;;;;GAYG;AAC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AAM,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAA;IAC9C,IAAI,cAAc,CAAC,IAAI,CAAC,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;IACvF,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,cAAc,CAAC,KAAK,CAAC;QAAE,OAAO,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IACvF,IAAI,cAAc,CAAC,IAAI,CAAC,IAAI,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC;QAClD,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAA;IACzE,CAAC;IACD,IAAI,cAAc,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAA;IACtD,iFAAiF;IACjF,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,cAAc,CAAC,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;IACvE,0EAA0E;IAC1E,OAAO,IAAI,CAAA;AACb,CAAC,CAAA","sourcesContent":["/**\n * Static filesystem declaration vocabulary shared by planning and execution.\n *\n * Declared paths use `/` as their canonical separator and normalize Unicode\n * to NFC. Workspace-relative paths reject C0 controls (U+0000 through U+001F)\n * and DEL (U+007F), which name nothing a supported filesystem can open. C1\n * controls (U+0080 through U+009F) remain accepted because those bytes are\n * legal in a POSIX file name.\n *\n * @since 0.1.0\n */\n\nimport * as Schema from \"effect/Schema\"\n\n/**\n * How strictly a declared file set is enforced at the boundary.\n *\n * `hard` rejects undeclared access. `expected` records access for validation\n * after execution without requiring the sandbox to reject it immediately.\n *\n * This is the ONE spelling of the pair. `Plan.NodeEffects.boundaryMode` is this\n * schema and so is `@smthrs/flow`'s `Action.BoundaryMode`; the literal used to\n * be written out in all three places.\n *\n * @category schemas\n * @since 1.0.0-rc.0\n */\nexport const BoundaryMode = Schema.Literals([\"hard\", \"expected\"])\n\n/**\n * The value form of {@link BoundaryMode}.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type BoundaryMode = typeof BoundaryMode.Type\n\n/**\n * The canonical spelling of a declared path or pattern: every separator is\n * `/`, and Unicode is normalized to NFC.\n *\n * {@link workspaceRelative} accepts a backslash as a separator, so\n * `dist\\same.js` and `dist/same.js` are two spellings of ONE workspace path.\n * Every exact-path comparison in this module goes through this form, because\n * comparing the raw spellings would let the separator alias defeat overlap\n * detection exactly as `.` segments and empty segments would.\n *\n * @category accessors\n * @since 0.1.0\n */\nexport const canonical = (path: string): string => path.replaceAll(\"\\\\\", \"/\").normalize(\"NFC\")\n\n/**\n * The {@link canonical} spelling with letter case folded away.\n *\n * A case-insensitive filesystem (default macOS APFS, Windows NTFS) opens\n * `src/A.ts` and `src/a.ts` as one file, so static overlap compares this form:\n * two declarations that differ only in case must serialize. Folding goes\n * through upper case because that mapping is context-free, so it folds each\n * character alone and commutes with splitting a path into segments.\n *\n * @category accessors\n * @since 1.0.0-rc.0\n */\nexport const folded = (path: string): string => canonical(path).toUpperCase().normalize(\"NFC\")\n\n/**\n * A non-empty workspace-relative path or pattern.\n *\n * Decoding fails with a `SchemaError` when {@link workspaceRelative} refuses\n * the string. A bare `Pattern` in a declaration names one literal path; only a\n * {@link Glob} gives `*` and `**` wildcard meaning.\n *\n * @category schemas\n * @since 0.1.0\n */\nexport const Pattern = Schema.NonEmptyString.check(\n Schema.makeFilter(\n (pattern) => workspaceRelative(pattern) || \"file patterns must be workspace-relative and cannot traverse upward\",\n { title: \"workspaceRelativePattern\" }\n )\n)\n\n/**\n * Whether a declared path or pattern stays inside the workspace and names it\n * one way only. Refuses absolute paths (POSIX and drive-letter), upward\n * traversal, and the aliasing forms — `.` segments, empty segments — that\n * would let two spellings of one file defeat exact-string overlap detection.\n *\n * C0 controls and DEL are refused as well.\n *\n * @category predicates\n * @since 0.1.0\n */\nexport const workspaceRelative = (pattern: string): boolean => {\n for (let index = 0; index < pattern.length; index++) {\n const code = pattern.charCodeAt(index)\n if (code <= 0x1f || code === 0x7f) return false\n }\n if (pattern.startsWith(\"/\")) return false\n const segments = canonical(pattern).split(\"/\")\n // `C:foo` is drive-relative on Windows, so any drive-letter prefix escapes.\n if (/^[A-Za-z]:/.test(segments[0]!) || segments[0]!.endsWith(\":\")) return false\n return segments.every((segment) => segment !== \"..\" && segment !== \".\" && segment !== \"\")\n}\n\n/**\n * A Bazel-style file glob: the paths matching any `include` pattern and no\n * `exclude` pattern.\n *\n * In a pattern, `*` matches within one path segment and a `**` segment\n * matches zero or more whole segments. A trailing `**` needs its separator,\n * so `src/**` does not match `src` itself.\n *\n * @category schemas\n * @since 0.1.0\n */\nexport const Glob = Schema.TaggedStruct(\"Glob\", {\n include: Schema.NonEmptyArray(Pattern),\n exclude: Schema.optional(Schema.Array(Pattern))\n})\n\n/**\n * The value form of {@link Glob}.\n *\n * @category models\n * @since 0.1.0\n */\nexport type Glob = typeof Glob.Type\n\n/**\n * A directory output captured and replayed as one tree artifact.\n *\n * It covers `path` and every path beneath it, compared in {@link folded}\n * form.\n *\n * @category schemas\n * @since 0.1.0\n */\nexport const TreeArtifact = Schema.TaggedStruct(\"TreeArtifact\", {\n path: Pattern\n})\n\n/**\n * The value form of {@link TreeArtifact}.\n *\n * @category models\n * @since 0.1.0\n */\nexport type TreeArtifact = typeof TreeArtifact.Type\n\n/**\n * One leaf declaration: a literal path, a {@link Glob}, or a\n * {@link TreeArtifact}. Write sets and filegroups hold entries.\n *\n * @category schemas\n * @since 0.1.0\n */\nexport const Entry = Schema.Union([Pattern, Glob, TreeArtifact])\n\n/**\n * The value form of {@link Entry}.\n *\n * @category models\n * @since 0.1.0\n */\nexport type Entry = typeof Entry.Type\n\n/**\n * One leaf declaration valid in a read set: a literal path or a {@link Glob}.\n * A read set cannot name a {@link TreeArtifact}, which is an output form.\n *\n * @category schemas\n * @since 0.1.0\n */\nexport const ReadEntry = Schema.Union([Pattern, Glob])\n\n/**\n * The value form of {@link ReadEntry}.\n *\n * @category models\n * @since 0.1.0\n */\nexport type ReadEntry = typeof ReadEntry.Type\n\n/**\n * A named, reusable list of {@link Entry} declarations.\n *\n * {@link expand} replaces a filegroup with its entries in place before any\n * overlap check or measurement, so the name never reaches the boundary.\n * Filegroups do not nest.\n *\n * @category schemas\n * @since 0.1.0\n */\nexport const Filegroup = Schema.TaggedStruct(\"Filegroup\", {\n name: Schema.NonEmptyString,\n entries: Schema.Array(Entry)\n})\n\n/**\n * The value form of {@link Filegroup}.\n *\n * @category models\n * @since 0.1.0\n */\nexport type Filegroup = typeof Filegroup.Type\n\n/**\n * A {@link Filegroup} restricted to {@link ReadEntry} declarations, for use\n * in a read set. It shares the `\"Filegroup\"` tag.\n *\n * @category schemas\n * @since 0.1.0\n */\nexport const ReadFilegroup = Schema.TaggedStruct(\"Filegroup\", {\n name: Schema.NonEmptyString,\n entries: Schema.Array(ReadEntry)\n})\n\n/**\n * The value form of {@link ReadFilegroup}.\n *\n * @category models\n * @since 0.1.0\n */\nexport type ReadFilegroup = typeof ReadFilegroup.Type\n\n/**\n * Any declaration accepted in a write set: an {@link Entry} or a\n * {@link Filegroup}.\n *\n * @category schemas\n * @since 0.1.0\n */\nexport const Declaration = Schema.Union([Entry, Filegroup])\n\n/**\n * The value form of {@link Declaration}.\n *\n * @category models\n * @since 0.1.0\n */\nexport type Declaration = typeof Declaration.Type\n\n/**\n * Any declaration accepted in a read set: a {@link ReadEntry} or a\n * {@link ReadFilegroup}.\n *\n * @category schemas\n * @since 0.1.0\n */\nexport const ReadDeclaration = Schema.Union([ReadEntry, ReadFilegroup])\n\n/**\n * The value form of {@link ReadDeclaration}.\n *\n * @category models\n * @since 0.1.0\n */\nexport type ReadDeclaration = typeof ReadDeclaration.Type\n\n/**\n * Creates a {@link Filegroup}. It does not validate `name` or `entries`;\n * decode through {@link Filegroup} when the input is untrusted.\n *\n * @param name - The filegroup name.\n * @param entries - The entries the filegroup expands to, in order.\n * @returns The filegroup value.\n * @category constructors\n * @since 0.1.0\n */\nexport const makeFilegroup = (name: string, entries: ReadonlyArray<Entry>): Filegroup => ({\n _tag: \"Filegroup\",\n name,\n entries\n})\n\n/**\n * Replaces each {@link Filegroup} with its entries, in place, and keeps every\n * other declaration as it is. Order is preserved and duplicates are kept.\n *\n * @param declarations - Write-set declarations, possibly holding filegroups.\n * @returns The flat list of entries.\n * @category accessors\n * @since 0.1.0\n */\nexport const expand = (declarations: ReadonlyArray<Declaration>): ReadonlyArray<Entry> =>\n declarations.flatMap((declaration) =>\n typeof declaration !== \"string\" && declaration._tag === \"Filegroup\" ? declaration.entries : [declaration]\n )\n\n/**\n * {@link expand} for read sets: replaces each {@link ReadFilegroup} with its\n * entries, in place, preserving order and duplicates.\n *\n * @param declarations - Read-set declarations, possibly holding filegroups.\n * @returns The flat list of read entries.\n * @category accessors\n * @since 0.1.0\n */\nexport const expandReads = (declarations: ReadonlyArray<ReadDeclaration>): ReadonlyArray<ReadEntry> =>\n declarations.flatMap((declaration) =>\n typeof declaration !== \"string\" && declaration._tag === \"Filegroup\" ? declaration.entries : [declaration]\n )\n\n/**\n * Whether a value carries the `\"Glob\"` tag. It checks only the tag, not the\n * patterns.\n *\n * @param value - Any value.\n * @returns `true` for an object whose `_tag` is `\"Glob\"`.\n * @category guards\n * @since 0.1.0\n */\nexport const isGlob = (value: unknown): value is Glob =>\n typeof value === \"object\" && value !== null && \"_tag\" in value && value._tag === \"Glob\"\n\n/**\n * Whether a value carries the `\"TreeArtifact\"` tag. It checks only the tag,\n * not the path.\n *\n * @param value - Any value.\n * @returns `true` for an object whose `_tag` is `\"TreeArtifact\"`.\n * @category guards\n * @since 0.1.0\n */\nexport const isTreeArtifact = (value: unknown): value is TreeArtifact =>\n typeof value === \"object\" && value !== null && \"_tag\" in value && value._tag === \"TreeArtifact\"\n\n/** KMP searches a literal without rescanning a long near-matching prefix. */\nconst literalSearch = (literal: string) => {\n const fallback = new Uint32Array(literal.length)\n let matched = 0\n for (let index = 1; index < literal.length; index++) {\n while (matched > 0 && literal[index] !== literal[matched]) matched = fallback[matched - 1]!\n if (literal[index] === literal[matched]) matched++\n fallback[index] = matched\n }\n return (path: string, start: number, end: number): number => {\n let matched = 0\n for (let index = start; index < end; index++) {\n while (matched > 0 && path[index] !== literal[matched]) matched = fallback[matched - 1]!\n if (path[index] === literal[matched]) matched++\n if (matched === literal.length) return index + 1\n }\n return -1\n }\n}\n\n/** Anchored ends and disjoint literal searches make each segment match linear. */\nconst segmentMatcher = (segment: string): (path: string) => boolean => {\n const chunks = segment.split(/\\*+/)\n const prefix = chunks.shift()!\n if (chunks.length === 0) return (path) => path === prefix\n const suffix = chunks.pop()!\n const searches = chunks.map(literalSearch)\n return (path) => {\n const end = path.length - suffix.length\n if (prefix.length > end || !path.startsWith(prefix) || !path.endsWith(suffix)) return false\n let position = prefix.length\n for (const search of searches) {\n position = search(path, position, end)\n if (position === -1) return false\n }\n return true\n }\n}\n\nconst patternMatchers = new Map<string, (path: string) => boolean>()\n\n/** Compile once per canonical spelling; recursive segments use no backtracking. */\nconst patternMatcher = (pattern: string): (path: string) => boolean => {\n const key = canonical(pattern)\n const cached = patternMatchers.get(key)\n if (cached !== undefined) return cached\n const segments = key.split(\"/\").map((segment) => segment === \"**\" ? undefined : segmentMatcher(segment))\n const matcher = (path: string): boolean => {\n const parts = path.split(\"/\")\n // Suffix membership: next[j] says the remaining pattern matches parts[j..].\n // Each pattern/path segment pair is visited once, even with repeated **.\n let next = new Uint8Array(parts.length + 1)\n next[parts.length] = 1\n for (let index = segments.length - 1; index >= 0; index--) {\n const segment = segments[index]\n const current = new Uint8Array(parts.length + 1)\n for (let part = parts.length - 1; part >= 0; part--) {\n current[part] = segment === undefined\n // A trailing ** accepts every remaining code unit. It still needs\n // the separator preceding it: src/** does not match bare src.\n ? Number(\n index === segments.length - 1 || next[part] === 1 ||\n (parts[part] !== \"\" && current[part + 1] === 1)\n )\n : Number(next[part + 1] === 1 && segment(parts[part]!))\n }\n next = current\n }\n return next[0] === 1\n }\n patternMatchers.set(key, matcher)\n return matcher\n}\n\n/**\n * Whether `path` matches `pattern` under {@link Glob} wildcard rules.\n *\n * The pattern is read in its {@link canonical} spelling; the path is matched\n * as given, case-sensitively, with `/` as its only separator.\n *\n * @param pattern - A Bazel-style pattern such as `src/*.ts` or `docs/**`.\n * @param path - A workspace-relative path.\n * @returns `true` when the path matches.\n * @category predicates\n * @since 0.1.0\n */\nexport const matchesPattern = (pattern: string, path: string): boolean => patternMatcher(pattern)(path)\n\n/**\n * Whether `path` matches some `include` pattern of `glob` and no `exclude`\n * pattern, each tested with {@link matchesPattern}. Case-sensitive.\n *\n * @param glob - The glob to test.\n * @param path - A workspace-relative path.\n * @returns `true` when the glob selects the path.\n * @category predicates\n * @since 0.1.0\n */\nexport const matchesGlob = (glob: Glob, path: string): boolean =>\n glob.include.some((pattern) => matchesPattern(pattern, path)) &&\n !(glob.exclude ?? []).some((pattern) => matchesPattern(pattern, path))\n\nconst beneath = (tree: string, path: string): boolean => {\n const root = folded(tree)\n const inside = folded(path)\n return inside === root || inside.startsWith(`${root}/`)\n}\n\n/**\n * Whether a canonical path is inside a declaration, case-sensitively.\n * Unlike {@link overlaps}, this predicate establishes replay authority.\n *\n * @category predicates\n * @since 1.0.0-rc.0\n */\nexport const contains = (entry: Entry, path: string): boolean => {\n const inside = canonical(path)\n if (typeof entry === \"string\") return canonical(entry) === inside\n if (isGlob(entry)) return matchesGlob(entry, inside)\n const root = canonical(entry.path)\n return inside === root || inside.startsWith(`${root}/`)\n}\n\n/** Includes fold conservatively; exclusions cannot rule out all case aliases. */\nconst mayMatchGlob = (glob: Glob, path: string): boolean =>\n glob.include.some((pattern) => matchesPattern(folded(pattern), folded(path)))\n\n/**\n * Conservative static overlap. `true` may over-serialize; `false` proves that\n * no path can belong to both declarations.\n *\n * A plain string is a literal path, even when it contains `*` or `**`, as it\n * is at execution (sandbox admission, capture, removal, and replay); wildcard\n * matching belongs to a Glob.\n *\n * Exact paths and tree roots compare in their\n * {@link folded} form, so separator aliases, canonically equivalent Unicode\n * spellings, and spellings that differ only in letter case overlap. A Glob\n * against an exact path folds its includes and ignores exclusions: an excluded\n * spelling may alias an included spelling on another filesystem. {@link matchesGlob} itself stays case-sensitive and tests the path bytes it\n * is handed; its property suite pins a backslash inside a path segment as\n * literal text, so canonicalizing a measured path before matching is its\n * caller's decision, not this module's.\n *\n * @category predicates\n * @since 0.1.0\n */\nexport const overlaps = (left: Entry, right: Entry): boolean => {\n if (typeof left === \"string\" && typeof right === \"string\") return folded(left) === folded(right)\n if (typeof left === \"string\" && isGlob(right)) return mayMatchGlob(right, left)\n if (isGlob(left) && typeof right === \"string\") return mayMatchGlob(left, right)\n if (isGlob(left) && isGlob(right)) return true\n if (isTreeArtifact(left) && typeof right === \"string\") return beneath(left.path, right)\n if (typeof left === \"string\" && isTreeArtifact(right)) return beneath(right.path, left)\n if (isTreeArtifact(left) && isTreeArtifact(right)) {\n return beneath(left.path, right.path) || beneath(right.path, left.path)\n }\n if (isTreeArtifact(left) && isGlob(right)) return true\n /* v8 ignore else -- the closed Entry union leaves only Glob/TreeArtifact here */\n if (isGlob(left) && isTreeArtifact(right)) return overlaps(right, left)\n /* v8 ignore next -- Entry's closed union makes every pair return above */\n return true\n}\n"]}
@@ -0,0 +1,120 @@
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 declare const GraphBuildErrorCode: Schema.Literals<readonly ["planned_value_computed", "invalid_all_member", "invalid_join", "invalid_continuation", "recursion_requires_boundary", "placement_requires_boundary", "cyclic_payload", "payload_too_deep", "graph_too_deep", "duplicate_node", "invalid_priority", "invalid_payload", "unstable_callback", "effect_outside_envelope", "effect_mode_widening", "effect_tier_widening", "capability_outside_grant", "write_conflict", "missing_key_material", "dependency_cycle", "plan_too_large", "payload_too_large", "invalid_node"]>;
73
+ /**
74
+ * The value form of {@link GraphBuildErrorCode}.
75
+ *
76
+ * @since 0.1.0
77
+ * @category models
78
+ */
79
+ export type GraphBuildErrorCode = typeof GraphBuildErrorCode.Type;
80
+ declare const GraphBuildError_base: Schema.Class<GraphBuildError, Schema.TaggedStruct<"@smthrs/plan/GraphBuildError", {
81
+ readonly code: Schema.Literals<readonly ["planned_value_computed", "invalid_all_member", "invalid_join", "invalid_continuation", "recursion_requires_boundary", "placement_requires_boundary", "cyclic_payload", "payload_too_deep", "graph_too_deep", "duplicate_node", "invalid_priority", "invalid_payload", "unstable_callback", "effect_outside_envelope", "effect_mode_widening", "effect_tier_widening", "capability_outside_grant", "write_conflict", "missing_key_material", "dependency_cycle", "plan_too_large", "payload_too_large", "invalid_node"]>;
82
+ readonly node: Schema.String;
83
+ readonly path: Schema.$Array<Schema.String>;
84
+ readonly message: Schema.String;
85
+ }>, import("effect/Cause").YieldableError>;
86
+ /**
87
+ * A build the planner refuses, naming the site and the fix.
88
+ *
89
+ * `node` is the node reference the failure belongs to — a planned value's
90
+ * origin node, an `all` member name, a branch arm, or the node whose admission
91
+ * crossed a bound. `path` is the property path recorded on a planned value
92
+ * before it was misused, the effect paths an over-claiming declaration named,
93
+ * the capabilities a call lost, or the value path of an oversized payload; it
94
+ * is empty for every other code.
95
+ *
96
+ * This is the ONE build refusal. `@smthrs/core`'s graph builder raised a second
97
+ * `GraphBuildError` of its own, with `paths`, `nodeId` and `nodes` in place of
98
+ * these fields, and the two code sets diverged instead of merging. A conflict's
99
+ * second node is read from `Graph.conflicts`, which carries the pair.
100
+ *
101
+ * @since 0.1.0
102
+ * @category errors
103
+ */
104
+ export declare class GraphBuildError extends GraphBuildError_base {
105
+ }
106
+ /**
107
+ * Whether a recorded refusal blocks the drafts a plan is compiled from.
108
+ *
109
+ * A fatal refusal means the graph describes something no plan could execute as
110
+ * written, so the drafts are withheld. An advisory one reports a narrowing the
111
+ * author should see while the graph still compiles.
112
+ *
113
+ * @param diagnostic - A recorded refusal.
114
+ * @returns `false` only for an advisory code (`capability_outside_grant`).
115
+ * @since 0.1.0
116
+ * @category predicates
117
+ */
118
+ export declare const isFatalDiagnostic: (diagnostic: GraphBuildError) => boolean;
119
+ export {};
120
+ //# sourceMappingURL=GraphBuildError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GraphBuildError.d.ts","sourceRoot":"","sources":["../../src/GraphBuildError.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,eAAO,MAAM,mBAAmB,ohBAwB9B,CAAA;AAEF;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,GAAG,OAAO,mBAAmB,CAAC,IAAI,CAAA;;;;;;;AAEjE;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,eAAgB,SAAQ,oBAKnC;CAAG;AAaL;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,iBAAiB,GAAI,YAAY,eAAe,KAAG,OAA8C,CAAA"}