@smthrs/plan 0.0.0-stage → 1.0.0-rc.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +185 -0
- package/LICENSE +21 -0
- package/README.md +230 -2
- package/THIRD_PARTY_NOTICES.md +48 -0
- package/dist/cjs/CachePolicy.d.ts +131 -0
- package/dist/cjs/CachePolicy.d.ts.map +1 -0
- package/dist/cjs/CachePolicy.js +50 -0
- package/dist/cjs/CachePolicy.js.map +7 -0
- package/dist/cjs/Effects.d.ts +258 -0
- package/dist/cjs/Effects.d.ts.map +1 -0
- package/dist/cjs/Effects.js +76 -0
- package/dist/cjs/Effects.js.map +7 -0
- package/dist/cjs/FileSet.d.ts +366 -0
- package/dist/cjs/FileSet.d.ts.map +1 -0
- package/dist/cjs/FileSet.js +196 -0
- package/dist/cjs/FileSet.js.map +7 -0
- package/dist/cjs/GraphBuildError.d.ts +120 -0
- package/dist/cjs/GraphBuildError.d.ts.map +1 -0
- package/dist/cjs/GraphBuildError.js +71 -0
- package/dist/cjs/GraphBuildError.js.map +7 -0
- package/dist/cjs/KeyMaterial.d.ts +107 -0
- package/dist/cjs/KeyMaterial.d.ts.map +1 -0
- package/dist/cjs/KeyMaterial.js +64 -0
- package/dist/cjs/KeyMaterial.js.map +7 -0
- package/dist/cjs/Node.d.ts +677 -0
- package/dist/cjs/Node.d.ts.map +1 -0
- package/dist/cjs/Node.js +229 -0
- package/dist/cjs/Node.js.map +7 -0
- package/dist/cjs/Placement.d.ts +117 -0
- package/dist/cjs/Placement.d.ts.map +1 -0
- package/dist/cjs/Placement.js +46 -0
- package/dist/cjs/Placement.js.map +7 -0
- package/dist/cjs/Plan.d.ts +489 -0
- package/dist/cjs/Plan.d.ts.map +1 -0
- package/dist/cjs/Plan.js +511 -0
- package/dist/cjs/Plan.js.map +7 -0
- package/dist/cjs/PlanDiff.d.ts +77 -0
- package/dist/cjs/PlanDiff.d.ts.map +1 -0
- package/dist/cjs/PlanDiff.js +149 -0
- package/dist/cjs/PlanDiff.js.map +7 -0
- package/dist/cjs/Planned.d.ts +121 -0
- package/dist/cjs/Planned.d.ts.map +1 -0
- package/dist/cjs/Planned.js +72 -0
- package/dist/cjs/Planned.js.map +7 -0
- package/dist/cjs/Repetition.d.ts +31 -0
- package/dist/cjs/Repetition.d.ts.map +1 -0
- package/dist/cjs/Repetition.js +36 -0
- package/dist/cjs/Repetition.js.map +7 -0
- package/dist/cjs/Scheduling.d.ts +89 -0
- package/dist/cjs/Scheduling.d.ts.map +1 -0
- package/dist/cjs/Scheduling.js +76 -0
- package/dist/cjs/Scheduling.js.map +7 -0
- package/dist/cjs/StepKey.d.ts +354 -0
- package/dist/cjs/StepKey.d.ts.map +1 -0
- package/dist/cjs/StepKey.js +313 -0
- package/dist/cjs/StepKey.js.map +7 -0
- package/dist/cjs/index.d.ts +91 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +59 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/internal/ConflictAnnotation.d.ts +59 -0
- package/dist/cjs/internal/ConflictAnnotation.d.ts.map +1 -0
- package/dist/cjs/internal/ConflictAnnotation.js +247 -0
- package/dist/cjs/internal/ConflictAnnotation.js.map +7 -0
- package/dist/cjs/internal/EffectCandidates.d.ts +19 -0
- package/dist/cjs/internal/EffectCandidates.d.ts.map +1 -0
- package/dist/cjs/internal/EffectCandidates.js +92 -0
- package/dist/cjs/internal/EffectCandidates.js.map +7 -0
- package/dist/cjs/internal/JsonMirror.d.ts +34 -0
- package/dist/cjs/internal/JsonMirror.d.ts.map +1 -0
- package/dist/cjs/internal/JsonMirror.js +195 -0
- package/dist/cjs/internal/JsonMirror.js.map +7 -0
- package/dist/cjs/internal/SchemaIdentity.d.ts +140 -0
- package/dist/cjs/internal/SchemaIdentity.d.ts.map +1 -0
- package/dist/cjs/internal/SchemaIdentity.js +718 -0
- package/dist/cjs/internal/SchemaIdentity.js.map +7 -0
- package/dist/cjs/internal/effects.d.ts +245 -0
- package/dist/cjs/internal/effects.d.ts.map +1 -0
- package/dist/cjs/internal/effects.js +290 -0
- package/dist/cjs/internal/effects.js.map +7 -0
- package/dist/cjs/internal/node.d.ts +526 -0
- package/dist/cjs/internal/node.d.ts.map +1 -0
- package/dist/cjs/internal/node.js +313 -0
- package/dist/cjs/internal/node.js.map +7 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/test/PlanFixtures.d.ts +127 -0
- package/dist/cjs/test/PlanFixtures.d.ts.map +1 -0
- package/dist/cjs/test/PlanFixtures.js +59 -0
- package/dist/cjs/test/PlanFixtures.js.map +7 -0
- package/dist/esm/CachePolicy.d.ts +131 -0
- package/dist/esm/CachePolicy.d.ts.map +1 -0
- package/dist/esm/CachePolicy.js +117 -0
- package/dist/esm/CachePolicy.js.map +1 -0
- package/dist/esm/Effects.d.ts +258 -0
- package/dist/esm/Effects.d.ts.map +1 -0
- package/dist/esm/Effects.js +178 -0
- package/dist/esm/Effects.js.map +1 -0
- package/dist/esm/FileSet.d.ts +366 -0
- package/dist/esm/FileSet.d.ts.map +1 -0
- package/dist/esm/FileSet.js +398 -0
- package/dist/esm/FileSet.js.map +1 -0
- package/dist/esm/GraphBuildError.d.ts +120 -0
- package/dist/esm/GraphBuildError.d.ts.map +1 -0
- package/dist/esm/GraphBuildError.js +145 -0
- package/dist/esm/GraphBuildError.js.map +1 -0
- package/dist/esm/KeyMaterial.d.ts +107 -0
- package/dist/esm/KeyMaterial.d.ts.map +1 -0
- package/dist/esm/KeyMaterial.js +92 -0
- package/dist/esm/KeyMaterial.js.map +1 -0
- package/dist/esm/Node.d.ts +677 -0
- package/dist/esm/Node.d.ts.map +1 -0
- package/dist/esm/Node.js +586 -0
- package/dist/esm/Node.js.map +1 -0
- package/dist/esm/Placement.d.ts +117 -0
- package/dist/esm/Placement.d.ts.map +1 -0
- package/dist/esm/Placement.js +65 -0
- package/dist/esm/Placement.js.map +1 -0
- package/dist/esm/Plan.d.ts +489 -0
- package/dist/esm/Plan.d.ts.map +1 -0
- package/dist/esm/Plan.js +718 -0
- package/dist/esm/Plan.js.map +1 -0
- package/dist/esm/PlanDiff.d.ts +77 -0
- package/dist/esm/PlanDiff.d.ts.map +1 -0
- package/dist/esm/PlanDiff.js +205 -0
- package/dist/esm/PlanDiff.js.map +1 -0
- package/dist/esm/Planned.d.ts +121 -0
- package/dist/esm/Planned.d.ts.map +1 -0
- package/dist/esm/Planned.js +147 -0
- package/dist/esm/Planned.js.map +1 -0
- package/dist/esm/Repetition.d.ts +31 -0
- package/dist/esm/Repetition.d.ts.map +1 -0
- package/dist/esm/Repetition.js +24 -0
- package/dist/esm/Repetition.js.map +1 -0
- package/dist/esm/Scheduling.d.ts +89 -0
- package/dist/esm/Scheduling.d.ts.map +1 -0
- package/dist/esm/Scheduling.js +82 -0
- package/dist/esm/Scheduling.js.map +1 -0
- package/dist/esm/StepKey.d.ts +354 -0
- package/dist/esm/StepKey.d.ts.map +1 -0
- package/dist/esm/StepKey.js +503 -0
- package/dist/esm/StepKey.js.map +1 -0
- package/dist/esm/index.d.ts +91 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +91 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/internal/ConflictAnnotation.d.ts +59 -0
- package/dist/esm/internal/ConflictAnnotation.d.ts.map +1 -0
- package/dist/esm/internal/ConflictAnnotation.js +332 -0
- package/dist/esm/internal/ConflictAnnotation.js.map +1 -0
- package/dist/esm/internal/EffectCandidates.d.ts +19 -0
- package/dist/esm/internal/EffectCandidates.d.ts.map +1 -0
- package/dist/esm/internal/EffectCandidates.js +86 -0
- package/dist/esm/internal/EffectCandidates.js.map +1 -0
- package/dist/esm/internal/JsonMirror.d.ts +34 -0
- package/dist/esm/internal/JsonMirror.d.ts.map +1 -0
- package/dist/esm/internal/JsonMirror.js +204 -0
- package/dist/esm/internal/JsonMirror.js.map +1 -0
- package/dist/esm/internal/SchemaIdentity.d.ts +140 -0
- package/dist/esm/internal/SchemaIdentity.d.ts.map +1 -0
- package/dist/esm/internal/SchemaIdentity.js +1002 -0
- package/dist/esm/internal/SchemaIdentity.js.map +1 -0
- package/dist/esm/internal/effects.d.ts +245 -0
- package/dist/esm/internal/effects.d.ts.map +1 -0
- package/dist/esm/internal/effects.js +459 -0
- package/dist/esm/internal/effects.js.map +1 -0
- package/dist/esm/internal/node.d.ts +526 -0
- package/dist/esm/internal/node.d.ts.map +1 -0
- package/dist/esm/internal/node.js +565 -0
- package/dist/esm/internal/node.js.map +1 -0
- package/dist/esm/test/PlanFixtures.d.ts +127 -0
- package/dist/esm/test/PlanFixtures.d.ts.map +1 -0
- package/dist/esm/test/PlanFixtures.js +60 -0
- package/dist/esm/test/PlanFixtures.js.map +1 -0
- package/docs/README.md +167 -0
- package/docs/api.md +1485 -0
- package/docs/concepts/authoring-ast.md +204 -0
- package/docs/concepts/effects-and-conflicts.md +135 -0
- package/docs/concepts/plan-value.md +168 -0
- package/docs/concepts/step-keys.md +179 -0
- package/docs/guides/author-a-node-graph.md +182 -0
- package/docs/guides/compile-a-plan.md +146 -0
- package/docs/guides/declare-file-effects.md +143 -0
- package/docs/guides/diff-two-plans.md +310 -0
- package/docs/installation.md +75 -0
- package/docs/quickstart.md +128 -0
- package/docs/testing.md +73 -0
- package/docs/troubleshooting.md +314 -0
- package/package.json +255 -3
- package/src/CachePolicy.ts +143 -0
- package/src/Effects.ts +302 -0
- package/src/FileSet.ts +493 -0
- package/src/GraphBuildError.ts +156 -0
- package/src/KeyMaterial.ts +111 -0
- package/src/Node.ts +969 -0
- package/src/Placement.ts +99 -0
- package/src/Plan.ts +911 -0
- package/src/PlanDiff.ts +244 -0
- package/src/Planned.ts +208 -0
- package/src/Repetition.ts +33 -0
- package/src/Scheduling.ts +154 -0
- package/src/StepKey.ts +736 -0
- package/src/index.ts +103 -0
- package/src/internal/ConflictAnnotation.ts +374 -0
- package/src/internal/EffectCandidates.ts +89 -0
- package/src/internal/JsonMirror.ts +255 -0
- package/src/internal/SchemaIdentity.ts +1096 -0
- package/src/internal/effects.ts +543 -0
- package/src/internal/node.ts +859 -0
- package/src/test/PlanFixtures.ts +76 -0
package/src/FileSet.ts
ADDED
|
@@ -0,0 +1,493 @@
|
|
|
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
|
+
|
|
13
|
+
import * as Schema from "effect/Schema"
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* How strictly a declared file set is enforced at the boundary.
|
|
17
|
+
*
|
|
18
|
+
* `hard` rejects undeclared access. `expected` records access for validation
|
|
19
|
+
* after execution without requiring the sandbox to reject it immediately.
|
|
20
|
+
*
|
|
21
|
+
* This is the ONE spelling of the pair. `Plan.NodeEffects.boundaryMode` is this
|
|
22
|
+
* schema and so is `@smthrs/flow`'s `Action.BoundaryMode`; the literal used to
|
|
23
|
+
* be written out in all three places.
|
|
24
|
+
*
|
|
25
|
+
* @category schemas
|
|
26
|
+
* @since 1.0.0-rc.0
|
|
27
|
+
*/
|
|
28
|
+
export const BoundaryMode = Schema.Literals(["hard", "expected"])
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The value form of {@link BoundaryMode}.
|
|
32
|
+
*
|
|
33
|
+
* @category models
|
|
34
|
+
* @since 1.0.0-rc.0
|
|
35
|
+
*/
|
|
36
|
+
export type BoundaryMode = typeof BoundaryMode.Type
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The canonical spelling of a declared path or pattern: every separator is
|
|
40
|
+
* `/`, and Unicode is normalized to NFC.
|
|
41
|
+
*
|
|
42
|
+
* {@link workspaceRelative} accepts a backslash as a separator, so
|
|
43
|
+
* `dist\same.js` and `dist/same.js` are two spellings of ONE workspace path.
|
|
44
|
+
* Every exact-path comparison in this module goes through this form, because
|
|
45
|
+
* comparing the raw spellings would let the separator alias defeat overlap
|
|
46
|
+
* detection exactly as `.` segments and empty segments would.
|
|
47
|
+
*
|
|
48
|
+
* @category accessors
|
|
49
|
+
* @since 0.1.0
|
|
50
|
+
*/
|
|
51
|
+
export const canonical = (path: string): string => path.replaceAll("\\", "/").normalize("NFC")
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The {@link canonical} spelling with letter case folded away.
|
|
55
|
+
*
|
|
56
|
+
* A case-insensitive filesystem (default macOS APFS, Windows NTFS) opens
|
|
57
|
+
* `src/A.ts` and `src/a.ts` as one file, so static overlap compares this form:
|
|
58
|
+
* two declarations that differ only in case must serialize. Folding goes
|
|
59
|
+
* through upper case because that mapping is context-free, so it folds each
|
|
60
|
+
* character alone and commutes with splitting a path into segments.
|
|
61
|
+
*
|
|
62
|
+
* @category accessors
|
|
63
|
+
* @since 1.0.0-rc.0
|
|
64
|
+
*/
|
|
65
|
+
export const folded = (path: string): string => canonical(path).toUpperCase().normalize("NFC")
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* A non-empty workspace-relative path or pattern.
|
|
69
|
+
*
|
|
70
|
+
* Decoding fails with a `SchemaError` when {@link workspaceRelative} refuses
|
|
71
|
+
* the string. A bare `Pattern` in a declaration names one literal path; only a
|
|
72
|
+
* {@link Glob} gives `*` and `**` wildcard meaning.
|
|
73
|
+
*
|
|
74
|
+
* @category schemas
|
|
75
|
+
* @since 0.1.0
|
|
76
|
+
*/
|
|
77
|
+
export const Pattern = Schema.NonEmptyString.check(
|
|
78
|
+
Schema.makeFilter(
|
|
79
|
+
(pattern) => workspaceRelative(pattern) || "file patterns must be workspace-relative and cannot traverse upward",
|
|
80
|
+
{ title: "workspaceRelativePattern" }
|
|
81
|
+
)
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Whether a declared path or pattern stays inside the workspace and names it
|
|
86
|
+
* one way only. Refuses absolute paths (POSIX and drive-letter), upward
|
|
87
|
+
* traversal, and the aliasing forms — `.` segments, empty segments — that
|
|
88
|
+
* would let two spellings of one file defeat exact-string overlap detection.
|
|
89
|
+
*
|
|
90
|
+
* C0 controls and DEL are refused as well.
|
|
91
|
+
*
|
|
92
|
+
* @category predicates
|
|
93
|
+
* @since 0.1.0
|
|
94
|
+
*/
|
|
95
|
+
export const workspaceRelative = (pattern: string): boolean => {
|
|
96
|
+
for (let index = 0; index < pattern.length; index++) {
|
|
97
|
+
const code = pattern.charCodeAt(index)
|
|
98
|
+
if (code <= 0x1f || code === 0x7f) return false
|
|
99
|
+
}
|
|
100
|
+
if (pattern.startsWith("/")) return false
|
|
101
|
+
const segments = canonical(pattern).split("/")
|
|
102
|
+
// `C:foo` is drive-relative on Windows, so any drive-letter prefix escapes.
|
|
103
|
+
if (/^[A-Za-z]:/.test(segments[0]!) || segments[0]!.endsWith(":")) return false
|
|
104
|
+
return segments.every((segment) => segment !== ".." && segment !== "." && segment !== "")
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* A Bazel-style file glob: the paths matching any `include` pattern and no
|
|
109
|
+
* `exclude` pattern.
|
|
110
|
+
*
|
|
111
|
+
* In a pattern, `*` matches within one path segment and a `**` segment
|
|
112
|
+
* matches zero or more whole segments. A trailing `**` needs its separator,
|
|
113
|
+
* so `src/**` does not match `src` itself.
|
|
114
|
+
*
|
|
115
|
+
* @category schemas
|
|
116
|
+
* @since 0.1.0
|
|
117
|
+
*/
|
|
118
|
+
export const Glob = Schema.TaggedStruct("Glob", {
|
|
119
|
+
include: Schema.NonEmptyArray(Pattern),
|
|
120
|
+
exclude: Schema.optional(Schema.Array(Pattern))
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* The value form of {@link Glob}.
|
|
125
|
+
*
|
|
126
|
+
* @category models
|
|
127
|
+
* @since 0.1.0
|
|
128
|
+
*/
|
|
129
|
+
export type Glob = typeof Glob.Type
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* A directory output captured and replayed as one tree artifact.
|
|
133
|
+
*
|
|
134
|
+
* It covers `path` and every path beneath it, compared in {@link folded}
|
|
135
|
+
* form.
|
|
136
|
+
*
|
|
137
|
+
* @category schemas
|
|
138
|
+
* @since 0.1.0
|
|
139
|
+
*/
|
|
140
|
+
export const TreeArtifact = Schema.TaggedStruct("TreeArtifact", {
|
|
141
|
+
path: Pattern
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* The value form of {@link TreeArtifact}.
|
|
146
|
+
*
|
|
147
|
+
* @category models
|
|
148
|
+
* @since 0.1.0
|
|
149
|
+
*/
|
|
150
|
+
export type TreeArtifact = typeof TreeArtifact.Type
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* One leaf declaration: a literal path, a {@link Glob}, or a
|
|
154
|
+
* {@link TreeArtifact}. Write sets and filegroups hold entries.
|
|
155
|
+
*
|
|
156
|
+
* @category schemas
|
|
157
|
+
* @since 0.1.0
|
|
158
|
+
*/
|
|
159
|
+
export const Entry = Schema.Union([Pattern, Glob, TreeArtifact])
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* The value form of {@link Entry}.
|
|
163
|
+
*
|
|
164
|
+
* @category models
|
|
165
|
+
* @since 0.1.0
|
|
166
|
+
*/
|
|
167
|
+
export type Entry = typeof Entry.Type
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* One leaf declaration valid in a read set: a literal path or a {@link Glob}.
|
|
171
|
+
* A read set cannot name a {@link TreeArtifact}, which is an output form.
|
|
172
|
+
*
|
|
173
|
+
* @category schemas
|
|
174
|
+
* @since 0.1.0
|
|
175
|
+
*/
|
|
176
|
+
export const ReadEntry = Schema.Union([Pattern, Glob])
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* The value form of {@link ReadEntry}.
|
|
180
|
+
*
|
|
181
|
+
* @category models
|
|
182
|
+
* @since 0.1.0
|
|
183
|
+
*/
|
|
184
|
+
export type ReadEntry = typeof ReadEntry.Type
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* A named, reusable list of {@link Entry} declarations.
|
|
188
|
+
*
|
|
189
|
+
* {@link expand} replaces a filegroup with its entries in place before any
|
|
190
|
+
* overlap check or measurement, so the name never reaches the boundary.
|
|
191
|
+
* Filegroups do not nest.
|
|
192
|
+
*
|
|
193
|
+
* @category schemas
|
|
194
|
+
* @since 0.1.0
|
|
195
|
+
*/
|
|
196
|
+
export const Filegroup = Schema.TaggedStruct("Filegroup", {
|
|
197
|
+
name: Schema.NonEmptyString,
|
|
198
|
+
entries: Schema.Array(Entry)
|
|
199
|
+
})
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* The value form of {@link Filegroup}.
|
|
203
|
+
*
|
|
204
|
+
* @category models
|
|
205
|
+
* @since 0.1.0
|
|
206
|
+
*/
|
|
207
|
+
export type Filegroup = typeof Filegroup.Type
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* A {@link Filegroup} restricted to {@link ReadEntry} declarations, for use
|
|
211
|
+
* in a read set. It shares the `"Filegroup"` tag.
|
|
212
|
+
*
|
|
213
|
+
* @category schemas
|
|
214
|
+
* @since 0.1.0
|
|
215
|
+
*/
|
|
216
|
+
export const ReadFilegroup = Schema.TaggedStruct("Filegroup", {
|
|
217
|
+
name: Schema.NonEmptyString,
|
|
218
|
+
entries: Schema.Array(ReadEntry)
|
|
219
|
+
})
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* The value form of {@link ReadFilegroup}.
|
|
223
|
+
*
|
|
224
|
+
* @category models
|
|
225
|
+
* @since 0.1.0
|
|
226
|
+
*/
|
|
227
|
+
export type ReadFilegroup = typeof ReadFilegroup.Type
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Any declaration accepted in a write set: an {@link Entry} or a
|
|
231
|
+
* {@link Filegroup}.
|
|
232
|
+
*
|
|
233
|
+
* @category schemas
|
|
234
|
+
* @since 0.1.0
|
|
235
|
+
*/
|
|
236
|
+
export const Declaration = Schema.Union([Entry, Filegroup])
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* The value form of {@link Declaration}.
|
|
240
|
+
*
|
|
241
|
+
* @category models
|
|
242
|
+
* @since 0.1.0
|
|
243
|
+
*/
|
|
244
|
+
export type Declaration = typeof Declaration.Type
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Any declaration accepted in a read set: a {@link ReadEntry} or a
|
|
248
|
+
* {@link ReadFilegroup}.
|
|
249
|
+
*
|
|
250
|
+
* @category schemas
|
|
251
|
+
* @since 0.1.0
|
|
252
|
+
*/
|
|
253
|
+
export const ReadDeclaration = Schema.Union([ReadEntry, ReadFilegroup])
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* The value form of {@link ReadDeclaration}.
|
|
257
|
+
*
|
|
258
|
+
* @category models
|
|
259
|
+
* @since 0.1.0
|
|
260
|
+
*/
|
|
261
|
+
export type ReadDeclaration = typeof ReadDeclaration.Type
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Creates a {@link Filegroup}. It does not validate `name` or `entries`;
|
|
265
|
+
* decode through {@link Filegroup} when the input is untrusted.
|
|
266
|
+
*
|
|
267
|
+
* @param name - The filegroup name.
|
|
268
|
+
* @param entries - The entries the filegroup expands to, in order.
|
|
269
|
+
* @returns The filegroup value.
|
|
270
|
+
* @category constructors
|
|
271
|
+
* @since 0.1.0
|
|
272
|
+
*/
|
|
273
|
+
export const makeFilegroup = (name: string, entries: ReadonlyArray<Entry>): Filegroup => ({
|
|
274
|
+
_tag: "Filegroup",
|
|
275
|
+
name,
|
|
276
|
+
entries
|
|
277
|
+
})
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Replaces each {@link Filegroup} with its entries, in place, and keeps every
|
|
281
|
+
* other declaration as it is. Order is preserved and duplicates are kept.
|
|
282
|
+
*
|
|
283
|
+
* @param declarations - Write-set declarations, possibly holding filegroups.
|
|
284
|
+
* @returns The flat list of entries.
|
|
285
|
+
* @category accessors
|
|
286
|
+
* @since 0.1.0
|
|
287
|
+
*/
|
|
288
|
+
export const expand = (declarations: ReadonlyArray<Declaration>): ReadonlyArray<Entry> =>
|
|
289
|
+
declarations.flatMap((declaration) =>
|
|
290
|
+
typeof declaration !== "string" && declaration._tag === "Filegroup" ? declaration.entries : [declaration]
|
|
291
|
+
)
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* {@link expand} for read sets: replaces each {@link ReadFilegroup} with its
|
|
295
|
+
* entries, in place, preserving order and duplicates.
|
|
296
|
+
*
|
|
297
|
+
* @param declarations - Read-set declarations, possibly holding filegroups.
|
|
298
|
+
* @returns The flat list of read entries.
|
|
299
|
+
* @category accessors
|
|
300
|
+
* @since 0.1.0
|
|
301
|
+
*/
|
|
302
|
+
export const expandReads = (declarations: ReadonlyArray<ReadDeclaration>): ReadonlyArray<ReadEntry> =>
|
|
303
|
+
declarations.flatMap((declaration) =>
|
|
304
|
+
typeof declaration !== "string" && declaration._tag === "Filegroup" ? declaration.entries : [declaration]
|
|
305
|
+
)
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Whether a value carries the `"Glob"` tag. It checks only the tag, not the
|
|
309
|
+
* patterns.
|
|
310
|
+
*
|
|
311
|
+
* @param value - Any value.
|
|
312
|
+
* @returns `true` for an object whose `_tag` is `"Glob"`.
|
|
313
|
+
* @category guards
|
|
314
|
+
* @since 0.1.0
|
|
315
|
+
*/
|
|
316
|
+
export const isGlob = (value: unknown): value is Glob =>
|
|
317
|
+
typeof value === "object" && value !== null && "_tag" in value && value._tag === "Glob"
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Whether a value carries the `"TreeArtifact"` tag. It checks only the tag,
|
|
321
|
+
* not the path.
|
|
322
|
+
*
|
|
323
|
+
* @param value - Any value.
|
|
324
|
+
* @returns `true` for an object whose `_tag` is `"TreeArtifact"`.
|
|
325
|
+
* @category guards
|
|
326
|
+
* @since 0.1.0
|
|
327
|
+
*/
|
|
328
|
+
export const isTreeArtifact = (value: unknown): value is TreeArtifact =>
|
|
329
|
+
typeof value === "object" && value !== null && "_tag" in value && value._tag === "TreeArtifact"
|
|
330
|
+
|
|
331
|
+
/** KMP searches a literal without rescanning a long near-matching prefix. */
|
|
332
|
+
const literalSearch = (literal: string) => {
|
|
333
|
+
const fallback = new Uint32Array(literal.length)
|
|
334
|
+
let matched = 0
|
|
335
|
+
for (let index = 1; index < literal.length; index++) {
|
|
336
|
+
while (matched > 0 && literal[index] !== literal[matched]) matched = fallback[matched - 1]!
|
|
337
|
+
if (literal[index] === literal[matched]) matched++
|
|
338
|
+
fallback[index] = matched
|
|
339
|
+
}
|
|
340
|
+
return (path: string, start: number, end: number): number => {
|
|
341
|
+
let matched = 0
|
|
342
|
+
for (let index = start; index < end; index++) {
|
|
343
|
+
while (matched > 0 && path[index] !== literal[matched]) matched = fallback[matched - 1]!
|
|
344
|
+
if (path[index] === literal[matched]) matched++
|
|
345
|
+
if (matched === literal.length) return index + 1
|
|
346
|
+
}
|
|
347
|
+
return -1
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/** Anchored ends and disjoint literal searches make each segment match linear. */
|
|
352
|
+
const segmentMatcher = (segment: string): (path: string) => boolean => {
|
|
353
|
+
const chunks = segment.split(/\*+/)
|
|
354
|
+
const prefix = chunks.shift()!
|
|
355
|
+
if (chunks.length === 0) return (path) => path === prefix
|
|
356
|
+
const suffix = chunks.pop()!
|
|
357
|
+
const searches = chunks.map(literalSearch)
|
|
358
|
+
return (path) => {
|
|
359
|
+
const end = path.length - suffix.length
|
|
360
|
+
if (prefix.length > end || !path.startsWith(prefix) || !path.endsWith(suffix)) return false
|
|
361
|
+
let position = prefix.length
|
|
362
|
+
for (const search of searches) {
|
|
363
|
+
position = search(path, position, end)
|
|
364
|
+
if (position === -1) return false
|
|
365
|
+
}
|
|
366
|
+
return true
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
const patternMatchers = new Map<string, (path: string) => boolean>()
|
|
371
|
+
|
|
372
|
+
/** Compile once per canonical spelling; recursive segments use no backtracking. */
|
|
373
|
+
const patternMatcher = (pattern: string): (path: string) => boolean => {
|
|
374
|
+
const key = canonical(pattern)
|
|
375
|
+
const cached = patternMatchers.get(key)
|
|
376
|
+
if (cached !== undefined) return cached
|
|
377
|
+
const segments = key.split("/").map((segment) => segment === "**" ? undefined : segmentMatcher(segment))
|
|
378
|
+
const matcher = (path: string): boolean => {
|
|
379
|
+
const parts = path.split("/")
|
|
380
|
+
// Suffix membership: next[j] says the remaining pattern matches parts[j..].
|
|
381
|
+
// Each pattern/path segment pair is visited once, even with repeated **.
|
|
382
|
+
let next = new Uint8Array(parts.length + 1)
|
|
383
|
+
next[parts.length] = 1
|
|
384
|
+
for (let index = segments.length - 1; index >= 0; index--) {
|
|
385
|
+
const segment = segments[index]
|
|
386
|
+
const current = new Uint8Array(parts.length + 1)
|
|
387
|
+
for (let part = parts.length - 1; part >= 0; part--) {
|
|
388
|
+
current[part] = segment === undefined
|
|
389
|
+
// A trailing ** accepts every remaining code unit. It still needs
|
|
390
|
+
// the separator preceding it: src/** does not match bare src.
|
|
391
|
+
? Number(
|
|
392
|
+
index === segments.length - 1 || next[part] === 1 ||
|
|
393
|
+
(parts[part] !== "" && current[part + 1] === 1)
|
|
394
|
+
)
|
|
395
|
+
: Number(next[part + 1] === 1 && segment(parts[part]!))
|
|
396
|
+
}
|
|
397
|
+
next = current
|
|
398
|
+
}
|
|
399
|
+
return next[0] === 1
|
|
400
|
+
}
|
|
401
|
+
patternMatchers.set(key, matcher)
|
|
402
|
+
return matcher
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* Whether `path` matches `pattern` under {@link Glob} wildcard rules.
|
|
407
|
+
*
|
|
408
|
+
* The pattern is read in its {@link canonical} spelling; the path is matched
|
|
409
|
+
* as given, case-sensitively, with `/` as its only separator.
|
|
410
|
+
*
|
|
411
|
+
* @param pattern - A Bazel-style pattern such as `src/*.ts` or `docs/**`.
|
|
412
|
+
* @param path - A workspace-relative path.
|
|
413
|
+
* @returns `true` when the path matches.
|
|
414
|
+
* @category predicates
|
|
415
|
+
* @since 0.1.0
|
|
416
|
+
*/
|
|
417
|
+
export const matchesPattern = (pattern: string, path: string): boolean => patternMatcher(pattern)(path)
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* Whether `path` matches some `include` pattern of `glob` and no `exclude`
|
|
421
|
+
* pattern, each tested with {@link matchesPattern}. Case-sensitive.
|
|
422
|
+
*
|
|
423
|
+
* @param glob - The glob to test.
|
|
424
|
+
* @param path - A workspace-relative path.
|
|
425
|
+
* @returns `true` when the glob selects the path.
|
|
426
|
+
* @category predicates
|
|
427
|
+
* @since 0.1.0
|
|
428
|
+
*/
|
|
429
|
+
export const matchesGlob = (glob: Glob, path: string): boolean =>
|
|
430
|
+
glob.include.some((pattern) => matchesPattern(pattern, path)) &&
|
|
431
|
+
!(glob.exclude ?? []).some((pattern) => matchesPattern(pattern, path))
|
|
432
|
+
|
|
433
|
+
const beneath = (tree: string, path: string): boolean => {
|
|
434
|
+
const root = folded(tree)
|
|
435
|
+
const inside = folded(path)
|
|
436
|
+
return inside === root || inside.startsWith(`${root}/`)
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* Whether a canonical path is inside a declaration, case-sensitively.
|
|
441
|
+
* Unlike {@link overlaps}, this predicate establishes replay authority.
|
|
442
|
+
*
|
|
443
|
+
* @category predicates
|
|
444
|
+
* @since 1.0.0-rc.0
|
|
445
|
+
*/
|
|
446
|
+
export const contains = (entry: Entry, path: string): boolean => {
|
|
447
|
+
const inside = canonical(path)
|
|
448
|
+
if (typeof entry === "string") return canonical(entry) === inside
|
|
449
|
+
if (isGlob(entry)) return matchesGlob(entry, inside)
|
|
450
|
+
const root = canonical(entry.path)
|
|
451
|
+
return inside === root || inside.startsWith(`${root}/`)
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
/** Includes fold conservatively; exclusions cannot rule out all case aliases. */
|
|
455
|
+
const mayMatchGlob = (glob: Glob, path: string): boolean =>
|
|
456
|
+
glob.include.some((pattern) => matchesPattern(folded(pattern), folded(path)))
|
|
457
|
+
|
|
458
|
+
/**
|
|
459
|
+
* Conservative static overlap. `true` may over-serialize; `false` proves that
|
|
460
|
+
* no path can belong to both declarations.
|
|
461
|
+
*
|
|
462
|
+
* A plain string is a literal path, even when it contains `*` or `**`, as it
|
|
463
|
+
* is at execution (sandbox admission, capture, removal, and replay); wildcard
|
|
464
|
+
* matching belongs to a Glob.
|
|
465
|
+
*
|
|
466
|
+
* Exact paths and tree roots compare in their
|
|
467
|
+
* {@link folded} form, so separator aliases, canonically equivalent Unicode
|
|
468
|
+
* spellings, and spellings that differ only in letter case overlap. A Glob
|
|
469
|
+
* against an exact path folds its includes and ignores exclusions: an excluded
|
|
470
|
+
* spelling may alias an included spelling on another filesystem. {@link matchesGlob} itself stays case-sensitive and tests the path bytes it
|
|
471
|
+
* is handed; its property suite pins a backslash inside a path segment as
|
|
472
|
+
* literal text, so canonicalizing a measured path before matching is its
|
|
473
|
+
* caller's decision, not this module's.
|
|
474
|
+
*
|
|
475
|
+
* @category predicates
|
|
476
|
+
* @since 0.1.0
|
|
477
|
+
*/
|
|
478
|
+
export const overlaps = (left: Entry, right: Entry): boolean => {
|
|
479
|
+
if (typeof left === "string" && typeof right === "string") return folded(left) === folded(right)
|
|
480
|
+
if (typeof left === "string" && isGlob(right)) return mayMatchGlob(right, left)
|
|
481
|
+
if (isGlob(left) && typeof right === "string") return mayMatchGlob(left, right)
|
|
482
|
+
if (isGlob(left) && isGlob(right)) return true
|
|
483
|
+
if (isTreeArtifact(left) && typeof right === "string") return beneath(left.path, right)
|
|
484
|
+
if (typeof left === "string" && isTreeArtifact(right)) return beneath(right.path, left)
|
|
485
|
+
if (isTreeArtifact(left) && isTreeArtifact(right)) {
|
|
486
|
+
return beneath(left.path, right.path) || beneath(right.path, left.path)
|
|
487
|
+
}
|
|
488
|
+
if (isTreeArtifact(left) && isGlob(right)) return true
|
|
489
|
+
/* v8 ignore else -- the closed Entry union leaves only Glob/TreeArtifact here */
|
|
490
|
+
if (isGlob(left) && isTreeArtifact(right)) return overlaps(right, left)
|
|
491
|
+
/* v8 ignore next -- Entry's closed union makes every pair return above */
|
|
492
|
+
return true
|
|
493
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
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
|
+
|
|
18
|
+
import * as Schema from "effect/Schema"
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The stable code of a build refusal.
|
|
22
|
+
*
|
|
23
|
+
* `planned_value_computed` is a body computing on a step result;
|
|
24
|
+
* `invalid_all_member` is a non-node handed to {@link module:Node.all};
|
|
25
|
+
* `invalid_join` is a race, any, or quorum with a non-node member, no members,
|
|
26
|
+
* or a quorum count its members cannot reach;
|
|
27
|
+
* `invalid_continuation` is a branch arm or continuation that did not return a
|
|
28
|
+
* node; `recursion_requires_boundary` is a flow calling itself inline, which
|
|
29
|
+
* has to become a trampoline handoff or an explicit child boundary;
|
|
30
|
+
* `placement_requires_boundary` is an inline call whose callee declares a
|
|
31
|
+
* placement the enclosing flow cannot satisfy, which has to become that same
|
|
32
|
+
* explicit child boundary; `cyclic_payload` is a payload that contains itself,
|
|
33
|
+
* which no plan could serialize or hash; `payload_too_deep` is a payload
|
|
34
|
+
* nested past the build bound, which has to be flattened into shallower data;
|
|
35
|
+
* `graph_too_deep` is authored topology nested past the build bound, which
|
|
36
|
+
* has to be split with `.child()` boundaries or trampoline handoffs;
|
|
37
|
+
* `duplicate_node` is two structural graph addresses resolving to one durable
|
|
38
|
+
* node id;
|
|
39
|
+
* `invalid_priority` is a scheduling priority that is not a safe integer,
|
|
40
|
+
* which no ordering could compare; `invalid_payload` is a payload member that
|
|
41
|
+
* cannot be captured as inert JSON without executing author code or losing
|
|
42
|
+
* identity; `unstable_callback` is a function with process-local identity in a
|
|
43
|
+
* graph that requires stable callbacks. Declare its complete inert captures
|
|
44
|
+
* with `Node.capture`, including semantic implementation versions. The two
|
|
45
|
+
* depth refusals exist because graph building walks with an explicit stack
|
|
46
|
+
* and refuses at a bound, rather than recursing until the native stack
|
|
47
|
+
* overflows without a typed error.
|
|
48
|
+
*
|
|
49
|
+
* The four effect-authority refusals are raised when a declaration claims more
|
|
50
|
+
* than the declaration enclosing it granted:
|
|
51
|
+
* `effect_outside_envelope` is a read or write path the envelope does not
|
|
52
|
+
* cover, and it names those paths in `path`; `effect_mode_widening` is an
|
|
53
|
+
* `expected` declaration inside a `hermetic` envelope; `effect_tier_widening`
|
|
54
|
+
* is a tier less reversible than the envelope's; and
|
|
55
|
+
* `capability_outside_grant` is a called flow or action requiring a capability
|
|
56
|
+
* the caller does not hold, which names the dropped capabilities in `path`. The
|
|
57
|
+
* first three are fatal by {@link isFatalDiagnostic}; the fourth is advisory,
|
|
58
|
+
* because dropping a capability narrows authority rather than widening it.
|
|
59
|
+
*
|
|
60
|
+
* The last six are raised by `@smthrs/core`'s graph builder, which uses this
|
|
61
|
+
* one error rather than a second class of its own. `write_conflict` is two work
|
|
62
|
+
* nodes overlapping under `onConflict: "fail"`, and `node` names the first of
|
|
63
|
+
* the pair while `Graph.conflicts` carries both; `missing_key_material` is a
|
|
64
|
+
* node that reached key compilation without any; `dependency_cycle` is a
|
|
65
|
+
* dependency set that cannot be ordered, and `node` names a node in the cycle;
|
|
66
|
+
* `plan_too_large` is a node, edge, conflict, or effect-path limit crossed, and
|
|
67
|
+
* `node` names the node whose admission crossed it; `payload_too_large` is a
|
|
68
|
+
* plan value with more members than the bound, and `path` names the offending
|
|
69
|
+
* value path; `invalid_node` is a malformed node AST. All six are fatal.
|
|
70
|
+
*
|
|
71
|
+
* @since 0.1.0
|
|
72
|
+
* @category schemas
|
|
73
|
+
*/
|
|
74
|
+
export const GraphBuildErrorCode = Schema.Literals([
|
|
75
|
+
"planned_value_computed",
|
|
76
|
+
"invalid_all_member",
|
|
77
|
+
"invalid_join",
|
|
78
|
+
"invalid_continuation",
|
|
79
|
+
"recursion_requires_boundary",
|
|
80
|
+
"placement_requires_boundary",
|
|
81
|
+
"cyclic_payload",
|
|
82
|
+
"payload_too_deep",
|
|
83
|
+
"graph_too_deep",
|
|
84
|
+
"duplicate_node",
|
|
85
|
+
"invalid_priority",
|
|
86
|
+
"invalid_payload",
|
|
87
|
+
"unstable_callback",
|
|
88
|
+
"effect_outside_envelope",
|
|
89
|
+
"effect_mode_widening",
|
|
90
|
+
"effect_tier_widening",
|
|
91
|
+
"capability_outside_grant",
|
|
92
|
+
"write_conflict",
|
|
93
|
+
"missing_key_material",
|
|
94
|
+
"dependency_cycle",
|
|
95
|
+
"plan_too_large",
|
|
96
|
+
"payload_too_large",
|
|
97
|
+
"invalid_node"
|
|
98
|
+
])
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* The value form of {@link GraphBuildErrorCode}.
|
|
102
|
+
*
|
|
103
|
+
* @since 0.1.0
|
|
104
|
+
* @category models
|
|
105
|
+
*/
|
|
106
|
+
export type GraphBuildErrorCode = typeof GraphBuildErrorCode.Type
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* A build the planner refuses, naming the site and the fix.
|
|
110
|
+
*
|
|
111
|
+
* `node` is the node reference the failure belongs to — a planned value's
|
|
112
|
+
* origin node, an `all` member name, a branch arm, or the node whose admission
|
|
113
|
+
* crossed a bound. `path` is the property path recorded on a planned value
|
|
114
|
+
* before it was misused, the effect paths an over-claiming declaration named,
|
|
115
|
+
* the capabilities a call lost, or the value path of an oversized payload; it
|
|
116
|
+
* is empty for every other code.
|
|
117
|
+
*
|
|
118
|
+
* This is the ONE build refusal. `@smthrs/core`'s graph builder raised a second
|
|
119
|
+
* `GraphBuildError` of its own, with `paths`, `nodeId` and `nodes` in place of
|
|
120
|
+
* these fields, and the two code sets diverged instead of merging. A conflict's
|
|
121
|
+
* second node is read from `Graph.conflicts`, which carries the pair.
|
|
122
|
+
*
|
|
123
|
+
* @since 0.1.0
|
|
124
|
+
* @category errors
|
|
125
|
+
*/
|
|
126
|
+
export class GraphBuildError extends Schema.TaggedError<GraphBuildError>()("@smthrs/plan/GraphBuildError", {
|
|
127
|
+
code: GraphBuildErrorCode,
|
|
128
|
+
node: Schema.String,
|
|
129
|
+
path: Schema.Array(Schema.String),
|
|
130
|
+
message: Schema.String
|
|
131
|
+
}) {}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* The one advisory code. Everything else a build records blocks the drafts.
|
|
135
|
+
*
|
|
136
|
+
* A capability the caller does not grant is DROPPED, not granted: the callee
|
|
137
|
+
* runs with less authority than it asked for, which is the safe direction. The
|
|
138
|
+
* author still needs to know, because a flow that silently loses a capability
|
|
139
|
+
* fails later at the action that needed it, so the build records the refusal
|
|
140
|
+
* and lets the graph compile.
|
|
141
|
+
*/
|
|
142
|
+
const advisoryCodes: ReadonlySet<GraphBuildErrorCode> = new Set<GraphBuildErrorCode>(["capability_outside_grant"])
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Whether a recorded refusal blocks the drafts a plan is compiled from.
|
|
146
|
+
*
|
|
147
|
+
* A fatal refusal means the graph describes something no plan could execute as
|
|
148
|
+
* written, so the drafts are withheld. An advisory one reports a narrowing the
|
|
149
|
+
* author should see while the graph still compiles.
|
|
150
|
+
*
|
|
151
|
+
* @param diagnostic - A recorded refusal.
|
|
152
|
+
* @returns `false` only for an advisory code (`capability_outside_grant`).
|
|
153
|
+
* @since 0.1.0
|
|
154
|
+
* @category predicates
|
|
155
|
+
*/
|
|
156
|
+
export const isFatalDiagnostic = (diagnostic: GraphBuildError): boolean => !advisoryCodes.has(diagnostic.code)
|