@smthrs/plan 0.0.0-stage → 1.0.0-rc.4
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 +183 -0
- package/LICENSE +21 -0
- package/README.md +228 -2
- 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 +240 -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 +288 -0
- package/dist/cjs/FileSet.d.ts.map +1 -0
- package/dist/cjs/FileSet.js +191 -0
- package/dist/cjs/FileSet.js.map +7 -0
- package/dist/cjs/GraphBuildError.d.ts +122 -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 +102 -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 +606 -0
- package/dist/cjs/Node.d.ts.map +1 -0
- package/dist/cjs/Node.js +207 -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 +440 -0
- package/dist/cjs/Plan.d.ts.map +1 -0
- package/dist/cjs/Plan.js +508 -0
- package/dist/cjs/Plan.js.map +7 -0
- package/dist/cjs/PlanDiff.d.ts +58 -0
- package/dist/cjs/PlanDiff.d.ts.map +1 -0
- package/dist/cjs/PlanDiff.js +124 -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 +333 -0
- package/dist/cjs/StepKey.d.ts.map +1 -0
- package/dist/cjs/StepKey.js +311 -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/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 +312 -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 +240 -0
- package/dist/esm/Effects.d.ts.map +1 -0
- package/dist/esm/Effects.js +167 -0
- package/dist/esm/Effects.js.map +1 -0
- package/dist/esm/FileSet.d.ts +288 -0
- package/dist/esm/FileSet.d.ts.map +1 -0
- package/dist/esm/FileSet.js +324 -0
- package/dist/esm/FileSet.js.map +1 -0
- package/dist/esm/GraphBuildError.d.ts +122 -0
- package/dist/esm/GraphBuildError.d.ts.map +1 -0
- package/dist/esm/GraphBuildError.js +146 -0
- package/dist/esm/GraphBuildError.js.map +1 -0
- package/dist/esm/KeyMaterial.d.ts +102 -0
- package/dist/esm/KeyMaterial.d.ts.map +1 -0
- package/dist/esm/KeyMaterial.js +85 -0
- package/dist/esm/KeyMaterial.js.map +1 -0
- package/dist/esm/Node.d.ts +606 -0
- package/dist/esm/Node.d.ts.map +1 -0
- package/dist/esm/Node.js +521 -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 +440 -0
- package/dist/esm/Plan.d.ts.map +1 -0
- package/dist/esm/Plan.js +673 -0
- package/dist/esm/Plan.js.map +1 -0
- package/dist/esm/PlanDiff.d.ts +58 -0
- package/dist/esm/PlanDiff.d.ts.map +1 -0
- package/dist/esm/PlanDiff.js +159 -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 +333 -0
- package/dist/esm/StepKey.d.ts.map +1 -0
- package/dist/esm/StepKey.js +478 -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/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 +564 -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 +165 -0
- package/docs/api.md +1475 -0
- package/docs/concepts/authoring-ast.md +203 -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 +101 -0
- package/docs/installation.md +71 -0
- package/docs/quickstart.md +128 -0
- package/docs/testing.md +73 -0
- package/docs/troubleshooting.md +314 -0
- package/package.json +254 -3
- package/src/CachePolicy.ts +143 -0
- package/src/Effects.ts +284 -0
- package/src/FileSet.ts +411 -0
- package/src/GraphBuildError.ts +158 -0
- package/src/KeyMaterial.ts +106 -0
- package/src/Node.ts +871 -0
- package/src/Placement.ts +99 -0
- package/src/Plan.ts +868 -0
- package/src/PlanDiff.ts +199 -0
- package/src/Planned.ts +208 -0
- package/src/Repetition.ts +33 -0
- package/src/Scheduling.ts +154 -0
- package/src/StepKey.ts +710 -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/effects.ts +543 -0
- package/src/internal/node.ts +858 -0
- package/src/test/PlanFixtures.ts +76 -0
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var FileSet_exports = {};
|
|
30
|
+
__export(FileSet_exports, {
|
|
31
|
+
BoundaryMode: () => BoundaryMode,
|
|
32
|
+
Declaration: () => Declaration,
|
|
33
|
+
Entry: () => Entry,
|
|
34
|
+
Filegroup: () => Filegroup,
|
|
35
|
+
Glob: () => Glob,
|
|
36
|
+
Pattern: () => Pattern,
|
|
37
|
+
ReadDeclaration: () => ReadDeclaration,
|
|
38
|
+
ReadEntry: () => ReadEntry,
|
|
39
|
+
ReadFilegroup: () => ReadFilegroup,
|
|
40
|
+
TreeArtifact: () => TreeArtifact,
|
|
41
|
+
canonical: () => canonical,
|
|
42
|
+
expand: () => expand,
|
|
43
|
+
expandReads: () => expandReads,
|
|
44
|
+
folded: () => folded,
|
|
45
|
+
isGlob: () => isGlob,
|
|
46
|
+
isTreeArtifact: () => isTreeArtifact,
|
|
47
|
+
makeFilegroup: () => makeFilegroup,
|
|
48
|
+
matchesGlob: () => matchesGlob,
|
|
49
|
+
matchesPattern: () => matchesPattern,
|
|
50
|
+
overlaps: () => overlaps,
|
|
51
|
+
workspaceRelative: () => workspaceRelative
|
|
52
|
+
});
|
|
53
|
+
module.exports = __toCommonJS(FileSet_exports);
|
|
54
|
+
var Schema = __toESM(require("effect/Schema"), 1);
|
|
55
|
+
const BoundaryMode = Schema.Literals(["hard", "expected"]);
|
|
56
|
+
const canonical = (path) => path.replaceAll("\\", "/").normalize("NFC");
|
|
57
|
+
const folded = (path) => canonical(path).toUpperCase().normalize("NFC");
|
|
58
|
+
const Pattern = Schema.NonEmptyString.check(
|
|
59
|
+
Schema.makeFilter(
|
|
60
|
+
(pattern) => workspaceRelative(pattern) || "file patterns must be workspace-relative and cannot traverse upward",
|
|
61
|
+
{ title: "workspaceRelativePattern" }
|
|
62
|
+
)
|
|
63
|
+
);
|
|
64
|
+
const workspaceRelative = (pattern) => {
|
|
65
|
+
for (let index = 0; index < pattern.length; index++) {
|
|
66
|
+
const code = pattern.charCodeAt(index);
|
|
67
|
+
if (code <= 31 || code === 127) return false;
|
|
68
|
+
}
|
|
69
|
+
if (pattern.startsWith("/")) return false;
|
|
70
|
+
const segments = canonical(pattern).split("/");
|
|
71
|
+
if (/^[A-Za-z]:/.test(segments[0]) || segments[0].endsWith(":")) return false;
|
|
72
|
+
return segments.every((segment) => segment !== ".." && segment !== "." && segment !== "");
|
|
73
|
+
};
|
|
74
|
+
const Glob = Schema.TaggedStruct("Glob", {
|
|
75
|
+
include: Schema.NonEmptyArray(Pattern),
|
|
76
|
+
exclude: Schema.optional(Schema.Array(Pattern))
|
|
77
|
+
});
|
|
78
|
+
const TreeArtifact = Schema.TaggedStruct("TreeArtifact", {
|
|
79
|
+
path: Pattern
|
|
80
|
+
});
|
|
81
|
+
const Entry = Schema.Union([Pattern, Glob, TreeArtifact]);
|
|
82
|
+
const ReadEntry = Schema.Union([Pattern, Glob]);
|
|
83
|
+
const Filegroup = Schema.TaggedStruct("Filegroup", {
|
|
84
|
+
name: Schema.NonEmptyString,
|
|
85
|
+
entries: Schema.Array(Entry)
|
|
86
|
+
});
|
|
87
|
+
const ReadFilegroup = Schema.TaggedStruct("Filegroup", {
|
|
88
|
+
name: Schema.NonEmptyString,
|
|
89
|
+
entries: Schema.Array(ReadEntry)
|
|
90
|
+
});
|
|
91
|
+
const Declaration = Schema.Union([Entry, Filegroup]);
|
|
92
|
+
const ReadDeclaration = Schema.Union([ReadEntry, ReadFilegroup]);
|
|
93
|
+
const makeFilegroup = (name, entries) => ({
|
|
94
|
+
_tag: "Filegroup",
|
|
95
|
+
name,
|
|
96
|
+
entries
|
|
97
|
+
});
|
|
98
|
+
const expand = (declarations) => declarations.flatMap(
|
|
99
|
+
(declaration) => typeof declaration !== "string" && declaration._tag === "Filegroup" ? declaration.entries : [declaration]
|
|
100
|
+
);
|
|
101
|
+
const expandReads = (declarations) => declarations.flatMap(
|
|
102
|
+
(declaration) => typeof declaration !== "string" && declaration._tag === "Filegroup" ? declaration.entries : [declaration]
|
|
103
|
+
);
|
|
104
|
+
const isGlob = (value) => typeof value === "object" && value !== null && "_tag" in value && value._tag === "Glob";
|
|
105
|
+
const isTreeArtifact = (value) => typeof value === "object" && value !== null && "_tag" in value && value._tag === "TreeArtifact";
|
|
106
|
+
const literalSearch = (literal) => {
|
|
107
|
+
const fallback = new Uint32Array(literal.length);
|
|
108
|
+
let matched = 0;
|
|
109
|
+
for (let index = 1; index < literal.length; index++) {
|
|
110
|
+
while (matched > 0 && literal[index] !== literal[matched]) matched = fallback[matched - 1];
|
|
111
|
+
if (literal[index] === literal[matched]) matched++;
|
|
112
|
+
fallback[index] = matched;
|
|
113
|
+
}
|
|
114
|
+
return (path, start, end) => {
|
|
115
|
+
let matched2 = 0;
|
|
116
|
+
for (let index = start; index < end; index++) {
|
|
117
|
+
while (matched2 > 0 && path[index] !== literal[matched2]) matched2 = fallback[matched2 - 1];
|
|
118
|
+
if (path[index] === literal[matched2]) matched2++;
|
|
119
|
+
if (matched2 === literal.length) return index + 1;
|
|
120
|
+
}
|
|
121
|
+
return -1;
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
const segmentMatcher = (segment) => {
|
|
125
|
+
const chunks = segment.split(/\*+/);
|
|
126
|
+
const prefix = chunks.shift();
|
|
127
|
+
if (chunks.length === 0) return (path) => path === prefix;
|
|
128
|
+
const suffix = chunks.pop();
|
|
129
|
+
const searches = chunks.map(literalSearch);
|
|
130
|
+
return (path) => {
|
|
131
|
+
const end = path.length - suffix.length;
|
|
132
|
+
if (prefix.length > end || !path.startsWith(prefix) || !path.endsWith(suffix)) return false;
|
|
133
|
+
let position = prefix.length;
|
|
134
|
+
for (const search of searches) {
|
|
135
|
+
position = search(path, position, end);
|
|
136
|
+
if (position === -1) return false;
|
|
137
|
+
}
|
|
138
|
+
return true;
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
const patternMatchers = /* @__PURE__ */ new Map();
|
|
142
|
+
const patternMatcher = (pattern) => {
|
|
143
|
+
const key = canonical(pattern);
|
|
144
|
+
const cached = patternMatchers.get(key);
|
|
145
|
+
if (cached !== void 0) return cached;
|
|
146
|
+
const segments = key.split("/").map((segment) => segment === "**" ? void 0 : segmentMatcher(segment));
|
|
147
|
+
const matcher = (path) => {
|
|
148
|
+
const parts = path.split("/");
|
|
149
|
+
let next = new Uint8Array(parts.length + 1);
|
|
150
|
+
next[parts.length] = 1;
|
|
151
|
+
for (let index = segments.length - 1; index >= 0; index--) {
|
|
152
|
+
const segment = segments[index];
|
|
153
|
+
const current = new Uint8Array(parts.length + 1);
|
|
154
|
+
for (let part = parts.length - 1; part >= 0; part--) {
|
|
155
|
+
current[part] = segment === void 0 ? Number(
|
|
156
|
+
index === segments.length - 1 || next[part] === 1 || parts[part] !== "" && current[part + 1] === 1
|
|
157
|
+
) : Number(next[part + 1] === 1 && segment(parts[part]));
|
|
158
|
+
}
|
|
159
|
+
next = current;
|
|
160
|
+
}
|
|
161
|
+
return next[0] === 1;
|
|
162
|
+
};
|
|
163
|
+
patternMatchers.set(key, matcher);
|
|
164
|
+
return matcher;
|
|
165
|
+
};
|
|
166
|
+
const matchesPattern = (pattern, path) => patternMatcher(pattern)(path);
|
|
167
|
+
const matchesGlob = (glob, path) => glob.include.some((pattern) => matchesPattern(pattern, path)) && !(glob.exclude ?? []).some((pattern) => matchesPattern(pattern, path));
|
|
168
|
+
const beneath = (tree, path) => {
|
|
169
|
+
const root = folded(tree);
|
|
170
|
+
const inside = folded(path);
|
|
171
|
+
return inside === root || inside.startsWith(`${root}/`);
|
|
172
|
+
};
|
|
173
|
+
const matchesGlobFolded = (glob, path) => {
|
|
174
|
+
const inside = folded(path);
|
|
175
|
+
return glob.include.some((pattern) => matchesPattern(folded(pattern), inside)) && !(glob.exclude ?? []).some((pattern) => matchesPattern(folded(pattern), inside));
|
|
176
|
+
};
|
|
177
|
+
const overlaps = (left, right) => {
|
|
178
|
+
if (typeof left === "string" && typeof right === "string") return folded(left) === folded(right);
|
|
179
|
+
if (typeof left === "string" && isGlob(right)) return matchesGlobFolded(right, left);
|
|
180
|
+
if (isGlob(left) && typeof right === "string") return matchesGlobFolded(left, right);
|
|
181
|
+
if (isGlob(left) && isGlob(right)) return true;
|
|
182
|
+
if (isTreeArtifact(left) && typeof right === "string") return beneath(left.path, right);
|
|
183
|
+
if (typeof left === "string" && isTreeArtifact(right)) return beneath(right.path, left);
|
|
184
|
+
if (isTreeArtifact(left) && isTreeArtifact(right)) {
|
|
185
|
+
return beneath(left.path, right.path) || beneath(right.path, left.path);
|
|
186
|
+
}
|
|
187
|
+
if (isTreeArtifact(left) && isGlob(right)) return true;
|
|
188
|
+
if (isGlob(left) && isTreeArtifact(right)) return overlaps(right, left);
|
|
189
|
+
return true;
|
|
190
|
+
};
|
|
191
|
+
//# sourceMappingURL=FileSet.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/FileSet.ts"],
|
|
4
|
+
"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 * @slop\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/** Workspace-relative glob pattern.\n * @category schemas\n * @since 0.1.0\n * @slop\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 \u2014 `.` segments, empty segments \u2014 that\n * would let two spellings of one file defeat exact-string overlap detection.\n *\n * @category predicates\n * @since 0.1.0\n * @slop\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/** Bazel-style file glob.\n * @category schemas\n * @since 0.1.0\n * @slop\n */\nexport const Glob = Schema.TaggedStruct(\"Glob\", {\n include: Schema.NonEmptyArray(Pattern),\n exclude: Schema.optional(Schema.Array(Pattern))\n})\n\n/** Bazel-style file glob.\n * @category models\n * @since 0.1.0\n * @slop\n */\nexport type Glob = typeof Glob.Type\n\n/** A directory output captured and replayed as one tree artifact.\n * @category schemas\n * @since 0.1.0\n * @slop\n */\nexport const TreeArtifact = Schema.TaggedStruct(\"TreeArtifact\", {\n path: Pattern\n})\n\n/** A directory output captured and replayed as one tree artifact.\n * @category models\n * @since 0.1.0\n * @slop\n */\nexport type TreeArtifact = typeof TreeArtifact.Type\n\n/** One leaf of a named filegroup.\n * @category schemas\n * @since 0.1.0\n * @slop\n */\nexport const Entry = Schema.Union([Pattern, Glob, TreeArtifact])\n\n/** One leaf of a named filegroup.\n * @category models\n * @since 0.1.0\n * @slop\n */\nexport type Entry = typeof Entry.Type\n\n/** A declaration valid in a read set.\n * @category schemas\n * @since 0.1.0\n * @slop\n */\nexport const ReadEntry = Schema.Union([Pattern, Glob])\n\n/** A declaration valid in a read set.\n * @category models\n * @since 0.1.0\n * @slop\n */\nexport type ReadEntry = typeof ReadEntry.Type\n\n/** A named reusable collection expanded before measurement.\n * @category schemas\n * @since 0.1.0\n * @slop\n */\nexport const Filegroup = Schema.TaggedStruct(\"Filegroup\", {\n name: Schema.NonEmptyString,\n entries: Schema.Array(Entry)\n})\n\n/** A named reusable collection expanded before measurement.\n * @category models\n * @since 0.1.0\n * @slop\n */\nexport type Filegroup = typeof Filegroup.Type\n\n/** A named read-only collection.\n * @category schemas\n * @since 0.1.0\n * @slop\n */\nexport const ReadFilegroup = Schema.TaggedStruct(\"Filegroup\", {\n name: Schema.NonEmptyString,\n entries: Schema.Array(ReadEntry)\n})\n\n/** A named read-only collection.\n * @category models\n * @since 0.1.0\n * @slop\n */\nexport type ReadFilegroup = typeof ReadFilegroup.Type\n\n/** Any declaration accepted by a plan effect set.\n * @category schemas\n * @since 0.1.0\n * @slop\n */\nexport const Declaration = Schema.Union([Entry, Filegroup])\n\n/** Any declaration accepted by a plan effect set.\n * @category models\n * @since 0.1.0\n * @slop\n */\nexport type Declaration = typeof Declaration.Type\n\n/** Any declaration accepted by a plan read set.\n * @category schemas\n * @since 0.1.0\n * @slop\n */\nexport const ReadDeclaration = Schema.Union([ReadEntry, ReadFilegroup])\n\n/** Any declaration accepted by a plan read set.\n * @category models\n * @since 0.1.0\n * @slop\n */\nexport type ReadDeclaration = typeof ReadDeclaration.Type\n\n/** Creates a named filegroup.\n * @category constructors\n * @since 0.1.0\n * @slop\n */\nexport const makeFilegroup = (name: string, entries: ReadonlyArray<Entry>): Filegroup => ({\n _tag: \"Filegroup\",\n name,\n entries\n})\n\n/** Expands filegroups deterministically, preserving declaration order.\n * @category accessors\n * @since 0.1.0\n * @slop\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/** Expands read filegroups deterministically, preserving declaration order.\n * @category accessors\n * @since 0.1.0\n * @slop\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/** Whether a value is a glob declaration.\n * @category guards\n * @since 0.1.0\n * @slop\n */\nexport const isGlob = (value: unknown): value is Glob =>\n typeof value === \"object\" && value !== null && \"_tag\" in value && value._tag === \"Glob\"\n\n/** Whether a value is a tree artifact declaration.\n * @category guards\n * @since 0.1.0\n * @slop\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/** Tests one workspace-relative path against one Bazel-style pattern.\n * @category predicates\n * @since 0.1.0\n * @slop\n */\nexport const matchesPattern = (pattern: string, path: string): boolean => patternMatcher(pattern)(path)\n\n/** Tests one file path against a glob, including exclusions.\n * @category predicates\n * @since 0.1.0\n * @slop\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/** {@link matchesGlob} over {@link folded} spellings of the glob and the path. */\nconst matchesGlobFolded = (glob: Glob, path: string): boolean => {\n const inside = folded(path)\n return glob.include.some((pattern) => matchesPattern(folded(pattern), inside)) &&\n !(glob.exclude ?? []).some((pattern) => matchesPattern(folded(pattern), inside))\n}\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 matches both its `include` and `exclude` patterns in\n * folded form. {@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 * @slop\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 matchesGlobFolded(right, left)\n if (isGlob(left) && typeof right === \"string\") return matchesGlobFolded(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"],
|
|
5
|
+
"mappings": ";;;;;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AC,YAAY,eAAe,OAAO,OAAO,GAAG,MAAM,CAAC;AACnF;AAuBO,MAAM,WAAW,CAAC,MAAa,UAA0B;AAC9D,MAAI,OAAO,SAAS,YAAY,OAAO,UAAU,SAAU,QAAO,OAAO,IAAI,MAAM,OAAO,KAAK;AAC/F,MAAI,OAAO,SAAS,YAAY,OAAO,KAAK,EAAG,QAAO,kBAAkB,OAAO,IAAI;AACnF,MAAI,OAAO,IAAI,KAAK,OAAO,UAAU,SAAU,QAAO,kBAAkB,MAAM,KAAK;AACnF,MAAI,OAAO,IAAI,KAAK,OAAO,KAAK,EAAG,QAAO;AAC1C,MAAI,eAAe,IAAI,KAAK,OAAO,UAAU,SAAU,QAAO,QAAQ,KAAK,MAAM,KAAK;AACtF,MAAI,OAAO,SAAS,YAAY,eAAe,KAAK,EAAG,QAAO,QAAQ,MAAM,MAAM,IAAI;AACtF,MAAI,eAAe,IAAI,KAAK,eAAe,KAAK,GAAG;AACjD,WAAO,QAAQ,KAAK,MAAM,MAAM,IAAI,KAAK,QAAQ,MAAM,MAAM,KAAK,IAAI;AAAA,EACxE;AACA,MAAI,eAAe,IAAI,KAAK,OAAO,KAAK,EAAG,QAAO;AAElD,MAAI,OAAO,IAAI,KAAK,eAAe,KAAK,EAAG,QAAO,SAAS,OAAO,IAAI;AAEtE,SAAO;AACT;",
|
|
6
|
+
"names": ["matched"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
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
|
+
* @slop
|
|
72
|
+
*/
|
|
73
|
+
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"]>;
|
|
74
|
+
/**
|
|
75
|
+
* The value form of {@link GraphBuildErrorCode}.
|
|
76
|
+
*
|
|
77
|
+
* @since 0.1.0
|
|
78
|
+
* @category models
|
|
79
|
+
* @slop
|
|
80
|
+
*/
|
|
81
|
+
export type GraphBuildErrorCode = typeof GraphBuildErrorCode.Type;
|
|
82
|
+
declare const GraphBuildError_base: Schema.Class<GraphBuildError, Schema.TaggedStruct<"@smthrs/plan/GraphBuildError", {
|
|
83
|
+
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"]>;
|
|
84
|
+
readonly node: Schema.String;
|
|
85
|
+
readonly path: Schema.$Array<Schema.String>;
|
|
86
|
+
readonly message: Schema.String;
|
|
87
|
+
}>, import("effect/Cause").YieldableError>;
|
|
88
|
+
/**
|
|
89
|
+
* A build the planner refuses, naming the site and the fix.
|
|
90
|
+
*
|
|
91
|
+
* `node` is the node reference the failure belongs to — a planned value's
|
|
92
|
+
* origin node, an `all` member name, a branch arm, or the node whose admission
|
|
93
|
+
* crossed a bound. `path` is the property path recorded on a planned value
|
|
94
|
+
* before it was misused, the effect paths an over-claiming declaration named,
|
|
95
|
+
* the capabilities a call lost, or the value path of an oversized payload; it
|
|
96
|
+
* is empty for every other code.
|
|
97
|
+
*
|
|
98
|
+
* This is the ONE build refusal. `@smthrs/core`'s graph builder raised a second
|
|
99
|
+
* `GraphBuildError` of its own, with `paths`, `nodeId` and `nodes` in place of
|
|
100
|
+
* these fields, and the two code sets diverged instead of merging. A conflict's
|
|
101
|
+
* second node is read from `Graph.conflicts`, which carries the pair.
|
|
102
|
+
*
|
|
103
|
+
* @since 0.1.0
|
|
104
|
+
* @category errors
|
|
105
|
+
* @slop
|
|
106
|
+
*/
|
|
107
|
+
export declare class GraphBuildError extends GraphBuildError_base {
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Whether a recorded refusal blocks the drafts a plan is compiled from.
|
|
111
|
+
*
|
|
112
|
+
* A fatal refusal means the graph describes something no plan could execute as
|
|
113
|
+
* written, so the drafts are withheld. An advisory one reports a narrowing the
|
|
114
|
+
* author should see while the graph still compiles.
|
|
115
|
+
*
|
|
116
|
+
* @since 0.1.0
|
|
117
|
+
* @category predicates
|
|
118
|
+
* @slop
|
|
119
|
+
*/
|
|
120
|
+
export declare const isFatalDiagnostic: (diagnostic: GraphBuildError) => boolean;
|
|
121
|
+
export {};
|
|
122
|
+
//# 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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,eAAO,MAAM,mBAAmB,ohBAwB9B,CAAA;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,mBAAmB,GAAG,OAAO,mBAAmB,CAAC,IAAI,CAAA;;;;;;;AAEjE;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,eAAgB,SAAQ,oBAKnC;CAAG;AAaL;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB,GAAI,YAAY,eAAe,KAAG,OAA8C,CAAA"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var GraphBuildError_exports = {};
|
|
30
|
+
__export(GraphBuildError_exports, {
|
|
31
|
+
GraphBuildError: () => GraphBuildError,
|
|
32
|
+
GraphBuildErrorCode: () => GraphBuildErrorCode,
|
|
33
|
+
isFatalDiagnostic: () => isFatalDiagnostic
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(GraphBuildError_exports);
|
|
36
|
+
var Schema = __toESM(require("effect/Schema"), 1);
|
|
37
|
+
const GraphBuildErrorCode = Schema.Literals([
|
|
38
|
+
"planned_value_computed",
|
|
39
|
+
"invalid_all_member",
|
|
40
|
+
"invalid_join",
|
|
41
|
+
"invalid_continuation",
|
|
42
|
+
"recursion_requires_boundary",
|
|
43
|
+
"placement_requires_boundary",
|
|
44
|
+
"cyclic_payload",
|
|
45
|
+
"payload_too_deep",
|
|
46
|
+
"graph_too_deep",
|
|
47
|
+
"duplicate_node",
|
|
48
|
+
"invalid_priority",
|
|
49
|
+
"invalid_payload",
|
|
50
|
+
"unstable_callback",
|
|
51
|
+
"effect_outside_envelope",
|
|
52
|
+
"effect_mode_widening",
|
|
53
|
+
"effect_tier_widening",
|
|
54
|
+
"capability_outside_grant",
|
|
55
|
+
"write_conflict",
|
|
56
|
+
"missing_key_material",
|
|
57
|
+
"dependency_cycle",
|
|
58
|
+
"plan_too_large",
|
|
59
|
+
"payload_too_large",
|
|
60
|
+
"invalid_node"
|
|
61
|
+
]);
|
|
62
|
+
class GraphBuildError extends Schema.TaggedError()("@smthrs/plan/GraphBuildError", {
|
|
63
|
+
code: GraphBuildErrorCode,
|
|
64
|
+
node: Schema.String,
|
|
65
|
+
path: Schema.Array(Schema.String),
|
|
66
|
+
message: Schema.String
|
|
67
|
+
}) {
|
|
68
|
+
}
|
|
69
|
+
const advisoryCodes = /* @__PURE__ */ new Set(["capability_outside_grant"]);
|
|
70
|
+
const isFatalDiagnostic = (diagnostic) => !advisoryCodes.has(diagnostic.code);
|
|
71
|
+
//# sourceMappingURL=GraphBuildError.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/GraphBuildError.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * The refusals a plan-time build raises instead of producing a wrong plan.\n *\n * Every one of these fails LOUDLY at build time: a planned value that was computed on must not\n * bake `NaN` into a plan, an arm that returned something other than a node must\n * not silently vanish from the topology, and a recursive `.call()` must direct\n * the author to `.to()` or `.child()` rather than expanding forever. Each\n * failure therefore names the site (`node` plus the recorded property `path`)\n * and states the fix in `message`, because the author reading it is mid-body\n * and needs the correction, not a classification.\n *\n * The codes are a closed schema literal so a caller can switch on them, and so\n * a new refusal is a deliberate addition rather than a new free-form string.\n *\n * @since 0.1.0\n */\n\nimport * as Schema from \"effect/Schema\"\n\n/**\n * The stable code of a build refusal.\n *\n * `planned_value_computed` is a body computing on a step result;\n * `invalid_all_member` is a non-node handed to {@link module:Node.all};\n * `invalid_join` is a race, any, or quorum with a non-node member, no members,\n * or a quorum count its members cannot reach;\n * `invalid_continuation` is a branch arm or continuation that did not return a\n * node; `recursion_requires_boundary` is a flow calling itself inline, which\n * has to become a trampoline handoff or an explicit child boundary;\n * `placement_requires_boundary` is an inline call whose callee declares a\n * placement the enclosing flow cannot satisfy, which has to become that same\n * explicit child boundary; `cyclic_payload` is a payload that contains itself,\n * which no plan could serialize or hash; `payload_too_deep` is a payload\n * nested past the build bound, which has to be flattened into shallower data;\n * `graph_too_deep` is authored topology nested past the build bound, which\n * has to be split with `.child()` boundaries or trampoline handoffs;\n * `duplicate_node` is two structural graph addresses resolving to one durable\n * node id;\n * `invalid_priority` is a scheduling priority that is not a safe integer,\n * which no ordering could compare; `invalid_payload` is a payload member that\n * cannot be captured as inert JSON without executing author code or losing\n * identity; `unstable_callback` is a function with process-local identity in a\n * graph that requires stable callbacks. Declare its complete inert captures\n * with `Node.capture`, including semantic implementation versions. The two\n * depth refusals exist because graph building walks with an explicit stack\n * and refuses at a bound, rather than recursing until the native stack\n * overflows without a typed error.\n *\n * The four effect-authority refusals are raised when a declaration claims more\n * than the declaration enclosing it granted:\n * `effect_outside_envelope` is a read or write path the envelope does not\n * cover, and it names those paths in `path`; `effect_mode_widening` is an\n * `expected` declaration inside a `hermetic` envelope; `effect_tier_widening`\n * is a tier less reversible than the envelope's; and\n * `capability_outside_grant` is a called flow or action requiring a capability\n * the caller does not hold, which names the dropped capabilities in `path`. The\n * first three are fatal by {@link isFatalDiagnostic}; the fourth is advisory,\n * because dropping a capability narrows authority rather than widening it.\n *\n * The last six are raised by `@smthrs/core`'s graph builder, which uses this\n * one error rather than a second class of its own. `write_conflict` is two work\n * nodes overlapping under `onConflict: \"fail\"`, and `node` names the first of\n * the pair while `Graph.conflicts` carries both; `missing_key_material` is a\n * node that reached key compilation without any; `dependency_cycle` is a\n * dependency set that cannot be ordered, and `node` names a node in the cycle;\n * `plan_too_large` is a node, edge, conflict, or effect-path limit crossed, and\n * `node` names the node whose admission crossed it; `payload_too_large` is a\n * plan value with more members than the bound, and `path` names the offending\n * value path; `invalid_node` is a malformed node AST. All six are fatal.\n *\n * @since 0.1.0\n * @category schemas\n * @slop\n */\nexport const GraphBuildErrorCode = Schema.Literals([\n \"planned_value_computed\",\n \"invalid_all_member\",\n \"invalid_join\",\n \"invalid_continuation\",\n \"recursion_requires_boundary\",\n \"placement_requires_boundary\",\n \"cyclic_payload\",\n \"payload_too_deep\",\n \"graph_too_deep\",\n \"duplicate_node\",\n \"invalid_priority\",\n \"invalid_payload\",\n \"unstable_callback\",\n \"effect_outside_envelope\",\n \"effect_mode_widening\",\n \"effect_tier_widening\",\n \"capability_outside_grant\",\n \"write_conflict\",\n \"missing_key_material\",\n \"dependency_cycle\",\n \"plan_too_large\",\n \"payload_too_large\",\n \"invalid_node\"\n])\n\n/**\n * The value form of {@link GraphBuildErrorCode}.\n *\n * @since 0.1.0\n * @category models\n * @slop\n */\nexport type GraphBuildErrorCode = typeof GraphBuildErrorCode.Type\n\n/**\n * A build the planner refuses, naming the site and the fix.\n *\n * `node` is the node reference the failure belongs to \u2014 a planned value's\n * origin node, an `all` member name, a branch arm, or the node whose admission\n * crossed a bound. `path` is the property path recorded on a planned value\n * before it was misused, the effect paths an over-claiming declaration named,\n * the capabilities a call lost, or the value path of an oversized payload; it\n * is empty for every other code.\n *\n * This is the ONE build refusal. `@smthrs/core`'s graph builder raised a second\n * `GraphBuildError` of its own, with `paths`, `nodeId` and `nodes` in place of\n * these fields, and the two code sets diverged instead of merging. A conflict's\n * second node is read from `Graph.conflicts`, which carries the pair.\n *\n * @since 0.1.0\n * @category errors\n * @slop\n */\nexport class GraphBuildError extends Schema.TaggedError<GraphBuildError>()(\"@smthrs/plan/GraphBuildError\", {\n code: GraphBuildErrorCode,\n node: Schema.String,\n path: Schema.Array(Schema.String),\n message: Schema.String\n}) {}\n\n/**\n * The one advisory code. Everything else a build records blocks the drafts.\n *\n * A capability the caller does not grant is DROPPED, not granted: the callee\n * runs with less authority than it asked for, which is the safe direction. The\n * author still needs to know, because a flow that silently loses a capability\n * fails later at the action that needed it, so the build records the refusal\n * and lets the graph compile.\n */\nconst advisoryCodes: ReadonlySet<GraphBuildErrorCode> = new Set<GraphBuildErrorCode>([\"capability_outside_grant\"])\n\n/**\n * Whether a recorded refusal blocks the drafts a plan is compiled from.\n *\n * A fatal refusal means the graph describes something no plan could execute as\n * written, so the drafts are withheld. An advisory one reports a narrowing the\n * author should see while the graph still compiles.\n *\n * @since 0.1.0\n * @category predicates\n * @slop\n */\nexport const isFatalDiagnostic = (diagnostic: GraphBuildError): boolean => !advisoryCodes.has(diagnostic.code)\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBA,aAAwB;AAyDjB,MAAM,sBAAsB,OAAO,SAAS;AAAA,EACjD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AA8BM,MAAM,wBAAwB,OAAO,YAA6B,EAAE,gCAAgC;AAAA,EACzG,MAAM;AAAA,EACN,MAAM,OAAO;AAAA,EACb,MAAM,OAAO,MAAM,OAAO,MAAM;AAAA,EAChC,SAAS,OAAO;AAClB,CAAC,EAAE;AAAC;AAWJ,MAAM,gBAAkD,oBAAI,IAAyB,CAAC,0BAA0B,CAAC;AAa1G,MAAM,oBAAoB,CAAC,eAAyC,CAAC,cAAc,IAAI,WAAW,IAAI;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The key-material contract: what a planner hands the step-key compiler.
|
|
3
|
+
*
|
|
4
|
+
* Revived from the deleted `packages/smithers/flows/keys/src/KeyMaterial.ts`.
|
|
5
|
+
* It does NOT return to `@smthrs/keys`: that package owns generic derivation
|
|
6
|
+
* and stored-key validation, while material is a *plan-shaped* concept. It
|
|
7
|
+
* lives here, above `@smthrs/keys`, so the key package stays a leaf.
|
|
8
|
+
*
|
|
9
|
+
* Governing contract: the step-key rules at
|
|
10
|
+
* https://smithers.sh/docs/concepts/content-addressing. Material is computed with no I/O,
|
|
11
|
+
* and two hardening rules shape it: the nominal, never shape-sniffed
|
|
12
|
+
* `InputRef` and the hashed `version`.
|
|
13
|
+
*
|
|
14
|
+
* @since 0.1.0
|
|
15
|
+
*/
|
|
16
|
+
import * as Schema from "effect/Schema";
|
|
17
|
+
/**
|
|
18
|
+
* A reference to one declared input of a node: a value hashed inline, or the
|
|
19
|
+
* key of an upstream node whose result this node consumes.
|
|
20
|
+
*
|
|
21
|
+
* The three variants are tagged, and the tag is hashed, so `Pending{from}` and
|
|
22
|
+
* `Ref{from, path: []}` — which resolve to the same dependency digest — can
|
|
23
|
+
* never collide.
|
|
24
|
+
*
|
|
25
|
+
* @since 0.1.0
|
|
26
|
+
* @category schemas
|
|
27
|
+
* @slop
|
|
28
|
+
*/
|
|
29
|
+
export declare const InputRef: Schema.Union<readonly [Schema.TaggedStruct<"Literal", {
|
|
30
|
+
readonly value: Schema.Unknown;
|
|
31
|
+
}>, Schema.TaggedStruct<"Ref", {
|
|
32
|
+
readonly from: Schema.NonEmptyString;
|
|
33
|
+
readonly path: Schema.$Array<Schema.String>;
|
|
34
|
+
}>, Schema.TaggedStruct<"Pending", {
|
|
35
|
+
readonly from: Schema.NonEmptyString;
|
|
36
|
+
}>]>;
|
|
37
|
+
/**
|
|
38
|
+
* A reference to one declared input of a node.
|
|
39
|
+
*
|
|
40
|
+
* @since 0.1.0
|
|
41
|
+
* @category models
|
|
42
|
+
* @slop
|
|
43
|
+
*/
|
|
44
|
+
export type InputRef = typeof InputRef.Type;
|
|
45
|
+
/**
|
|
46
|
+
* The material version. Folded into every hashed body so a bump re-keys every
|
|
47
|
+
* node derived from it — the original's second collision fix, kept.
|
|
48
|
+
*
|
|
49
|
+
* @since 0.1.0
|
|
50
|
+
* @category constants
|
|
51
|
+
* @slop
|
|
52
|
+
*/
|
|
53
|
+
export declare const version = "flows/key-material/v2";
|
|
54
|
+
/**
|
|
55
|
+
* Everything that can change a node's result, handed to the digest.
|
|
56
|
+
*
|
|
57
|
+
* `effects` and `placement` are opaque: canonically serialized, never
|
|
58
|
+
* interpreted, which is what keeps the compiler independent of whatever the
|
|
59
|
+
* flow builder decides an effect declaration looks like.
|
|
60
|
+
*
|
|
61
|
+
* @since 0.1.0
|
|
62
|
+
* @category schemas
|
|
63
|
+
* @slop
|
|
64
|
+
*/
|
|
65
|
+
export declare const KeyMaterial: Schema.Struct<{
|
|
66
|
+
readonly version: Schema.Literal<"flows/key-material/v2">;
|
|
67
|
+
readonly kind: Schema.Literals<readonly ["sealed", "compensable", "irreversible"]>;
|
|
68
|
+
readonly nondeterministic: Schema.optional<Schema.Literal<true>>;
|
|
69
|
+
readonly body: Schema.Unknown;
|
|
70
|
+
readonly inputs: Schema.$Array<Schema.Union<readonly [Schema.TaggedStruct<"Literal", {
|
|
71
|
+
readonly value: Schema.Unknown;
|
|
72
|
+
}>, Schema.TaggedStruct<"Ref", {
|
|
73
|
+
readonly from: Schema.NonEmptyString;
|
|
74
|
+
readonly path: Schema.$Array<Schema.String>;
|
|
75
|
+
}>, Schema.TaggedStruct<"Pending", {
|
|
76
|
+
readonly from: Schema.NonEmptyString;
|
|
77
|
+
}>]>>;
|
|
78
|
+
readonly layers: Schema.$Array<Schema.String>;
|
|
79
|
+
readonly capabilities: Schema.$Array<Schema.String>;
|
|
80
|
+
readonly effects: Schema.optional<Schema.Unknown>;
|
|
81
|
+
readonly placement: Schema.optional<Schema.Unknown>;
|
|
82
|
+
}>;
|
|
83
|
+
/**
|
|
84
|
+
* Everything that can change a node's result, handed to the digest.
|
|
85
|
+
*
|
|
86
|
+
* @since 0.1.0
|
|
87
|
+
* @category models
|
|
88
|
+
* @slop
|
|
89
|
+
*/
|
|
90
|
+
export type KeyMaterial = typeof KeyMaterial.Type;
|
|
91
|
+
/**
|
|
92
|
+
* The graph-local dependencies a material names, in declaration order and
|
|
93
|
+
* without duplicates. The compiler resolves exactly these before hashing, and
|
|
94
|
+
* {@link module:Plan} uses them as the edge set — one derivation, so an edge
|
|
95
|
+
* and a hashed reference can never disagree.
|
|
96
|
+
*
|
|
97
|
+
* @since 0.1.0
|
|
98
|
+
* @category accessors
|
|
99
|
+
* @slop
|
|
100
|
+
*/
|
|
101
|
+
export declare const dependencies: (material: KeyMaterial) => ReadonlyArray<string>;
|
|
102
|
+
//# sourceMappingURL=KeyMaterial.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KeyMaterial.d.ts","sourceRoot":"","sources":["../../src/KeyMaterial.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAGvC;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,QAAQ;;;;;;;IAInB,CAAA;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC,IAAI,CAAA;AAE3C;;;;;;;GAOG;AACH,eAAO,MAAM,OAAO,0BAA0B,CAAA;AAE9C;;;;;;;;;;GAUG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;EAWtB,CAAA;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,GAAG,OAAO,WAAW,CAAC,IAAI,CAAA;AAEjD;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY,GAAI,UAAU,WAAW,KAAG,aAAa,CAAC,MAAM,CAMxE,CAAA"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var KeyMaterial_exports = {};
|
|
30
|
+
__export(KeyMaterial_exports, {
|
|
31
|
+
InputRef: () => InputRef,
|
|
32
|
+
KeyMaterial: () => KeyMaterial,
|
|
33
|
+
dependencies: () => dependencies,
|
|
34
|
+
version: () => version
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(KeyMaterial_exports);
|
|
37
|
+
var Schema = __toESM(require("effect/Schema"), 1);
|
|
38
|
+
var Effects = __toESM(require("./Effects.js"), 1);
|
|
39
|
+
const InputRef = Schema.Union([
|
|
40
|
+
Schema.TaggedStruct("Literal", { value: Schema.Unknown }),
|
|
41
|
+
Schema.TaggedStruct("Ref", { from: Schema.NonEmptyString, path: Schema.Array(Schema.String) }),
|
|
42
|
+
Schema.TaggedStruct("Pending", { from: Schema.NonEmptyString })
|
|
43
|
+
]);
|
|
44
|
+
const version = "flows/key-material/v2";
|
|
45
|
+
const KeyMaterial = Schema.Struct({
|
|
46
|
+
version: Schema.Literal(version),
|
|
47
|
+
kind: Effects.Tier,
|
|
48
|
+
// Absence claims determinism; only the explicit declaration changes identity.
|
|
49
|
+
nondeterministic: Schema.optional(Schema.Literal(true)),
|
|
50
|
+
body: Schema.Unknown,
|
|
51
|
+
inputs: Schema.Array(InputRef),
|
|
52
|
+
layers: Schema.Array(Schema.String),
|
|
53
|
+
capabilities: Schema.Array(Schema.String),
|
|
54
|
+
effects: Schema.optional(Schema.Unknown),
|
|
55
|
+
placement: Schema.optional(Schema.Unknown)
|
|
56
|
+
});
|
|
57
|
+
const dependencies = (material) => {
|
|
58
|
+
const seen = /* @__PURE__ */ new Set();
|
|
59
|
+
for (const input of material.inputs) {
|
|
60
|
+
if (input._tag !== "Literal") seen.add(input.from);
|
|
61
|
+
}
|
|
62
|
+
return [...seen];
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=KeyMaterial.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/KeyMaterial.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * The key-material contract: what a planner hands the step-key compiler.\n *\n * Revived from the deleted `packages/smithers/flows/keys/src/KeyMaterial.ts`.\n * It does NOT return to `@smthrs/keys`: that package owns generic derivation\n * and stored-key validation, while material is a *plan-shaped* concept. It\n * lives here, above `@smthrs/keys`, so the key package stays a leaf.\n *\n * Governing contract: the step-key rules at\n * https://smithers.sh/docs/concepts/content-addressing. Material is computed with no I/O,\n * and two hardening rules shape it: the nominal, never shape-sniffed\n * `InputRef` and the hashed `version`.\n *\n * @since 0.1.0\n */\n\nimport * as Schema from \"effect/Schema\"\nimport * as Effects from \"./Effects.ts\"\n\n/**\n * A reference to one declared input of a node: a value hashed inline, or the\n * key of an upstream node whose result this node consumes.\n *\n * The three variants are tagged, and the tag is hashed, so `Pending{from}` and\n * `Ref{from, path: []}` \u2014 which resolve to the same dependency digest \u2014 can\n * never collide.\n *\n * @since 0.1.0\n * @category schemas\n * @slop\n */\nexport const InputRef = Schema.Union([\n Schema.TaggedStruct(\"Literal\", { value: Schema.Unknown }),\n Schema.TaggedStruct(\"Ref\", { from: Schema.NonEmptyString, path: Schema.Array(Schema.String) }),\n Schema.TaggedStruct(\"Pending\", { from: Schema.NonEmptyString })\n])\n\n/**\n * A reference to one declared input of a node.\n *\n * @since 0.1.0\n * @category models\n * @slop\n */\nexport type InputRef = typeof InputRef.Type\n\n/**\n * The material version. Folded into every hashed body so a bump re-keys every\n * node derived from it \u2014 the original's second collision fix, kept.\n *\n * @since 0.1.0\n * @category constants\n * @slop\n */\nexport const version = \"flows/key-material/v2\"\n\n/**\n * Everything that can change a node's result, handed to the digest.\n *\n * `effects` and `placement` are opaque: canonically serialized, never\n * interpreted, which is what keeps the compiler independent of whatever the\n * flow builder decides an effect declaration looks like.\n *\n * @since 0.1.0\n * @category schemas\n * @slop\n */\nexport const KeyMaterial = Schema.Struct({\n version: Schema.Literal(version),\n kind: Effects.Tier,\n // Absence claims determinism; only the explicit declaration changes identity.\n nondeterministic: Schema.optional(Schema.Literal(true)),\n body: Schema.Unknown,\n inputs: Schema.Array(InputRef),\n layers: Schema.Array(Schema.String),\n capabilities: Schema.Array(Schema.String),\n effects: Schema.optional(Schema.Unknown),\n placement: Schema.optional(Schema.Unknown)\n})\n\n/**\n * Everything that can change a node's result, handed to the digest.\n *\n * @since 0.1.0\n * @category models\n * @slop\n */\nexport type KeyMaterial = typeof KeyMaterial.Type\n\n/**\n * The graph-local dependencies a material names, in declaration order and\n * without duplicates. The compiler resolves exactly these before hashing, and\n * {@link module:Plan} uses them as the edge set \u2014 one derivation, so an edge\n * and a hashed reference can never disagree.\n *\n * @since 0.1.0\n * @category accessors\n * @slop\n */\nexport const dependencies = (material: KeyMaterial): ReadonlyArray<string> => {\n const seen = new Set<string>()\n for (const input of material.inputs) {\n if (input._tag !== \"Literal\") seen.add(input.from)\n }\n return [...seen]\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBA,aAAwB;AACxB,cAAyB;AAclB,MAAM,WAAW,OAAO,MAAM;AAAA,EACnC,OAAO,aAAa,WAAW,EAAE,OAAO,OAAO,QAAQ,CAAC;AAAA,EACxD,OAAO,aAAa,OAAO,EAAE,MAAM,OAAO,gBAAgB,MAAM,OAAO,MAAM,OAAO,MAAM,EAAE,CAAC;AAAA,EAC7F,OAAO,aAAa,WAAW,EAAE,MAAM,OAAO,eAAe,CAAC;AAChE,CAAC;AAmBM,MAAM,UAAU;AAahB,MAAM,cAAc,OAAO,OAAO;AAAA,EACvC,SAAS,OAAO,QAAQ,OAAO;AAAA,EAC/B,MAAM,QAAQ;AAAA;AAAA,EAEd,kBAAkB,OAAO,SAAS,OAAO,QAAQ,IAAI,CAAC;AAAA,EACtD,MAAM,OAAO;AAAA,EACb,QAAQ,OAAO,MAAM,QAAQ;AAAA,EAC7B,QAAQ,OAAO,MAAM,OAAO,MAAM;AAAA,EAClC,cAAc,OAAO,MAAM,OAAO,MAAM;AAAA,EACxC,SAAS,OAAO,SAAS,OAAO,OAAO;AAAA,EACvC,WAAW,OAAO,SAAS,OAAO,OAAO;AAC3C,CAAC;AAqBM,MAAM,eAAe,CAAC,aAAiD;AAC5E,QAAM,OAAO,oBAAI,IAAY;AAC7B,aAAW,SAAS,SAAS,QAAQ;AACnC,QAAI,MAAM,SAAS,UAAW,MAAK,IAAI,MAAM,IAAI;AAAA,EACnD;AACA,SAAO,CAAC,GAAG,IAAI;AACjB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|