@smthrs/plan 1.0.0-rc.8 → 1.0.0-rc.9
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/dist/cjs/Effects.d.ts +29 -11
- package/dist/cjs/Effects.d.ts.map +1 -1
- package/dist/cjs/Effects.js.map +2 -2
- package/dist/cjs/FileSet.d.ts +121 -51
- package/dist/cjs/FileSet.d.ts.map +1 -1
- package/dist/cjs/FileSet.js.map +2 -2
- package/dist/cjs/GraphBuildError.d.ts +2 -4
- package/dist/cjs/GraphBuildError.d.ts.map +1 -1
- package/dist/cjs/GraphBuildError.js.map +2 -2
- package/dist/cjs/KeyMaterial.d.ts +13 -8
- package/dist/cjs/KeyMaterial.d.ts.map +1 -1
- package/dist/cjs/KeyMaterial.js.map +2 -2
- package/dist/cjs/Plan.d.ts +72 -23
- package/dist/cjs/Plan.d.ts.map +1 -1
- package/dist/cjs/Plan.js +3 -0
- package/dist/cjs/Plan.js.map +2 -2
- package/dist/cjs/PlanDiff.d.ts +7 -3
- package/dist/cjs/PlanDiff.d.ts.map +1 -1
- package/dist/cjs/PlanDiff.js.map +2 -2
- package/dist/cjs/StepKey.d.ts +38 -17
- package/dist/cjs/StepKey.d.ts.map +1 -1
- package/dist/cjs/StepKey.js.map +2 -2
- package/dist/esm/Effects.d.ts +29 -11
- package/dist/esm/Effects.d.ts.map +1 -1
- package/dist/esm/Effects.js +18 -7
- package/dist/esm/Effects.js.map +1 -1
- package/dist/esm/FileSet.d.ts +121 -51
- package/dist/esm/FileSet.d.ts.map +1 -1
- package/dist/esm/FileSet.js +97 -35
- package/dist/esm/FileSet.js.map +1 -1
- package/dist/esm/GraphBuildError.d.ts +2 -4
- package/dist/esm/GraphBuildError.d.ts.map +1 -1
- package/dist/esm/GraphBuildError.js +2 -3
- package/dist/esm/GraphBuildError.js.map +1 -1
- package/dist/esm/KeyMaterial.d.ts +13 -8
- package/dist/esm/KeyMaterial.d.ts.map +1 -1
- package/dist/esm/KeyMaterial.js +11 -4
- package/dist/esm/KeyMaterial.js.map +1 -1
- package/dist/esm/Plan.d.ts +72 -23
- package/dist/esm/Plan.d.ts.map +1 -1
- package/dist/esm/Plan.js +61 -16
- package/dist/esm/Plan.js.map +1 -1
- package/dist/esm/PlanDiff.d.ts +7 -3
- package/dist/esm/PlanDiff.d.ts.map +1 -1
- package/dist/esm/PlanDiff.js +0 -1
- package/dist/esm/PlanDiff.js.map +1 -1
- package/dist/esm/StepKey.d.ts +38 -17
- package/dist/esm/StepKey.d.ts.map +1 -1
- package/dist/esm/StepKey.js +33 -11
- package/dist/esm/StepKey.js.map +1 -1
- package/docs/guides/diff-two-plans.md +78 -1
- package/package.json +4 -4
- package/src/Effects.ts +29 -11
- package/src/FileSet.ts +121 -51
- package/src/GraphBuildError.ts +2 -4
- package/src/KeyMaterial.ts +13 -8
- package/src/Plan.ts +66 -23
- package/src/PlanDiff.ts +7 -3
- package/src/StepKey.ts +38 -17
package/dist/esm/StepKey.js
CHANGED
|
@@ -48,9 +48,12 @@ const DigestInputTypeId = Symbol.for("@smthrs/plan/StepKey/DigestInput");
|
|
|
48
48
|
* Nominally tags a precomputed digest so it is hashed as a digest reference
|
|
49
49
|
* rather than a literal value.
|
|
50
50
|
*
|
|
51
|
+
* @param digest - The precomputed digest.
|
|
52
|
+
* @param reference - Which graph reference resolved to the digest, and the
|
|
53
|
+
* projection path for `ref-projected`. Omit for a plain digest.
|
|
54
|
+
* @returns The tagged digest input.
|
|
51
55
|
* @since 0.1.0
|
|
52
56
|
* @category constructors
|
|
53
|
-
* @slop
|
|
54
57
|
*/
|
|
55
58
|
export const digestInput = (digest, reference) => ({
|
|
56
59
|
[DigestInputTypeId]: DigestInputTypeId,
|
|
@@ -59,11 +62,13 @@ export const digestInput = (digest, reference) => ({
|
|
|
59
62
|
...(reference?.path === undefined ? {} : { path: reference.path })
|
|
60
63
|
});
|
|
61
64
|
/**
|
|
62
|
-
* Type guard for values produced by {@link digestInput}.
|
|
65
|
+
* Type guard for values produced by {@link digestInput}. A plain object
|
|
66
|
+
* shaped like `{ digest: "..." }` is not one.
|
|
63
67
|
*
|
|
68
|
+
* @param value - Any value.
|
|
69
|
+
* @returns `true` only for a value carrying the private digest-input brand.
|
|
64
70
|
* @since 0.1.0
|
|
65
71
|
* @category guards
|
|
66
|
-
* @slop
|
|
67
72
|
*/
|
|
68
73
|
export const isDigestInput = (value) => typeof value === "object" && value !== null && DigestInputTypeId in value &&
|
|
69
74
|
value[DigestInputTypeId] === DigestInputTypeId;
|
|
@@ -91,9 +96,9 @@ export const EnvironmentIdentity = Schema.Union([
|
|
|
91
96
|
* Creates an empty projected-value digest memo. Projection addresses are
|
|
92
97
|
* JSON-encoded `[from, path]` tuples so segment boundaries are unambiguous.
|
|
93
98
|
*
|
|
99
|
+
* @returns A memo with no entries.
|
|
94
100
|
* @since 0.1.0
|
|
95
101
|
* @category constructors
|
|
96
|
-
* @slop
|
|
97
102
|
*/
|
|
98
103
|
export const makeDigestMemo = () => {
|
|
99
104
|
const entries = new Map();
|
|
@@ -124,11 +129,18 @@ export const makeDigestMemo = () => {
|
|
|
124
129
|
return { digest };
|
|
125
130
|
};
|
|
126
131
|
/**
|
|
127
|
-
* Stable failures while
|
|
132
|
+
* Stable failures while deriving a key. `code` names the rule:
|
|
133
|
+
*
|
|
134
|
+
* - `invalid_environment`: an {@link EnvironmentIdentity} that is neither
|
|
135
|
+
* declared nor run-scoped.
|
|
136
|
+
* - `missing_dependency`: a `Ref` or `Pending` input names a node with no
|
|
137
|
+
* recorded digest, or, at dispatch, a `Ref` names one with no settled
|
|
138
|
+
* result.
|
|
139
|
+
* - `non_content_material`: a content-key constructor received material whose
|
|
140
|
+
* tier is not `sealed`.
|
|
128
141
|
*
|
|
129
142
|
* @since 0.1.0
|
|
130
143
|
* @category errors
|
|
131
|
-
* @slop
|
|
132
144
|
*/
|
|
133
145
|
export class KeyMaterialError extends Schema.TaggedError()("@smthrs/plan/KeyMaterialError", {
|
|
134
146
|
code: Schema.Literals(["invalid_environment", "missing_dependency", "non_content_material"]),
|
|
@@ -246,9 +258,11 @@ export const environmentIdentity = (environment) => Effect.gen(function* () {
|
|
|
246
258
|
* declarations are normalized before serialization; write declarations remain
|
|
247
259
|
* part of the identity even when the step writes nothing.
|
|
248
260
|
*
|
|
261
|
+
* @param identity - The step's content material.
|
|
262
|
+
* @returns The content key. Fails with `invalid_environment` for a malformed
|
|
263
|
+
* environment, or `SchemaError` when the material cannot be serialized.
|
|
249
264
|
* @since 0.1.0
|
|
250
265
|
* @category constructors
|
|
251
|
-
* @slop
|
|
252
266
|
*/
|
|
253
267
|
export const content = (identity) => Effect.gen(function* () {
|
|
254
268
|
const environment = identity.environment === undefined ? undefined : yield* decodeEnvironment(identity.environment);
|
|
@@ -266,9 +280,10 @@ export const content = (identity) => Effect.gen(function* () {
|
|
|
266
280
|
* Produces a run-local ordinal key for compensable, irreversible, or unsealed
|
|
267
281
|
* work. These keys intentionally cannot be reused across runs.
|
|
268
282
|
*
|
|
283
|
+
* @param identity - The run id, optional parent scope, ordinal, and tier.
|
|
284
|
+
* @returns The ordinal key.
|
|
269
285
|
* @since 0.1.0
|
|
270
286
|
* @category constructors
|
|
271
|
-
* @slop
|
|
272
287
|
*/
|
|
273
288
|
export const ordinal = (identity) => decodeKey({ kind: "ordinal", ...identity });
|
|
274
289
|
/**
|
|
@@ -282,9 +297,13 @@ export const ordinal = (identity) => decodeKey({ kind: "ordinal", ...identity })
|
|
|
282
297
|
* and never enter the hashed value — rename a node and nothing re-keys; change
|
|
283
298
|
* what a node consumes and everything downstream of it does.
|
|
284
299
|
*
|
|
300
|
+
* @param material - The node's key material; its tier must be `sealed`.
|
|
301
|
+
* @param dependencyDigests - The key of every node the material references,
|
|
302
|
+
* by node id.
|
|
303
|
+
* @returns The content key. Fails with `non_content_material` for a
|
|
304
|
+
* non-sealed tier and `missing_dependency` for an unresolved reference.
|
|
285
305
|
* @since 0.1.0
|
|
286
306
|
* @category constructors
|
|
287
|
-
* @slop
|
|
288
307
|
*/
|
|
289
308
|
export const fromKeyMaterial = (material, dependencyDigests) => {
|
|
290
309
|
if (material.kind !== "sealed") {
|
|
@@ -412,7 +431,6 @@ const orderingOnly = "ordering-only";
|
|
|
412
431
|
*
|
|
413
432
|
* @since 0.1.0
|
|
414
433
|
* @category utilities
|
|
415
|
-
* @slop
|
|
416
434
|
*/
|
|
417
435
|
export const project = (value, path) => {
|
|
418
436
|
let current = value;
|
|
@@ -448,9 +466,13 @@ export const project = (value, path) => {
|
|
|
448
466
|
* halt rule guarantees it: a dependent of failed or skipped work never
|
|
449
467
|
* dispatches, so a `Ref` always resolves against a success.
|
|
450
468
|
*
|
|
469
|
+
* @param options - The material, the dependencies' settled results, the
|
|
470
|
+
* measured hermetic boundary, and an optional environment and memo.
|
|
471
|
+
* @returns The dispatch key. Fails with `non_content_material` for a
|
|
472
|
+
* non-sealed tier, `missing_dependency` for a `Ref` absent from `results`,
|
|
473
|
+
* or `invalid_environment` for a malformed environment.
|
|
451
474
|
* @since 0.1.0
|
|
452
475
|
* @category constructors
|
|
453
|
-
* @slop
|
|
454
476
|
*/
|
|
455
477
|
export const dispatchIdentity = (options) => Effect.gen(function* () {
|
|
456
478
|
const material = options.material;
|
package/dist/esm/StepKey.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StepKey.js","sourceRoot":"","sources":["../../src/StepKey.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAE,UAAU,EAAkB,MAAM,cAAc,CAAA;AACzD,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAA;AAC3C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,IAAI,MAAM,aAAa,CAAA;AACnC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAcvC;;;;;;;;;;GAUG;AACH,M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AAW;QACX,QAAQ,EAAE,OAAO,CAAC,QAAQ;KAC3B,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["/**\n * The KeyMaterial → step-key compiler.\n *\n * Revived from the deleted `packages/smithers/flows/keys/src/StepKey.ts`. Two\n * deliberate deviations from the original:\n *\n * 1. **It lives here, not in `@smthrs/keys`.** That package owns generic\n * derivation and stored-key validation; a compiler that understands plan\n * material belongs above it.\n * 2. **It produces `@smthrs/keys` `StoredKey` values, not a second `sk1_` digest\n * format.** The original minted its own prefix over a private `Digest`\n * module. The engine dispatches under `StoredKey` (`FlowEngine/ActionKey.ts`),\n * so a plan whose node keys were a *different* string format could never be\n * the thing the cache is consulted against, and that is the whole point of\n * a `Plan`. One key format, one hashing\n * chokepoint (canonical JSON + injected `Crypto`), one namespace field\n * (`kind`) distinguishing content keys from ordinal ones.\n *\n * Everything the original earned is kept: nominally branded digest inputs (a\n * literal that merely *looks* like `{digest}` hashes as a literal), set\n * normalization, the separate environment namespace, per-variant tagging of\n * resolved references, and the hashed `version`.\n *\n * Governing contract: the step-key rules at\n * https://github.com/smithersai/smithers/blob/main/packages/smithers/flows/plan/docs/concepts/step-keys.md.\n *\n * @since 0.1.0\n */\n\nimport { DerivedKey, type StoredKey } from \"@smthrs/keys\"\nimport * as Cause from \"effect/Cause\"\nimport type * as Crypto from \"effect/Crypto\"\nimport * as Deferred from \"effect/Deferred\"\nimport * as Effect from \"effect/Effect\"\nimport * as Exit from \"effect/Exit\"\nimport * as Schema from \"effect/Schema\"\nimport type * as FileSet from \"./FileSet.ts\"\nimport type * as KeyMaterial from \"./KeyMaterial.ts\"\n\n/**\n * A computed step key. Identical in representation to any other flow key —\n * `key1_` plus a SHA-256 digest of the canonical serialization of the material.\n *\n * @since 0.1.0\n * @category models\n * @slop\n */\nexport type StepKey = StoredKey\n\n/**\n * The nominal brand carried by every {@link DigestInput}. Kept private: the\n * only way to produce a value bearing it is {@link digestInput}, so a plain\n * value that merely happens to look like `{ digest: \"...\" }` — actions pass\n * content hashes around as ordinary data — can never be mistaken for a genuine\n * upstream-result digest reference. This closes a step-key collision where\n * shape-sniffing (`\"digest\" in value`) hashed the two identically.\n *\n * @since 0.1.0\n * @category symbols\n */\nconst DigestInputTypeId: unique symbol = Symbol.for(\"@smthrs/plan/StepKey/DigestInput\")\n\n/**\n * Which kind of graph reference a {@link DigestInput} stands for. Declared\n * once here so the field on `DigestInput` and the parameter of\n * {@link digestInput} name one set and cannot drift apart.\n */\ntype GraphReference = \"ref\" | \"pending\" | \"ref-projected\"\n\n/**\n * A precomputed digest supplied as a step input rather than a literal value.\n *\n * @since 0.1.0\n * @category models\n * @slop\n */\nexport interface DigestInput {\n readonly [DigestInputTypeId]: typeof DigestInputTypeId\n readonly digest: string\n /**\n * Which kind of graph reference resolved to this digest.\n *\n * Carrying the discriminator on the digest input keeps `normalizeInputs` the\n * single normalizer: it wraps every variant once, and the variants stay\n * mutually distinct because they differ in this field rather than in a\n * hand-built object a second wrap would hide.\n */\n readonly reference?: GraphReference\n /** The projection applied to the referenced result, for `ref-projected`. */\n readonly path?: ReadonlyArray<string>\n}\n\n/**\n * Nominally tags a precomputed digest so it is hashed as a digest reference\n * rather than a literal value.\n *\n * @since 0.1.0\n * @category constructors\n * @slop\n */\nexport const digestInput = (\n digest: string,\n reference?: {\n readonly reference: GraphReference\n readonly path?: ReadonlyArray<string>\n }\n): DigestInput => ({\n [DigestInputTypeId]: DigestInputTypeId,\n digest,\n ...(reference === undefined ? {} : { reference: reference.reference }),\n ...(reference?.path === undefined ? {} : { path: reference.path })\n})\n\n/**\n * Type guard for values produced by {@link digestInput}.\n *\n * @since 0.1.0\n * @category guards\n * @slop\n */\nexport const isDigestInput = (value: unknown): value is DigestInput =>\n typeof value === \"object\" && value !== null && DigestInputTypeId in value &&\n (value as Record<PropertyKey, unknown>)[DigestInputTypeId] === DigestInputTypeId\n\n/**\n * The engine-resolved execution environment a content key is computed under,\n * hashed in its OWN namespace rather than merged into the caller's `layers`\n * and `capabilities`.\n *\n * Three properties matter and none survives a merge:\n *\n * 1. **Non-aliasing.** Concatenating environment material onto the caller's\n * made `caller{fs:[\"a\"]} + env{fs:[\"b\"]}` hash identically to\n * `caller{fs:[\"a\",\"b\"]} + env{}` — a cross-run collision in the very\n * material whose purpose is preventing one.\n * 2. **Declared vs undeclared.** `declared: false` is not the same value as\n * `declared: true` with empty sets.\n * 3. **Composition order.** Environment layers retain declaration order,\n * because plugin and service composition order can change behavior. The\n * caller-owned `ContentIdentity.layers` stays set-normalized.\n *\n * `runScope` is set only when `declared` is `false`: it pins the key to one\n * run, so a step whose environment identity is unknown can never serve a\n * cross-run hit. The union enforces this for typed callers; both\n * {@link content} and {@link dispatchIdentity} validate it at run time.\n *\n * @since 0.1.0\n * @category models\n * @slop\n */\nexport type EnvironmentIdentity = typeof EnvironmentIdentity.Type\n\n/**\n * Validated, copyable runtime environment identity. Layer order matters;\n * capability patterns are set-like. Unknown fields are not identity material.\n * @since 1.0.0\n * @category schemas\n */\nexport const EnvironmentIdentity = Schema.Union([\n Schema.Struct({\n declared: Schema.Literal(true),\n layers: Schema.Array(Schema.String),\n capabilities: Schema.Record(Schema.String, Schema.Array(Schema.String)),\n runScope: Schema.optionalKey(Schema.Undefined)\n }),\n Schema.Struct({\n declared: Schema.Literal(false),\n layers: Schema.Array(Schema.String),\n capabilities: Schema.Record(Schema.String, Schema.Array(Schema.String)),\n runScope: Schema.NonEmptyString\n })\n])\n\n/**\n * Caller-owned memoization context for projected dependency-value digests.\n *\n * This is the flows counterpart of Bazel's `ActionKeyContext`: one context is\n * passed through related key computations so shared input material is hashed\n * once. Concurrent requests for the same projection share the in-flight\n * digest. Entries are sound only while each settled `from` value is immutable;\n * callers must create a fresh memo when those values can change.\n *\n * @since 0.1.0\n * @category models\n * @slop\n */\nexport interface DigestMemo {\n readonly digest: (\n from: string,\n path: ReadonlyArray<string>,\n compute: Effect.Effect<StepKey, Schema.SchemaError, Crypto.Crypto>\n ) => Effect.Effect<StepKey, Schema.SchemaError, Crypto.Crypto>\n}\n\n/**\n * Creates an empty projected-value digest memo. Projection addresses are\n * JSON-encoded `[from, path]` tuples so segment boundaries are unambiguous.\n *\n * @since 0.1.0\n * @category constructors\n * @slop\n */\nexport const makeDigestMemo = (): DigestMemo => {\n const entries = new Map<string, Deferred.Deferred<StepKey, Schema.SchemaError>>()\n // Registering the entry and installing its exit handler run uninterruptibly,\n // so an interrupt can never land between them and strand a Deferred that no\n // fiber will complete. The wait and the computation stay interruptible.\n const digest: DigestMemo[\"digest\"] = (from, path, compute) =>\n Effect.uninterruptibleMask((restore) =>\n Effect.suspend(() => {\n const address = JSON.stringify([from, path])\n const existing = entries.get(address)\n if (existing !== undefined) {\n return restore(Effect.flatMap(Effect.exit(Deferred.await(existing)), (exit) => {\n if (Exit.isSuccess(exit)) return Effect.succeed(exit.value)\n // A waiter did not request the leader's cancellation. It competes to\n // become the replacement leader instead of inheriting that interrupt.\n return Cause.hasInterrupts(exit.cause) ? digest(from, path, compute) : Effect.failCause(exit.cause)\n }))\n }\n const pending = Deferred.makeUnsafe<StepKey, Schema.SchemaError>()\n entries.set(address, pending)\n return restore(compute).pipe(\n Effect.onExit((exit) =>\n Effect.gen(function*() {\n if (Exit.isFailure(exit) && entries.get(address) === pending) {\n entries.delete(address)\n }\n yield* Deferred.done(pending, exit)\n })\n )\n )\n })\n )\n return { digest }\n}\n\n/**\n * Material describing a sealed or hermetic content-addressed step.\n *\n * @since 0.1.0\n * @category models\n * @slop\n */\nexport interface ContentIdentity {\n readonly body: unknown\n readonly inputs: Readonly<Record<string, unknown | DigestInput>>\n readonly layers: ReadonlyArray<string>\n readonly capabilities: Readonly<Record<string, ReadonlyArray<string>>>\n readonly environment?: EnvironmentIdentity | undefined\n readonly hermetic?: {\n readonly readSet: ReadonlyArray<{ readonly path: string; readonly digest: string }>\n readonly writeSet: ReadonlyArray<FileSet.Entry>\n readonly removes?: ReadonlyArray<string> | undefined\n readonly boundaryMode: FileSet.BoundaryMode\n } | undefined\n}\n\n/**\n * Material describing the run-local identity of a non-cacheable step.\n *\n * @since 0.1.0\n * @category models\n * @slop\n */\nexport interface OrdinalIdentity {\n readonly runId: string\n readonly parentScope?: string | undefined\n readonly ordinal: number\n readonly tier: \"compensable\" | \"irreversible\" | \"unsealed\"\n}\n\n/**\n * Stable failures while resolving graph-local dependency references.\n *\n * @since 0.1.0\n * @category errors\n * @slop\n */\nexport class KeyMaterialError extends Schema.TaggedError<KeyMaterialError>()(\"@smthrs/plan/KeyMaterialError\", {\n code: Schema.Literals([\"invalid_environment\", \"missing_dependency\", \"non_content_material\"]),\n message: Schema.String\n}) {}\n\nconst validateEnvironment = (environment: EnvironmentIdentity): KeyMaterialError | undefined => {\n const candidate = environment as { readonly declared?: unknown; readonly runScope?: unknown }\n if (candidate.declared === false) {\n if (typeof candidate.runScope !== \"string\" || candidate.runScope.length === 0) {\n return new KeyMaterialError({\n code: \"invalid_environment\",\n message: \"Undeclared environment identity requires a non-empty runScope\"\n })\n }\n return undefined\n }\n if (candidate.declared === true) {\n return candidate.runScope === undefined\n ? undefined\n : new KeyMaterialError({\n code: \"invalid_environment\",\n message: \"Declared environment identity must not include runScope\"\n })\n }\n return new KeyMaterialError({\n code: \"invalid_environment\",\n message: \"Environment identity requires a boolean declared field\"\n })\n}\n\nconst decodeEnvironment = (environment: EnvironmentIdentity) =>\n Effect.try({\n try: () => {\n const invalid = validateEnvironment(environment)\n if (invalid !== undefined) throw invalid\n return Schema.decodeUnknownSync(EnvironmentIdentity)(environment, { onExcessProperty: \"error\" })\n },\n catch: (cause) =>\n cause instanceof KeyMaterialError ? cause : new KeyMaterialError({\n code: \"invalid_environment\",\n message:\n \"Environment identity must contain only its declared fields, string layers, and string capability patterns\"\n })\n })\n\nconst sortStrings = (values: ReadonlyArray<string>): Array<string> =>\n [...new Set(values.map((value) => value.normalize(\"NFC\")))].sort()\n\nconst normalizeInputs = (inputs: ContentIdentity[\"inputs\"]): Record<string, unknown> =>\n Object.fromEntries(\n Object.entries(inputs).map(([name, value]) => [\n name,\n isDigestInput(value)\n ? {\n kind: \"digest\",\n digest: value.digest,\n ...(value.reference === undefined ? {} : { reference: value.reference }),\n ...(value.path === undefined ? {} : { path: value.path })\n }\n : { kind: \"literal\", value }\n ])\n )\n\nconst normalizeCapabilities = (capabilities: ContentIdentity[\"capabilities\"]): Record<string, Array<string>> =>\n Object.fromEntries(Object.entries(capabilities).map(([group, patterns]) => [group, sortStrings(patterns)]))\n\nconst normalizeEnvironment = (environment: EnvironmentIdentity) => ({\n declared: environment.declared,\n layers: environment.layers.map((layer) => layer.normalize(\"NFC\")),\n capabilities: normalizeCapabilities(environment.capabilities),\n ...(environment.runScope === undefined ? {} : { runScope: environment.runScope })\n})\n\nconst compareCodeUnits = (left: string, right: string): number => left < right ? -1 : 1\n\ntype NormalizedWriteEntry =\n | string\n | { readonly _tag: \"TreeArtifact\"; readonly path: string }\n | {\n readonly _tag: \"Glob\"\n readonly include: ReadonlyArray<string>\n readonly exclude?: ReadonlyArray<string> | undefined\n }\n\nconst writeEntryKey = (entry: NormalizedWriteEntry): string =>\n typeof entry === \"string\"\n ? JSON.stringify([\"Path\", entry])\n : entry._tag === \"TreeArtifact\"\n ? JSON.stringify([entry._tag, entry.path])\n : JSON.stringify([entry._tag, entry.include, entry.exclude ?? null])\n\nconst normalizeHermetic = (hermetic: NonNullable<ContentIdentity[\"hermetic\"]>) => {\n const readSet = [...hermetic.readSet]\n .map((entry) => ({ path: entry.path.normalize(\"NFC\"), digest: entry.digest }))\n .sort((left, right) => {\n if (left.path !== right.path) return left.path < right.path ? -1 : 1\n return left.digest < right.digest ? -1 : left.digest > right.digest ? 1 : 0\n })\n .filter((entry, index, entries) =>\n index === 0 || entry.path !== entries[index - 1]!.path || entry.digest !== entries[index - 1]!.digest\n )\n const normalizedWrites = [...hermetic.writeSet].map((entry) => {\n if (typeof entry === \"string\") return entry.normalize(\"NFC\")\n if (entry._tag === \"TreeArtifact\") return { ...entry, path: entry.path.normalize(\"NFC\") }\n return {\n ...entry,\n include: sortStrings(entry.include),\n ...(entry.exclude === undefined ? {} : { exclude: sortStrings(entry.exclude) })\n }\n })\n const writeSet = [...new Map(normalizedWrites.map((entry) => [writeEntryKey(entry), entry])).entries()]\n .sort(([left], [right]) => compareCodeUnits(left, right))\n .map(([, entry]) => entry)\n return {\n readSet,\n writeSet,\n ...(hermetic.removes === undefined ? {} : { removes: sortStrings(hermetic.removes) }),\n boundaryMode: hermetic.boundaryMode\n }\n}\n\nconst decodeKey = Schema.decodeUnknownEffect(DerivedKey)\n\n/**\n * Fingerprint for binding one execution to its runtime environment, not an\n * action dispatch key. Uses the same normalization as content/dispatch keys.\n * An omitted environment is distinct from declared-empty and run-scoped ones.\n * @since 1.0.0\n * @category constructors\n */\nexport const environmentIdentity = (\n environment?: EnvironmentIdentity\n): Effect.Effect<StoredKey, KeyMaterialError | Schema.SchemaError, Crypto.Crypto> =>\n Effect.gen(function*() {\n const captured = environment === undefined ? undefined : yield* decodeEnvironment(environment)\n return yield* decodeKey({\n kind: \"execution-environment/v1\",\n environment: captured === undefined ? null : normalizeEnvironment(captured)\n })\n })\n\n/**\n * Produces a cross-run reusable key for a sealed or hermetic step. Set-like\n * declarations are normalized before serialization; write declarations remain\n * part of the identity even when the step writes nothing.\n *\n * @since 0.1.0\n * @category constructors\n * @slop\n */\nexport const content = (\n identity: ContentIdentity\n): Effect.Effect<StepKey, KeyMaterialError | Schema.SchemaError, Crypto.Crypto> =>\n Effect.gen(function*() {\n const environment = identity.environment === undefined ? undefined : yield* decodeEnvironment(identity.environment)\n return yield* decodeKey({\n kind: \"content\",\n body: identity.body,\n inputs: normalizeInputs(identity.inputs),\n layers: sortStrings(identity.layers),\n capabilities: normalizeCapabilities(identity.capabilities),\n ...(environment === undefined ? {} : { environment: normalizeEnvironment(environment) }),\n ...(identity.hermetic === undefined ? {} : { hermetic: normalizeHermetic(identity.hermetic) })\n })\n })\n\n/**\n * Produces a run-local ordinal key for compensable, irreversible, or unsealed\n * work. These keys intentionally cannot be reused across runs.\n *\n * @since 0.1.0\n * @category constructors\n * @slop\n */\nexport const ordinal = (\n identity: OrdinalIdentity\n): Effect.Effect<StepKey, Schema.SchemaError, Crypto.Crypto> => decodeKey({ kind: \"ordinal\", ...identity })\n\n/**\n * Resolves graph-local references to dependency digests and constructs a\n * sealed content key. Use {@link planIdentity} to compile any effect tier.\n *\n * This is the handoff the Flow Builder Brief describes: the planner hands over\n * a topologically ordered sequence of `{ nodeId, material }`, and for each one\n * the compiler substitutes every `Ref`/`Pending` with the *already computed\n * key of the referenced node*. Structural node ids are lookup addresses only\n * and never enter the hashed value — rename a node and nothing re-keys; change\n * what a node consumes and everything downstream of it does.\n *\n * @since 0.1.0\n * @category constructors\n * @slop\n */\nexport const fromKeyMaterial = (\n material: KeyMaterial.KeyMaterial,\n dependencyDigests: Readonly<Record<string, string>>\n): Effect.Effect<StepKey, KeyMaterialError | Schema.SchemaError, Crypto.Crypto> => {\n if (material.kind !== \"sealed\") {\n return Effect.fail(\n new KeyMaterialError({\n code: \"non_content_material\",\n message: `Cannot create a content key for ${material.kind} material`\n })\n )\n }\n return materialIdentity(material, dependencyDigests).pipe(Effect.flatMap(content))\n}\n\n/**\n * Identifies a declaration in a plan, independently of whether its execution\n * can be cached. Sealed material retains its existing content-key format;\n * compensable and irreversible material use a distinct, tier-bearing plan\n * namespace. These fingerprints bind approvals, not cross-run result reuse.\n * Dispatch non-cacheable work under a run-local {@link ordinal} instead.\n *\n * @since 1.0.0\n * @category constructors\n */\nexport const planIdentity = (\n material: KeyMaterial.KeyMaterial,\n dependencyDigests: Readonly<Record<string, string>>\n): Effect.Effect<StepKey, KeyMaterialError | Schema.SchemaError, Crypto.Crypto> =>\n material.kind === \"sealed\" ?\n fromKeyMaterial(material, dependencyDigests) :\n materialIdentity(material, dependencyDigests).pipe(Effect.flatMap((identity) =>\n decodeKey({\n kind: \"plan-declaration\",\n tier: material.kind,\n body: identity.body,\n inputs: normalizeInputs(identity.inputs),\n layers: sortStrings(identity.layers),\n capabilities: normalizeCapabilities(identity.capabilities)\n })\n ))\n\n/**\n * Reads the entry a graph reference names. Only an own data property counts:\n * an absent name or an accessor is a missing dependency, and no getter runs.\n * `label` names what the record holds, as each refusal says it.\n *\n * @private\n */\nconst ownDataProperty = (\n record: Readonly<Record<string, unknown>>,\n from: string,\n label: \"Digest\" | \"Settled result\"\n): Effect.Effect<unknown, KeyMaterialError> => {\n const descriptor = Object.getOwnPropertyDescriptor(record, from)\n if (descriptor === undefined) {\n return Effect.fail(\n new KeyMaterialError({\n code: \"missing_dependency\",\n message: `Missing ${label.toLowerCase()} for graph dependency ${from}`\n })\n )\n }\n if (!(\"value\" in descriptor)) {\n return Effect.fail(\n new KeyMaterialError({\n code: \"missing_dependency\",\n message: `${label} for graph dependency ${from} must be a data property`\n })\n )\n }\n return Effect.succeed(descriptor.value)\n}\n\n/**\n * The positional inputs both identities hash. A `Literal` contributes its raw\n * value, so `normalizeInputs` applies the one literal wrap; `resolve` supplies\n * the digest for each `Ref` and `Pending`, tagged with the reference variant.\n *\n * @private\n */\nconst resolveInputs = <E, R>(\n material: KeyMaterial.KeyMaterial,\n resolve: (reference: Exclude<KeyMaterial.InputRef, { readonly _tag: \"Literal\" }>) => Effect.Effect<string, E, R>\n): Effect.Effect<Record<string, unknown>, E, R> =>\n Effect.gen(function*() {\n const inputs: Record<string, unknown> = {}\n for (let index = 0; index < material.inputs.length; index++) {\n const input = material.inputs[index]!\n if (input._tag === \"Literal\") {\n inputs[String(index)] = input.value\n continue\n }\n const digest = yield* resolve(input)\n inputs[String(index)] = input._tag === \"Pending\"\n ? digestInput(digest, { reference: \"pending\" })\n : input.path.length > 0\n ? digestInput(digest, { reference: \"ref-projected\", path: input.path })\n : digestInput(digest, { reference: \"ref\" })\n }\n return inputs\n })\n\n/** Resolves plan references once for both content and non-cacheable declarations. */\nconst materialIdentity = (\n material: KeyMaterial.KeyMaterial,\n dependencyDigests: Readonly<Record<string, string>>\n): Effect.Effect<ContentIdentity, KeyMaterialError> =>\n resolveInputs(\n material,\n (reference) =>\n Effect.flatMap(ownDataProperty(dependencyDigests, reference.from, \"Digest\"), (digest) =>\n typeof digest === \"string\" ? Effect.succeed(digest) : Effect.fail(\n new KeyMaterialError({\n code: \"missing_dependency\",\n message: `Digest for graph dependency ${reference.from} must be a string`\n })\n ))\n ).pipe(Effect.map((inputs) => ({\n body: materialBody(material),\n inputs,\n layers: material.layers,\n capabilities: { declared: material.capabilities }\n })))\n\n/**\n * The node's own declaration, hashed. Shared by {@link planIdentity},\n * {@link fromKeyMaterial}, and {@link dispatchIdentity} so derivations cannot drift about what\n * \"the node itself\" means.\n *\n * @private\n */\nconst materialBody = (material: KeyMaterial.KeyMaterial) => ({\n version: material.version,\n declaration: material.body,\n ...(material.nondeterministic === undefined ? {} : { nondeterministic: material.nondeterministic }),\n ...(material.effects === undefined ? {} : { effects: material.effects }),\n ...(material.placement === undefined ? {} : { placement: material.placement })\n})\n\n/**\n * The digest a `Pending` input contributes to a dispatch key. It is a\n * constant, and that is the point: `Pending` is an ordering reference, and\n * ordering does not change what a node consumes, so it must not change what\n * the node caches under. The string is self-describing, so a reader of a\n * hashed payload can see that no upstream value was folded.\n *\n * @private\n */\nconst orderingOnly = \"ordering-only\"\n\n/**\n * Projects a settled result along a `Ref` path. Only own data properties\n * resolve, so a missing, inherited, or accessor segment yields `undefined`\n * without invoking a getter. This is a stable, distinct value: a projection that\n * walks off the end of a result is a fact about the graph, not a failure.\n * `undefined` drops out of the canonical form, so it hashes distinctly from\n * every JSON value including `null`.\n *\n * Exported because it is the ONE projection semantics for the value channel:\n * {@link dispatchIdentity} digests what this returns, so every consumer that\n * resolves a `Ref` at execution time must resolve it the same way, or two\n * inputs that key identically could be consumed differently — a stale-hit\n * vector.\n *\n * @since 0.1.0\n * @category utilities\n * @slop\n */\nexport const project = (value: unknown, path: ReadonlyArray<string>): unknown => {\n let current = value\n for (const segment of path) {\n if (typeof current !== \"object\" || current === null) return undefined\n const descriptor = Object.getOwnPropertyDescriptor(current, segment)\n if (descriptor === undefined || !(\"value\" in descriptor)) return undefined\n current = descriptor.value\n }\n return current\n}\n\n/**\n * The key a dispatch is *cached* under, as distinct from the plan key a node\n * is *identified* by.\n *\n * A plan key folds the resolved keys of every upstream node, transitively, so\n * an edit anywhere upstream re-keys everything below it — even when the edited\n * node's output value is byte for byte what it was before. Bazel does not work\n * that way: `ActionCacheChecker` keys an action by the *content* of its\n * inputs, so an unchanged output stops invalidation dead. The file channel in\n * flows already had that property through the measured boundary digests; the\n * JSON value channel did not, and this is what gives it one.\n *\n * The derivation folds the node's OWN material — body, version, effects,\n * placement, layers, capabilities — and never an upstream key. Each material\n * input contributes content instead: a `Literal` its value, a `Ref` the digest\n * of the settled result of `from` projected along `path`, and a `Pending`\n * nothing beyond its tag. The measured hermetic boundary is folded unchanged.\n *\n * `results` must hold every dependency the material names. The scheduler's\n * halt rule guarantees it: a dependent of failed or skipped work never\n * dispatches, so a `Ref` always resolves against a success.\n *\n * @since 0.1.0\n * @category constructors\n * @slop\n */\nexport const dispatchIdentity = (options: {\n readonly material: KeyMaterial.KeyMaterial\n /** The settled output value of each dependency, by node id. */\n readonly results: Readonly<Record<string, unknown>>\n readonly hermetic: NonNullable<ContentIdentity[\"hermetic\"]>\n /** The engine-resolved execution environment this dispatch runs under. */\n readonly environment?: EnvironmentIdentity | undefined\n /** Reuses projected-value digests while the corresponding settled values remain immutable. */\n readonly digestMemo?: DigestMemo | undefined\n}): Effect.Effect<StepKey, KeyMaterialError | Schema.SchemaError, Crypto.Crypto> =>\n Effect.gen(function*() {\n const material = options.material\n if (material.kind !== \"sealed\") {\n return yield* new KeyMaterialError({\n code: \"non_content_material\",\n message: `Cannot create a dispatch key for ${material.kind} material`\n })\n }\n const environment = options.environment === undefined ? undefined : yield* decodeEnvironment(options.environment)\n const inputs = yield* resolveInputs(material, (reference) =>\n reference._tag === \"Pending\"\n ? Effect.succeed(orderingOnly)\n : Effect.flatMap(ownDataProperty(options.results, reference.from, \"Settled result\"), (settled) => {\n const compute = decodeKey({ kind: \"input-value\", value: project(settled, reference.path) })\n return options.digestMemo === undefined\n ? compute\n : options.digestMemo.digest(reference.from, reference.path, compute)\n }))\n return yield* content({\n body: materialBody(material),\n inputs,\n layers: material.layers,\n capabilities: { declared: material.capabilities },\n environment,\n hermetic: options.hermetic\n })\n })\n"]}
|
|
1
|
+
{"version":3,"file":"StepKey.js","sourceRoot":"","sources":["../../src/StepKey.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAE,UAAU,EAAkB,MAAM,cAAc,CAAA;AACzD,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAA;AAC3C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,IAAI,MAAM,aAAa,CAAA;AACnC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAavC;;;;;;;;;;GAUG;AACH,MAAM,iBAAiB,GAAkB,MAAM,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAA;AA+BvF;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,MAAc,EACd,SAGC,EACY,EAAE,CAAC,CAAC;IACjB,CAAC,iBAAiB,CAAC,EAAE,iBAAiB;IACtC,MAAM;IACN,GAAG,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS,CAAC,SAAS,EAAE,CAAC;IACtE,GAAG,CAAC,SAAS,EAAE,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,IAAI,EAAE,CAAC;CACnE,CAAC,CAAA;AAEF;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAAc,EAAwB,E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CAAC,eAAe,CAAC,OAAO,CAAC,OAAO,EAAE,SAAS,CAAC,IAAI,EAAE,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE;YAC/F,MAAM,OAAO,GAAG,SAAS,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,OAAO,CAAC,OAAO,EAAE,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;YAC3F,OAAO,OAAO,CAAC,UAAU,KAAK,SAAS;gBACrC,CAAC,CAAC,OAAO;gBACT,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;QACxE,CAAC,CAAC,CAAC,CAAA;IACP,OAAO,KAAK,CAAC,CAAC,OAAO,CAAC;QACpB,IAAI,EAAE,YAAY,CAAC,QAAQ,CAAC;QAC5B,MAAM;QACN,MAAM,EAAE,QAAQ,CAAC,MAAM;QACvB,YAAY,EAAE,EAAE,QAAQ,EAAE,QAAQ,CAAC,YAAY,EAAE;QACjD,WAAW;QACX,QAAQ,EAAE,OAAO,CAAC,QAAQ;KAC3B,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["/**\n * The KeyMaterial → step-key compiler.\n *\n * Revived from the deleted `packages/smithers/flows/keys/src/StepKey.ts`. Two\n * deliberate deviations from the original:\n *\n * 1. **It lives here, not in `@smthrs/keys`.** That package owns generic\n * derivation and stored-key validation; a compiler that understands plan\n * material belongs above it.\n * 2. **It produces `@smthrs/keys` `StoredKey` values, not a second `sk1_` digest\n * format.** The original minted its own prefix over a private `Digest`\n * module. The engine dispatches under `StoredKey` (`FlowEngine/ActionKey.ts`),\n * so a plan whose node keys were a *different* string format could never be\n * the thing the cache is consulted against, and that is the whole point of\n * a `Plan`. One key format, one hashing\n * chokepoint (canonical JSON + injected `Crypto`), one namespace field\n * (`kind`) distinguishing content keys from ordinal ones.\n *\n * Everything the original earned is kept: nominally branded digest inputs (a\n * literal that merely *looks* like `{digest}` hashes as a literal), set\n * normalization, the separate environment namespace, per-variant tagging of\n * resolved references, and the hashed `version`.\n *\n * Governing contract: the step-key rules at\n * https://github.com/smithersai/smithers/blob/main/packages/smithers/flows/plan/docs/concepts/step-keys.md.\n *\n * @since 0.1.0\n */\n\nimport { DerivedKey, type StoredKey } from \"@smthrs/keys\"\nimport * as Cause from \"effect/Cause\"\nimport type * as Crypto from \"effect/Crypto\"\nimport * as Deferred from \"effect/Deferred\"\nimport * as Effect from \"effect/Effect\"\nimport * as Exit from \"effect/Exit\"\nimport * as Schema from \"effect/Schema\"\nimport type * as FileSet from \"./FileSet.ts\"\nimport type * as KeyMaterial from \"./KeyMaterial.ts\"\n\n/**\n * A computed step key. Identical in representation to any other flow key —\n * `key1_` plus a SHA-256 digest of the canonical serialization of the material.\n *\n * @since 0.1.0\n * @category models\n */\nexport type StepKey = StoredKey\n\n/**\n * The nominal brand carried by every {@link DigestInput}. Kept private: the\n * only way to produce a value bearing it is {@link digestInput}, so a plain\n * value that merely happens to look like `{ digest: \"...\" }` — actions pass\n * content hashes around as ordinary data — can never be mistaken for a genuine\n * upstream-result digest reference. This closes a step-key collision where\n * shape-sniffing (`\"digest\" in value`) hashed the two identically.\n *\n * @since 0.1.0\n * @category symbols\n */\nconst DigestInputTypeId: unique symbol = Symbol.for(\"@smthrs/plan/StepKey/DigestInput\")\n\n/**\n * Which kind of graph reference a {@link DigestInput} stands for. Declared\n * once here so the field on `DigestInput` and the parameter of\n * {@link digestInput} name one set and cannot drift apart.\n */\ntype GraphReference = \"ref\" | \"pending\" | \"ref-projected\"\n\n/**\n * A precomputed digest supplied as a step input rather than a literal value.\n *\n * @since 0.1.0\n * @category models\n */\nexport interface DigestInput {\n readonly [DigestInputTypeId]: typeof DigestInputTypeId\n readonly digest: string\n /**\n * Which kind of graph reference resolved to this digest.\n *\n * Carrying the discriminator on the digest input keeps `normalizeInputs` the\n * single normalizer: it wraps every variant once, and the variants stay\n * mutually distinct because they differ in this field rather than in a\n * hand-built object a second wrap would hide.\n */\n readonly reference?: GraphReference\n /** The projection applied to the referenced result, for `ref-projected`. */\n readonly path?: ReadonlyArray<string>\n}\n\n/**\n * Nominally tags a precomputed digest so it is hashed as a digest reference\n * rather than a literal value.\n *\n * @param digest - The precomputed digest.\n * @param reference - Which graph reference resolved to the digest, and the\n * projection path for `ref-projected`. Omit for a plain digest.\n * @returns The tagged digest input.\n * @since 0.1.0\n * @category constructors\n */\nexport const digestInput = (\n digest: string,\n reference?: {\n readonly reference: GraphReference\n readonly path?: ReadonlyArray<string>\n }\n): DigestInput => ({\n [DigestInputTypeId]: DigestInputTypeId,\n digest,\n ...(reference === undefined ? {} : { reference: reference.reference }),\n ...(reference?.path === undefined ? {} : { path: reference.path })\n})\n\n/**\n * Type guard for values produced by {@link digestInput}. A plain object\n * shaped like `{ digest: \"...\" }` is not one.\n *\n * @param value - Any value.\n * @returns `true` only for a value carrying the private digest-input brand.\n * @since 0.1.0\n * @category guards\n */\nexport const isDigestInput = (value: unknown): value is DigestInput =>\n typeof value === \"object\" && value !== null && DigestInputTypeId in value &&\n (value as Record<PropertyKey, unknown>)[DigestInputTypeId] === DigestInputTypeId\n\n/**\n * The engine-resolved execution environment a content key is computed under,\n * hashed in its OWN namespace rather than merged into the caller's `layers`\n * and `capabilities`.\n *\n * Three properties matter and none survives a merge:\n *\n * 1. **Non-aliasing.** Concatenating environment material onto the caller's\n * made `caller{fs:[\"a\"]} + env{fs:[\"b\"]}` hash identically to\n * `caller{fs:[\"a\",\"b\"]} + env{}` — a cross-run collision in the very\n * material whose purpose is preventing one.\n * 2. **Declared vs undeclared.** `declared: false` is not the same value as\n * `declared: true` with empty sets.\n * 3. **Composition order.** Environment layers retain declaration order,\n * because plugin and service composition order can change behavior. The\n * caller-owned `ContentIdentity.layers` stays set-normalized.\n *\n * `runScope` is set only when `declared` is `false`: it pins the key to one\n * run, so a step whose environment identity is unknown can never serve a\n * cross-run hit. The union enforces this for typed callers; both\n * {@link content} and {@link dispatchIdentity} validate it at run time.\n *\n * @since 0.1.0\n * @category models\n */\nexport type EnvironmentIdentity = typeof EnvironmentIdentity.Type\n\n/**\n * Validated, copyable runtime environment identity. Layer order matters;\n * capability patterns are set-like. Unknown fields are not identity material.\n * @since 1.0.0\n * @category schemas\n */\nexport const EnvironmentIdentity = Schema.Union([\n Schema.Struct({\n declared: Schema.Literal(true),\n layers: Schema.Array(Schema.String),\n capabilities: Schema.Record(Schema.String, Schema.Array(Schema.String)),\n runScope: Schema.optionalKey(Schema.Undefined)\n }),\n Schema.Struct({\n declared: Schema.Literal(false),\n layers: Schema.Array(Schema.String),\n capabilities: Schema.Record(Schema.String, Schema.Array(Schema.String)),\n runScope: Schema.NonEmptyString\n })\n])\n\n/**\n * Caller-owned memoization context for projected dependency-value digests.\n *\n * This is the flows counterpart of Bazel's `ActionKeyContext`: one context is\n * passed through related key computations so shared input material is hashed\n * once. Concurrent requests for the same projection share the in-flight\n * digest. Entries are sound only while each settled `from` value is immutable;\n * callers must create a fresh memo when those values can change.\n *\n * `digest(from, path, compute)` runs `compute` once per address and shares its\n * result with concurrent callers. A failed or interrupted computation is not\n * kept: the next caller recomputes, and a waiter whose leader was interrupted\n * becomes the new leader instead of inheriting the interrupt.\n *\n * @since 0.1.0\n * @category models\n */\nexport interface DigestMemo {\n readonly digest: (\n from: string,\n path: ReadonlyArray<string>,\n compute: Effect.Effect<StepKey, Schema.SchemaError, Crypto.Crypto>\n ) => Effect.Effect<StepKey, Schema.SchemaError, Crypto.Crypto>\n}\n\n/**\n * Creates an empty projected-value digest memo. Projection addresses are\n * JSON-encoded `[from, path]` tuples so segment boundaries are unambiguous.\n *\n * @returns A memo with no entries.\n * @since 0.1.0\n * @category constructors\n */\nexport const makeDigestMemo = (): DigestMemo => {\n const entries = new Map<string, Deferred.Deferred<StepKey, Schema.SchemaError>>()\n // Registering the entry and installing its exit handler run uninterruptibly,\n // so an interrupt can never land between them and strand a Deferred that no\n // fiber will complete. The wait and the computation stay interruptible.\n const digest: DigestMemo[\"digest\"] = (from, path, compute) =>\n Effect.uninterruptibleMask((restore) =>\n Effect.suspend(() => {\n const address = JSON.stringify([from, path])\n const existing = entries.get(address)\n if (existing !== undefined) {\n return restore(Effect.flatMap(Effect.exit(Deferred.await(existing)), (exit) => {\n if (Exit.isSuccess(exit)) return Effect.succeed(exit.value)\n // A waiter did not request the leader's cancellation. It competes to\n // become the replacement leader instead of inheriting that interrupt.\n return Cause.hasInterrupts(exit.cause) ? digest(from, path, compute) : Effect.failCause(exit.cause)\n }))\n }\n const pending = Deferred.makeUnsafe<StepKey, Schema.SchemaError>()\n entries.set(address, pending)\n return restore(compute).pipe(\n Effect.onExit((exit) =>\n Effect.gen(function*() {\n if (Exit.isFailure(exit) && entries.get(address) === pending) {\n entries.delete(address)\n }\n yield* Deferred.done(pending, exit)\n })\n )\n )\n })\n )\n return { digest }\n}\n\n/**\n * Material describing a sealed or hermetic content-addressed step.\n *\n * @since 0.1.0\n * @category models\n */\nexport interface ContentIdentity {\n readonly body: unknown\n readonly inputs: Readonly<Record<string, unknown | DigestInput>>\n readonly layers: ReadonlyArray<string>\n readonly capabilities: Readonly<Record<string, ReadonlyArray<string>>>\n readonly environment?: EnvironmentIdentity | undefined\n readonly hermetic?: {\n readonly readSet: ReadonlyArray<{ readonly path: string; readonly digest: string }>\n readonly writeSet: ReadonlyArray<FileSet.Entry>\n readonly removes?: ReadonlyArray<string> | undefined\n readonly boundaryMode: FileSet.BoundaryMode\n } | undefined\n}\n\n/**\n * Material describing the run-local identity of a non-cacheable step.\n *\n * @since 0.1.0\n * @category models\n */\nexport interface OrdinalIdentity {\n readonly runId: string\n readonly parentScope?: string | undefined\n readonly ordinal: number\n readonly tier: \"compensable\" | \"irreversible\" | \"unsealed\"\n}\n\n/**\n * Stable failures while deriving a key. `code` names the rule:\n *\n * - `invalid_environment`: an {@link EnvironmentIdentity} that is neither\n * declared nor run-scoped.\n * - `missing_dependency`: a `Ref` or `Pending` input names a node with no\n * recorded digest, or, at dispatch, a `Ref` names one with no settled\n * result.\n * - `non_content_material`: a content-key constructor received material whose\n * tier is not `sealed`.\n *\n * @since 0.1.0\n * @category errors\n */\nexport class KeyMaterialError extends Schema.TaggedError<KeyMaterialError>()(\"@smthrs/plan/KeyMaterialError\", {\n code: Schema.Literals([\"invalid_environment\", \"missing_dependency\", \"non_content_material\"]),\n message: Schema.String\n}) {}\n\nconst validateEnvironment = (environment: EnvironmentIdentity): KeyMaterialError | undefined => {\n const candidate = environment as { readonly declared?: unknown; readonly runScope?: unknown }\n if (candidate.declared === false) {\n if (typeof candidate.runScope !== \"string\" || candidate.runScope.length === 0) {\n return new KeyMaterialError({\n code: \"invalid_environment\",\n message: \"Undeclared environment identity requires a non-empty runScope\"\n })\n }\n return undefined\n }\n if (candidate.declared === true) {\n return candidate.runScope === undefined\n ? undefined\n : new KeyMaterialError({\n code: \"invalid_environment\",\n message: \"Declared environment identity must not include runScope\"\n })\n }\n return new KeyMaterialError({\n code: \"invalid_environment\",\n message: \"Environment identity requires a boolean declared field\"\n })\n}\n\nconst decodeEnvironment = (environment: EnvironmentIdentity) =>\n Effect.try({\n try: () => {\n const invalid = validateEnvironment(environment)\n if (invalid !== undefined) throw invalid\n return Schema.decodeUnknownSync(EnvironmentIdentity)(environment, { onExcessProperty: \"error\" })\n },\n catch: (cause) =>\n cause instanceof KeyMaterialError ? cause : new KeyMaterialError({\n code: \"invalid_environment\",\n message:\n \"Environment identity must contain only its declared fields, string layers, and string capability patterns\"\n })\n })\n\nconst sortStrings = (values: ReadonlyArray<string>): Array<string> =>\n [...new Set(values.map((value) => value.normalize(\"NFC\")))].sort()\n\nconst normalizeInputs = (inputs: ContentIdentity[\"inputs\"]): Record<string, unknown> =>\n Object.fromEntries(\n Object.entries(inputs).map(([name, value]) => [\n name,\n isDigestInput(value)\n ? {\n kind: \"digest\",\n digest: value.digest,\n ...(value.reference === undefined ? {} : { reference: value.reference }),\n ...(value.path === undefined ? {} : { path: value.path })\n }\n : { kind: \"literal\", value }\n ])\n )\n\nconst normalizeCapabilities = (capabilities: ContentIdentity[\"capabilities\"]): Record<string, Array<string>> =>\n Object.fromEntries(Object.entries(capabilities).map(([group, patterns]) => [group, sortStrings(patterns)]))\n\nconst normalizeEnvironment = (environment: EnvironmentIdentity) => ({\n declared: environment.declared,\n layers: environment.layers.map((layer) => layer.normalize(\"NFC\")),\n capabilities: normalizeCapabilities(environment.capabilities),\n ...(environment.runScope === undefined ? {} : { runScope: environment.runScope })\n})\n\nconst compareCodeUnits = (left: string, right: string): number => left < right ? -1 : 1\n\ntype NormalizedWriteEntry =\n | string\n | { readonly _tag: \"TreeArtifact\"; readonly path: string }\n | {\n readonly _tag: \"Glob\"\n readonly include: ReadonlyArray<string>\n readonly exclude?: ReadonlyArray<string> | undefined\n }\n\nconst writeEntryKey = (entry: NormalizedWriteEntry): string =>\n typeof entry === \"string\"\n ? JSON.stringify([\"Path\", entry])\n : entry._tag === \"TreeArtifact\"\n ? JSON.stringify([entry._tag, entry.path])\n : JSON.stringify([entry._tag, entry.include, entry.exclude ?? null])\n\nconst normalizeHermetic = (hermetic: NonNullable<ContentIdentity[\"hermetic\"]>) => {\n const readSet = [...hermetic.readSet]\n .map((entry) => ({ path: entry.path.normalize(\"NFC\"), digest: entry.digest }))\n .sort((left, right) => {\n if (left.path !== right.path) return left.path < right.path ? -1 : 1\n return left.digest < right.digest ? -1 : left.digest > right.digest ? 1 : 0\n })\n .filter((entry, index, entries) =>\n index === 0 || entry.path !== entries[index - 1]!.path || entry.digest !== entries[index - 1]!.digest\n )\n const normalizedWrites = [...hermetic.writeSet].map((entry) => {\n if (typeof entry === \"string\") return entry.normalize(\"NFC\")\n if (entry._tag === \"TreeArtifact\") return { ...entry, path: entry.path.normalize(\"NFC\") }\n return {\n ...entry,\n include: sortStrings(entry.include),\n ...(entry.exclude === undefined ? {} : { exclude: sortStrings(entry.exclude) })\n }\n })\n const writeSet = [...new Map(normalizedWrites.map((entry) => [writeEntryKey(entry), entry])).entries()]\n .sort(([left], [right]) => compareCodeUnits(left, right))\n .map(([, entry]) => entry)\n return {\n readSet,\n writeSet,\n ...(hermetic.removes === undefined ? {} : { removes: sortStrings(hermetic.removes) }),\n boundaryMode: hermetic.boundaryMode\n }\n}\n\nconst decodeKey = Schema.decodeUnknownEffect(DerivedKey)\n\n/**\n * Fingerprint for binding one execution to its runtime environment, not an\n * action dispatch key. Uses the same normalization as content/dispatch keys.\n * An omitted environment is distinct from declared-empty and run-scoped ones.\n * @since 1.0.0\n * @category constructors\n */\nexport const environmentIdentity = (\n environment?: EnvironmentIdentity\n): Effect.Effect<StoredKey, KeyMaterialError | Schema.SchemaError, Crypto.Crypto> =>\n Effect.gen(function*() {\n const captured = environment === undefined ? undefined : yield* decodeEnvironment(environment)\n return yield* decodeKey({\n kind: \"execution-environment/v1\",\n environment: captured === undefined ? null : normalizeEnvironment(captured)\n })\n })\n\n/**\n * Produces a cross-run reusable key for a sealed or hermetic step. Set-like\n * declarations are normalized before serialization; write declarations remain\n * part of the identity even when the step writes nothing.\n *\n * @param identity - The step's content material.\n * @returns The content key. Fails with `invalid_environment` for a malformed\n * environment, or `SchemaError` when the material cannot be serialized.\n * @since 0.1.0\n * @category constructors\n */\nexport const content = (\n identity: ContentIdentity\n): Effect.Effect<StepKey, KeyMaterialError | Schema.SchemaError, Crypto.Crypto> =>\n Effect.gen(function*() {\n const environment = identity.environment === undefined ? undefined : yield* decodeEnvironment(identity.environment)\n return yield* decodeKey({\n kind: \"content\",\n body: identity.body,\n inputs: normalizeInputs(identity.inputs),\n layers: sortStrings(identity.layers),\n capabilities: normalizeCapabilities(identity.capabilities),\n ...(environment === undefined ? {} : { environment: normalizeEnvironment(environment) }),\n ...(identity.hermetic === undefined ? {} : { hermetic: normalizeHermetic(identity.hermetic) })\n })\n })\n\n/**\n * Produces a run-local ordinal key for compensable, irreversible, or unsealed\n * work. These keys intentionally cannot be reused across runs.\n *\n * @param identity - The run id, optional parent scope, ordinal, and tier.\n * @returns The ordinal key.\n * @since 0.1.0\n * @category constructors\n */\nexport const ordinal = (\n identity: OrdinalIdentity\n): Effect.Effect<StepKey, Schema.SchemaError, Crypto.Crypto> => decodeKey({ kind: \"ordinal\", ...identity })\n\n/**\n * Resolves graph-local references to dependency digests and constructs a\n * sealed content key. Use {@link planIdentity} to compile any effect tier.\n *\n * This is the handoff the Flow Builder Brief describes: the planner hands over\n * a topologically ordered sequence of `{ nodeId, material }`, and for each one\n * the compiler substitutes every `Ref`/`Pending` with the *already computed\n * key of the referenced node*. Structural node ids are lookup addresses only\n * and never enter the hashed value — rename a node and nothing re-keys; change\n * what a node consumes and everything downstream of it does.\n *\n * @param material - The node's key material; its tier must be `sealed`.\n * @param dependencyDigests - The key of every node the material references,\n * by node id.\n * @returns The content key. Fails with `non_content_material` for a\n * non-sealed tier and `missing_dependency` for an unresolved reference.\n * @since 0.1.0\n * @category constructors\n */\nexport const fromKeyMaterial = (\n material: KeyMaterial.KeyMaterial,\n dependencyDigests: Readonly<Record<string, string>>\n): Effect.Effect<StepKey, KeyMaterialError | Schema.SchemaError, Crypto.Crypto> => {\n if (material.kind !== \"sealed\") {\n return Effect.fail(\n new KeyMaterialError({\n code: \"non_content_material\",\n message: `Cannot create a content key for ${material.kind} material`\n })\n )\n }\n return materialIdentity(material, dependencyDigests).pipe(Effect.flatMap(content))\n}\n\n/**\n * Identifies a declaration in a plan, independently of whether its execution\n * can be cached. Sealed material retains its existing content-key format;\n * compensable and irreversible material use a distinct, tier-bearing plan\n * namespace. These fingerprints bind approvals, not cross-run result reuse.\n * Dispatch non-cacheable work under a run-local {@link ordinal} instead.\n *\n * @since 1.0.0\n * @category constructors\n */\nexport const planIdentity = (\n material: KeyMaterial.KeyMaterial,\n dependencyDigests: Readonly<Record<string, string>>\n): Effect.Effect<StepKey, KeyMaterialError | Schema.SchemaError, Crypto.Crypto> =>\n material.kind === \"sealed\" ?\n fromKeyMaterial(material, dependencyDigests) :\n materialIdentity(material, dependencyDigests).pipe(Effect.flatMap((identity) =>\n decodeKey({\n kind: \"plan-declaration\",\n tier: material.kind,\n body: identity.body,\n inputs: normalizeInputs(identity.inputs),\n layers: sortStrings(identity.layers),\n capabilities: normalizeCapabilities(identity.capabilities)\n })\n ))\n\n/**\n * Reads the entry a graph reference names. Only an own data property counts:\n * an absent name or an accessor is a missing dependency, and no getter runs.\n * `label` names what the record holds, as each refusal says it.\n *\n * @private\n */\nconst ownDataProperty = (\n record: Readonly<Record<string, unknown>>,\n from: string,\n label: \"Digest\" | \"Settled result\"\n): Effect.Effect<unknown, KeyMaterialError> => {\n const descriptor = Object.getOwnPropertyDescriptor(record, from)\n if (descriptor === undefined) {\n return Effect.fail(\n new KeyMaterialError({\n code: \"missing_dependency\",\n message: `Missing ${label.toLowerCase()} for graph dependency ${from}`\n })\n )\n }\n if (!(\"value\" in descriptor)) {\n return Effect.fail(\n new KeyMaterialError({\n code: \"missing_dependency\",\n message: `${label} for graph dependency ${from} must be a data property`\n })\n )\n }\n return Effect.succeed(descriptor.value)\n}\n\n/**\n * The positional inputs both identities hash. A `Literal` contributes its raw\n * value, so `normalizeInputs` applies the one literal wrap; `resolve` supplies\n * the digest for each `Ref` and `Pending`, tagged with the reference variant.\n *\n * @private\n */\nconst resolveInputs = <E, R>(\n material: KeyMaterial.KeyMaterial,\n resolve: (reference: Exclude<KeyMaterial.InputRef, { readonly _tag: \"Literal\" }>) => Effect.Effect<string, E, R>\n): Effect.Effect<Record<string, unknown>, E, R> =>\n Effect.gen(function*() {\n const inputs: Record<string, unknown> = {}\n for (let index = 0; index < material.inputs.length; index++) {\n const input = material.inputs[index]!\n if (input._tag === \"Literal\") {\n inputs[String(index)] = input.value\n continue\n }\n const digest = yield* resolve(input)\n inputs[String(index)] = input._tag === \"Pending\"\n ? digestInput(digest, { reference: \"pending\" })\n : input.path.length > 0\n ? digestInput(digest, { reference: \"ref-projected\", path: input.path })\n : digestInput(digest, { reference: \"ref\" })\n }\n return inputs\n })\n\n/** Resolves plan references once for both content and non-cacheable declarations. */\nconst materialIdentity = (\n material: KeyMaterial.KeyMaterial,\n dependencyDigests: Readonly<Record<string, string>>\n): Effect.Effect<ContentIdentity, KeyMaterialError> =>\n resolveInputs(\n material,\n (reference) =>\n Effect.flatMap(ownDataProperty(dependencyDigests, reference.from, \"Digest\"), (digest) =>\n typeof digest === \"string\" ? Effect.succeed(digest) : Effect.fail(\n new KeyMaterialError({\n code: \"missing_dependency\",\n message: `Digest for graph dependency ${reference.from} must be a string`\n })\n ))\n ).pipe(Effect.map((inputs) => ({\n body: materialBody(material),\n inputs,\n layers: material.layers,\n capabilities: { declared: material.capabilities }\n })))\n\n/**\n * The node's own declaration, hashed. Shared by {@link planIdentity},\n * {@link fromKeyMaterial}, and {@link dispatchIdentity} so derivations cannot drift about what\n * \"the node itself\" means.\n *\n * @private\n */\nconst materialBody = (material: KeyMaterial.KeyMaterial) => ({\n version: material.version,\n declaration: material.body,\n ...(material.nondeterministic === undefined ? {} : { nondeterministic: material.nondeterministic }),\n ...(material.effects === undefined ? {} : { effects: material.effects }),\n ...(material.placement === undefined ? {} : { placement: material.placement })\n})\n\n/**\n * The digest a `Pending` input contributes to a dispatch key. It is a\n * constant, and that is the point: `Pending` is an ordering reference, and\n * ordering does not change what a node consumes, so it must not change what\n * the node caches under. The string is self-describing, so a reader of a\n * hashed payload can see that no upstream value was folded.\n *\n * @private\n */\nconst orderingOnly = \"ordering-only\"\n\n/**\n * Projects a settled result along a `Ref` path. Only own data properties\n * resolve, so a missing, inherited, or accessor segment yields `undefined`\n * without invoking a getter. This is a stable, distinct value: a projection that\n * walks off the end of a result is a fact about the graph, not a failure.\n * `undefined` drops out of the canonical form, so it hashes distinctly from\n * every JSON value including `null`.\n *\n * Exported because it is the ONE projection semantics for the value channel:\n * {@link dispatchIdentity} digests what this returns, so every consumer that\n * resolves a `Ref` at execution time must resolve it the same way, or two\n * inputs that key identically could be consumed differently — a stale-hit\n * vector.\n *\n * @since 0.1.0\n * @category utilities\n */\nexport const project = (value: unknown, path: ReadonlyArray<string>): unknown => {\n let current = value\n for (const segment of path) {\n if (typeof current !== \"object\" || current === null) return undefined\n const descriptor = Object.getOwnPropertyDescriptor(current, segment)\n if (descriptor === undefined || !(\"value\" in descriptor)) return undefined\n current = descriptor.value\n }\n return current\n}\n\n/**\n * The key a dispatch is *cached* under, as distinct from the plan key a node\n * is *identified* by.\n *\n * A plan key folds the resolved keys of every upstream node, transitively, so\n * an edit anywhere upstream re-keys everything below it — even when the edited\n * node's output value is byte for byte what it was before. Bazel does not work\n * that way: `ActionCacheChecker` keys an action by the *content* of its\n * inputs, so an unchanged output stops invalidation dead. The file channel in\n * flows already had that property through the measured boundary digests; the\n * JSON value channel did not, and this is what gives it one.\n *\n * The derivation folds the node's OWN material — body, version, effects,\n * placement, layers, capabilities — and never an upstream key. Each material\n * input contributes content instead: a `Literal` its value, a `Ref` the digest\n * of the settled result of `from` projected along `path`, and a `Pending`\n * nothing beyond its tag. The measured hermetic boundary is folded unchanged.\n *\n * `results` must hold every dependency the material names. The scheduler's\n * halt rule guarantees it: a dependent of failed or skipped work never\n * dispatches, so a `Ref` always resolves against a success.\n *\n * @param options - The material, the dependencies' settled results, the\n * measured hermetic boundary, and an optional environment and memo.\n * @returns The dispatch key. Fails with `non_content_material` for a\n * non-sealed tier, `missing_dependency` for a `Ref` absent from `results`,\n * or `invalid_environment` for a malformed environment.\n * @since 0.1.0\n * @category constructors\n */\nexport const dispatchIdentity = (options: {\n readonly material: KeyMaterial.KeyMaterial\n /** The settled output value of each dependency, by node id. */\n readonly results: Readonly<Record<string, unknown>>\n readonly hermetic: NonNullable<ContentIdentity[\"hermetic\"]>\n /** The engine-resolved execution environment this dispatch runs under. */\n readonly environment?: EnvironmentIdentity | undefined\n /** Reuses projected-value digests while the corresponding settled values remain immutable. */\n readonly digestMemo?: DigestMemo | undefined\n}): Effect.Effect<StepKey, KeyMaterialError | Schema.SchemaError, Crypto.Crypto> =>\n Effect.gen(function*() {\n const material = options.material\n if (material.kind !== \"sealed\") {\n return yield* new KeyMaterialError({\n code: \"non_content_material\",\n message: `Cannot create a dispatch key for ${material.kind} material`\n })\n }\n const environment = options.environment === undefined ? undefined : yield* decodeEnvironment(options.environment)\n const inputs = yield* resolveInputs(material, (reference) =>\n reference._tag === \"Pending\"\n ? Effect.succeed(orderingOnly)\n : Effect.flatMap(ownDataProperty(options.results, reference.from, \"Settled result\"), (settled) => {\n const compute = decodeKey({ kind: \"input-value\", value: project(settled, reference.path) })\n return options.digestMemo === undefined\n ? compute\n : options.digestMemo.digest(reference.from, reference.path, compute)\n }))\n return yield* content({\n body: materialBody(material),\n inputs,\n layers: material.layers,\n capabilities: { declared: material.capabilities },\n environment,\n hermetic: options.hermetic\n })\n })\n"]}
|
|
@@ -17,7 +17,7 @@ add this package and `@smthrs/flow` at the version of `@smthrs/flows` you have,
|
|
|
17
17
|
plus the platform package:
|
|
18
18
|
|
|
19
19
|
```bash
|
|
20
|
-
npm install @smthrs/plan@1.0.0-rc.
|
|
20
|
+
npm install @smthrs/plan@1.0.0-rc.9 @smthrs/flow@1.0.0-rc.9 @effect/platform-node
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
The outputs below are real output from the release that install line names.
|
|
@@ -220,6 +220,83 @@ will skip. That reading holds when a step is added or removed and ids move,
|
|
|
220
220
|
because `diff` pairs a moved step by its key, as
|
|
221
221
|
[Node ids are positional](#node-ids-are-positional) shows.
|
|
222
222
|
|
|
223
|
+
On a body built with `Flow.make`, `added` and `rekeyed` also list structural
|
|
224
|
+
nodes: each `AndThen` that sequences steps, and the `FlowCall` at `root`. Their
|
|
225
|
+
keys fold their children's keys, so they move whenever a child does, and they
|
|
226
|
+
run no work. Count steps as the entries whose material body names an `action`.
|
|
227
|
+
|
|
228
|
+
Create `replan.ts`. It appends a `Summarize` step to a two-step review and
|
|
229
|
+
compares the two plans:
|
|
230
|
+
|
|
231
|
+
```ts
|
|
232
|
+
import * as NodeCrypto from "@effect/platform-node/NodeCrypto"
|
|
233
|
+
import { Action, Flow, Graph } from "@smthrs/flow"
|
|
234
|
+
import { Node } from "@smthrs/plan"
|
|
235
|
+
import * as Plan from "@smthrs/plan/Plan"
|
|
236
|
+
import * as PlanDiff from "@smthrs/plan/PlanDiff"
|
|
237
|
+
import * as Effect from "effect/Effect"
|
|
238
|
+
import * as Schema from "effect/Schema"
|
|
239
|
+
|
|
240
|
+
const ReadPr = Action.make("review/ReadPr", { payload: { pr: Schema.Number }, success: Schema.String })
|
|
241
|
+
const RunTests = Action.make("review/RunTests", { payload: { diff: Schema.String }, success: Schema.String })
|
|
242
|
+
const Summarize = Action.make("review/Summarize", { payload: { report: Schema.String }, success: Schema.String })
|
|
243
|
+
|
|
244
|
+
const review = (summarize: boolean) =>
|
|
245
|
+
Flow.make("review/Review", {
|
|
246
|
+
payload: { pr: Schema.Number },
|
|
247
|
+
success: Schema.String,
|
|
248
|
+
body: (payload) => {
|
|
249
|
+
const tested = ReadPr.call(payload).pipe(Node.bindPlanned((diff) => RunTests.call({ diff })))
|
|
250
|
+
return summarize ? tested.pipe(Node.bindPlanned((report) => Summarize.call({ report }))) : tested
|
|
251
|
+
}
|
|
252
|
+
})
|
|
253
|
+
|
|
254
|
+
const compile = (summarize: boolean) =>
|
|
255
|
+
Plan.compile({
|
|
256
|
+
planId: "review-4821",
|
|
257
|
+
flow: "review/Review",
|
|
258
|
+
nodes: Graph.drafts(Graph.build(review(summarize), { pr: 4821 }))
|
|
259
|
+
})
|
|
260
|
+
|
|
261
|
+
/** A step is a node whose material body names an action; the rest only compose steps. */
|
|
262
|
+
const isStep = (node: Plan.PlanNode) => {
|
|
263
|
+
const body = node.material.body
|
|
264
|
+
return typeof body === "object" && body !== null && "action" in body
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
const program = Effect.gen(function*() {
|
|
268
|
+
const previous = yield* compile(false)
|
|
269
|
+
const next = yield* compile(true)
|
|
270
|
+
const changes = PlanDiff.diff(previous, next)
|
|
271
|
+
const steps = new Set(next.nodes.filter(isStep).map((node) => node.id))
|
|
272
|
+
console.log({
|
|
273
|
+
added: changes.added,
|
|
274
|
+
rekeyed: changes.rekeyed.map((entry) => entry.id),
|
|
275
|
+
addedSteps: changes.added.filter((id) => steps.has(id)),
|
|
276
|
+
rekeyedSteps: changes.rekeyed.filter((entry) => steps.has(entry.id)).map((entry) => entry.id)
|
|
277
|
+
})
|
|
278
|
+
}).pipe(Effect.provide(NodeCrypto.layer))
|
|
279
|
+
|
|
280
|
+
await Effect.runPromise(program)
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
```bash
|
|
284
|
+
node replan.ts
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
```text
|
|
288
|
+
{
|
|
289
|
+
added: [ 'root.flow.andThen', 'root.flow.then' ],
|
|
290
|
+
rekeyed: [ 'root.flow', 'root' ],
|
|
291
|
+
addedSteps: [ 'root.flow.then' ],
|
|
292
|
+
rekeyedSteps: []
|
|
293
|
+
}
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
One step was added: `Summarize`, at `root.flow.then`. `ReadPr` and `RunTests`
|
|
297
|
+
moved under the new `AndThen` with the keys they had, so they are `unchanged`.
|
|
298
|
+
The other three entries are structure: two `AndThen` nodes and the `FlowCall`.
|
|
299
|
+
|
|
223
300
|
The command line prints the same comparison through
|
|
224
301
|
[`smthrs flow plan`](/cli/flow), and the plan card it renders is what
|
|
225
302
|
[`smthrs approvals approve`](/cli/approvals) binds a decision to.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smthrs/plan",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.0-rc.
|
|
4
|
+
"version": "1.0.0-rc.9",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"smthrs": {
|
|
7
7
|
"group": "engine"
|
|
@@ -218,9 +218,9 @@
|
|
|
218
218
|
"tag": "next"
|
|
219
219
|
},
|
|
220
220
|
"dependencies": {
|
|
221
|
-
"@smthrs/crypto": "1.0.0-rc.
|
|
222
|
-
"@smthrs/keys": "1.0.0-rc.
|
|
223
|
-
"@smthrs/canonical": "1.0.0-rc.
|
|
221
|
+
"@smthrs/crypto": "1.0.0-rc.9",
|
|
222
|
+
"@smthrs/keys": "1.0.0-rc.9",
|
|
223
|
+
"@smthrs/canonical": "1.0.0-rc.9"
|
|
224
224
|
},
|
|
225
225
|
"devDependencies": {
|
|
226
226
|
"@effect/language-service": "0.87.2",
|
package/src/Effects.ts
CHANGED
|
@@ -139,17 +139,21 @@ export {
|
|
|
139
139
|
|
|
140
140
|
/**
|
|
141
141
|
* A normalized description of the resources a flow or step may read and
|
|
142
|
-
* write.
|
|
142
|
+
* write. Build one with {@link make}.
|
|
143
143
|
*
|
|
144
144
|
* @category models
|
|
145
145
|
* @since 0.0.0
|
|
146
|
-
* @slop
|
|
147
146
|
*/
|
|
148
147
|
export interface Declaration {
|
|
148
|
+
/** Readable paths or envelope patterns, sorted and duplicate-free. */
|
|
149
149
|
readonly reads: ReadonlyArray<string>
|
|
150
|
+
/** Writable paths or envelope patterns, sorted and duplicate-free. */
|
|
150
151
|
readonly writes: ReadonlyArray<string>
|
|
152
|
+
/** `hermetic` or `expected` enforcement. */
|
|
151
153
|
readonly mode: Mode
|
|
154
|
+
/** What a plan does when another node writes an overlapping path. */
|
|
152
155
|
readonly onConflict: ConflictStrategy
|
|
156
|
+
/** The effect tier. Absent means `sealed`. */
|
|
153
157
|
readonly tier?: Tier | undefined
|
|
154
158
|
}
|
|
155
159
|
|
|
@@ -163,7 +167,6 @@ export interface Declaration {
|
|
|
163
167
|
*
|
|
164
168
|
* @category models
|
|
165
169
|
* @since 0.0.0
|
|
166
|
-
* @slop
|
|
167
170
|
*/
|
|
168
171
|
export interface MakeOptions {
|
|
169
172
|
readonly reads: Iterable<string>
|
|
@@ -176,9 +179,13 @@ export interface MakeOptions {
|
|
|
176
179
|
/**
|
|
177
180
|
* A result of checking that a step declaration narrows a flow envelope.
|
|
178
181
|
*
|
|
182
|
+
* On failure, `code` names the first rule broken, checked in this order:
|
|
183
|
+
* `effect_outside_envelope` (with the uncovered read and write paths, sorted),
|
|
184
|
+
* `effect_mode_widening`, then `effect_tier_widening` (both with empty
|
|
185
|
+
* `paths`).
|
|
186
|
+
*
|
|
179
187
|
* @category models
|
|
180
188
|
* @since 0.0.0
|
|
181
|
-
* @slop
|
|
182
189
|
*/
|
|
183
190
|
export type NarrowResult =
|
|
184
191
|
| { readonly ok: true }
|
|
@@ -191,11 +198,14 @@ export type NarrowResult =
|
|
|
191
198
|
const normalize = (paths: Iterable<string>): ReadonlyArray<string> => [...new Set(paths)].sort()
|
|
192
199
|
|
|
193
200
|
/**
|
|
194
|
-
* Constructs a deterministic effect declaration
|
|
201
|
+
* Constructs a deterministic effect declaration: `reads` and `writes` are
|
|
202
|
+
* collected, deduplicated, and sorted; an absent `tier` is omitted. Paths are
|
|
203
|
+
* not validated or rewritten.
|
|
195
204
|
*
|
|
205
|
+
* @param input - The paths, mode, conflict strategy, and optional tier.
|
|
206
|
+
* @returns The normalized declaration.
|
|
196
207
|
* @category constructors
|
|
197
208
|
* @since 0.0.0
|
|
198
|
-
* @slop
|
|
199
209
|
*/
|
|
200
210
|
export const make = (input: MakeOptions): Declaration => ({
|
|
201
211
|
reads: normalize(input.reads),
|
|
@@ -216,9 +226,11 @@ export const make = (input: MakeOptions): Declaration => ({
|
|
|
216
226
|
* covered, so {@link narrow} reports it as `effect_outside_envelope` rather
|
|
217
227
|
* than silently accepting an escape.
|
|
218
228
|
*
|
|
229
|
+
* @param envelope - One envelope entry.
|
|
230
|
+
* @param path - One declared path.
|
|
231
|
+
* @returns `true` when the entry covers the path.
|
|
219
232
|
* @category predicates
|
|
220
233
|
* @since 0.0.0
|
|
221
|
-
* @slop
|
|
222
234
|
*/
|
|
223
235
|
export const covers = (envelope: string, path: string): boolean => {
|
|
224
236
|
if (Index.hasDotSegment(path)) return false
|
|
@@ -239,9 +251,11 @@ export const covers = (envelope: string, path: string): boolean => {
|
|
|
239
251
|
* patterns nest. A graph build prepares each envelope once for every node it
|
|
240
252
|
* encloses.
|
|
241
253
|
*
|
|
254
|
+
* @param envelope - The flow's declaration.
|
|
255
|
+
* @param step - The step's declaration.
|
|
256
|
+
* @returns `{ ok: true }`, or the first rule the step breaks.
|
|
242
257
|
* @category validation
|
|
243
258
|
* @since 0.0.0
|
|
244
|
-
* @slop
|
|
245
259
|
*/
|
|
246
260
|
export const narrow = (envelope: Declaration, step: Declaration): NarrowResult =>
|
|
247
261
|
Index.narrowPrepared(Index.prepareEnvelope(envelope), step)
|
|
@@ -263,9 +277,11 @@ export const narrow = (envelope: Declaration, step: Declaration): NarrowResult =
|
|
|
263
277
|
* ranks inside its interval, so the cost is linear in the two declarations
|
|
264
278
|
* plus the matches, whatever the paths' lengths or how many patterns nest.
|
|
265
279
|
*
|
|
280
|
+
* @param a - One declaration.
|
|
281
|
+
* @param b - The other declaration.
|
|
282
|
+
* @returns The shared write paths; empty when the writes are disjoint.
|
|
266
283
|
* @category analysis
|
|
267
284
|
* @since 0.0.0
|
|
268
|
-
* @slop
|
|
269
285
|
*/
|
|
270
286
|
export const overlaps = (a: Declaration, b: Declaration): ReadonlyArray<string> => {
|
|
271
287
|
const indexed = Index.indexPaths([a.writes, b.writes])
|
|
@@ -274,11 +290,13 @@ export const overlaps = (a: Declaration, b: Declaration): ReadonlyArray<string>
|
|
|
274
290
|
}
|
|
275
291
|
|
|
276
292
|
/**
|
|
277
|
-
* Returns a sealed, hermetic copy of an effect declaration
|
|
293
|
+
* Returns a sealed, hermetic copy of an effect declaration, normalized by
|
|
294
|
+
* {@link make}. Paths and `onConflict` are kept.
|
|
278
295
|
*
|
|
296
|
+
* @param declaration - The declaration to copy.
|
|
297
|
+
* @returns The copy with `mode: "hermetic"` and `tier: "sealed"`.
|
|
279
298
|
* @category constructors
|
|
280
299
|
* @since 0.0.0
|
|
281
|
-
* @slop
|
|
282
300
|
*/
|
|
283
301
|
export const sealed = (declaration: Declaration): Declaration =>
|
|
284
302
|
make({ ...declaration, mode: "hermetic", tier: "sealed" })
|