@smthrs/plan 1.0.0-rc.13 → 1.0.0-rc.14
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/internal/node.d.ts +2 -0
- package/dist/cjs/internal/node.d.ts.map +1 -1
- package/dist/cjs/internal/node.js +13 -2
- package/dist/cjs/internal/node.js.map +2 -2
- package/dist/esm/internal/node.d.ts +2 -0
- package/dist/esm/internal/node.d.ts.map +1 -1
- package/dist/esm/internal/node.js +13 -2
- package/dist/esm/internal/node.js.map +1 -1
- package/docs/guides/diff-two-plans.md +1 -1
- package/package.json +4 -4
- package/src/internal/node.ts +17 -2
|
@@ -269,6 +269,8 @@ export interface FunctionIdentity {
|
|
|
269
269
|
readonly _tag: "FunctionIdentity";
|
|
270
270
|
readonly algorithm: IdentityAlgorithm;
|
|
271
271
|
readonly digest: string;
|
|
272
|
+
/** Nonce-free resume comparison material. Step keys still use `digest`. */
|
|
273
|
+
readonly sourceDigest?: string | undefined;
|
|
272
274
|
}
|
|
273
275
|
/**
|
|
274
276
|
* Brands an operation with every inert value it closes over, so its identity
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../src/internal/node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAOH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAKtC;;;;;;GAMG;AACH,eAAO,MAAM,MAAM,EAAG,oBAA6B,CAAA;AAEnD;;;;;;GAMG;AACH,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAA;AAElC;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CACvC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,OAAQ,SAAQ,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b,WAAW,OAAO,KACjB,MAWF,CAAA;AAqDD;;;;;;GAMG;AACH,eAAO,MAAM,MAAM,GAAI,SAAS,MAAM,EAAE,cAAc,OAAO,EAAE,SAAS,OAAO,EAAE,SAAS,MAAM,CAAC,GAAG,KAAG,KAetG,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,GAAI,aAAa,OAAO,EAAE,MAAM,MAAM,EAAE,MAAM,QAAQ,EAAE,SAAS,OAAO,KAAG,QAI/F,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,GAAI,aAAa,OAAO,EAAE,QAAQ,MAAM,EAAE,SAAS,OAAO,KAAG,UAInF,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,GAAI,KAAK,OAAO,GAAG,GAAG,KAAG,SAAS,GAAG,SAAgC,CAAA;AAE3F;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,GAAI,KAAK,MAAM,KAAG,SAAS,GAAG,SAAgC,CAAA;AAEpF;;;;;;GAMG;AACH,eAAO,MAAM,MAAM,GAAI,KAAK,KAAK,KAAG,MAAM,CAAC,GAAG,GAAG,SAA6B,CAAA;AAE9E;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,GAAI,KAAK,UAAU,GAAG,QAAQ,KAAG,OAAgC,CAAA;AAEzF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,YAAY,GAAI,KAAK,OAAO,EAAE,UAAU,MAAM,KAAG,OAmB7D,CAAA"}
|
|
@@ -256,10 +256,21 @@ const filterIdentity = (filter2) => {
|
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
258
|
}
|
|
259
|
+
const ephemeral = identities.some(([, identity2]) => identity2.algorithm === "sha256-source-ephemeral/v4");
|
|
260
|
+
const sourceComparable = identities.every(
|
|
261
|
+
([, identity2]) => identity2.algorithm !== "sha256-source-ephemeral/v4" || identity2.sourceDigest !== void 0
|
|
262
|
+
);
|
|
259
263
|
return {
|
|
260
264
|
_tag: "FunctionIdentity",
|
|
261
|
-
algorithm:
|
|
262
|
-
digest: (0, import_crypto.digestSync)(JSON.stringify(identities))
|
|
265
|
+
algorithm: ephemeral ? "sha256-source-ephemeral/v4" : "sha256-source-captures/v5",
|
|
266
|
+
digest: (0, import_crypto.digestSync)(JSON.stringify(identities)),
|
|
267
|
+
...ephemeral && sourceComparable ? {
|
|
268
|
+
sourceDigest: (0, import_crypto.digestSync)(JSON.stringify(identities.map(([path, identity2]) => [path, {
|
|
269
|
+
_tag: identity2._tag,
|
|
270
|
+
algorithm: identity2.algorithm,
|
|
271
|
+
digest: identity2.sourceDigest ?? identity2.digest
|
|
272
|
+
}])))
|
|
273
|
+
} : {}
|
|
263
274
|
};
|
|
264
275
|
};
|
|
265
276
|
const catch_ = (subject, protectedAst, failure, filter2) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/internal/node.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * The node AST, and the side tables the functions hang off.\n *\n * Two invariants shape every declaration here. The AST is **closure-free**\n * and keeps payloads as inert JSON mirrors, so a valid plan can be shipped,\n * stored, diffed, and rendered without the process that built it; control flow is\n * **structure**, so a branch stores both arms as ASTs rather than a function\n * that would have to be run to find out what comes next.\n *\n * The functions an author does write \u2014 a mapper, a continuation, a branch\n * predicate \u2014 live in `WeakMap`s keyed by the AST node they belong to, and the\n * AST keeps only a {@link FunctionIdentity} digest of their source. The digest\n * is what enters content identity (https://github.com/smithersai/smithers/blob/main/packages/smithers/flows/plan/docs/concepts/step-keys.md); the\n * `WeakMap` is what the run reaches for when it has the real value in hand, and\n * it drops with the AST it is keyed by.\n *\n * Adapted from `@smthrs/core` (`packages/smithers/flows/core`)\n * `internal/node.ts`. `Dynamic` does not come across \u2014 a model call is an\n * ordinary action here \u2014 and neither do annotations, which are `Context`\n * values and would break serializability. Scheduling priority is the one thing that does cross, as\n * the plain JSON field {@link Scheduled.priority} rather than as an\n * annotation, because the scheduler has to read it out of a stored plan.\n *\n * @since 0.1.0\n */\n\nimport { isRecord } from \"@smthrs/canonical/Record\"\nimport { digestSync } from \"@smthrs/crypto\"\nimport * as Identity from \"@smthrs/crypto/Identity\"\nimport { identity } from \"effect/Function\"\nimport { pipeArguments } from \"effect/Pipeable\"\nimport * as Schema from \"effect/Schema\"\nimport type { Node } from \"../Node.ts\"\nimport type * as Planned from \"../Planned.ts\"\nimport { jsonMirror } from \"./JsonMirror.ts\"\nimport { schemaIdentity } from \"./SchemaIdentity.ts\"\n\n/**\n * The runtime type identifier every node carries.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const TypeId = \"~@smthrs/plan/Node\" as const\n\n/**\n * The type-level form of {@link TypeId}.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport type TypeId = typeof TypeId\n\n/**\n * What every AST variant carries besides its own shape: an optional scheduling\n * priority.\n *\n * A priority is JSON, not a `Context` annotation, which is why it can live in\n * the AST at all: the whole point of dropping core's annotations was to keep a\n * plan shippable, storable, and diffable. It is a scheduling HINT \u2014 the plan\n * compiler copies it onto the node draft and the scheduler orders ready work by\n * it, while key material never reads it, so raising a priority reorders work\n * without re-keying a single step.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport interface Scheduled {\n readonly priority?: number | undefined\n}\n\n/**\n * A constant, known before anything runs.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport interface Succeed extends Scheduled {\n readonly _tag: \"Succeed\"\n readonly value: unknown\n}\n\n/**\n * A constant typed failure, known before anything runs.\n *\n * The error is an inert JSON mirror for the same reason {@link Succeed.value}\n * is: a stored plan has to carry what the node produces without the process\n * that built it.\n *\n * @since 1.0.0\n * @private\n * @slop\n */\nexport interface Fail extends Scheduled {\n readonly _tag: \"Fail\"\n readonly error: unknown\n}\n\n/**\n * Independent children, combined by name. Width is fixed here, at plan time:\n * there is no dynamic fan-out.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport interface All extends Scheduled {\n readonly _tag: \"All\"\n readonly nodes: Readonly<Record<string, NodeAst>>\n}\n\n/**\n * How a {@link Race} settles: `race` on the first member to settle, `any` on\n * the first member to succeed, and `quorum` once `count` members succeed.\n *\n * @since 1.0.0\n * @private\n */\nexport type RaceMode = \"race\" | \"any\" | \"quorum\"\n\n/**\n * Independent children that settle early: the join decides as soon as its\n * {@link RaceMode} can, and the members it did not wait for are interrupted.\n * `count` is the successes a quorum needs, and 1 for `race` and `any`.\n *\n * @since 1.0.0\n * @private\n */\nexport interface Race extends Scheduled {\n readonly _tag: \"Race\"\n readonly mode: RaceMode\n readonly count: number\n readonly nodes: Readonly<Record<string, NodeAst>>\n}\n\n/**\n * A deferred pure transformation of an upstream result. `map` transforms; it\n * never decides.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport interface Map extends Scheduled {\n readonly _tag: \"Map\"\n readonly first: NodeAst\n readonly mapper: FunctionIdentity\n}\n\n/**\n * A continuation after an upstream node. `next` is present when the author\n * supplied a node directly instead of a builder, in which case the topology is\n * already known and nothing has to be evaluated to reveal it.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport interface AndThen extends Scheduled {\n readonly _tag: \"AndThen\"\n readonly first: NodeAst\n readonly continuation: FunctionIdentity\n readonly next?: NodeAst | undefined\n}\n\n/**\n * A decision whose arms are static topology. The predicate runs at run time on\n * the real value; both arms are already ASTs, so the exit condition and the\n * handoff site are visible before anything runs.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport interface Branch extends Scheduled {\n readonly _tag: \"Branch\"\n readonly subject: string\n readonly first: NodeAst\n readonly predicate: FunctionIdentity\n readonly then: NodeAst\n readonly else: NodeAst\n}\n\n/**\n * A protected graph and its statically planned typed-failure continuation.\n *\n * The symbolic error `subject` is minted per catch node rather than shared,\n * mirroring {@link Branch}. Failure arms are built before the graph assigns\n * ids, so a nested arm that captured an outer error would resolve it to the\n * inner catch's protected node under one shared token.\n *\n * An absent filter catches the entire typed error channel, while a present\n * schema catches only values it accepts. This mirrors Effect's typed-error\n * boundary and keeps defects outside normal recovery. The serializable AST carries the schema identity; the live schema\n * remains in a side table beside the AST.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport interface Catch extends Scheduled {\n readonly _tag: \"Catch\"\n readonly subject: string\n readonly protected: NodeAst\n readonly failure: NodeAst\n readonly filter?: unknown | undefined\n readonly filterIdentity?: FunctionIdentity | undefined\n}\n\n/**\n * How a flow call joins the caller's plan: `inline` splices the callee's body\n * in, `boundary` makes it one child execution, and `handoff` names the next\n * trampoline round. Why the child call is a mode rather than a second AST tag\n * is in `docs/concepts/authoring-ast.md`.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const CallMode = Schema.Literals([\"inline\", \"boundary\", \"handoff\"])\n\n/**\n * How a flow call joins the caller's plan.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport type CallMode = typeof CallMode.Type\n\n/**\n * A call to another flow. The AST keeps the callee's tag and the payload;\n * the declaration itself is in the side table, because a flow value carries\n * schemas and a body and is not JSON.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport interface FlowCall extends Scheduled {\n readonly _tag: \"FlowCall\"\n readonly flow: string\n readonly mode: CallMode\n readonly payload: unknown\n}\n\n/**\n * A call to an action: the atom that does work. Same split as\n * {@link FlowCall}, and no mode \u2014 an action is always one node.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport interface ActionCall extends Scheduled {\n readonly _tag: \"ActionCall\"\n readonly action: string\n readonly payload: unknown\n}\n\n/**\n * The algorithms a {@link FunctionIdentity} may name. The tag is versioned so a\n * change to identity semantics re-keys everything derived from one, rather than\n * colliding with it.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const IdentityAlgorithm = Schema.Literals([\n \"sha256-source-ephemeral/v4\",\n \"sha256-source-captures/v5\",\n \"static-node/v1\"\n])\n\n/**\n * The algorithms a {@link FunctionIdentity} may name.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport type IdentityAlgorithm = typeof IdentityAlgorithm.Type\n\n/**\n * The serializable stand-in for a function. Captured functions digest their\n * exact source and declared inert captures. Unannotated functions additionally\n * carry process-local, per-object entropy so indistinguishable closure sources\n * fail closed instead of sharing a cache key. The tag it names is\n * {@link IdentityAlgorithm}.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport interface FunctionIdentity {\n readonly _tag: \"FunctionIdentity\"\n readonly algorithm: IdentityAlgorithm\n readonly digest: string\n}\n\n/**\n * Brands an operation with every inert value it closes over, so its identity\n * covers what it computes with and not only its source.\n *\n * `@smthrs/crypto` owns the captures, nested metadata, and freezing contract.\n *\n * @since 0.1.0\n * @private\n */\nexport const capture = Identity.capture\n\n/**\n * The serializable form of a planned value embedded in an AST value or\n * payload. The strict proxy itself cannot enter the AST because serializing it\n * is deliberately a build error.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport interface PlannedReference {\n readonly _tag: \"PlannedReference\"\n readonly node: string\n readonly path: ReadonlyArray<string>\n}\n\n// A bundled runtime and a dynamically loaded flow may contain separate\n// compatible package copies. Share only live object metadata: JSON round trips\n// still lose executable bindings, and structural lookalikes remain inert.\nconst stateKey = Symbol.for(\"@smthrs/plan/Node/live/v1\")\ninterface LiveState {\n readonly references: WeakSet<object>\n readonly nodes: WeakSet<object>\n readonly operations: WeakMap<AndThen | Map, Operation>\n readonly predicates: WeakMap<Branch, Predicate>\n readonly filters: WeakMap<Catch, Schema.Top>\n readonly declarations: WeakMap<ActionCall | FlowCall, unknown>\n}\nconst globals = globalThis as typeof globalThis & { [stateKey]?: LiveState }\nconst liveState = globals[stateKey] ??= {\n references: new WeakSet(),\n nodes: new WeakSet(),\n operations: new WeakMap(),\n predicates: new WeakMap(),\n filters: new WeakMap(),\n declarations: new WeakMap()\n}\n\n/** The AST references minted by this module; structural lookalikes are data. */\nconst plannedReferences = liveState.references\n\nconst makePlannedReference = (reference: Planned.Reference): PlannedReference => {\n const value = Object.freeze({\n _tag: \"PlannedReference\" as const,\n node: reference.node,\n path: Object.freeze([...reference.path])\n })\n plannedReferences.add(value)\n return value\n}\n\n/**\n * Reads an AST-owned planned reference without trusting its public data shape.\n *\n * @since 1.0.0\n * @private\n */\nexport const plannedReference = (value: unknown): PlannedReference | undefined =>\n typeof value === \"object\" && value !== null && plannedReferences.has(value)\n ? value as PlannedReference\n : undefined\n\n/**\n * Every AST variant.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport type NodeAst = Succeed | Fail | All | Race | Map | AndThen | Branch | Catch | FlowCall | ActionCall\n\ntype Operation = (value: unknown) => unknown\n\ntype Predicate = (value: unknown) => boolean\n\nconst operations = liveState.operations\nconst predicates = liveState.predicates\nconst filters = liveState.filters\nconst declarations = liveState.declarations\n\n/**\n * The JSON mirror of an AST payload. A planned value becomes an AST-owned\n * {@link PlannedReference}, so the AST stays inert JSON.\n *\n * @private\n */\nconst payloadMirror = (input: unknown): unknown =>\n jsonMirror(input, (_value, reference) => makePlannedReference(reference))\n\n/**\n * Digests a function's exact source as UTF-8 with SHA-256. Exact source matters:\n * whitespace inside a string literal is behavior, and normalizing it before\n * hashing can make different functions share an identity. Unless its inert\n * captures were declared with {@link capture}, the digest also includes\n * process-local, per-function entropy: JavaScript cannot inspect a closure, so\n * source-only identity would permit incorrect cache hits.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const functionIdentity: (operation: unknown) => FunctionIdentity = Identity.functionIdentity\n\n/**\n * The prototype every node shares, so `pipe` is one function rather than one\n * closure per node.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const NodeProto = {\n [TypeId]: {\n _A: identity,\n _E: identity,\n _R: identity\n },\n pipe() {\n // eslint-disable-next-line prefer-rest-params -- `pipeArguments` takes the arguments object itself.\n return pipeArguments(this, arguments)\n }\n}\n\n/**\n * Every node {@link makeNode} built, so a node this module made is recognized\n * in constant time without walking its AST again.\n */\nconst liveNodes = liveState.nodes\n\n/** Recognizes the algorithms {@link IdentityAlgorithm} declares, and nothing else. */\nconst isIdentityAlgorithm = Schema.is(IdentityAlgorithm)\n\n/** Recognizes the modes {@link CallMode} declares, and nothing else. */\nconst isCallMode = Schema.is(CallMode)\n\n/** Recognizes the modes {@link RaceMode} names, and nothing else. @private */\nconst isRaceMode = (value: unknown): value is RaceMode => value === \"race\" || value === \"any\" || value === \"quorum\"\n\n/**\n * Whether `count` is a successes target a {@link Race} of `members` can reach:\n * a quorum needs between one and every member, and the other modes need one.\n *\n * @since 1.0.0\n * @private\n */\nexport const isRaceCount = (mode: RaceMode, count: unknown, members: number): boolean =>\n members > 0 && Number.isSafeInteger(count) &&\n (mode === \"quorum\" ? (count as number) >= 1 && (count as number) <= members : count === 1)\n\n/** @private */\nconst isFunctionIdentity = (value: unknown): value is FunctionIdentity =>\n isRecord(value) && value._tag === \"FunctionIdentity\" && isIdentityAlgorithm(value.algorithm) &&\n typeof value.digest === \"string\"\n\n/** One position of the {@link isNodeAst} walk: an AST to check, or one whose children are all checked. @private */\ntype AstVisit = { readonly enter: unknown } | { readonly exit: object }\n\n/**\n * Checks whether a value has the shape of a {@link NodeAst}: what a JSON round\n * trip of a genuine AST produces, and nothing looser. Every variant's own\n * fields are checked, and every child is walked. The walk is an explicit stack\n * rather than recursion, so an arbitrarily deep AST cannot overflow the native\n * stack, and it tracks the ancestors of the position it has reached, so a\n * cyclic object is refused rather than walked forever while a shared sub-AST\n * still passes.\n *\n * @since 1.0.0\n * @private\n */\nexport const isNodeAst = (value: unknown): value is NodeAst => {\n const ancestors = new Set<object>()\n const pending: Array<AstVisit> = [{ enter: value }]\n while (pending.length > 0) {\n const visit = pending.pop()!\n if (\"exit\" in visit) {\n ancestors.delete(visit.exit)\n continue\n }\n const ast = visit.enter\n if (!isRecord(ast) || ancestors.has(ast)) return false\n if (ast.priority !== undefined && !Number.isSafeInteger(ast.priority)) return false\n const children: Array<unknown> = []\n switch (ast._tag) {\n case \"Succeed\":\n case \"Fail\":\n break\n case \"All\": {\n if (!isRecord(ast.nodes) || Array.isArray(ast.nodes)) return false\n for (const child of Object.values(ast.nodes)) children.push(child)\n break\n }\n case \"Race\": {\n if (!isRecord(ast.nodes) || Array.isArray(ast.nodes)) return false\n const members = Object.values(ast.nodes)\n if (!isRaceMode(ast.mode) || !isRaceCount(ast.mode, ast.count, members.length)) return false\n for (const child of members) children.push(child)\n break\n }\n case \"Map\": {\n if (!isFunctionIdentity(ast.mapper)) return false\n children.push(ast.first)\n break\n }\n case \"AndThen\": {\n if (!isFunctionIdentity(ast.continuation)) return false\n children.push(ast.first)\n if (ast.next !== undefined) children.push(ast.next)\n break\n }\n case \"Branch\": {\n if (typeof ast.subject !== \"string\" || !isFunctionIdentity(ast.predicate)) return false\n children.push(ast.first, ast.then, ast.else)\n break\n }\n case \"Catch\": {\n if (typeof ast.subject !== \"string\") return false\n if (ast.filterIdentity !== undefined && !isFunctionIdentity(ast.filterIdentity)) return false\n children.push(ast.protected, ast.failure)\n break\n }\n case \"FlowCall\": {\n if (typeof ast.flow !== \"string\" || !isCallMode(ast.mode)) return false\n break\n }\n case \"ActionCall\": {\n if (typeof ast.action !== \"string\") return false\n break\n }\n default:\n return false\n }\n if (children.length > 0) {\n ancestors.add(ast)\n pending.push({ exit: ast })\n for (const child of children) pending.push({ enter: child })\n }\n }\n return true\n}\n\n/**\n * Checks whether a value is a node.\n *\n * A node this module built is recognized by registration. A node that crossed\n * a serialization boundary, an object whose prototype is {@link NodeProto} and\n * whose own `ast` data property passes {@link isNodeAst}, is recognized by that\n * shape: `@smthrs/flow` hands a rehydrated AST back as a node, and the side\n * tables are all a round trip loses. The {@link TypeId} marker is an exported\n * string any object can carry, so it counts for nothing on its own, and an\n * `ast` that is missing, malformed, cyclic, or an accessor is refused because\n * every combinator reads it as trusted topology. A proxy is judged by the\n * shape it forwards.\n *\n * @since 1.0.0\n * @private\n */\nexport const isNode = (value: unknown): value is Node<unknown, unknown, any> => {\n if (typeof value !== \"object\" || value === null) return false\n if (liveNodes.has(value)) return true\n if (Object.getPrototypeOf(value) !== NodeProto) return false\n const ast = Object.getOwnPropertyDescriptor(value, \"ast\")\n return ast !== undefined && \"value\" in ast && isNodeAst(ast.value)\n}\n\n/**\n * Wraps an AST as a node.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const makeNode = <A = unknown, E = never, R = never>(ast: NodeAst): Node<A, E, R> => {\n const node: Node<A, E, R> = Object.assign(Object.create(NodeProto), { ast })\n liveNodes.add(node)\n return node\n}\n\n/**\n * Constructs a {@link Succeed}.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const succeed = (input: unknown): Succeed => ({ _tag: \"Succeed\", value: payloadMirror(input) })\n\n/**\n * Constructs a {@link Fail}.\n *\n * @since 1.0.0\n * @private\n * @slop\n */\nexport const fail = (error: unknown): Fail => ({ _tag: \"Fail\", error: payloadMirror(error) })\n\n/**\n * Constructs an {@link All}.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const all = (nodes: Readonly<Record<string, NodeAst>>): All => ({ _tag: \"All\", nodes })\n\n/**\n * Constructs a {@link Race}.\n *\n * @since 1.0.0\n * @private\n */\nexport const race = (mode: RaceMode, count: number, nodes: Readonly<Record<string, NodeAst>>): Race => ({\n _tag: \"Race\",\n mode,\n count,\n nodes\n})\n\n/**\n * Constructs a {@link Map}, filing the mapper under the AST it belongs to.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const map = (first: NodeAst, operation: Operation, source: unknown): Map => {\n const ast: Map = { _tag: \"Map\", first, mapper: functionIdentity(source) }\n operations.set(ast, operation)\n return ast\n}\n\n/**\n * Constructs an {@link AndThen} from a builder. The builder is evaluated once\n * against a planned value when the graph is built, never here.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const andThen = (first: NodeAst, operation: Operation, source: unknown): AndThen => {\n const ast: AndThen = { _tag: \"AndThen\", first, continuation: functionIdentity(source) }\n operations.set(ast, operation)\n return ast\n}\n\n/**\n * Constructs an {@link AndThen} from a node the author supplied directly. There\n * is no function to digest, so the continuation carries a fixed marker.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const andThenNode = (first: NodeAst, next: NodeAst): AndThen => ({\n _tag: \"AndThen\",\n first,\n continuation: { _tag: \"FunctionIdentity\", algorithm: \"static-node/v1\", digest: digestSync(\"static-node\") },\n next\n})\n\n/**\n * Constructs a {@link Branch}. Both arms arrive already evaluated, because a\n * branch that had to be run to reveal its topology would not be a plan.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const branch = (\n subject: string,\n first: NodeAst,\n predicate: Predicate,\n source: unknown,\n then: NodeAst,\n otherwise: NodeAst\n): Branch => {\n const ast: Branch = {\n _tag: \"Branch\",\n subject,\n first,\n predicate: functionIdentity(source),\n then,\n else: otherwise\n }\n predicates.set(ast, predicate)\n return ast\n}\n\n/**\n * JSON Schema does not describe arbitrary checks, declaration parsers, or\n * suspended schema factories. Include every function reachable from the\n * schema AST, preserving declared captures and treating opaque wrappers as\n * ephemeral. The iterative walk also covers nested checks and cyclic ASTs.\n *\n * @private\n */\nconst filterIdentity = (filter: Schema.Top): FunctionIdentity => {\n const identities: Array<readonly [string, FunctionIdentity]> = []\n const pending: Array<readonly [string, unknown]> = [[\"$\", filter.ast]]\n const seen = new WeakSet<object>()\n while (pending.length > 0) {\n const [path, current] = pending.pop()!\n if (typeof current === \"function\") {\n identities.push([path, functionIdentity(current)])\n } else if (typeof current === \"object\" && current !== null && !seen.has(current)) {\n seen.add(current)\n const descriptors = Object.getOwnPropertyDescriptors(current)\n for (const key of Object.keys(descriptors).sort()) {\n const descriptor = descriptors[key]!\n if (\"value\" in descriptor) pending.push([`${path}/${JSON.stringify(key)}`, descriptor.value])\n else {\n if (descriptor.get !== undefined) pending.push([`${path}/${JSON.stringify(key)}/get`, descriptor.get])\n if (descriptor.set !== undefined) pending.push([`${path}/${JSON.stringify(key)}/set`, descriptor.set])\n }\n }\n }\n }\n return {\n _tag: \"FunctionIdentity\",\n algorithm: identities.some(([, identity]) => identity.algorithm === \"sha256-source-ephemeral/v4\")\n ? \"sha256-source-ephemeral/v4\"\n : \"sha256-source-captures/v5\",\n digest: digestSync(JSON.stringify(identities))\n }\n}\n\n/**\n * Constructs a {@link Catch} whose failure topology is already evaluated.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const catch_ = (subject: string, protectedAst: NodeAst, failure: NodeAst, filter?: Schema.Top): Catch => {\n const ast: Catch = {\n _tag: \"Catch\",\n subject,\n protected: protectedAst,\n failure,\n ...(filter === undefined\n ? {}\n : {\n filter: schemaIdentity(filter, { onExcessProperty: \"error\" }),\n filterIdentity: filterIdentity(filter)\n })\n }\n if (filter !== undefined) filters.set(ast, filter)\n return ast\n}\n\n/**\n * Constructs a {@link FlowCall}, filing the flow declaration beside it.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const flowCall = (declaration: unknown, flow: string, mode: CallMode, payload: unknown): FlowCall => {\n const ast: FlowCall = { _tag: \"FlowCall\", flow, mode, payload: payloadMirror(payload) }\n declarations.set(ast, declaration)\n return ast\n}\n\n/**\n * Constructs an {@link ActionCall}, filing the action declaration beside\n * it.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const actionCall = (declaration: unknown, action: string, payload: unknown): ActionCall => {\n const ast: ActionCall = { _tag: \"ActionCall\", action, payload: payloadMirror(payload) }\n declarations.set(ast, declaration)\n return ast\n}\n\n/**\n * The deferred function of a map or a continuation.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const operation = (ast: AndThen | Map): Operation | undefined => operations.get(ast)\n\n/**\n * The run-time predicate of a branch.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const predicate = (ast: Branch): Predicate | undefined => predicates.get(ast)\n\n/**\n * The optional error schema filter of a catch node.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const filter = (ast: Catch): Schema.Top | undefined => filters.get(ast)\n\n/**\n * The flow or action declaration a call node names.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const declaration = (ast: ActionCall | FlowCall): unknown => declarations.get(ast)\n\n/**\n * Copies an AST with a scheduling priority attached.\n *\n * The copy is shallow and the side tables are re-filed against it, because a\n * function, a predicate, a filter schema, and a declaration are keyed by the\n * exact AST object they belong to: a copy that left them behind would silently\n * lose the continuation the graph walk has to evaluate.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const withPriority = (ast: NodeAst, priority: number): NodeAst => {\n const prioritized = { ...ast, priority }\n if (ast._tag === \"AndThen\" || ast._tag === \"Map\") {\n const deferred = operations.get(ast)\n if (deferred !== undefined) operations.set(prioritized as AndThen | Map, deferred)\n }\n if (ast._tag === \"Branch\") {\n const decision = predicates.get(ast)\n if (decision !== undefined) predicates.set(prioritized as Branch, decision)\n }\n if (ast._tag === \"Catch\") {\n const schema = filters.get(ast)\n if (schema !== undefined) filters.set(prioritized as Catch, schema)\n }\n if (ast._tag === \"ActionCall\" || ast._tag === \"FlowCall\") {\n const target = declarations.get(ast)\n if (target !== undefined) declarations.set(prioritized as ActionCall | FlowCall, target)\n }\n return prioritized\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA0BA,oBAAyB;AACzB,oBAA2B;AAC3B,eAA0B;AAC1B,sBAAyB;AACzB,sBAA8B;AAC9B,aAAwB;AAGxB,wBAA2B;AAC3B,4BAA+B;AASxB,MAAM,SAAS;AAmLf,MAAM,WAAW,OAAO,SAAS,CAAC,UAAU,YAAY,SAAS,CAAC;AAkDlE,MAAM,oBAAoB,OAAO,SAAS;AAAA,EAC/C;AAAA,EACA;AAAA,EACA;AACF,CAAC;
|
|
4
|
+
"sourcesContent": ["/**\n * The node AST, and the side tables the functions hang off.\n *\n * Two invariants shape every declaration here. The AST is **closure-free**\n * and keeps payloads as inert JSON mirrors, so a valid plan can be shipped,\n * stored, diffed, and rendered without the process that built it; control flow is\n * **structure**, so a branch stores both arms as ASTs rather than a function\n * that would have to be run to find out what comes next.\n *\n * The functions an author does write \u2014 a mapper, a continuation, a branch\n * predicate \u2014 live in `WeakMap`s keyed by the AST node they belong to, and the\n * AST keeps only a {@link FunctionIdentity} digest of their source. The digest\n * is what enters content identity (https://github.com/smithersai/smithers/blob/main/packages/smithers/flows/plan/docs/concepts/step-keys.md); the\n * `WeakMap` is what the run reaches for when it has the real value in hand, and\n * it drops with the AST it is keyed by.\n *\n * Adapted from `@smthrs/core` (`packages/smithers/flows/core`)\n * `internal/node.ts`. `Dynamic` does not come across \u2014 a model call is an\n * ordinary action here \u2014 and neither do annotations, which are `Context`\n * values and would break serializability. Scheduling priority is the one thing that does cross, as\n * the plain JSON field {@link Scheduled.priority} rather than as an\n * annotation, because the scheduler has to read it out of a stored plan.\n *\n * @since 0.1.0\n */\n\nimport { isRecord } from \"@smthrs/canonical/Record\"\nimport { digestSync } from \"@smthrs/crypto\"\nimport * as Identity from \"@smthrs/crypto/Identity\"\nimport { identity } from \"effect/Function\"\nimport { pipeArguments } from \"effect/Pipeable\"\nimport * as Schema from \"effect/Schema\"\nimport type { Node } from \"../Node.ts\"\nimport type * as Planned from \"../Planned.ts\"\nimport { jsonMirror } from \"./JsonMirror.ts\"\nimport { schemaIdentity } from \"./SchemaIdentity.ts\"\n\n/**\n * The runtime type identifier every node carries.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const TypeId = \"~@smthrs/plan/Node\" as const\n\n/**\n * The type-level form of {@link TypeId}.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport type TypeId = typeof TypeId\n\n/**\n * What every AST variant carries besides its own shape: an optional scheduling\n * priority.\n *\n * A priority is JSON, not a `Context` annotation, which is why it can live in\n * the AST at all: the whole point of dropping core's annotations was to keep a\n * plan shippable, storable, and diffable. It is a scheduling HINT \u2014 the plan\n * compiler copies it onto the node draft and the scheduler orders ready work by\n * it, while key material never reads it, so raising a priority reorders work\n * without re-keying a single step.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport interface Scheduled {\n readonly priority?: number | undefined\n}\n\n/**\n * A constant, known before anything runs.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport interface Succeed extends Scheduled {\n readonly _tag: \"Succeed\"\n readonly value: unknown\n}\n\n/**\n * A constant typed failure, known before anything runs.\n *\n * The error is an inert JSON mirror for the same reason {@link Succeed.value}\n * is: a stored plan has to carry what the node produces without the process\n * that built it.\n *\n * @since 1.0.0\n * @private\n * @slop\n */\nexport interface Fail extends Scheduled {\n readonly _tag: \"Fail\"\n readonly error: unknown\n}\n\n/**\n * Independent children, combined by name. Width is fixed here, at plan time:\n * there is no dynamic fan-out.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport interface All extends Scheduled {\n readonly _tag: \"All\"\n readonly nodes: Readonly<Record<string, NodeAst>>\n}\n\n/**\n * How a {@link Race} settles: `race` on the first member to settle, `any` on\n * the first member to succeed, and `quorum` once `count` members succeed.\n *\n * @since 1.0.0\n * @private\n */\nexport type RaceMode = \"race\" | \"any\" | \"quorum\"\n\n/**\n * Independent children that settle early: the join decides as soon as its\n * {@link RaceMode} can, and the members it did not wait for are interrupted.\n * `count` is the successes a quorum needs, and 1 for `race` and `any`.\n *\n * @since 1.0.0\n * @private\n */\nexport interface Race extends Scheduled {\n readonly _tag: \"Race\"\n readonly mode: RaceMode\n readonly count: number\n readonly nodes: Readonly<Record<string, NodeAst>>\n}\n\n/**\n * A deferred pure transformation of an upstream result. `map` transforms; it\n * never decides.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport interface Map extends Scheduled {\n readonly _tag: \"Map\"\n readonly first: NodeAst\n readonly mapper: FunctionIdentity\n}\n\n/**\n * A continuation after an upstream node. `next` is present when the author\n * supplied a node directly instead of a builder, in which case the topology is\n * already known and nothing has to be evaluated to reveal it.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport interface AndThen extends Scheduled {\n readonly _tag: \"AndThen\"\n readonly first: NodeAst\n readonly continuation: FunctionIdentity\n readonly next?: NodeAst | undefined\n}\n\n/**\n * A decision whose arms are static topology. The predicate runs at run time on\n * the real value; both arms are already ASTs, so the exit condition and the\n * handoff site are visible before anything runs.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport interface Branch extends Scheduled {\n readonly _tag: \"Branch\"\n readonly subject: string\n readonly first: NodeAst\n readonly predicate: FunctionIdentity\n readonly then: NodeAst\n readonly else: NodeAst\n}\n\n/**\n * A protected graph and its statically planned typed-failure continuation.\n *\n * The symbolic error `subject` is minted per catch node rather than shared,\n * mirroring {@link Branch}. Failure arms are built before the graph assigns\n * ids, so a nested arm that captured an outer error would resolve it to the\n * inner catch's protected node under one shared token.\n *\n * An absent filter catches the entire typed error channel, while a present\n * schema catches only values it accepts. This mirrors Effect's typed-error\n * boundary and keeps defects outside normal recovery. The serializable AST carries the schema identity; the live schema\n * remains in a side table beside the AST.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport interface Catch extends Scheduled {\n readonly _tag: \"Catch\"\n readonly subject: string\n readonly protected: NodeAst\n readonly failure: NodeAst\n readonly filter?: unknown | undefined\n readonly filterIdentity?: FunctionIdentity | undefined\n}\n\n/**\n * How a flow call joins the caller's plan: `inline` splices the callee's body\n * in, `boundary` makes it one child execution, and `handoff` names the next\n * trampoline round. Why the child call is a mode rather than a second AST tag\n * is in `docs/concepts/authoring-ast.md`.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const CallMode = Schema.Literals([\"inline\", \"boundary\", \"handoff\"])\n\n/**\n * How a flow call joins the caller's plan.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport type CallMode = typeof CallMode.Type\n\n/**\n * A call to another flow. The AST keeps the callee's tag and the payload;\n * the declaration itself is in the side table, because a flow value carries\n * schemas and a body and is not JSON.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport interface FlowCall extends Scheduled {\n readonly _tag: \"FlowCall\"\n readonly flow: string\n readonly mode: CallMode\n readonly payload: unknown\n}\n\n/**\n * A call to an action: the atom that does work. Same split as\n * {@link FlowCall}, and no mode \u2014 an action is always one node.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport interface ActionCall extends Scheduled {\n readonly _tag: \"ActionCall\"\n readonly action: string\n readonly payload: unknown\n}\n\n/**\n * The algorithms a {@link FunctionIdentity} may name. The tag is versioned so a\n * change to identity semantics re-keys everything derived from one, rather than\n * colliding with it.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const IdentityAlgorithm = Schema.Literals([\n \"sha256-source-ephemeral/v4\",\n \"sha256-source-captures/v5\",\n \"static-node/v1\"\n])\n\n/**\n * The algorithms a {@link FunctionIdentity} may name.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport type IdentityAlgorithm = typeof IdentityAlgorithm.Type\n\n/**\n * The serializable stand-in for a function. Captured functions digest their\n * exact source and declared inert captures. Unannotated functions additionally\n * carry process-local, per-object entropy so indistinguishable closure sources\n * fail closed instead of sharing a cache key. The tag it names is\n * {@link IdentityAlgorithm}.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport interface FunctionIdentity {\n readonly _tag: \"FunctionIdentity\"\n readonly algorithm: IdentityAlgorithm\n readonly digest: string\n /** Nonce-free resume comparison material. Step keys still use `digest`. */\n readonly sourceDigest?: string | undefined\n}\n\n/**\n * Brands an operation with every inert value it closes over, so its identity\n * covers what it computes with and not only its source.\n *\n * `@smthrs/crypto` owns the captures, nested metadata, and freezing contract.\n *\n * @since 0.1.0\n * @private\n */\nexport const capture = Identity.capture\n\n/**\n * The serializable form of a planned value embedded in an AST value or\n * payload. The strict proxy itself cannot enter the AST because serializing it\n * is deliberately a build error.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport interface PlannedReference {\n readonly _tag: \"PlannedReference\"\n readonly node: string\n readonly path: ReadonlyArray<string>\n}\n\n// A bundled runtime and a dynamically loaded flow may contain separate\n// compatible package copies. Share only live object metadata: JSON round trips\n// still lose executable bindings, and structural lookalikes remain inert.\nconst stateKey = Symbol.for(\"@smthrs/plan/Node/live/v1\")\ninterface LiveState {\n readonly references: WeakSet<object>\n readonly nodes: WeakSet<object>\n readonly operations: WeakMap<AndThen | Map, Operation>\n readonly predicates: WeakMap<Branch, Predicate>\n readonly filters: WeakMap<Catch, Schema.Top>\n readonly declarations: WeakMap<ActionCall | FlowCall, unknown>\n}\nconst globals = globalThis as typeof globalThis & { [stateKey]?: LiveState }\nconst liveState = globals[stateKey] ??= {\n references: new WeakSet(),\n nodes: new WeakSet(),\n operations: new WeakMap(),\n predicates: new WeakMap(),\n filters: new WeakMap(),\n declarations: new WeakMap()\n}\n\n/** The AST references minted by this module; structural lookalikes are data. */\nconst plannedReferences = liveState.references\n\nconst makePlannedReference = (reference: Planned.Reference): PlannedReference => {\n const value = Object.freeze({\n _tag: \"PlannedReference\" as const,\n node: reference.node,\n path: Object.freeze([...reference.path])\n })\n plannedReferences.add(value)\n return value\n}\n\n/**\n * Reads an AST-owned planned reference without trusting its public data shape.\n *\n * @since 1.0.0\n * @private\n */\nexport const plannedReference = (value: unknown): PlannedReference | undefined =>\n typeof value === \"object\" && value !== null && plannedReferences.has(value)\n ? value as PlannedReference\n : undefined\n\n/**\n * Every AST variant.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport type NodeAst = Succeed | Fail | All | Race | Map | AndThen | Branch | Catch | FlowCall | ActionCall\n\ntype Operation = (value: unknown) => unknown\n\ntype Predicate = (value: unknown) => boolean\n\nconst operations = liveState.operations\nconst predicates = liveState.predicates\nconst filters = liveState.filters\nconst declarations = liveState.declarations\n\n/**\n * The JSON mirror of an AST payload. A planned value becomes an AST-owned\n * {@link PlannedReference}, so the AST stays inert JSON.\n *\n * @private\n */\nconst payloadMirror = (input: unknown): unknown =>\n jsonMirror(input, (_value, reference) => makePlannedReference(reference))\n\n/**\n * Digests a function's exact source as UTF-8 with SHA-256. Exact source matters:\n * whitespace inside a string literal is behavior, and normalizing it before\n * hashing can make different functions share an identity. Unless its inert\n * captures were declared with {@link capture}, the digest also includes\n * process-local, per-function entropy: JavaScript cannot inspect a closure, so\n * source-only identity would permit incorrect cache hits.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const functionIdentity: (operation: unknown) => FunctionIdentity = Identity.functionIdentity\n\n/**\n * The prototype every node shares, so `pipe` is one function rather than one\n * closure per node.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const NodeProto = {\n [TypeId]: {\n _A: identity,\n _E: identity,\n _R: identity\n },\n pipe() {\n // eslint-disable-next-line prefer-rest-params -- `pipeArguments` takes the arguments object itself.\n return pipeArguments(this, arguments)\n }\n}\n\n/**\n * Every node {@link makeNode} built, so a node this module made is recognized\n * in constant time without walking its AST again.\n */\nconst liveNodes = liveState.nodes\n\n/** Recognizes the algorithms {@link IdentityAlgorithm} declares, and nothing else. */\nconst isIdentityAlgorithm = Schema.is(IdentityAlgorithm)\n\n/** Recognizes the modes {@link CallMode} declares, and nothing else. */\nconst isCallMode = Schema.is(CallMode)\n\n/** Recognizes the modes {@link RaceMode} names, and nothing else. @private */\nconst isRaceMode = (value: unknown): value is RaceMode => value === \"race\" || value === \"any\" || value === \"quorum\"\n\n/**\n * Whether `count` is a successes target a {@link Race} of `members` can reach:\n * a quorum needs between one and every member, and the other modes need one.\n *\n * @since 1.0.0\n * @private\n */\nexport const isRaceCount = (mode: RaceMode, count: unknown, members: number): boolean =>\n members > 0 && Number.isSafeInteger(count) &&\n (mode === \"quorum\" ? (count as number) >= 1 && (count as number) <= members : count === 1)\n\n/** @private */\nconst isFunctionIdentity = (value: unknown): value is FunctionIdentity =>\n isRecord(value) && value._tag === \"FunctionIdentity\" && isIdentityAlgorithm(value.algorithm) &&\n typeof value.digest === \"string\"\n\n/** One position of the {@link isNodeAst} walk: an AST to check, or one whose children are all checked. @private */\ntype AstVisit = { readonly enter: unknown } | { readonly exit: object }\n\n/**\n * Checks whether a value has the shape of a {@link NodeAst}: what a JSON round\n * trip of a genuine AST produces, and nothing looser. Every variant's own\n * fields are checked, and every child is walked. The walk is an explicit stack\n * rather than recursion, so an arbitrarily deep AST cannot overflow the native\n * stack, and it tracks the ancestors of the position it has reached, so a\n * cyclic object is refused rather than walked forever while a shared sub-AST\n * still passes.\n *\n * @since 1.0.0\n * @private\n */\nexport const isNodeAst = (value: unknown): value is NodeAst => {\n const ancestors = new Set<object>()\n const pending: Array<AstVisit> = [{ enter: value }]\n while (pending.length > 0) {\n const visit = pending.pop()!\n if (\"exit\" in visit) {\n ancestors.delete(visit.exit)\n continue\n }\n const ast = visit.enter\n if (!isRecord(ast) || ancestors.has(ast)) return false\n if (ast.priority !== undefined && !Number.isSafeInteger(ast.priority)) return false\n const children: Array<unknown> = []\n switch (ast._tag) {\n case \"Succeed\":\n case \"Fail\":\n break\n case \"All\": {\n if (!isRecord(ast.nodes) || Array.isArray(ast.nodes)) return false\n for (const child of Object.values(ast.nodes)) children.push(child)\n break\n }\n case \"Race\": {\n if (!isRecord(ast.nodes) || Array.isArray(ast.nodes)) return false\n const members = Object.values(ast.nodes)\n if (!isRaceMode(ast.mode) || !isRaceCount(ast.mode, ast.count, members.length)) return false\n for (const child of members) children.push(child)\n break\n }\n case \"Map\": {\n if (!isFunctionIdentity(ast.mapper)) return false\n children.push(ast.first)\n break\n }\n case \"AndThen\": {\n if (!isFunctionIdentity(ast.continuation)) return false\n children.push(ast.first)\n if (ast.next !== undefined) children.push(ast.next)\n break\n }\n case \"Branch\": {\n if (typeof ast.subject !== \"string\" || !isFunctionIdentity(ast.predicate)) return false\n children.push(ast.first, ast.then, ast.else)\n break\n }\n case \"Catch\": {\n if (typeof ast.subject !== \"string\") return false\n if (ast.filterIdentity !== undefined && !isFunctionIdentity(ast.filterIdentity)) return false\n children.push(ast.protected, ast.failure)\n break\n }\n case \"FlowCall\": {\n if (typeof ast.flow !== \"string\" || !isCallMode(ast.mode)) return false\n break\n }\n case \"ActionCall\": {\n if (typeof ast.action !== \"string\") return false\n break\n }\n default:\n return false\n }\n if (children.length > 0) {\n ancestors.add(ast)\n pending.push({ exit: ast })\n for (const child of children) pending.push({ enter: child })\n }\n }\n return true\n}\n\n/**\n * Checks whether a value is a node.\n *\n * A node this module built is recognized by registration. A node that crossed\n * a serialization boundary, an object whose prototype is {@link NodeProto} and\n * whose own `ast` data property passes {@link isNodeAst}, is recognized by that\n * shape: `@smthrs/flow` hands a rehydrated AST back as a node, and the side\n * tables are all a round trip loses. The {@link TypeId} marker is an exported\n * string any object can carry, so it counts for nothing on its own, and an\n * `ast` that is missing, malformed, cyclic, or an accessor is refused because\n * every combinator reads it as trusted topology. A proxy is judged by the\n * shape it forwards.\n *\n * @since 1.0.0\n * @private\n */\nexport const isNode = (value: unknown): value is Node<unknown, unknown, any> => {\n if (typeof value !== \"object\" || value === null) return false\n if (liveNodes.has(value)) return true\n if (Object.getPrototypeOf(value) !== NodeProto) return false\n const ast = Object.getOwnPropertyDescriptor(value, \"ast\")\n return ast !== undefined && \"value\" in ast && isNodeAst(ast.value)\n}\n\n/**\n * Wraps an AST as a node.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const makeNode = <A = unknown, E = never, R = never>(ast: NodeAst): Node<A, E, R> => {\n const node: Node<A, E, R> = Object.assign(Object.create(NodeProto), { ast })\n liveNodes.add(node)\n return node\n}\n\n/**\n * Constructs a {@link Succeed}.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const succeed = (input: unknown): Succeed => ({ _tag: \"Succeed\", value: payloadMirror(input) })\n\n/**\n * Constructs a {@link Fail}.\n *\n * @since 1.0.0\n * @private\n * @slop\n */\nexport const fail = (error: unknown): Fail => ({ _tag: \"Fail\", error: payloadMirror(error) })\n\n/**\n * Constructs an {@link All}.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const all = (nodes: Readonly<Record<string, NodeAst>>): All => ({ _tag: \"All\", nodes })\n\n/**\n * Constructs a {@link Race}.\n *\n * @since 1.0.0\n * @private\n */\nexport const race = (mode: RaceMode, count: number, nodes: Readonly<Record<string, NodeAst>>): Race => ({\n _tag: \"Race\",\n mode,\n count,\n nodes\n})\n\n/**\n * Constructs a {@link Map}, filing the mapper under the AST it belongs to.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const map = (first: NodeAst, operation: Operation, source: unknown): Map => {\n const ast: Map = { _tag: \"Map\", first, mapper: functionIdentity(source) }\n operations.set(ast, operation)\n return ast\n}\n\n/**\n * Constructs an {@link AndThen} from a builder. The builder is evaluated once\n * against a planned value when the graph is built, never here.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const andThen = (first: NodeAst, operation: Operation, source: unknown): AndThen => {\n const ast: AndThen = { _tag: \"AndThen\", first, continuation: functionIdentity(source) }\n operations.set(ast, operation)\n return ast\n}\n\n/**\n * Constructs an {@link AndThen} from a node the author supplied directly. There\n * is no function to digest, so the continuation carries a fixed marker.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const andThenNode = (first: NodeAst, next: NodeAst): AndThen => ({\n _tag: \"AndThen\",\n first,\n continuation: { _tag: \"FunctionIdentity\", algorithm: \"static-node/v1\", digest: digestSync(\"static-node\") },\n next\n})\n\n/**\n * Constructs a {@link Branch}. Both arms arrive already evaluated, because a\n * branch that had to be run to reveal its topology would not be a plan.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const branch = (\n subject: string,\n first: NodeAst,\n predicate: Predicate,\n source: unknown,\n then: NodeAst,\n otherwise: NodeAst\n): Branch => {\n const ast: Branch = {\n _tag: \"Branch\",\n subject,\n first,\n predicate: functionIdentity(source),\n then,\n else: otherwise\n }\n predicates.set(ast, predicate)\n return ast\n}\n\n/**\n * JSON Schema does not describe arbitrary checks, declaration parsers, or\n * suspended schema factories. Include every function reachable from the\n * schema AST, preserving declared captures and treating opaque wrappers as\n * ephemeral. The iterative walk also covers nested checks and cyclic ASTs.\n *\n * @private\n */\nconst filterIdentity = (filter: Schema.Top): FunctionIdentity => {\n const identities: Array<readonly [string, FunctionIdentity]> = []\n const pending: Array<readonly [string, unknown]> = [[\"$\", filter.ast]]\n const seen = new WeakSet<object>()\n while (pending.length > 0) {\n const [path, current] = pending.pop()!\n if (typeof current === \"function\") {\n identities.push([path, functionIdentity(current)])\n } else if (typeof current === \"object\" && current !== null && !seen.has(current)) {\n seen.add(current)\n const descriptors = Object.getOwnPropertyDescriptors(current)\n for (const key of Object.keys(descriptors).sort()) {\n const descriptor = descriptors[key]!\n if (\"value\" in descriptor) pending.push([`${path}/${JSON.stringify(key)}`, descriptor.value])\n else {\n if (descriptor.get !== undefined) pending.push([`${path}/${JSON.stringify(key)}/get`, descriptor.get])\n if (descriptor.set !== undefined) pending.push([`${path}/${JSON.stringify(key)}/set`, descriptor.set])\n }\n }\n }\n }\n const ephemeral = identities.some(([, identity]) => identity.algorithm === \"sha256-source-ephemeral/v4\")\n const sourceComparable = identities.every(([, identity]) =>\n identity.algorithm !== \"sha256-source-ephemeral/v4\" || identity.sourceDigest !== undefined\n )\n return {\n _tag: \"FunctionIdentity\",\n algorithm: ephemeral\n ? \"sha256-source-ephemeral/v4\"\n : \"sha256-source-captures/v5\",\n digest: digestSync(JSON.stringify(identities)),\n ...(ephemeral && sourceComparable\n ? {\n sourceDigest: digestSync(JSON.stringify(identities.map(([path, identity]) => [path, {\n _tag: identity._tag,\n algorithm: identity.algorithm,\n digest: identity.sourceDigest ?? identity.digest\n }])))\n }\n : {})\n }\n}\n\n/**\n * Constructs a {@link Catch} whose failure topology is already evaluated.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const catch_ = (subject: string, protectedAst: NodeAst, failure: NodeAst, filter?: Schema.Top): Catch => {\n const ast: Catch = {\n _tag: \"Catch\",\n subject,\n protected: protectedAst,\n failure,\n ...(filter === undefined\n ? {}\n : {\n filter: schemaIdentity(filter, { onExcessProperty: \"error\" }),\n filterIdentity: filterIdentity(filter)\n })\n }\n if (filter !== undefined) filters.set(ast, filter)\n return ast\n}\n\n/**\n * Constructs a {@link FlowCall}, filing the flow declaration beside it.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const flowCall = (declaration: unknown, flow: string, mode: CallMode, payload: unknown): FlowCall => {\n const ast: FlowCall = { _tag: \"FlowCall\", flow, mode, payload: payloadMirror(payload) }\n declarations.set(ast, declaration)\n return ast\n}\n\n/**\n * Constructs an {@link ActionCall}, filing the action declaration beside\n * it.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const actionCall = (declaration: unknown, action: string, payload: unknown): ActionCall => {\n const ast: ActionCall = { _tag: \"ActionCall\", action, payload: payloadMirror(payload) }\n declarations.set(ast, declaration)\n return ast\n}\n\n/**\n * The deferred function of a map or a continuation.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const operation = (ast: AndThen | Map): Operation | undefined => operations.get(ast)\n\n/**\n * The run-time predicate of a branch.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const predicate = (ast: Branch): Predicate | undefined => predicates.get(ast)\n\n/**\n * The optional error schema filter of a catch node.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const filter = (ast: Catch): Schema.Top | undefined => filters.get(ast)\n\n/**\n * The flow or action declaration a call node names.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const declaration = (ast: ActionCall | FlowCall): unknown => declarations.get(ast)\n\n/**\n * Copies an AST with a scheduling priority attached.\n *\n * The copy is shallow and the side tables are re-filed against it, because a\n * function, a predicate, a filter schema, and a declaration are keyed by the\n * exact AST object they belong to: a copy that left them behind would silently\n * lose the continuation the graph walk has to evaluate.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const withPriority = (ast: NodeAst, priority: number): NodeAst => {\n const prioritized = { ...ast, priority }\n if (ast._tag === \"AndThen\" || ast._tag === \"Map\") {\n const deferred = operations.get(ast)\n if (deferred !== undefined) operations.set(prioritized as AndThen | Map, deferred)\n }\n if (ast._tag === \"Branch\") {\n const decision = predicates.get(ast)\n if (decision !== undefined) predicates.set(prioritized as Branch, decision)\n }\n if (ast._tag === \"Catch\") {\n const schema = filters.get(ast)\n if (schema !== undefined) filters.set(prioritized as Catch, schema)\n }\n if (ast._tag === \"ActionCall\" || ast._tag === \"FlowCall\") {\n const target = declarations.get(ast)\n if (target !== undefined) declarations.set(prioritized as ActionCall | FlowCall, target)\n }\n return prioritized\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA0BA,oBAAyB;AACzB,oBAA2B;AAC3B,eAA0B;AAC1B,sBAAyB;AACzB,sBAA8B;AAC9B,aAAwB;AAGxB,wBAA2B;AAC3B,4BAA+B;AASxB,MAAM,SAAS;AAmLf,MAAM,WAAW,OAAO,SAAS,CAAC,UAAU,YAAY,SAAS,CAAC;AAkDlE,MAAM,oBAAoB,OAAO,SAAS;AAAA,EAC/C;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAuCM,MAAM,UAAU,SAAS;AAoBhC,MAAM,WAAW,uBAAO,IAAI,2BAA2B;AASvD,MAAM,UAAU;AAChB,MAAM,YAAY,QAAQ,QAAQ,MAAM;AAAA,EACtC,YAAY,oBAAI,QAAQ;AAAA,EACxB,OAAO,oBAAI,QAAQ;AAAA,EACnB,YAAY,oBAAI,QAAQ;AAAA,EACxB,YAAY,oBAAI,QAAQ;AAAA,EACxB,SAAS,oBAAI,QAAQ;AAAA,EACrB,cAAc,oBAAI,QAAQ;AAC5B;AAGA,MAAM,oBAAoB,UAAU;AAEpC,MAAM,uBAAuB,CAAC,cAAmD;AAC/E,QAAM,QAAQ,OAAO,OAAO;AAAA,IAC1B,MAAM;AAAA,IACN,MAAM,UAAU;AAAA,IAChB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AAM,SAAS,QAAQ,IAAI,GAAG;AAC9B,QAAI,WAAW,OAAW,SAAQ,IAAI,aAAsB,MAAM;AAAA,EACpE;AACA,MAAI,IAAI,SAAS,gBAAgB,IAAI,SAAS,YAAY;AACxD,UAAM,SAAS,aAAa,IAAI,GAAG;AACnC,QAAI,WAAW,OAAW,cAAa,IAAI,aAAsC,MAAM;AAAA,EACzF;AACA,SAAO;AACT;",
|
|
6
6
|
"names": ["operation", "predicate", "filter", "identity", "declaration"]
|
|
7
7
|
}
|
|
@@ -269,6 +269,8 @@ export interface FunctionIdentity {
|
|
|
269
269
|
readonly _tag: "FunctionIdentity";
|
|
270
270
|
readonly algorithm: IdentityAlgorithm;
|
|
271
271
|
readonly digest: string;
|
|
272
|
+
/** Nonce-free resume comparison material. Step keys still use `digest`. */
|
|
273
|
+
readonly sourceDigest?: string | undefined;
|
|
272
274
|
}
|
|
273
275
|
/**
|
|
274
276
|
* Brands an operation with every inert value it closes over, so its identity
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../src/internal/node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAOH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAKtC;;;;;;GAMG;AACH,eAAO,MAAM,MAAM,EAAG,oBAA6B,CAAA;AAEnD;;;;;;GAMG;AACH,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAA;AAElC;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CACvC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,OAAQ,SAAQ,SAAS;IACxC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;IACxB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CACxB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,cAAc,OAAO,EAAE,SAAS,OAAO,EAAE,SAAS,MAAM,CAAC,GAAG,KAAG,KAetG,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,GAAI,aAAa,OAAO,EAAE,MAAM,MAAM,EAAE,MAAM,QAAQ,EAAE,SAAS,OAAO,KAAG,QAI/F,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,GAAI,aAAa,OAAO,EAAE,QAAQ,MAAM,EAAE,SAAS,OAAO,KAAG,UAInF,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,GAAI,KAAK,OAAO,GAAG,GAAG,KAAG,SAAS,GAAG,SAAgC,CAAA;AAE3F;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,GAAI,KAAK,MAAM,KAAG,SAAS,GAAG,SAAgC,CAAA;AAEpF;;;;;;GAMG;AACH,eAAO,MAAM,MAAM,GAAI,KAAK,KAAK,KAAG,MAAM,CAAC,GAAG,GAAG,SAA6B,CAAA;AAE9E;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,GAAI,KAAK,UAAU,GAAG,QAAQ,KAAG,OAAgC,CAAA;AAEzF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,YAAY,GAAI,KAAK,OAAO,EAAE,UAAU,MAAM,KAAG,OAmB7D,CAAA"}
|
|
@@ -437,12 +437,23 @@ const filterIdentity = (filter) => {
|
|
|
437
437
|
}
|
|
438
438
|
}
|
|
439
439
|
}
|
|
440
|
+
const ephemeral = identities.some(([, identity]) => identity.algorithm === "sha256-source-ephemeral/v4");
|
|
441
|
+
const sourceComparable = identities.every(([, identity]) => identity.algorithm !== "sha256-source-ephemeral/v4" || identity.sourceDigest !== undefined);
|
|
440
442
|
return {
|
|
441
443
|
_tag: "FunctionIdentity",
|
|
442
|
-
algorithm:
|
|
444
|
+
algorithm: ephemeral
|
|
443
445
|
? "sha256-source-ephemeral/v4"
|
|
444
446
|
: "sha256-source-captures/v5",
|
|
445
|
-
digest: digestSync(JSON.stringify(identities))
|
|
447
|
+
digest: digestSync(JSON.stringify(identities)),
|
|
448
|
+
...(ephemeral && sourceComparable
|
|
449
|
+
? {
|
|
450
|
+
sourceDigest: digestSync(JSON.stringify(identities.map(([path, identity]) => [path, {
|
|
451
|
+
_tag: identity._tag,
|
|
452
|
+
algorithm: identity.algorithm,
|
|
453
|
+
digest: identity.sourceDigest ?? identity.digest
|
|
454
|
+
}])))
|
|
455
|
+
}
|
|
456
|
+
: {})
|
|
446
457
|
};
|
|
447
458
|
};
|
|
448
459
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../../src/internal/node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CAAA;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAGvC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAEpD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,oBAA6B,CAAA;AAyKnD;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,QAAQ,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC,CAAA;AAyC1E;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,QAAQ,CAAC;IAC/C,4BAA4B;IAC5B,2BAA2B;IAC3B,gBAAgB;CACjB,CAA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B,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QAC/B,IAAI,MAAM,KAAK,SAAS;YAAE,OAAO,CAAC,GAAG,CAAC,WAAoB,EAAE,MAAM,CAAC,CAAA;IACrE,CAAC;IACD,IAAI,GAAG,CAAC,IAAI,KAAK,YAAY,IAAI,GAAG,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;QACzD,MAAM,MAAM,GAAG,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QACpC,IAAI,MAAM,KAAK,SAAS;YAAE,YAAY,CAAC,GAAG,CAAC,WAAoC,EAAE,MAAM,CAAC,CAAA;IAC1F,CAAC;IACD,OAAO,WAAW,CAAA;AACpB,CAAC,CAAA","sourcesContent":["/**\n * The node AST, and the side tables the functions hang off.\n *\n * Two invariants shape every declaration here. The AST is **closure-free**\n * and keeps payloads as inert JSON mirrors, so a valid plan can be shipped,\n * stored, diffed, and rendered without the process that built it; control flow is\n * **structure**, so a branch stores both arms as ASTs rather than a function\n * that would have to be run to find out what comes next.\n *\n * The functions an author does write — a mapper, a continuation, a branch\n * predicate — live in `WeakMap`s keyed by the AST node they belong to, and the\n * AST keeps only a {@link FunctionIdentity} digest of their source. The digest\n * is what enters content identity (https://github.com/smithersai/smithers/blob/main/packages/smithers/flows/plan/docs/concepts/step-keys.md); the\n * `WeakMap` is what the run reaches for when it has the real value in hand, and\n * it drops with the AST it is keyed by.\n *\n * Adapted from `@smthrs/core` (`packages/smithers/flows/core`)\n * `internal/node.ts`. `Dynamic` does not come across — a model call is an\n * ordinary action here — and neither do annotations, which are `Context`\n * values and would break serializability. Scheduling priority is the one thing that does cross, as\n * the plain JSON field {@link Scheduled.priority} rather than as an\n * annotation, because the scheduler has to read it out of a stored plan.\n *\n * @since 0.1.0\n */\n\nimport { isRecord } from \"@smthrs/canonical/Record\"\nimport { digestSync } from \"@smthrs/crypto\"\nimport * as Identity from \"@smthrs/crypto/Identity\"\nimport { identity } from \"effect/Function\"\nimport { pipeArguments } from \"effect/Pipeable\"\nimport * as Schema from \"effect/Schema\"\nimport type { Node } from \"../Node.ts\"\nimport type * as Planned from \"../Planned.ts\"\nimport { jsonMirror } from \"./JsonMirror.ts\"\nimport { schemaIdentity } from \"./SchemaIdentity.ts\"\n\n/**\n * The runtime type identifier every node carries.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const TypeId = \"~@smthrs/plan/Node\" as const\n\n/**\n * The type-level form of {@link TypeId}.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport type TypeId = typeof TypeId\n\n/**\n * What every AST variant carries besides its own shape: an optional scheduling\n * priority.\n *\n * A priority is JSON, not a `Context` annotation, which is why it can live in\n * the AST at all: the whole point of dropping core's annotations was to keep a\n * plan shippable, storable, and diffable. It is a scheduling HINT — the plan\n * compiler copies it onto the node draft and the scheduler orders ready work by\n * it, while key material never reads it, so raising a priority reorders work\n * without re-keying a single step.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport interface Scheduled {\n readonly priority?: number | undefined\n}\n\n/**\n * A constant, known before anything runs.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport interface Succeed extends Scheduled {\n readonly _tag: \"Succeed\"\n readonly value: unknown\n}\n\n/**\n * A constant typed failure, known before anything runs.\n *\n * The error is an inert JSON mirror for the same reason {@link Succeed.value}\n * is: a stored plan has to carry what the node produces without the process\n * that built it.\n *\n * @since 1.0.0\n * @private\n * @slop\n */\nexport interface Fail extends Scheduled {\n readonly _tag: \"Fail\"\n readonly error: unknown\n}\n\n/**\n * Independent children, combined by name. Width is fixed here, at plan time:\n * there is no dynamic fan-out.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport interface All extends Scheduled {\n readonly _tag: \"All\"\n readonly nodes: Readonly<Record<string, NodeAst>>\n}\n\n/**\n * How a {@link Race} settles: `race` on the first member to settle, `any` on\n * the first member to succeed, and `quorum` once `count` members succeed.\n *\n * @since 1.0.0\n * @private\n */\nexport type RaceMode = \"race\" | \"any\" | \"quorum\"\n\n/**\n * Independent children that settle early: the join decides as soon as its\n * {@link RaceMode} can, and the members it did not wait for are interrupted.\n * `count` is the successes a quorum needs, and 1 for `race` and `any`.\n *\n * @since 1.0.0\n * @private\n */\nexport interface Race extends Scheduled {\n readonly _tag: \"Race\"\n readonly mode: RaceMode\n readonly count: number\n readonly nodes: Readonly<Record<string, NodeAst>>\n}\n\n/**\n * A deferred pure transformation of an upstream result. `map` transforms; it\n * never decides.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport interface Map extends Scheduled {\n readonly _tag: \"Map\"\n readonly first: NodeAst\n readonly mapper: FunctionIdentity\n}\n\n/**\n * A continuation after an upstream node. `next` is present when the author\n * supplied a node directly instead of a builder, in which case the topology is\n * already known and nothing has to be evaluated to reveal it.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport interface AndThen extends Scheduled {\n readonly _tag: \"AndThen\"\n readonly first: NodeAst\n readonly continuation: FunctionIdentity\n readonly next?: NodeAst | undefined\n}\n\n/**\n * A decision whose arms are static topology. The predicate runs at run time on\n * the real value; both arms are already ASTs, so the exit condition and the\n * handoff site are visible before anything runs.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport interface Branch extends Scheduled {\n readonly _tag: \"Branch\"\n readonly subject: string\n readonly first: NodeAst\n readonly predicate: FunctionIdentity\n readonly then: NodeAst\n readonly else: NodeAst\n}\n\n/**\n * A protected graph and its statically planned typed-failure continuation.\n *\n * The symbolic error `subject` is minted per catch node rather than shared,\n * mirroring {@link Branch}. Failure arms are built before the graph assigns\n * ids, so a nested arm that captured an outer error would resolve it to the\n * inner catch's protected node under one shared token.\n *\n * An absent filter catches the entire typed error channel, while a present\n * schema catches only values it accepts. This mirrors Effect's typed-error\n * boundary and keeps defects outside normal recovery. The serializable AST carries the schema identity; the live schema\n * remains in a side table beside the AST.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport interface Catch extends Scheduled {\n readonly _tag: \"Catch\"\n readonly subject: string\n readonly protected: NodeAst\n readonly failure: NodeAst\n readonly filter?: unknown | undefined\n readonly filterIdentity?: FunctionIdentity | undefined\n}\n\n/**\n * How a flow call joins the caller's plan: `inline` splices the callee's body\n * in, `boundary` makes it one child execution, and `handoff` names the next\n * trampoline round. Why the child call is a mode rather than a second AST tag\n * is in `docs/concepts/authoring-ast.md`.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const CallMode = Schema.Literals([\"inline\", \"boundary\", \"handoff\"])\n\n/**\n * How a flow call joins the caller's plan.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport type CallMode = typeof CallMode.Type\n\n/**\n * A call to another flow. The AST keeps the callee's tag and the payload;\n * the declaration itself is in the side table, because a flow value carries\n * schemas and a body and is not JSON.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport interface FlowCall extends Scheduled {\n readonly _tag: \"FlowCall\"\n readonly flow: string\n readonly mode: CallMode\n readonly payload: unknown\n}\n\n/**\n * A call to an action: the atom that does work. Same split as\n * {@link FlowCall}, and no mode — an action is always one node.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport interface ActionCall extends Scheduled {\n readonly _tag: \"ActionCall\"\n readonly action: string\n readonly payload: unknown\n}\n\n/**\n * The algorithms a {@link FunctionIdentity} may name. The tag is versioned so a\n * change to identity semantics re-keys everything derived from one, rather than\n * colliding with it.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const IdentityAlgorithm = Schema.Literals([\n \"sha256-source-ephemeral/v4\",\n \"sha256-source-captures/v5\",\n \"static-node/v1\"\n])\n\n/**\n * The algorithms a {@link FunctionIdentity} may name.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport type IdentityAlgorithm = typeof IdentityAlgorithm.Type\n\n/**\n * The serializable stand-in for a function. Captured functions digest their\n * exact source and declared inert captures. Unannotated functions additionally\n * carry process-local, per-object entropy so indistinguishable closure sources\n * fail closed instead of sharing a cache key. The tag it names is\n * {@link IdentityAlgorithm}.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport interface FunctionIdentity {\n readonly _tag: \"FunctionIdentity\"\n readonly algorithm: IdentityAlgorithm\n readonly digest: string\n}\n\n/**\n * Brands an operation with every inert value it closes over, so its identity\n * covers what it computes with and not only its source.\n *\n * `@smthrs/crypto` owns the captures, nested metadata, and freezing contract.\n *\n * @since 0.1.0\n * @private\n */\nexport const capture = Identity.capture\n\n/**\n * The serializable form of a planned value embedded in an AST value or\n * payload. The strict proxy itself cannot enter the AST because serializing it\n * is deliberately a build error.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport interface PlannedReference {\n readonly _tag: \"PlannedReference\"\n readonly node: string\n readonly path: ReadonlyArray<string>\n}\n\n// A bundled runtime and a dynamically loaded flow may contain separate\n// compatible package copies. Share only live object metadata: JSON round trips\n// still lose executable bindings, and structural lookalikes remain inert.\nconst stateKey = Symbol.for(\"@smthrs/plan/Node/live/v1\")\ninterface LiveState {\n readonly references: WeakSet<object>\n readonly nodes: WeakSet<object>\n readonly operations: WeakMap<AndThen | Map, Operation>\n readonly predicates: WeakMap<Branch, Predicate>\n readonly filters: WeakMap<Catch, Schema.Top>\n readonly declarations: WeakMap<ActionCall | FlowCall, unknown>\n}\nconst globals = globalThis as typeof globalThis & { [stateKey]?: LiveState }\nconst liveState = globals[stateKey] ??= {\n references: new WeakSet(),\n nodes: new WeakSet(),\n operations: new WeakMap(),\n predicates: new WeakMap(),\n filters: new WeakMap(),\n declarations: new WeakMap()\n}\n\n/** The AST references minted by this module; structural lookalikes are data. */\nconst plannedReferences = liveState.references\n\nconst makePlannedReference = (reference: Planned.Reference): PlannedReference => {\n const value = Object.freeze({\n _tag: \"PlannedReference\" as const,\n node: reference.node,\n path: Object.freeze([...reference.path])\n })\n plannedReferences.add(value)\n return value\n}\n\n/**\n * Reads an AST-owned planned reference without trusting its public data shape.\n *\n * @since 1.0.0\n * @private\n */\nexport const plannedReference = (value: unknown): PlannedReference | undefined =>\n typeof value === \"object\" && value !== null && plannedReferences.has(value)\n ? value as PlannedReference\n : undefined\n\n/**\n * Every AST variant.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport type NodeAst = Succeed | Fail | All | Race | Map | AndThen | Branch | Catch | FlowCall | ActionCall\n\ntype Operation = (value: unknown) => unknown\n\ntype Predicate = (value: unknown) => boolean\n\nconst operations = liveState.operations\nconst predicates = liveState.predicates\nconst filters = liveState.filters\nconst declarations = liveState.declarations\n\n/**\n * The JSON mirror of an AST payload. A planned value becomes an AST-owned\n * {@link PlannedReference}, so the AST stays inert JSON.\n *\n * @private\n */\nconst payloadMirror = (input: unknown): unknown =>\n jsonMirror(input, (_value, reference) => makePlannedReference(reference))\n\n/**\n * Digests a function's exact source as UTF-8 with SHA-256. Exact source matters:\n * whitespace inside a string literal is behavior, and normalizing it before\n * hashing can make different functions share an identity. Unless its inert\n * captures were declared with {@link capture}, the digest also includes\n * process-local, per-function entropy: JavaScript cannot inspect a closure, so\n * source-only identity would permit incorrect cache hits.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const functionIdentity: (operation: unknown) => FunctionIdentity = Identity.functionIdentity\n\n/**\n * The prototype every node shares, so `pipe` is one function rather than one\n * closure per node.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const NodeProto = {\n [TypeId]: {\n _A: identity,\n _E: identity,\n _R: identity\n },\n pipe() {\n // eslint-disable-next-line prefer-rest-params -- `pipeArguments` takes the arguments object itself.\n return pipeArguments(this, arguments)\n }\n}\n\n/**\n * Every node {@link makeNode} built, so a node this module made is recognized\n * in constant time without walking its AST again.\n */\nconst liveNodes = liveState.nodes\n\n/** Recognizes the algorithms {@link IdentityAlgorithm} declares, and nothing else. */\nconst isIdentityAlgorithm = Schema.is(IdentityAlgorithm)\n\n/** Recognizes the modes {@link CallMode} declares, and nothing else. */\nconst isCallMode = Schema.is(CallMode)\n\n/** Recognizes the modes {@link RaceMode} names, and nothing else. @private */\nconst isRaceMode = (value: unknown): value is RaceMode => value === \"race\" || value === \"any\" || value === \"quorum\"\n\n/**\n * Whether `count` is a successes target a {@link Race} of `members` can reach:\n * a quorum needs between one and every member, and the other modes need one.\n *\n * @since 1.0.0\n * @private\n */\nexport const isRaceCount = (mode: RaceMode, count: unknown, members: number): boolean =>\n members > 0 && Number.isSafeInteger(count) &&\n (mode === \"quorum\" ? (count as number) >= 1 && (count as number) <= members : count === 1)\n\n/** @private */\nconst isFunctionIdentity = (value: unknown): value is FunctionIdentity =>\n isRecord(value) && value._tag === \"FunctionIdentity\" && isIdentityAlgorithm(value.algorithm) &&\n typeof value.digest === \"string\"\n\n/** One position of the {@link isNodeAst} walk: an AST to check, or one whose children are all checked. @private */\ntype AstVisit = { readonly enter: unknown } | { readonly exit: object }\n\n/**\n * Checks whether a value has the shape of a {@link NodeAst}: what a JSON round\n * trip of a genuine AST produces, and nothing looser. Every variant's own\n * fields are checked, and every child is walked. The walk is an explicit stack\n * rather than recursion, so an arbitrarily deep AST cannot overflow the native\n * stack, and it tracks the ancestors of the position it has reached, so a\n * cyclic object is refused rather than walked forever while a shared sub-AST\n * still passes.\n *\n * @since 1.0.0\n * @private\n */\nexport const isNodeAst = (value: unknown): value is NodeAst => {\n const ancestors = new Set<object>()\n const pending: Array<AstVisit> = [{ enter: value }]\n while (pending.length > 0) {\n const visit = pending.pop()!\n if (\"exit\" in visit) {\n ancestors.delete(visit.exit)\n continue\n }\n const ast = visit.enter\n if (!isRecord(ast) || ancestors.has(ast)) return false\n if (ast.priority !== undefined && !Number.isSafeInteger(ast.priority)) return false\n const children: Array<unknown> = []\n switch (ast._tag) {\n case \"Succeed\":\n case \"Fail\":\n break\n case \"All\": {\n if (!isRecord(ast.nodes) || Array.isArray(ast.nodes)) return false\n for (const child of Object.values(ast.nodes)) children.push(child)\n break\n }\n case \"Race\": {\n if (!isRecord(ast.nodes) || Array.isArray(ast.nodes)) return false\n const members = Object.values(ast.nodes)\n if (!isRaceMode(ast.mode) || !isRaceCount(ast.mode, ast.count, members.length)) return false\n for (const child of members) children.push(child)\n break\n }\n case \"Map\": {\n if (!isFunctionIdentity(ast.mapper)) return false\n children.push(ast.first)\n break\n }\n case \"AndThen\": {\n if (!isFunctionIdentity(ast.continuation)) return false\n children.push(ast.first)\n if (ast.next !== undefined) children.push(ast.next)\n break\n }\n case \"Branch\": {\n if (typeof ast.subject !== \"string\" || !isFunctionIdentity(ast.predicate)) return false\n children.push(ast.first, ast.then, ast.else)\n break\n }\n case \"Catch\": {\n if (typeof ast.subject !== \"string\") return false\n if (ast.filterIdentity !== undefined && !isFunctionIdentity(ast.filterIdentity)) return false\n children.push(ast.protected, ast.failure)\n break\n }\n case \"FlowCall\": {\n if (typeof ast.flow !== \"string\" || !isCallMode(ast.mode)) return false\n break\n }\n case \"ActionCall\": {\n if (typeof ast.action !== \"string\") return false\n break\n }\n default:\n return false\n }\n if (children.length > 0) {\n ancestors.add(ast)\n pending.push({ exit: ast })\n for (const child of children) pending.push({ enter: child })\n }\n }\n return true\n}\n\n/**\n * Checks whether a value is a node.\n *\n * A node this module built is recognized by registration. A node that crossed\n * a serialization boundary, an object whose prototype is {@link NodeProto} and\n * whose own `ast` data property passes {@link isNodeAst}, is recognized by that\n * shape: `@smthrs/flow` hands a rehydrated AST back as a node, and the side\n * tables are all a round trip loses. The {@link TypeId} marker is an exported\n * string any object can carry, so it counts for nothing on its own, and an\n * `ast` that is missing, malformed, cyclic, or an accessor is refused because\n * every combinator reads it as trusted topology. A proxy is judged by the\n * shape it forwards.\n *\n * @since 1.0.0\n * @private\n */\nexport const isNode = (value: unknown): value is Node<unknown, unknown, any> => {\n if (typeof value !== \"object\" || value === null) return false\n if (liveNodes.has(value)) return true\n if (Object.getPrototypeOf(value) !== NodeProto) return false\n const ast = Object.getOwnPropertyDescriptor(value, \"ast\")\n return ast !== undefined && \"value\" in ast && isNodeAst(ast.value)\n}\n\n/**\n * Wraps an AST as a node.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const makeNode = <A = unknown, E = never, R = never>(ast: NodeAst): Node<A, E, R> => {\n const node: Node<A, E, R> = Object.assign(Object.create(NodeProto), { ast })\n liveNodes.add(node)\n return node\n}\n\n/**\n * Constructs a {@link Succeed}.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const succeed = (input: unknown): Succeed => ({ _tag: \"Succeed\", value: payloadMirror(input) })\n\n/**\n * Constructs a {@link Fail}.\n *\n * @since 1.0.0\n * @private\n * @slop\n */\nexport const fail = (error: unknown): Fail => ({ _tag: \"Fail\", error: payloadMirror(error) })\n\n/**\n * Constructs an {@link All}.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const all = (nodes: Readonly<Record<string, NodeAst>>): All => ({ _tag: \"All\", nodes })\n\n/**\n * Constructs a {@link Race}.\n *\n * @since 1.0.0\n * @private\n */\nexport const race = (mode: RaceMode, count: number, nodes: Readonly<Record<string, NodeAst>>): Race => ({\n _tag: \"Race\",\n mode,\n count,\n nodes\n})\n\n/**\n * Constructs a {@link Map}, filing the mapper under the AST it belongs to.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const map = (first: NodeAst, operation: Operation, source: unknown): Map => {\n const ast: Map = { _tag: \"Map\", first, mapper: functionIdentity(source) }\n operations.set(ast, operation)\n return ast\n}\n\n/**\n * Constructs an {@link AndThen} from a builder. The builder is evaluated once\n * against a planned value when the graph is built, never here.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const andThen = (first: NodeAst, operation: Operation, source: unknown): AndThen => {\n const ast: AndThen = { _tag: \"AndThen\", first, continuation: functionIdentity(source) }\n operations.set(ast, operation)\n return ast\n}\n\n/**\n * Constructs an {@link AndThen} from a node the author supplied directly. There\n * is no function to digest, so the continuation carries a fixed marker.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const andThenNode = (first: NodeAst, next: NodeAst): AndThen => ({\n _tag: \"AndThen\",\n first,\n continuation: { _tag: \"FunctionIdentity\", algorithm: \"static-node/v1\", digest: digestSync(\"static-node\") },\n next\n})\n\n/**\n * Constructs a {@link Branch}. Both arms arrive already evaluated, because a\n * branch that had to be run to reveal its topology would not be a plan.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const branch = (\n subject: string,\n first: NodeAst,\n predicate: Predicate,\n source: unknown,\n then: NodeAst,\n otherwise: NodeAst\n): Branch => {\n const ast: Branch = {\n _tag: \"Branch\",\n subject,\n first,\n predicate: functionIdentity(source),\n then,\n else: otherwise\n }\n predicates.set(ast, predicate)\n return ast\n}\n\n/**\n * JSON Schema does not describe arbitrary checks, declaration parsers, or\n * suspended schema factories. Include every function reachable from the\n * schema AST, preserving declared captures and treating opaque wrappers as\n * ephemeral. The iterative walk also covers nested checks and cyclic ASTs.\n *\n * @private\n */\nconst filterIdentity = (filter: Schema.Top): FunctionIdentity => {\n const identities: Array<readonly [string, FunctionIdentity]> = []\n const pending: Array<readonly [string, unknown]> = [[\"$\", filter.ast]]\n const seen = new WeakSet<object>()\n while (pending.length > 0) {\n const [path, current] = pending.pop()!\n if (typeof current === \"function\") {\n identities.push([path, functionIdentity(current)])\n } else if (typeof current === \"object\" && current !== null && !seen.has(current)) {\n seen.add(current)\n const descriptors = Object.getOwnPropertyDescriptors(current)\n for (const key of Object.keys(descriptors).sort()) {\n const descriptor = descriptors[key]!\n if (\"value\" in descriptor) pending.push([`${path}/${JSON.stringify(key)}`, descriptor.value])\n else {\n if (descriptor.get !== undefined) pending.push([`${path}/${JSON.stringify(key)}/get`, descriptor.get])\n if (descriptor.set !== undefined) pending.push([`${path}/${JSON.stringify(key)}/set`, descriptor.set])\n }\n }\n }\n }\n return {\n _tag: \"FunctionIdentity\",\n algorithm: identities.some(([, identity]) => identity.algorithm === \"sha256-source-ephemeral/v4\")\n ? \"sha256-source-ephemeral/v4\"\n : \"sha256-source-captures/v5\",\n digest: digestSync(JSON.stringify(identities))\n }\n}\n\n/**\n * Constructs a {@link Catch} whose failure topology is already evaluated.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const catch_ = (subject: string, protectedAst: NodeAst, failure: NodeAst, filter?: Schema.Top): Catch => {\n const ast: Catch = {\n _tag: \"Catch\",\n subject,\n protected: protectedAst,\n failure,\n ...(filter === undefined\n ? {}\n : {\n filter: schemaIdentity(filter, { onExcessProperty: \"error\" }),\n filterIdentity: filterIdentity(filter)\n })\n }\n if (filter !== undefined) filters.set(ast, filter)\n return ast\n}\n\n/**\n * Constructs a {@link FlowCall}, filing the flow declaration beside it.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const flowCall = (declaration: unknown, flow: string, mode: CallMode, payload: unknown): FlowCall => {\n const ast: FlowCall = { _tag: \"FlowCall\", flow, mode, payload: payloadMirror(payload) }\n declarations.set(ast, declaration)\n return ast\n}\n\n/**\n * Constructs an {@link ActionCall}, filing the action declaration beside\n * it.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const actionCall = (declaration: unknown, action: string, payload: unknown): ActionCall => {\n const ast: ActionCall = { _tag: \"ActionCall\", action, payload: payloadMirror(payload) }\n declarations.set(ast, declaration)\n return ast\n}\n\n/**\n * The deferred function of a map or a continuation.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const operation = (ast: AndThen | Map): Operation | undefined => operations.get(ast)\n\n/**\n * The run-time predicate of a branch.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const predicate = (ast: Branch): Predicate | undefined => predicates.get(ast)\n\n/**\n * The optional error schema filter of a catch node.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const filter = (ast: Catch): Schema.Top | undefined => filters.get(ast)\n\n/**\n * The flow or action declaration a call node names.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const declaration = (ast: ActionCall | FlowCall): unknown => declarations.get(ast)\n\n/**\n * Copies an AST with a scheduling priority attached.\n *\n * The copy is shallow and the side tables are re-filed against it, because a\n * function, a predicate, a filter schema, and a declaration are keyed by the\n * exact AST object they belong to: a copy that left them behind would silently\n * lose the continuation the graph walk has to evaluate.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const withPriority = (ast: NodeAst, priority: number): NodeAst => {\n const prioritized = { ...ast, priority }\n if (ast._tag === \"AndThen\" || ast._tag === \"Map\") {\n const deferred = operations.get(ast)\n if (deferred !== undefined) operations.set(prioritized as AndThen | Map, deferred)\n }\n if (ast._tag === \"Branch\") {\n const decision = predicates.get(ast)\n if (decision !== undefined) predicates.set(prioritized as Branch, decision)\n }\n if (ast._tag === \"Catch\") {\n const schema = filters.get(ast)\n if (schema !== undefined) filters.set(prioritized as Catch, schema)\n }\n if (ast._tag === \"ActionCall\" || ast._tag === \"FlowCall\") {\n const target = declarations.get(ast)\n if (target !== undefined) declarations.set(prioritized as ActionCall | FlowCall, target)\n }\n return prioritized\n}\n"]}
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../../src/internal/node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CAAA;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAGvC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAEpD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,oBAA6B,CAAA;AAyKnD;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,QAAQ,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC,CAAA;AAyC1E;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAA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ariants shape every declaration here. The AST is **closure-free**\n * and keeps payloads as inert JSON mirrors, so a valid plan can be shipped,\n * stored, diffed, and rendered without the process that built it; control flow is\n * **structure**, so a branch stores both arms as ASTs rather than a function\n * that would have to be run to find out what comes next.\n *\n * The functions an author does write — a mapper, a continuation, a branch\n * predicate — live in `WeakMap`s keyed by the AST node they belong to, and the\n * AST keeps only a {@link FunctionIdentity} digest of their source. The digest\n * is what enters content identity (https://github.com/smithersai/smithers/blob/main/packages/smithers/flows/plan/docs/concepts/step-keys.md); the\n * `WeakMap` is what the run reaches for when it has the real value in hand, and\n * it drops with the AST it is keyed by.\n *\n * Adapted from `@smthrs/core` (`packages/smithers/flows/core`)\n * `internal/node.ts`. `Dynamic` does not come across — a model call is an\n * ordinary action here — and neither do annotations, which are `Context`\n * values and would break serializability. Scheduling priority is the one thing that does cross, as\n * the plain JSON field {@link Scheduled.priority} rather than as an\n * annotation, because the scheduler has to read it out of a stored plan.\n *\n * @since 0.1.0\n */\n\nimport { isRecord } from \"@smthrs/canonical/Record\"\nimport { digestSync } from \"@smthrs/crypto\"\nimport * as Identity from \"@smthrs/crypto/Identity\"\nimport { identity } from \"effect/Function\"\nimport { pipeArguments } from \"effect/Pipeable\"\nimport * as Schema from \"effect/Schema\"\nimport type { Node } from \"../Node.ts\"\nimport type * as Planned from \"../Planned.ts\"\nimport { jsonMirror } from \"./JsonMirror.ts\"\nimport { schemaIdentity } from \"./SchemaIdentity.ts\"\n\n/**\n * The runtime type identifier every node carries.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const TypeId = \"~@smthrs/plan/Node\" as const\n\n/**\n * The type-level form of {@link TypeId}.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport type TypeId = typeof TypeId\n\n/**\n * What every AST variant carries besides its own shape: an optional scheduling\n * priority.\n *\n * A priority is JSON, not a `Context` annotation, which is why it can live in\n * the AST at all: the whole point of dropping core's annotations was to keep a\n * plan shippable, storable, and diffable. It is a scheduling HINT — the plan\n * compiler copies it onto the node draft and the scheduler orders ready work by\n * it, while key material never reads it, so raising a priority reorders work\n * without re-keying a single step.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport interface Scheduled {\n readonly priority?: number | undefined\n}\n\n/**\n * A constant, known before anything runs.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport interface Succeed extends Scheduled {\n readonly _tag: \"Succeed\"\n readonly value: unknown\n}\n\n/**\n * A constant typed failure, known before anything runs.\n *\n * The error is an inert JSON mirror for the same reason {@link Succeed.value}\n * is: a stored plan has to carry what the node produces without the process\n * that built it.\n *\n * @since 1.0.0\n * @private\n * @slop\n */\nexport interface Fail extends Scheduled {\n readonly _tag: \"Fail\"\n readonly error: unknown\n}\n\n/**\n * Independent children, combined by name. Width is fixed here, at plan time:\n * there is no dynamic fan-out.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport interface All extends Scheduled {\n readonly _tag: \"All\"\n readonly nodes: Readonly<Record<string, NodeAst>>\n}\n\n/**\n * How a {@link Race} settles: `race` on the first member to settle, `any` on\n * the first member to succeed, and `quorum` once `count` members succeed.\n *\n * @since 1.0.0\n * @private\n */\nexport type RaceMode = \"race\" | \"any\" | \"quorum\"\n\n/**\n * Independent children that settle early: the join decides as soon as its\n * {@link RaceMode} can, and the members it did not wait for are interrupted.\n * `count` is the successes a quorum needs, and 1 for `race` and `any`.\n *\n * @since 1.0.0\n * @private\n */\nexport interface Race extends Scheduled {\n readonly _tag: \"Race\"\n readonly mode: RaceMode\n readonly count: number\n readonly nodes: Readonly<Record<string, NodeAst>>\n}\n\n/**\n * A deferred pure transformation of an upstream result. `map` transforms; it\n * never decides.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport interface Map extends Scheduled {\n readonly _tag: \"Map\"\n readonly first: NodeAst\n readonly mapper: FunctionIdentity\n}\n\n/**\n * A continuation after an upstream node. `next` is present when the author\n * supplied a node directly instead of a builder, in which case the topology is\n * already known and nothing has to be evaluated to reveal it.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport interface AndThen extends Scheduled {\n readonly _tag: \"AndThen\"\n readonly first: NodeAst\n readonly continuation: FunctionIdentity\n readonly next?: NodeAst | undefined\n}\n\n/**\n * A decision whose arms are static topology. The predicate runs at run time on\n * the real value; both arms are already ASTs, so the exit condition and the\n * handoff site are visible before anything runs.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport interface Branch extends Scheduled {\n readonly _tag: \"Branch\"\n readonly subject: string\n readonly first: NodeAst\n readonly predicate: FunctionIdentity\n readonly then: NodeAst\n readonly else: NodeAst\n}\n\n/**\n * A protected graph and its statically planned typed-failure continuation.\n *\n * The symbolic error `subject` is minted per catch node rather than shared,\n * mirroring {@link Branch}. Failure arms are built before the graph assigns\n * ids, so a nested arm that captured an outer error would resolve it to the\n * inner catch's protected node under one shared token.\n *\n * An absent filter catches the entire typed error channel, while a present\n * schema catches only values it accepts. This mirrors Effect's typed-error\n * boundary and keeps defects outside normal recovery. The serializable AST carries the schema identity; the live schema\n * remains in a side table beside the AST.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport interface Catch extends Scheduled {\n readonly _tag: \"Catch\"\n readonly subject: string\n readonly protected: NodeAst\n readonly failure: NodeAst\n readonly filter?: unknown | undefined\n readonly filterIdentity?: FunctionIdentity | undefined\n}\n\n/**\n * How a flow call joins the caller's plan: `inline` splices the callee's body\n * in, `boundary` makes it one child execution, and `handoff` names the next\n * trampoline round. Why the child call is a mode rather than a second AST tag\n * is in `docs/concepts/authoring-ast.md`.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const CallMode = Schema.Literals([\"inline\", \"boundary\", \"handoff\"])\n\n/**\n * How a flow call joins the caller's plan.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport type CallMode = typeof CallMode.Type\n\n/**\n * A call to another flow. The AST keeps the callee's tag and the payload;\n * the declaration itself is in the side table, because a flow value carries\n * schemas and a body and is not JSON.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport interface FlowCall extends Scheduled {\n readonly _tag: \"FlowCall\"\n readonly flow: string\n readonly mode: CallMode\n readonly payload: unknown\n}\n\n/**\n * A call to an action: the atom that does work. Same split as\n * {@link FlowCall}, and no mode — an action is always one node.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport interface ActionCall extends Scheduled {\n readonly _tag: \"ActionCall\"\n readonly action: string\n readonly payload: unknown\n}\n\n/**\n * The algorithms a {@link FunctionIdentity} may name. The tag is versioned so a\n * change to identity semantics re-keys everything derived from one, rather than\n * colliding with it.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const IdentityAlgorithm = Schema.Literals([\n \"sha256-source-ephemeral/v4\",\n \"sha256-source-captures/v5\",\n \"static-node/v1\"\n])\n\n/**\n * The algorithms a {@link FunctionIdentity} may name.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport type IdentityAlgorithm = typeof IdentityAlgorithm.Type\n\n/**\n * The serializable stand-in for a function. Captured functions digest their\n * exact source and declared inert captures. Unannotated functions additionally\n * carry process-local, per-object entropy so indistinguishable closure sources\n * fail closed instead of sharing a cache key. The tag it names is\n * {@link IdentityAlgorithm}.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport interface FunctionIdentity {\n readonly _tag: \"FunctionIdentity\"\n readonly algorithm: IdentityAlgorithm\n readonly digest: string\n /** Nonce-free resume comparison material. Step keys still use `digest`. */\n readonly sourceDigest?: string | undefined\n}\n\n/**\n * Brands an operation with every inert value it closes over, so its identity\n * covers what it computes with and not only its source.\n *\n * `@smthrs/crypto` owns the captures, nested metadata, and freezing contract.\n *\n * @since 0.1.0\n * @private\n */\nexport const capture = Identity.capture\n\n/**\n * The serializable form of a planned value embedded in an AST value or\n * payload. The strict proxy itself cannot enter the AST because serializing it\n * is deliberately a build error.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport interface PlannedReference {\n readonly _tag: \"PlannedReference\"\n readonly node: string\n readonly path: ReadonlyArray<string>\n}\n\n// A bundled runtime and a dynamically loaded flow may contain separate\n// compatible package copies. Share only live object metadata: JSON round trips\n// still lose executable bindings, and structural lookalikes remain inert.\nconst stateKey = Symbol.for(\"@smthrs/plan/Node/live/v1\")\ninterface LiveState {\n readonly references: WeakSet<object>\n readonly nodes: WeakSet<object>\n readonly operations: WeakMap<AndThen | Map, Operation>\n readonly predicates: WeakMap<Branch, Predicate>\n readonly filters: WeakMap<Catch, Schema.Top>\n readonly declarations: WeakMap<ActionCall | FlowCall, unknown>\n}\nconst globals = globalThis as typeof globalThis & { [stateKey]?: LiveState }\nconst liveState = globals[stateKey] ??= {\n references: new WeakSet(),\n nodes: new WeakSet(),\n operations: new WeakMap(),\n predicates: new WeakMap(),\n filters: new WeakMap(),\n declarations: new WeakMap()\n}\n\n/** The AST references minted by this module; structural lookalikes are data. */\nconst plannedReferences = liveState.references\n\nconst makePlannedReference = (reference: Planned.Reference): PlannedReference => {\n const value = Object.freeze({\n _tag: \"PlannedReference\" as const,\n node: reference.node,\n path: Object.freeze([...reference.path])\n })\n plannedReferences.add(value)\n return value\n}\n\n/**\n * Reads an AST-owned planned reference without trusting its public data shape.\n *\n * @since 1.0.0\n * @private\n */\nexport const plannedReference = (value: unknown): PlannedReference | undefined =>\n typeof value === \"object\" && value !== null && plannedReferences.has(value)\n ? value as PlannedReference\n : undefined\n\n/**\n * Every AST variant.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport type NodeAst = Succeed | Fail | All | Race | Map | AndThen | Branch | Catch | FlowCall | ActionCall\n\ntype Operation = (value: unknown) => unknown\n\ntype Predicate = (value: unknown) => boolean\n\nconst operations = liveState.operations\nconst predicates = liveState.predicates\nconst filters = liveState.filters\nconst declarations = liveState.declarations\n\n/**\n * The JSON mirror of an AST payload. A planned value becomes an AST-owned\n * {@link PlannedReference}, so the AST stays inert JSON.\n *\n * @private\n */\nconst payloadMirror = (input: unknown): unknown =>\n jsonMirror(input, (_value, reference) => makePlannedReference(reference))\n\n/**\n * Digests a function's exact source as UTF-8 with SHA-256. Exact source matters:\n * whitespace inside a string literal is behavior, and normalizing it before\n * hashing can make different functions share an identity. Unless its inert\n * captures were declared with {@link capture}, the digest also includes\n * process-local, per-function entropy: JavaScript cannot inspect a closure, so\n * source-only identity would permit incorrect cache hits.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const functionIdentity: (operation: unknown) => FunctionIdentity = Identity.functionIdentity\n\n/**\n * The prototype every node shares, so `pipe` is one function rather than one\n * closure per node.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const NodeProto = {\n [TypeId]: {\n _A: identity,\n _E: identity,\n _R: identity\n },\n pipe() {\n // eslint-disable-next-line prefer-rest-params -- `pipeArguments` takes the arguments object itself.\n return pipeArguments(this, arguments)\n }\n}\n\n/**\n * Every node {@link makeNode} built, so a node this module made is recognized\n * in constant time without walking its AST again.\n */\nconst liveNodes = liveState.nodes\n\n/** Recognizes the algorithms {@link IdentityAlgorithm} declares, and nothing else. */\nconst isIdentityAlgorithm = Schema.is(IdentityAlgorithm)\n\n/** Recognizes the modes {@link CallMode} declares, and nothing else. */\nconst isCallMode = Schema.is(CallMode)\n\n/** Recognizes the modes {@link RaceMode} names, and nothing else. @private */\nconst isRaceMode = (value: unknown): value is RaceMode => value === \"race\" || value === \"any\" || value === \"quorum\"\n\n/**\n * Whether `count` is a successes target a {@link Race} of `members` can reach:\n * a quorum needs between one and every member, and the other modes need one.\n *\n * @since 1.0.0\n * @private\n */\nexport const isRaceCount = (mode: RaceMode, count: unknown, members: number): boolean =>\n members > 0 && Number.isSafeInteger(count) &&\n (mode === \"quorum\" ? (count as number) >= 1 && (count as number) <= members : count === 1)\n\n/** @private */\nconst isFunctionIdentity = (value: unknown): value is FunctionIdentity =>\n isRecord(value) && value._tag === \"FunctionIdentity\" && isIdentityAlgorithm(value.algorithm) &&\n typeof value.digest === \"string\"\n\n/** One position of the {@link isNodeAst} walk: an AST to check, or one whose children are all checked. @private */\ntype AstVisit = { readonly enter: unknown } | { readonly exit: object }\n\n/**\n * Checks whether a value has the shape of a {@link NodeAst}: what a JSON round\n * trip of a genuine AST produces, and nothing looser. Every variant's own\n * fields are checked, and every child is walked. The walk is an explicit stack\n * rather than recursion, so an arbitrarily deep AST cannot overflow the native\n * stack, and it tracks the ancestors of the position it has reached, so a\n * cyclic object is refused rather than walked forever while a shared sub-AST\n * still passes.\n *\n * @since 1.0.0\n * @private\n */\nexport const isNodeAst = (value: unknown): value is NodeAst => {\n const ancestors = new Set<object>()\n const pending: Array<AstVisit> = [{ enter: value }]\n while (pending.length > 0) {\n const visit = pending.pop()!\n if (\"exit\" in visit) {\n ancestors.delete(visit.exit)\n continue\n }\n const ast = visit.enter\n if (!isRecord(ast) || ancestors.has(ast)) return false\n if (ast.priority !== undefined && !Number.isSafeInteger(ast.priority)) return false\n const children: Array<unknown> = []\n switch (ast._tag) {\n case \"Succeed\":\n case \"Fail\":\n break\n case \"All\": {\n if (!isRecord(ast.nodes) || Array.isArray(ast.nodes)) return false\n for (const child of Object.values(ast.nodes)) children.push(child)\n break\n }\n case \"Race\": {\n if (!isRecord(ast.nodes) || Array.isArray(ast.nodes)) return false\n const members = Object.values(ast.nodes)\n if (!isRaceMode(ast.mode) || !isRaceCount(ast.mode, ast.count, members.length)) return false\n for (const child of members) children.push(child)\n break\n }\n case \"Map\": {\n if (!isFunctionIdentity(ast.mapper)) return false\n children.push(ast.first)\n break\n }\n case \"AndThen\": {\n if (!isFunctionIdentity(ast.continuation)) return false\n children.push(ast.first)\n if (ast.next !== undefined) children.push(ast.next)\n break\n }\n case \"Branch\": {\n if (typeof ast.subject !== \"string\" || !isFunctionIdentity(ast.predicate)) return false\n children.push(ast.first, ast.then, ast.else)\n break\n }\n case \"Catch\": {\n if (typeof ast.subject !== \"string\") return false\n if (ast.filterIdentity !== undefined && !isFunctionIdentity(ast.filterIdentity)) return false\n children.push(ast.protected, ast.failure)\n break\n }\n case \"FlowCall\": {\n if (typeof ast.flow !== \"string\" || !isCallMode(ast.mode)) return false\n break\n }\n case \"ActionCall\": {\n if (typeof ast.action !== \"string\") return false\n break\n }\n default:\n return false\n }\n if (children.length > 0) {\n ancestors.add(ast)\n pending.push({ exit: ast })\n for (const child of children) pending.push({ enter: child })\n }\n }\n return true\n}\n\n/**\n * Checks whether a value is a node.\n *\n * A node this module built is recognized by registration. A node that crossed\n * a serialization boundary, an object whose prototype is {@link NodeProto} and\n * whose own `ast` data property passes {@link isNodeAst}, is recognized by that\n * shape: `@smthrs/flow` hands a rehydrated AST back as a node, and the side\n * tables are all a round trip loses. The {@link TypeId} marker is an exported\n * string any object can carry, so it counts for nothing on its own, and an\n * `ast` that is missing, malformed, cyclic, or an accessor is refused because\n * every combinator reads it as trusted topology. A proxy is judged by the\n * shape it forwards.\n *\n * @since 1.0.0\n * @private\n */\nexport const isNode = (value: unknown): value is Node<unknown, unknown, any> => {\n if (typeof value !== \"object\" || value === null) return false\n if (liveNodes.has(value)) return true\n if (Object.getPrototypeOf(value) !== NodeProto) return false\n const ast = Object.getOwnPropertyDescriptor(value, \"ast\")\n return ast !== undefined && \"value\" in ast && isNodeAst(ast.value)\n}\n\n/**\n * Wraps an AST as a node.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const makeNode = <A = unknown, E = never, R = never>(ast: NodeAst): Node<A, E, R> => {\n const node: Node<A, E, R> = Object.assign(Object.create(NodeProto), { ast })\n liveNodes.add(node)\n return node\n}\n\n/**\n * Constructs a {@link Succeed}.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const succeed = (input: unknown): Succeed => ({ _tag: \"Succeed\", value: payloadMirror(input) })\n\n/**\n * Constructs a {@link Fail}.\n *\n * @since 1.0.0\n * @private\n * @slop\n */\nexport const fail = (error: unknown): Fail => ({ _tag: \"Fail\", error: payloadMirror(error) })\n\n/**\n * Constructs an {@link All}.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const all = (nodes: Readonly<Record<string, NodeAst>>): All => ({ _tag: \"All\", nodes })\n\n/**\n * Constructs a {@link Race}.\n *\n * @since 1.0.0\n * @private\n */\nexport const race = (mode: RaceMode, count: number, nodes: Readonly<Record<string, NodeAst>>): Race => ({\n _tag: \"Race\",\n mode,\n count,\n nodes\n})\n\n/**\n * Constructs a {@link Map}, filing the mapper under the AST it belongs to.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const map = (first: NodeAst, operation: Operation, source: unknown): Map => {\n const ast: Map = { _tag: \"Map\", first, mapper: functionIdentity(source) }\n operations.set(ast, operation)\n return ast\n}\n\n/**\n * Constructs an {@link AndThen} from a builder. The builder is evaluated once\n * against a planned value when the graph is built, never here.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const andThen = (first: NodeAst, operation: Operation, source: unknown): AndThen => {\n const ast: AndThen = { _tag: \"AndThen\", first, continuation: functionIdentity(source) }\n operations.set(ast, operation)\n return ast\n}\n\n/**\n * Constructs an {@link AndThen} from a node the author supplied directly. There\n * is no function to digest, so the continuation carries a fixed marker.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const andThenNode = (first: NodeAst, next: NodeAst): AndThen => ({\n _tag: \"AndThen\",\n first,\n continuation: { _tag: \"FunctionIdentity\", algorithm: \"static-node/v1\", digest: digestSync(\"static-node\") },\n next\n})\n\n/**\n * Constructs a {@link Branch}. Both arms arrive already evaluated, because a\n * branch that had to be run to reveal its topology would not be a plan.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const branch = (\n subject: string,\n first: NodeAst,\n predicate: Predicate,\n source: unknown,\n then: NodeAst,\n otherwise: NodeAst\n): Branch => {\n const ast: Branch = {\n _tag: \"Branch\",\n subject,\n first,\n predicate: functionIdentity(source),\n then,\n else: otherwise\n }\n predicates.set(ast, predicate)\n return ast\n}\n\n/**\n * JSON Schema does not describe arbitrary checks, declaration parsers, or\n * suspended schema factories. Include every function reachable from the\n * schema AST, preserving declared captures and treating opaque wrappers as\n * ephemeral. The iterative walk also covers nested checks and cyclic ASTs.\n *\n * @private\n */\nconst filterIdentity = (filter: Schema.Top): FunctionIdentity => {\n const identities: Array<readonly [string, FunctionIdentity]> = []\n const pending: Array<readonly [string, unknown]> = [[\"$\", filter.ast]]\n const seen = new WeakSet<object>()\n while (pending.length > 0) {\n const [path, current] = pending.pop()!\n if (typeof current === \"function\") {\n identities.push([path, functionIdentity(current)])\n } else if (typeof current === \"object\" && current !== null && !seen.has(current)) {\n seen.add(current)\n const descriptors = Object.getOwnPropertyDescriptors(current)\n for (const key of Object.keys(descriptors).sort()) {\n const descriptor = descriptors[key]!\n if (\"value\" in descriptor) pending.push([`${path}/${JSON.stringify(key)}`, descriptor.value])\n else {\n if (descriptor.get !== undefined) pending.push([`${path}/${JSON.stringify(key)}/get`, descriptor.get])\n if (descriptor.set !== undefined) pending.push([`${path}/${JSON.stringify(key)}/set`, descriptor.set])\n }\n }\n }\n }\n const ephemeral = identities.some(([, identity]) => identity.algorithm === \"sha256-source-ephemeral/v4\")\n const sourceComparable = identities.every(([, identity]) =>\n identity.algorithm !== \"sha256-source-ephemeral/v4\" || identity.sourceDigest !== undefined\n )\n return {\n _tag: \"FunctionIdentity\",\n algorithm: ephemeral\n ? \"sha256-source-ephemeral/v4\"\n : \"sha256-source-captures/v5\",\n digest: digestSync(JSON.stringify(identities)),\n ...(ephemeral && sourceComparable\n ? {\n sourceDigest: digestSync(JSON.stringify(identities.map(([path, identity]) => [path, {\n _tag: identity._tag,\n algorithm: identity.algorithm,\n digest: identity.sourceDigest ?? identity.digest\n }])))\n }\n : {})\n }\n}\n\n/**\n * Constructs a {@link Catch} whose failure topology is already evaluated.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const catch_ = (subject: string, protectedAst: NodeAst, failure: NodeAst, filter?: Schema.Top): Catch => {\n const ast: Catch = {\n _tag: \"Catch\",\n subject,\n protected: protectedAst,\n failure,\n ...(filter === undefined\n ? {}\n : {\n filter: schemaIdentity(filter, { onExcessProperty: \"error\" }),\n filterIdentity: filterIdentity(filter)\n })\n }\n if (filter !== undefined) filters.set(ast, filter)\n return ast\n}\n\n/**\n * Constructs a {@link FlowCall}, filing the flow declaration beside it.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const flowCall = (declaration: unknown, flow: string, mode: CallMode, payload: unknown): FlowCall => {\n const ast: FlowCall = { _tag: \"FlowCall\", flow, mode, payload: payloadMirror(payload) }\n declarations.set(ast, declaration)\n return ast\n}\n\n/**\n * Constructs an {@link ActionCall}, filing the action declaration beside\n * it.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const actionCall = (declaration: unknown, action: string, payload: unknown): ActionCall => {\n const ast: ActionCall = { _tag: \"ActionCall\", action, payload: payloadMirror(payload) }\n declarations.set(ast, declaration)\n return ast\n}\n\n/**\n * The deferred function of a map or a continuation.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const operation = (ast: AndThen | Map): Operation | undefined => operations.get(ast)\n\n/**\n * The run-time predicate of a branch.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const predicate = (ast: Branch): Predicate | undefined => predicates.get(ast)\n\n/**\n * The optional error schema filter of a catch node.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const filter = (ast: Catch): Schema.Top | undefined => filters.get(ast)\n\n/**\n * The flow or action declaration a call node names.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const declaration = (ast: ActionCall | FlowCall): unknown => declarations.get(ast)\n\n/**\n * Copies an AST with a scheduling priority attached.\n *\n * The copy is shallow and the side tables are re-filed against it, because a\n * function, a predicate, a filter schema, and a declaration are keyed by the\n * exact AST object they belong to: a copy that left them behind would silently\n * lose the continuation the graph walk has to evaluate.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const withPriority = (ast: NodeAst, priority: number): NodeAst => {\n const prioritized = { ...ast, priority }\n if (ast._tag === \"AndThen\" || ast._tag === \"Map\") {\n const deferred = operations.get(ast)\n if (deferred !== undefined) operations.set(prioritized as AndThen | Map, deferred)\n }\n if (ast._tag === \"Branch\") {\n const decision = predicates.get(ast)\n if (decision !== undefined) predicates.set(prioritized as Branch, decision)\n }\n if (ast._tag === \"Catch\") {\n const schema = filters.get(ast)\n if (schema !== undefined) filters.set(prioritized as Catch, schema)\n }\n if (ast._tag === \"ActionCall\" || ast._tag === \"FlowCall\") {\n const target = declarations.get(ast)\n if (target !== undefined) declarations.set(prioritized as ActionCall | FlowCall, target)\n }\n return prioritized\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.14 @smthrs/flow@1.0.0-rc.14 @effect/platform-node
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
The outputs below are real output from the release that install line names.
|
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.14",
|
|
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.14",
|
|
222
|
+
"@smthrs/keys": "1.0.0-rc.14",
|
|
223
|
+
"@smthrs/canonical": "1.0.0-rc.14"
|
|
224
224
|
},
|
|
225
225
|
"devDependencies": {
|
|
226
226
|
"@effect/language-service": "0.87.2",
|
package/src/internal/node.ts
CHANGED
|
@@ -301,6 +301,8 @@ export interface FunctionIdentity {
|
|
|
301
301
|
readonly _tag: "FunctionIdentity"
|
|
302
302
|
readonly algorithm: IdentityAlgorithm
|
|
303
303
|
readonly digest: string
|
|
304
|
+
/** Nonce-free resume comparison material. Step keys still use `digest`. */
|
|
305
|
+
readonly sourceDigest?: string | undefined
|
|
304
306
|
}
|
|
305
307
|
|
|
306
308
|
/**
|
|
@@ -729,12 +731,25 @@ const filterIdentity = (filter: Schema.Top): FunctionIdentity => {
|
|
|
729
731
|
}
|
|
730
732
|
}
|
|
731
733
|
}
|
|
734
|
+
const ephemeral = identities.some(([, identity]) => identity.algorithm === "sha256-source-ephemeral/v4")
|
|
735
|
+
const sourceComparable = identities.every(([, identity]) =>
|
|
736
|
+
identity.algorithm !== "sha256-source-ephemeral/v4" || identity.sourceDigest !== undefined
|
|
737
|
+
)
|
|
732
738
|
return {
|
|
733
739
|
_tag: "FunctionIdentity",
|
|
734
|
-
algorithm:
|
|
740
|
+
algorithm: ephemeral
|
|
735
741
|
? "sha256-source-ephemeral/v4"
|
|
736
742
|
: "sha256-source-captures/v5",
|
|
737
|
-
digest: digestSync(JSON.stringify(identities))
|
|
743
|
+
digest: digestSync(JSON.stringify(identities)),
|
|
744
|
+
...(ephemeral && sourceComparable
|
|
745
|
+
? {
|
|
746
|
+
sourceDigest: digestSync(JSON.stringify(identities.map(([path, identity]) => [path, {
|
|
747
|
+
_tag: identity._tag,
|
|
748
|
+
algorithm: identity.algorithm,
|
|
749
|
+
digest: identity.sourceDigest ?? identity.digest
|
|
750
|
+
}])))
|
|
751
|
+
}
|
|
752
|
+
: {})
|
|
738
753
|
}
|
|
739
754
|
}
|
|
740
755
|
|