@smthrs/flow 1.0.0-rc.3 → 1.0.0-rc.5

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.
@@ -1 +1 @@
1
- {"version":3,"file":"Graph.d.ts","sourceRoot":"","sources":["../../src/Graph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AAIH,OAAO,EAAE,eAAe,EAAqB,MAAM,8BAA8B,CAAA;AAEjF,OAAO,KAAK,IAAI,MAAM,mBAAmB,CAAA;AACzC,OAAO,KAAK,KAAK,IAAI,MAAM,mBAAmB,CAAA;AAQ9C,OAAO,KAAK,WAAW,MAAM,uBAAuB,CAAA;AAEpD,OAAO,KAAK,KAAK,IAAI,MAAM,gBAAgB,CAAA;AAE3C,OAAO,KAAK,eAAe,MAAM,+BAA+B,CAAA;AAKhE;;;;;;;GAOG;AACH,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,cAAc,GAAG,SAAS,CAAA;AAE7D;;;;;;GAMG;AACH,MAAM,WAAW,IAAI;IACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAA;CAC5B;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;IAC/B,QAAQ,CAAC,YAAY,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;IAC5C,QAAQ,CAAC,YAAY,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;IAC5C,QAAQ,CAAC,kBAAkB,EAAE,aAAa,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAA;IACjE,QAAQ,CAAC,SAA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AE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IAC9E,QAAQ,CAAC,WAAW,EAAE,aAAa,CAAC;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IACxF,oEAAoE;IACpE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CACzB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,OAAO,GAAI,MAAM,IAAI,CAAC,GAAG,KAAG,UAkDxC,CAAA"}
package/dist/cjs/Graph.js CHANGED
@@ -986,6 +986,7 @@ const drafts = (graph) => {
986
986
  const diagnostics = (graph) => graph.diagnostics;
987
987
  const inspect = (flow) => {
988
988
  const prompt = "prompt" in flow && typeof flow.prompt === "function" ? Function.prototype.toString.call(flow.prompt) : void 0;
989
+ const withPrompt = (inspection) => prompt === void 0 ? inspection : { ...inspection, prompt };
989
990
  try {
990
991
  const graph = build(flow, Planned.make("input"));
991
992
  const nodes2 = graph.nodes.map((node) => ({
@@ -997,15 +998,14 @@ const inspect = (flow) => {
997
998
  const steps = graph.nodes.flatMap(
998
999
  (node) => node.ast._tag === "ActionCall" ? [{ id: node.id, label: node.ast.action }] : node.ast._tag === "FlowCall" && node.ast.mode !== "inline" ? [{ id: node.id, label: node.ast.flow }] : []
999
1000
  );
1000
- return {
1001
+ return withPrompt({
1001
1002
  nodes: nodes2,
1002
1003
  edges: graph.edges,
1003
1004
  steps,
1004
- diagnostics: graph.diagnostics.map(({ code, message }) => ({ code, message })),
1005
- ...prompt === void 0 ? {} : { prompt }
1006
- };
1005
+ diagnostics: graph.diagnostics.map(({ code, message }) => ({ code, message }))
1006
+ });
1007
1007
  } catch (error) {
1008
- return {
1008
+ return withPrompt({
1009
1009
  // The declaration itself is a known boundary even when its internals
1010
1010
  // require real input. Do not publish a fictitious empty execution.
1011
1011
  nodes: [{ id: "root", kind: "FlowCall", label: flow._tag, dependencies: [] }],
@@ -1014,9 +1014,8 @@ const inspect = (flow) => {
1014
1014
  diagnostics: [{
1015
1015
  code: error instanceof import_GraphBuildError.GraphBuildError ? error.code === "planned_value_computed" ? "declaration_requires_input" : error.code : "declaration_inspection_failed",
1016
1016
  message: error instanceof Error ? error.message : String(error)
1017
- }],
1018
- ...prompt === void 0 ? {} : { prompt }
1019
- };
1017
+ }]
1018
+ });
1020
1019
  }
1021
1020
  };
1022
1021
  //# sourceMappingURL=Graph.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/Graph.ts"],
4
- "sourcesContent": ["/**\n * Graph building: a flow declaration plus a real payload, walked once into the\n * drafts a plan is compiled from.\n *\n * This is the plan phase of `docs/concepts/bodies-and-plans.md` and nothing\n * else \u2014 no I/O, no execution, no elaboration. {@link build} evaluates the\n * body with the REAL payload, because a body's own payload is data\n * (`docs/concepts/flows-and-actions.md`), and evaluates every\n * continuation and branch arm exactly once against a STRICT\n * {@link module:Planned.Planned} placeholder, because a step result does not\n * exist yet. A body that computes on a placeholder therefore fails here,\n * naming the node, rather than baking `NaN` into a plan.\n *\n * Fatal refusals stay fatal. Computing on a planned value throws its\n * `GraphBuildError` immediately, as does recursively expanding an inline\n * `.call()`, because either case makes the requested graph invalid. Recoverable\n * topology loss, such as a missing or invalid continuation, is reported in\n * {@link Graph.diagnostics} so the remaining graph can still be inspected.\n *\n * The walk is stack-safe by construction: topology and payloads are traversed\n * with explicit stacks, never native recursion, and each carries a nesting\n * bound. Topology past the bound is a typed `graph_too_deep` refusal, a\n * payload past it is `payload_too_deep`, and a payload containing itself is\n * `cyclic_payload` \u2014 all three fail loudly where unbounded recursion would\n * overflow the native stack without a typed error.\n *\n * Composition follows the same note: `Other.call(payload)` splices the\n * callee's body into this graph with the capabilities of the two declarations\n * intersected, and a flow that calls itself inline throws with the trampoline\n * (`docs/concepts/trampoline-rounds.md`) and the child boundary as the two\n * ways out. A callee whose declared placement the enclosing flow does not carry\n * throws for the same reason and names the same way out, because inline\n * expansion is the claim that these steps run in the caller's execution.\n * `Other.child(payload)` is that boundary: one leaf node here, its own\n * execution when the graph is driven. A branch expands BOTH arms, so the\n * exit condition and the handoff site are visible topology before anything\n * runs, and the predicate rides the branch's key material as a digest.\n *\n * What comes out is `@smthrs/plan` shaped: {@link Graph.drafts} feeds\n * `Plan.compile` and `Plan.append` unchanged, and the `Ref`/`Pending` inputs a\n * node's key material names are what the compiler turns into dependency\n * digests and the plan turns into edges. Structural node ids are derived only\n * from traversal positions and do not enter a plan draft's hashed value, so\n * editing a mapper re-keys exactly what reads it. The interpreter does use an\n * `ActionCall` id as durable dispatch-site material: it is the replay-stable\n * discriminator that keeps identical declarations at distinct graph\n * positions out of one arrival-ordered ordinal scope.\n *\n * Adapted from the agent repo's `@smthrs/core` `Graph.ts`. The lenient\n * placeholder, the model-shaped `Dynamic` node, the lane-merge elaboration,\n * and the conflict pass do not come across: the placeholder is strict here,\n * a model call is an ordinary action, and write overlap is resolved by\n * `Plan.compile`, which owns that verdict.\n *\n * @since 0.1.0\n */\n\nimport * as Capability from \"@smthrs/capability/Capability\"\nimport * as Effects from \"@smthrs/plan/Effects\"\nimport { GraphBuildError, isFatalDiagnostic } from \"@smthrs/plan/GraphBuildError\"\nimport * as KeyMaterial from \"@smthrs/plan/KeyMaterial\"\nimport * as Node from \"@smthrs/plan/Node\"\nimport type * as Plan from \"@smthrs/plan/Plan\"\nimport * as Planned from \"@smthrs/plan/Planned\"\nimport * as Context from \"effect/Context\"\nimport * as Option from \"effect/Option\"\nimport * as Predicate from \"effect/Predicate\"\nimport * as Schema from \"effect/Schema\"\nimport type * as Action from \"./Action/Action.ts\"\nimport { TypeId as ActionTypeId } from \"./Action/TypeId.ts\"\nimport * as Annotations from \"./Flow/Annotations.ts\"\nimport { capabilityCeilings } from \"./Flow/CapabilityCeiling.ts\"\nimport type * as Flow from \"./Flow/Flow.ts\"\nimport { TypeId as FlowTypeId } from \"./Flow/TypeId.ts\"\nimport * as DeclarationSite from \"./internal/DeclarationSite.ts\"\nimport { OutcomeNodeTypeId, OutcomeValueTypeId } from \"./internal/OutcomeMarker.ts\"\n\ntype OutcomeTag = \"Done\" | \"To\" | \"Park\"\n\n/**\n * Why one node depends on another: `value` consumes a result, `continuation`\n * is the sequencing edge a builder or a branch arm records against the\n * upstream node it was evaluated with.\n *\n * @since 0.1.0\n * @category models\n */\nexport type EdgeReason = \"value\" | \"continuation\" | \"failure\"\n\n/**\n * A dependency edge, pointing from the node that produces to the node that\n * consumes.\n *\n * @since 0.1.0\n * @category models\n */\nexport interface Edge {\n readonly from: string\n readonly to: string\n readonly reason: EdgeReason\n}\n\n/**\n * One observed node: its structural address, the AST variant it came from, and\n * the {@link module:Plan.NodeDraft} the plan is compiled from.\n *\n * `kind` is the authoring variant, not the plan's node kind \u2014 every draft a\n * graph produces is a plan `step`.\n *\n * @since 0.1.0\n * @category models\n */\nexport interface GraphNode {\n readonly id: string\n readonly kind: Node.Ast[\"_tag\"]\n readonly dependencies: ReadonlyArray<string>\n readonly capabilities: ReadonlyArray<string>\n readonly capabilityCeilings: ReadonlyArray<ReadonlyArray<string>>\n readonly placement: unknown\n readonly draft: Plan.NodeDraft\n /**\n * The authoring node this graph node was observed at.\n *\n * Key material digests a mapper, a predicate, and a callee's schemas; it\n * cannot carry them, because a digest is not a function. A driver that has\n * the real values in hand needs the functions themselves, so the AST rides\n * along: {@link module:Node.mapper}, {@link module:Node.predicate}, and the\n * member names of an `All` are read off it. The entry node a flow is entered\n * as is the call the graph synthesized, carrying the real payload rather than\n * the inert form an authored call records.\n */\n readonly ast: Node.Ast\n /**\n * What this node passes on, hydrated: real data where the author wrote data,\n * and a {@link module:Planned.Planned} placeholder where a step result goes.\n * It is the call payload of an `ActionCall` or a `FlowCall`, the value of a\n * `Succeed`, the error of a `Fail`, and `undefined` for every other variant,\n * which passes nothing of its own.\n */\n readonly payload: unknown\n /**\n * Where the declaration this node was observed at was written, when the\n * runtime's stack format says so.\n *\n * Provenance, never identity: it is carried on the declaration as a\n * non-enumerable property, so it is outside key material and a node keyed\n * with it is byte-identical to the same node keyed without it. A node with\n * no declaration to read \u2014 a map, a combination, an untagged succeed \u2014 has\n * none, and so does a declaration made inside the framework itself.\n */\n readonly declaredAt?: DeclarationSite.DeclaredAt | undefined\n}\n\n/**\n * What a pure per-node layer resolver is told. It is the identity of the\n * implementation a node would run against \u2014 hosts, services, permission\n * implementations \u2014 never a layer value or a runtime handle.\n *\n * @since 0.1.0\n * @category models\n */\nexport interface LayerRequest {\n readonly nodeId: string\n readonly kind: Node.Ast[\"_tag\"]\n readonly capabilities: ReadonlyArray<string>\n readonly effects: Annotations.Effects | undefined\n readonly placement: unknown\n}\n\n/**\n * The knobs {@link build} takes. `resolveLayers` is invoked once per node and\n * must be pure: planning performs no I/O, and a resolver that read the world\n * would make a plan a function of more than its declarations.\n *\n * @since 0.1.0\n * @category models\n */\nexport interface BuildOptions {\n readonly resolveLayers?: ((request: LayerRequest) => Iterable<string>) | undefined\n /**\n * `stable` refuses process-local flow bodies, mappers, predicates, and\n * continuation builders before drafts can be compiled or actions driven.\n * Declare every semantic capture with `Node.capture`; include an explicit\n * implementation version for imported behavior not represented by the\n * callback source. The default, `process-local`, supports inspection and\n * experimentation but does not promise reproducible plan identity.\n *\n * This validates callback identity only. Action implementations and resolved\n * layers still need their own semantic identity contract.\n */\n readonly callbackIdentity?: \"stable\" | \"process-local\" | undefined\n /**\n * The address the entry node is recorded under, `root` by default. A plan\n * grows by appending, and `Plan.append` refuses an id it already holds, so an\n * elaboration built for an existing plan names its own root.\n */\n readonly root?: string | undefined\n}\n\n/**\n * A built graph: the nodes in dependency order, the edges between them, and the\n * refusals that were recoverable enough to report rather than throw.\n *\n * DECIDED: the drafts are NOT a field here. They\n * are derived from `nodes`, and the derivation carries a refusal \u2014 a graph with\n * diagnostics is inspectable but not compilable \u2014 so {@link drafts} is the only\n * way to ask for them. A field beside the accessor was a second, silent answer\n * to the same question: reading `graph.drafts` handed back the truncated drafts\n * of an incomplete graph while `Graph.drafts(graph)` threw on it. Effect keeps\n * data interfaces plain and puts the policy in the accessor, so the field goes\n * rather than growing a getter that throws from inside a `readonly` record.\n *\n * @since 0.1.0\n * @category models\n */\nexport interface Graph {\n readonly nodes: ReadonlyArray<GraphNode>\n readonly edges: ReadonlyArray<Edge>\n readonly diagnostics: ReadonlyArray<GraphBuildError>\n}\n\n/**\n * The declared-action fields graph building reads. Only `Action.make`'s\n * declared form produces an `ActionCall`, so a call node's declaration is\n * one of these whenever the side table still holds it.\n *\n * @private\n */\ninterface ActionDeclaration {\n readonly name: string\n readonly implementationVersion?: string | undefined\n readonly payloadSchema: Schema.Top\n readonly successSchema: Schema.Top\n readonly errorSchema: Schema.Top\n readonly tier: Action.Tier\n readonly nondeterministic: true | undefined\n readonly annotations: Context.Context<never>\n}\n\n/**\n * The inert record `Node`'s AST keeps where a planned placeholder was.\n *\n * @private\n */\ninterface PlannedRecord {\n readonly node: string\n readonly path: ReadonlyArray<string>\n}\n\n/**\n * What a node that declared nothing contributes: it claims no path either way,\n * so `expected` is the honest default.\n *\n * @private\n */\nconst emptyEffects: Plan.NodeEffects = { reads: [], writes: [], boundaryMode: \"expected\" }\n\n/** @private */\nconst sorted = (values: Iterable<string>): ReadonlyArray<string> => [...new Set(values)].sort()\n\n/** @private */\nconst flowDeclaration = (value: unknown): Flow.Any | undefined =>\n Predicate.hasProperty(value, FlowTypeId) ? value as unknown as Flow.Any : undefined\n\n/** @private */\nconst actionDeclaration = (value: unknown): ActionDeclaration | undefined =>\n Predicate.hasProperty(value, ActionTypeId) ? value as unknown as ActionDeclaration : undefined\n\n/** @private */\nconst declaredEffects = (annotations: Context.Context<never>): Annotations.Effects | undefined =>\n Option.getOrUndefined(Context.getOption(annotations, Annotations.EffectsDeclaration))\n\n/** @private */\nconst declaredPlacement = (annotations: Context.Context<never>): unknown =>\n Option.getOrUndefined(Context.getOption(annotations, Annotations.Placement))\n\n/** @private */\nconst declaredEnvelope = (annotations: Context.Context<never>): Effects.Declaration | undefined =>\n Option.getOrUndefined(Context.getOption(annotations, Annotations.EffectEnvelope))\n\n/**\n * What an author reads when a declaration claimed more authority than the one\n * enclosing it granted. Each of the three states the claim, names the flow\n * whose envelope it escaped, and says the one thing that fixes it, because an\n * author who widened an envelope by accident needs the narrowing, not a\n * classification.\n *\n * @private\n */\nconst refusalMessage = (\n narrowed: Extract<Effects.NarrowResult, { readonly ok: false }>,\n site: { readonly id: string; readonly flow: string }\n): string => {\n const at = `\"${site.flow}\" at \"${site.id}\"`\n switch (narrowed.code) {\n case \"effect_outside_envelope\":\n return `Flow ${at} declares ${narrowed.paths.length === 1 ? \"a path\" : \"paths\"} its caller's effect ` +\n `envelope does not cover: ${narrowed.paths.join(\", \")}. Widen the caller's declared effects to cover ` +\n \"them, or narrow this declaration to what the envelope already allows.\"\n case \"effect_mode_widening\":\n return `Flow ${at} declares an expected effect mode inside a hermetic envelope. A hermetic envelope is ` +\n \"the claim that every effect beneath it is declared, so the callee has to declare a hermetic mode too.\"\n case \"effect_tier_widening\":\n return `Flow ${at} declares an effect tier its caller's envelope does not permit. A tier may only narrow ` +\n \"from irreversible to compensable to sealed, so raise the caller's tier or lower this one.\"\n }\n}\n\n/**\n * The declaration identity that enters a call node's hashed body: what the\n * callee accepts and produces, so a schema change re-keys the call.\n *\n * The identity is JSON-Schema-SHAPED, and that is its stated limit. Two\n * schemas whose decoders disagree can serialize to the same document, because\n * an effect transformation carries behaviour a JSON Schema document does not\n * describe. Changing only a codec's behaviour therefore does NOT re-key the\n * call, and a cached or recorded result computed under the old codec is\n * replayed under the new one. No fingerprint can close this automatically:\n * effect codecs are not serializable, so the identity would have to be\n * author-supplied. Until a declaration carries one, an author who changes a\n * transformation and needs the call re-keyed renames the declaration.\n * `@smthrs/core` carries the same algorithm and the same limit.\n *\n * @private\n */\nconst schemaIdentity = (schema: Schema.Top): unknown => {\n const cached = schemaDocuments.get(schema)\n if (cached !== undefined) return cached\n const document = Schema.toJsonSchemaDocument(schema, { onExcessProperty: \"error\" })\n schemaDocuments.set(schema, document)\n return document\n}\n\n/**\n * One document per schema object. A document is a pure function of the\n * schema's AST and schemas are immutable, so every node and every build that\n * names the same declaration reuses the document rather than regenerating it.\n *\n * @private\n */\nconst schemaDocuments = new WeakMap<Schema.Top, unknown>()\n\n/** @private */\nconst isPlainObject = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null &&\n (Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null)\n\n/**\n * The reference a value stands for, whether it is a live placeholder \u2014 a real\n * payload may carry one, naming a node an earlier generation already planned \u2014\n * or the inert record an AST payload kept.\n *\n * @private\n */\nconst referenceOf = (value: unknown): PlannedRecord | undefined => {\n const live = Planned.reference(value)\n if (live !== undefined) return live\n return Node.plannedReference(value)\n}\n\n/** @private */\nconst outcomeTagOf = (ast: Node.Ast): OutcomeTag | undefined => {\n const descriptor = Object.getOwnPropertyDescriptor(ast, OutcomeNodeTypeId)\n if (descriptor === undefined || !(\"value\" in descriptor)) return undefined\n const value = descriptor.value\n return value === \"Done\" || value === \"To\" || value === \"Park\" ? value : undefined\n}\n\n/**\n * Rebuilds the strict placeholder a reference names, so a spliced body sees\n * the same refusals an inline body does.\n *\n * @private\n */\nconst placeholder = (reference: PlannedRecord, node: string): unknown =>\n reference.path.reduce<unknown>(\n (value, key) => (value as Record<string, unknown>)[key],\n Planned.make<unknown>(node)\n )\n\n/**\n * The nesting bound the build enforces on authored topology. The walk itself\n * is iterative and cannot overflow the native stack, so the bound is policy:\n * topology a thousand combinators deep is a generated artifact, and refusing\n * it with a typed `graph_too_deep` names the fix \u2014 `.child()` boundaries or\n * trampoline handoffs \u2014 where unbounded acceptance would only defer the\n * failure to whatever walks the plan next.\n *\n * It is EXPORTED so a composition that unrolls its own topology, as\n * `@smthrs/patterns` does for a bounded loop, refuses at the same number the\n * build enforces instead of restating it and drifting.\n *\n * @since 0.1.0\n * @category models\n */\nexport const maximumGraphDepth = 1_000\n\n/**\n * The nesting bound the build enforces on payload data, for the same reason\n * {@link maximumGraphDepth} bounds topology: hydration, hashing, and reference\n * scanning walk iteratively, and the bound turns a pathologically deep payload\n * into a typed `payload_too_deep` refusal instead of an unbounded walk over\n * data a plan would have to hash and store level by level.\n *\n * @private\n */\nconst maximumPayloadDepth = 1_000\n\n/**\n * How one payload walk behaves: where it is walking, for refusal attribution;\n * how a placeholder-like leaf resolves; and the member order of a plain\n * object.\n *\n * @private\n */\ninterface PayloadWalk {\n readonly at: string\n readonly resolve: (value: unknown) => { readonly value: unknown } | undefined\n readonly keysOf: (keys: ReadonlyArray<string>) => ReadonlyArray<string>\n}\n\n/**\n * One container being walked: the source, the copy being filled, and the\n * member position reached. `keys` is `undefined` for an\n * array, whose members are positional.\n *\n * @private\n */\ninterface PayloadFrame {\n readonly source: Record<string, unknown> | ReadonlyArray<unknown>\n readonly keys: ReadonlyArray<string> | undefined\n readonly members: ReadonlyArray<unknown>\n readonly output: Record<string, unknown> | Array<unknown>\n index: number\n}\n\n/** @private */\nconst container = (\n value: unknown,\n at: string\n): Record<string, unknown> | ReadonlyArray<unknown> | undefined => {\n if (Array.isArray(value)) return value\n if (typeof value !== \"object\" || value === null) return undefined\n try {\n return isPlainObject(value) ? value : undefined\n } catch {\n throw new GraphBuildError({\n code: \"invalid_payload\",\n node: at,\n path: [],\n message: `Payload at \"${at}\" does not expose an inert object prototype.`\n })\n }\n}\n\n/**\n * Walks one payload with an explicit stack. Real recursion would let a deep\n * payload overflow the native stack instead of failing loudly, so depth is a\n * typed refusal here: a value already on the ancestor chain is\n * `cyclic_payload`, and nesting past {@link maximumPayloadDepth} is\n * `payload_too_deep`. Values that are neither placeholders nor plain data\n * pass through untraversed to the key canonicalizer, which is the one\n * component entitled to refuse them.\n *\n * Rebuilding writes members with a null-prototype target and\n * `defineProperty`, never `output[key] = \u2026`: `__proto__` routes through\n * `Object.prototype`'s accessor, so an own `__proto__` field whose value is a\n * primitive would be silently DROPPED and one whose value is an object would\n * reparent the copy instead of being recorded on it. A payload may carry that\n * key \u2014 `JSON.parse` produces it as an own data property \u2014 and both outcomes\n * are wrong here: a hydrated payload would be planned and run with a field\n * its author wrote missing, and two payloads that differ only in that field\n * would hash to one key. `@smthrs/plan`'s AST cloner answers this the\n * same way.\n *\n * @private\n */\nconst walkPayload = (root: unknown, walk: PayloadWalk): unknown => {\n const resolvedRoot = walk.resolve(root)\n if (resolvedRoot !== undefined) return resolvedRoot.value\n const rootContainer = container(root, walk.at)\n if (rootContainer === undefined) return root\n const open = (source: Record<string, unknown> | ReadonlyArray<unknown>): PayloadFrame => {\n const descriptors = (() => {\n try {\n return Object.getOwnPropertyDescriptors(source)\n } catch {\n throw new GraphBuildError({\n code: \"invalid_payload\",\n node: walk.at,\n path: [],\n message: `Payload at \"${walk.at}\" does not expose inert own properties.`\n })\n }\n })()\n if (Array.isArray(source)) {\n const members = Array.from({ length: source.length }, (_, index) => {\n const descriptor = descriptors[String(index)]\n if (descriptor === undefined) return undefined\n if (!(\"value\" in descriptor)) {\n throw new GraphBuildError({\n code: \"invalid_payload\",\n node: walk.at,\n path: [String(index)],\n message: `Payload at \"${walk.at}\" contains an accessor at index ${index}. Pass inert data.`\n })\n }\n return descriptor.value\n })\n return { source, keys: undefined, members, output: [], index: 0 }\n }\n const keys = walk.keysOf(\n Object.keys(descriptors).filter((key) => descriptors[key]?.enumerable === true)\n )\n const members = keys.map((key) => {\n const descriptor = descriptors[key]!\n if (!(\"value\" in descriptor)) {\n throw new GraphBuildError({\n code: \"invalid_payload\",\n node: walk.at,\n path: [key],\n message: `Payload at \"${walk.at}\" contains accessor property \"${key}\". Pass inert data.`\n })\n }\n return descriptor.value\n })\n return {\n source,\n keys,\n members,\n output: Object.create(null) as Record<string, unknown>,\n index: 0\n }\n }\n const rootFrame = open(rootContainer)\n const frames: Array<PayloadFrame> = [rootFrame]\n const ancestors = new Set<object>([rootContainer])\n while (frames.length > 0) {\n const frame = frames[frames.length - 1]!\n if (frame.index >= frame.members.length) {\n frames.pop()\n ancestors.delete(frame.source)\n continue\n }\n const position = frame.index\n frame.index = position + 1\n const key = frame.keys?.[position]\n const member = frame.members[position]\n const place = (produced: unknown): void => {\n if (key === undefined) {\n const members = frame.output as Array<unknown>\n members.push(produced)\n return\n }\n Object.defineProperty(frame.output, key, {\n configurable: true,\n enumerable: true,\n value: produced,\n writable: true\n })\n }\n const resolved = walk.resolve(member)\n if (resolved !== undefined) {\n place(resolved.value)\n continue\n }\n const nested = container(member, walk.at)\n if (nested === undefined) {\n place(member)\n continue\n }\n if (ancestors.has(nested)) {\n throw new GraphBuildError({\n code: \"cyclic_payload\",\n node: walk.at,\n path: [],\n message: `Payload at \"${walk.at}\" contains itself, so no plan can hash or serialize it. Pass acyclic data.`\n })\n }\n if (frames.length >= maximumPayloadDepth) {\n throw new GraphBuildError({\n code: \"payload_too_deep\",\n node: walk.at,\n path: [],\n message: `Payload at \"${walk.at}\" nests more than ${maximumPayloadDepth} levels deep. ` +\n \"Flatten the payload: a plan hashes and stores every level of it.\"\n })\n }\n const opened = open(nested)\n place(opened.output)\n ancestors.add(nested)\n frames.push(opened)\n }\n return rootFrame.output\n}\n\n/**\n * Turns an AST payload back into what a body must see: real data where the\n * caller wrote data, strict placeholders where it passed a step result. The\n * substitution rewrites a branch's own subject token to its upstream node, and\n * a catch's own subject token to the node it protects, which are those arms'\n * subjects by construction.\n *\n * @private\n */\nconst hydrate = (value: unknown, substitutions: ReadonlyMap<string, string>, at: string): unknown =>\n walkPayload(value, {\n at,\n keysOf: (keys) => keys,\n resolve: (member) => {\n const reference = referenceOf(member)\n return reference === undefined\n ? undefined\n : { value: placeholder(reference, substitutions.get(reference.node) ?? reference.node) }\n }\n })\n\n/**\n * The hashed form of a payload: placeholders keep their property path and drop\n * the node they came from, because the node id is a lookup address and the\n * dependency itself is named by a separate `Ref`. The same walk collects every\n * upstream result the payload reads into `found`, in sorted-key order, so a\n * payload is canonicalized once rather than walked again for its references.\n *\n * @private\n */\nconst literal = (value: unknown, found: Array<PlannedRecord>, at: string): unknown =>\n walkPayload(value, {\n at,\n keysOf: (keys) => [...keys].sort(),\n resolve: (member) => {\n const reference = Planned.reference(member)\n if (reference === undefined) return undefined\n found.push(reference)\n return { value: { _tag: \"PlannedInput\", path: [...reference.path] } }\n }\n })\n\n/**\n * Whether an inline call would place the callee somewhere the enclosing flow\n * cannot run it.\n *\n * A placement directive is opaque to this package \u2014 `Annotations.Placement` is\n * `Schema.Unknown`, and interpreting it is a scheduler's job \u2014 so the only\n * verdict available here is identity: the same directive is satisfiable, a\n * different one is not. The local comparison has the structural semantics of a\n * canonicalized literal without serializing it: arrays compare by length and\n * element, objects by their own enumerable keys independent of key order, and\n * primitives by `Object.is`. That makes `NaN` equal to itself and cheaply keeps\n * `-0` distinct from `0`. A visited-pair map terminates cyclic object graphs.\n *\n * Identity is claimed only over data the comparison can read inertly. Two\n * distinct objects are identical only when both are plain \u2014 an ordinary object\n * literal or a null-prototype object, or two arrays \u2014 and only through own data\n * properties: a `Date`, `Map`, `RegExp`, class instance, or function is\n * identical to itself by reference and to nothing else, and an accessor-backed\n * key is identical to nothing at all, because reading it would run author code\n * during graph building. Every one of those is a REFUSAL to prove identity, so\n * the call is pushed to an explicit `.child()` boundary rather than admitted\n * inline against a placement nobody checked. A `Proxy` over a plain object\n * still observes the key and descriptor reads; making the directive inert\n * before it is compared is the remaining half of that hardening.\n *\n * Identity over a CYCLIC directive is bisimulation: the visited-pair map makes\n * two directives identical when they unfold to the same infinite tree, so a\n * self-cycle and a two-node cycle of the same shape are the same directive.\n * Cycle lengths that share no factor pair off against each other for their\n * least common multiple of comparisons, which is what\n * {@link maxComparisonPairs} bounds.\n *\n * DECIDED: an enclosing flow that declares NO\n * placement is unconstrained and satisfies any callee, rather than satisfying\n * only a callee that declares none. Inline expansion runs the callee's steps in\n * the caller's execution, so the constraint that matters is the one the caller\n * already carries; refusing an undeclared caller would make `Flow.Placement`\n * mandatory on every flow in a call chain to keep `.call()` usable.\n *\n * @private\n */\nconst structuralIdentity = (left: unknown, right: unknown): boolean => {\n const pending: Array<readonly [unknown, unknown]> = [[left, right]]\n const visited = new WeakMap<object, WeakSet<object>>()\n let examined = 0\n try {\n while (pending.length > 0) {\n const [left, right] = pending.pop()!\n if (++examined > maxComparisonPairs) return false\n if (Object.is(left, right)) continue\n if (left !== Object(left)) return false\n if (right !== Object(right)) return false\n const leftObject = left as object\n const rightObject = right as object\n const leftIsArray = Array.isArray(leftObject)\n if (leftIsArray !== Array.isArray(rightObject)) return false\n if (\n leftIsArray && (leftObject as ReadonlyArray<unknown>).length !== (rightObject as ReadonlyArray<unknown>).length\n ) {\n return false\n }\n const seen = visited.get(leftObject) ?? new WeakSet<object>()\n if (seen.has(rightObject)) continue\n seen.add(rightObject)\n visited.set(leftObject, seen)\n if (!leftIsArray && !(isPlainObject(leftObject) && isPlainObject(rightObject))) return false\n const leftKeys = Reflect.ownKeys(leftObject).filter((key) =>\n Object.prototype.propertyIsEnumerable.call(leftObject, key)\n )\n const rightKeys = Reflect.ownKeys(rightObject).filter((key) =>\n Object.prototype.propertyIsEnumerable.call(rightObject, key)\n )\n if (leftKeys.length !== rightKeys.length) return false\n for (const key of leftKeys) {\n if (!Object.prototype.propertyIsEnumerable.call(rightObject, key)) return false\n // Descriptors rather than `Reflect.get`: a getter is author code, and\n // graph building must not run it.\n const leftMember = Object.getOwnPropertyDescriptor(leftObject, key)!\n const rightMember = Object.getOwnPropertyDescriptor(rightObject, key)!\n if (!(\"value\" in leftMember) || !(\"value\" in rightMember)) return false\n pending.push([leftMember.value, rightMember.value])\n }\n }\n } catch {\n // Every reflection above is a Proxy trap, and a trap is author code that\n // may throw. Graph building must not fail with whatever it threw, so an\n // unreadable directive gets the verdict every other one gets: identity is\n // not proved, and the call goes to an explicit `.child()` boundary.\n return false\n }\n return true\n}\n\n/**\n * The most value pairs one placement comparison examines before giving up.\n *\n * A directive is author data walked at planning time, so the comparison needs a\n * ceiling that does not depend on how large or how cyclic that data is.\n * Exhausting the ceiling is a refusal to prove identity, not a claim that the\n * two directives differ.\n *\n * @private\n */\nconst maxComparisonPairs = 100_000\n\n/** @private */\nconst placementConflicts = (enclosing: unknown, callee: unknown): boolean =>\n enclosing !== undefined && callee !== undefined && !structuralIdentity(enclosing, callee)\n\n/** The most characters one rendered placement contributes to a diagnostic. */\nconst maxPlacementChars = 240\n\n/** How many levels of a placement a diagnostic renders before eliding. */\nconst maxPlacementDepth = 4\n\n/**\n * How many members of one array or object a diagnostic renders.\n *\n * An array's cost is its LENGTH, not its member count: `new Array(100_000)` owns\n * no properties and still renders a hundred thousand separators without this\n * bound, so a directive a byte long becomes a diagnostic megabytes long.\n */\nconst maxPlacementMembers = 32\n\n/**\n * A bounded, inert rendering of a placement directive, for the refusal that\n * names it.\n *\n * An author who declared two placements needs to see WHICH two the build\n * compared and how they differ, so the refusal prints both. The directive is\n * arbitrary author data, so this holds to exactly the discipline\n * {@link structuralIdentity} holds to: own enumerable data properties only,\n * never an accessor, plain objects and arrays walked and everything else named\n * by kind, under a depth bound, a cycle guard, and a length bound so a large\n * directive cannot become the whole message. Array indices are read as\n * descriptors rather than iterated, because iteration invokes an index getter;\n * a hole renders as `<hole>`. Both arrays and objects render at most\n * {@link maxPlacementMembers} members and mark the rest `<more>`, so the work\n * is bounded before the string is truncated rather than after. Object members\n * are sorted, so two directives that differ only in key order render\n * identically, matching the comparison that admitted them. It never throws.\n *\n * @private\n */\nconst renderPlacement = (value: unknown): string => {\n const render = (value: unknown, depth: number, seen: ReadonlyArray<object>): string => {\n if (typeof value === \"string\") return JSON.stringify(value)\n if (typeof value === \"bigint\") return `${value}n`\n if (Object(value) !== value) return String(value)\n const object = value as object\n if (seen.includes(object)) return \"<cycle>\"\n if (depth === maxPlacementDepth) return \"<elided>\"\n const nested = [...seen, object]\n if (Array.isArray(object)) {\n const length = (object as ReadonlyArray<unknown>).length\n const shown = Math.min(length, maxPlacementMembers)\n const members: Array<string> = []\n for (let index = 0; index < shown; index++) {\n // `Array.prototype.map` invokes an index getter, so indices are read as\n // descriptors here for the same reason keys are below.\n const member = Object.getOwnPropertyDescriptor(object, String(index))\n members.push(\n member === undefined\n ? \"<hole>\"\n : \"value\" in member\n ? render(member.value, depth + 1, nested)\n : \"<accessor>\"\n )\n }\n if (length > shown) members.push(\"<more>\")\n return `[${members.join(\",\")}]`\n }\n if (!isPlainObject(object)) return Object.prototype.toString.call(object)\n const keys = Reflect.ownKeys(object)\n .filter((key) => Object.prototype.propertyIsEnumerable.call(object, key))\n .sort((left, right) => String(left).localeCompare(String(right)))\n // Select the bounded prefix before rendering values. Rendering every\n // member and slicing afterward still traverses the entire omitted forest.\n const members = keys.slice(0, maxPlacementMembers)\n .map((key) => {\n const member = Object.getOwnPropertyDescriptor(object, key)!\n const rendered = \"value\" in member ? render(member.value, depth + 1, nested) : \"<accessor>\"\n return `${String(key)}:${rendered}`\n })\n .sort()\n const shown = keys.length > maxPlacementMembers\n ? [...members, \"<more>\"]\n : members\n return `{${shown.join(\",\")}}`\n }\n\n try {\n const rendered = render(value, 0, [])\n return rendered.length <= maxPlacementChars\n ? rendered\n : `${rendered.slice(0, maxPlacementChars)} [${rendered.length - maxPlacementChars} characters dropped]`\n } catch {\n return \"<unrenderable>\"\n }\n}\n\n/**\n * The `Literal` a payload hashes as, followed by one `Ref` per distinct\n * upstream result it reads.\n *\n * @private\n */\nconst payloadInputs = (payload: unknown, at: string): ReadonlyArray<KeyMaterial.InputRef> => {\n const found: Array<PlannedRecord> = []\n const inputs: Array<KeyMaterial.InputRef> = [{ _tag: \"Literal\", value: literal(payload, found, at) }]\n const seen = new Set<string>()\n for (const reference of found) {\n const identity = JSON.stringify([reference.node, ...reference.path])\n if (seen.has(identity)) continue\n seen.add(identity)\n inputs.push({ _tag: \"Ref\", from: reference.node, path: [...reference.path] })\n }\n return inputs\n}\n\n/**\n * What one visit needs to know: where it is, how deeply it is nested, what it\n * may do, where it runs, which node the enclosing branch's subject stands\n * for, which flows are already being spliced, and the upstream node it\n * continues from.\n *\n * @private\n */\ninterface Visit {\n readonly ast: Node.Ast\n readonly id: string\n /**\n * How many visits enclose this one, checked against\n * {@link maximumGraphDepth}. The walk itself is an explicit operation stack\n * and cannot overflow, so the count exists to refuse pathological topology\n * with a typed error rather than accept it unbounded.\n */\n readonly depth: number\n readonly capabilities: ReadonlyArray<string>\n /**\n * The placement of the flow whose body this visit is inside, which an inline\n * call has to be satisfiable under.\n */\n readonly placement: unknown\n /**\n * The effect authority in force here: the nearest enclosing declaration that\n * was ACCEPTED, so a refused one does not widen what its siblings are checked\n * against. `undefined` means nothing above this node declared an envelope,\n * which is unconstrained rather than empty.\n */\n readonly envelope: Effects.Declaration | undefined\n /**\n * The scheduling priority in force here: the nearest enclosing node's, unless\n * this node states its own. It rides the walk rather than the AST because\n * inheritance is lexical \u2014 annotating a container prioritizes everything\n * beneath it that stayed silent.\n */\n readonly priority: number | undefined\n readonly substitutions: ReadonlyMap<string, string>\n readonly stack: ReadonlyArray<Flow.Any>\n readonly prerequisite: string | undefined\n /** Explicit andThen success barriers inherited by the entire subtree. */\n readonly barriers: ReadonlyArray<string>\n}\n\n/**\n * Builds the graph of a flow declaration, or of a bare node, by walking the\n * AST once.\n *\n * A flow is entered as a call to itself: the returned graph's `root` node is\n * that call, carrying the flow's declared effects, placement, and\n * capabilities, and its body spliced beneath it. Every flow has a body, so the\n * only inline call this leaves as a leaf is one whose declaration did not\n * survive serialization beside its AST.\n *\n * @since 0.1.0\n * @category constructors\n */\nexport const build = (\n flowOrNode: Flow.Any | Node.Any,\n payload?: unknown,\n options: BuildOptions = {}\n): Graph => {\n const observed: Array<GraphNode> = []\n const observedIds = new Set<string>()\n const observedEdges: Array<Edge> = []\n const observedDiagnostics: Array<GraphBuildError> = []\n\n const observeIdentity = (node: string, field: string, identity: Node.FunctionIdentity | undefined): void => {\n if (\n options.callbackIdentity !== \"stable\" ||\n (identity !== undefined && identity.algorithm !== \"sha256-source-ephemeral/v4\")\n ) return\n observedDiagnostics.push(\n new GraphBuildError({\n code: \"unstable_callback\",\n node,\n path: [field],\n message:\n `Callback ${field} at \"${node}\" has ${identity === undefined ? \"unavailable\" : \"process-local\"} identity ` +\n \"and cannot enter a stable graph. \" +\n \"Use Node.capture with every semantic capture, including the version of imported implementation behavior.\"\n })\n )\n }\n\n /**\n * The explicit walk stack. Every step is a thunk; expanding a node pushes\n * its steps in reverse so they pop in authoring order, which keeps the\n * observed nodes, edges, and diagnostics in exactly the order a recursive\n * walk would produce while making depth a data structure instead of native\n * stack frames a deep graph could exhaust.\n */\n const operations: Array<() => void> = []\n\n /** Stacks steps to run in the order written, ahead of everything stacked. */\n const sequence = (steps: ReadonlyArray<() => void>): void => {\n for (let index = steps.length - 1; index >= 0; index--) operations.push(steps[index]!)\n }\n\n const record = (entry: {\n readonly id: string\n readonly kind: Node.Ast[\"_tag\"]\n readonly dependencies: ReadonlyArray<string>\n readonly capabilities: ReadonlyArray<string>\n readonly effects: Annotations.Effects | undefined\n readonly placement: unknown\n readonly priority: number | undefined\n readonly tier: KeyMaterial.KeyMaterial[\"kind\"]\n readonly nondeterministic?: true | undefined\n readonly body: unknown\n readonly capabilityCeilings?: ReadonlyArray<ReadonlyArray<string>>\n readonly inputs: ReadonlyArray<KeyMaterial.InputRef>\n readonly ast: Node.Ast\n readonly payload: unknown\n readonly declaredAt?: DeclarationSite.DeclaredAt | undefined\n }): void => {\n if (observedIds.has(entry.id)) {\n throw new GraphBuildError({\n code: \"duplicate_node\",\n node: entry.id,\n path: [],\n message: `Node id \"${entry.id}\" is durable dispatch identity, so two nodes may not share one. ` +\n \"Two structural addresses in this graph collided, most often because a Node.all member name \" +\n \"contains the separator a nested address also produces. Rename one of them.\"\n })\n }\n observedIds.add(entry.id)\n const material: KeyMaterial.KeyMaterial = {\n version: KeyMaterial.version,\n kind: entry.tier,\n body: entry.capabilityCeilings?.length\n ? { ...entry.body as object, capabilityCeilings: entry.capabilityCeilings }\n : entry.body,\n inputs: entry.inputs,\n layers: sorted(\n options.resolveLayers?.({\n nodeId: entry.id,\n kind: entry.kind,\n capabilities: entry.capabilities,\n effects: entry.effects,\n placement: entry.placement\n }) ?? []\n ),\n capabilities: entry.capabilities,\n ...(entry.nondeterministic === undefined ? {} : { nondeterministic: entry.nondeterministic }),\n ...(entry.effects === undefined ? {} : { effects: entry.effects }),\n ...(entry.placement === undefined ? {} : { placement: entry.placement })\n }\n observed.push({\n id: entry.id,\n kind: entry.kind,\n dependencies: entry.dependencies,\n capabilities: entry.capabilities,\n capabilityCeilings: entry.capabilityCeilings ?? [],\n placement: entry.placement,\n // Priority reaches the compiled plan through the draft and stays OUT of\n // `material`: it orders ready work without changing what the work\n // produces, so raising it must not re-key a step.\n draft: {\n id: entry.id,\n material,\n effects: entry.effects ?? emptyEffects,\n ...(entry.priority === undefined ? {} : { priority: entry.priority })\n },\n ast: entry.ast,\n payload: entry.payload,\n ...(entry.declaredAt === undefined ? {} : { declaredAt: entry.declaredAt })\n })\n }\n\n /**\n * An envelope is graph-owned and reaches every node it encloses as the same\n * object, so it is read into its prepared form once and each enclosed\n * declaration is checked against that: a wide envelope costs its size once\n * per build rather than once per node that narrows it.\n */\n const preparedEnvelopes = new Map<Effects.Declaration, Effects.PreparedEnvelope>()\n\n /**\n * Checks one declaration against the envelope enclosing it, recording the\n * refusal and answering whether the declaration may become the envelope for\n * what it encloses in turn. A refused declaration must NOT replace the last\n * accepted one: widening beneath it would then be measured against the very\n * claim that was just rejected.\n */\n const admitEnvelope = (\n enclosing: Effects.Declaration | undefined,\n declared: Effects.Declaration | undefined,\n site: { readonly id: string; readonly flow: string }\n ): Effects.Declaration | undefined => {\n if (declared === undefined) return enclosing\n if (enclosing === undefined) return declared\n let prepared = preparedEnvelopes.get(enclosing)\n if (prepared === undefined) {\n prepared = Effects.prepareEnvelope(enclosing)\n preparedEnvelopes.set(enclosing, prepared)\n }\n const narrowed = Effects.narrowPrepared(prepared, declared)\n if (narrowed.ok) return declared\n observedDiagnostics.push(\n new GraphBuildError({\n code: narrowed.code,\n node: site.id,\n path: [...narrowed.paths],\n message: refusalMessage(narrowed, site)\n })\n )\n return enclosing\n }\n\n /**\n * Expands the node a flow call becomes, shared by the entry point and by\n * every `FlowCall` in a body.\n */\n const coveredCapability = (stack: ReadonlyArray<Flow.Any>, text: string): boolean => {\n const groups = stack.flatMap((flow) => capabilityCeilings(flow.annotations))\n if (groups.length === 0) return true\n const candidate = Capability.parsePattern(text)\n if (Option.isNone(candidate)) return false\n return groups.every((group) =>\n group.some((text) => {\n const grant = Capability.parsePattern(text)\n return Option.isSome(grant) && Capability.subsumes(grant.value, candidate.value)\n })\n )\n }\n\n const expandFlowCall = (call: {\n readonly id: string\n readonly depth: number\n readonly ast: Node.Ast\n readonly flow: string\n readonly mode: Node.CallMode\n readonly declaration: Flow.Any | undefined\n readonly payload: unknown\n readonly capabilities: ReadonlyArray<string>\n /** The placement of the flow this call is written inside. */\n readonly placement: unknown\n /** The effect authority in force at this call, which the callee must narrow. */\n readonly envelope: Effects.Declaration | undefined\n /** The priority in force at this call, already including the call's own. */\n readonly priority: number | undefined\n readonly substitutions: ReadonlyMap<string, string>\n readonly stack: ReadonlyArray<Flow.Any>\n readonly barriers: ReadonlyArray<string>\n readonly dependencies: Array<string>\n readonly inputs: ReadonlyArray<KeyMaterial.InputRef>\n }): void => {\n const annotations = call.declaration?.annotations ?? Context.empty()\n const dependencies = call.dependencies\n const inputs: Array<KeyMaterial.InputRef> = [...payloadInputs(call.payload, call.id), ...call.inputs]\n const target = call.mode === \"inline\" ? call.declaration : undefined\n const ceiling = sorted(capabilityCeilings(annotations)[0] ?? call.capabilities)\n const placement = declaredPlacement(annotations)\n const envelope = declaredEnvelope(annotations)\n // The authority checks are recorded, not thrown: a graph whose callee\n // claimed too much is still worth inspecting, and the author needs every\n // over-claim in the composition at once rather than the first one.\n //\n // They run for EVERY call mode. An explicit `.child()` boundary and a\n // trampoline handoff give the callee its own execution, not its own\n // authority: whoever writes the call is still the one granting it, which is\n // the rule `@smthrs/core`'s graph applies to a call whose body it does not\n // splice.\n const calleeEnvelope = admitEnvelope(call.envelope, envelope, { id: call.id, flow: call.flow })\n const dropped = ceiling.filter((capability) => !coveredCapability(call.stack, capability))\n if (dropped.length > 0) {\n observedDiagnostics.push(\n new GraphBuildError({\n code: \"capability_outside_grant\",\n node: call.id,\n path: dropped,\n message: `Flow \"${call.flow}\" at \"${call.id}\" requires ${dropped.join(\", \")}, which the calling flow ` +\n \"does not provably grant. Execution intersects this declaration with every caller ceiling.\"\n })\n )\n }\n // The placement refusal precedes the recursion one only in position: an\n // inline call the caller cannot host is invalid whether or not the callee's\n // declaration survived to be spliced, because inline expansion is the claim\n // that these steps run in the caller's execution.\n if (call.mode === \"inline\" && placementConflicts(call.placement, placement)) {\n throw new GraphBuildError({\n code: \"placement_requires_boundary\",\n node: call.id,\n path: [],\n message: `Flow \"${call.flow}\" is called inline at \"${call.id}\", but its declared placement ` +\n `${renderPlacement(placement)} is not structurally identical to the enclosing flow's ` +\n `${renderPlacement(call.placement)}. An inline .call() runs in the caller's execution, so use ` +\n `${call.flow}.child(payload) to give it its own.`\n })\n }\n const recordCall = (): void => {\n const bodyIdentity = call.declaration === undefined ? undefined : Node.functionIdentity(call.declaration.body)\n observeIdentity(call.id, \"body\", bodyIdentity)\n record({\n id: call.id,\n kind: \"FlowCall\",\n dependencies,\n capabilities: call.capabilities,\n capabilityCeilings: [\n ...call.stack.flatMap((flow) => capabilityCeilings(flow.annotations)),\n ...capabilityCeilings(annotations)\n ],\n effects: declaredEffects(annotations),\n placement,\n priority: call.priority,\n // A declared envelope states how reversible the flow beneath it is, so\n // it is the call's tier. A flow that declared none keeps the sealed\n // default every call has always carried, which is what keeps every\n // existing flow's key exactly where it was.\n tier: envelope?.tier ?? \"sealed\",\n body: {\n _tag: \"FlowCall\",\n flow: call.flow,\n mode: call.mode,\n declaration: call.declaration === undefined ? undefined : {\n payload: schemaIdentity(call.declaration.payloadSchema),\n success: schemaIdentity(call.declaration.successSchema),\n error: schemaIdentity(call.declaration.errorSchema),\n capabilities: ceiling,\n // A spliced body re-keys this call through the `Ref` on the node it\n // produced. A call the graph keeps as a LEAF \u2014 an explicit boundary,\n // a handoff \u2014 has no such node, and its own digest is the only thing\n // an edited body can move.\n body: bodyIdentity\n }\n },\n inputs,\n ast: call.ast,\n payload: call.payload,\n declaredAt: DeclarationSite.declaredAt(call.declaration)\n })\n }\n if (target === undefined) {\n recordCall()\n return\n }\n if (call.stack.includes(target)) {\n throw new GraphBuildError({\n code: \"recursion_requires_boundary\",\n node: call.id,\n path: [],\n message: `Flow \"${call.flow}\" cannot call itself inline at \"${call.id}\". ` +\n `Use ${call.flow}.to(payload) to hand off to the next round, or .child(payload) for an explicit boundary.`\n })\n }\n const built = target.body(call.payload)\n const spliced = `${call.id}.flow`\n sequence([\n () =>\n expand({\n ast: built.ast,\n id: spliced,\n depth: call.depth + 1,\n capabilities: ceiling.filter((capability) => coveredCapability(call.stack, capability)),\n // Inside the spliced body the callee's own placement is the one to\n // satisfy; a callee that declared none keeps running under the\n // caller's.\n placement: placement ?? call.placement,\n envelope: calleeEnvelope,\n priority: call.priority,\n substitutions: call.substitutions,\n stack: [...call.stack, target],\n prerequisite: undefined,\n barriers: call.barriers\n }),\n () => {\n dependencies.push(spliced)\n observedEdges.push({ from: spliced, to: call.id, reason: \"value\" })\n inputs.push({ _tag: \"Ref\", from: spliced, path: [] })\n },\n recordCall\n ])\n }\n\n /**\n * The continuation of an `AndThen`, evaluated exactly once against the\n * placeholder standing for its upstream result. A continuation that is gone\n * \u2014 an AST that crossed a serialization boundary \u2014 or that answered with\n * something other than a node leaves the remainder out and says so, because\n * a graph missing that recoverable step is still worth inspecting. Computing\n * on the placeholder is a fatal build refusal and propagates unchanged.\n */\n const continuation = (\n ast: Extract<Node.Ast, { readonly _tag: \"AndThen\" }>,\n id: string,\n subject: string\n ): Node.Ast | undefined => {\n const builder = Node.continuation(ast)\n if (builder === undefined) {\n observedDiagnostics.push(\n new GraphBuildError({\n code: \"invalid_continuation\",\n node: id,\n path: [],\n message: `Node.bindPlanned at \"${id}\" no longer holds its continuation builder, so its continuation is ` +\n \"missing from the graph. An AST that crossed a serialization boundary left that side table behind.\"\n })\n )\n return undefined\n }\n const built = builder(Planned.make<unknown>(subject))\n if (Node.isNode(built)) return built.ast\n observedDiagnostics.push(\n new GraphBuildError({\n code: \"invalid_continuation\",\n node: id,\n path: [],\n message: `Node.bindPlanned at \"${id}\" did not produce a Node, so its continuation is missing from the graph.`\n })\n )\n return undefined\n }\n\n const expand = (request: Visit): void => {\n if (request.depth > maximumGraphDepth) {\n throw new GraphBuildError({\n code: \"graph_too_deep\",\n node: request.id,\n path: [],\n message: `The graph nests more than ${maximumGraphDepth} levels deep. ` +\n \"Split the flow with .child() boundaries or trampoline handoffs so one execution plans a bounded graph.\"\n })\n }\n const { ast, capabilities, depth, envelope, id, placement, stack, substitutions } = request\n // A node's own priority wins; otherwise it inherits the enclosing one.\n const priority = ast.priority ?? request.priority\n const dependencies: Array<string> = []\n const inputs: Array<KeyMaterial.InputRef> = []\n const depend = (from: string, reason: EdgeReason): void => {\n dependencies.push(from)\n observedEdges.push({ from, to: id, reason })\n inputs.push(reason === \"continuation\" ? { _tag: \"Pending\", from } : { _tag: \"Ref\", from, path: [] })\n }\n const child = (childAst: Node.Ast, childId: string, options: {\n readonly substitutions?: ReadonlyMap<string, string>\n readonly prerequisite?: string | undefined\n readonly barriers?: ReadonlyArray<string>\n } = {}): Visit => ({\n ast: childAst,\n id: childId,\n depth: depth + 1,\n capabilities,\n placement,\n envelope,\n priority,\n substitutions: options.substitutions ?? substitutions,\n stack,\n prerequisite: options.prerequisite,\n barriers: options.barriers ?? request.barriers\n })\n\n if (request.prerequisite !== undefined) depend(request.prerequisite, \"continuation\")\n for (const barrier of request.barriers) {\n if (barrier !== request.prerequisite) depend(barrier, \"continuation\")\n }\n\n switch (ast._tag) {\n case \"FlowCall\": {\n expandFlowCall({\n id,\n depth,\n ast,\n flow: ast.flow,\n mode: ast.mode,\n declaration: flowDeclaration(Node.declaration(ast)),\n payload: hydrate(ast.payload, substitutions, id),\n capabilities,\n placement,\n envelope,\n priority,\n substitutions,\n stack,\n barriers: request.barriers,\n dependencies,\n inputs\n })\n return\n }\n case \"ActionCall\": {\n const declared = actionDeclaration(Node.declaration(ast))\n const annotations = declared?.annotations ?? Context.empty()\n const payload = hydrate(ast.payload, substitutions, id)\n // An action is a leaf, so its declaration cannot become an envelope for\n // anything; it is only checked against the one it sits inside.\n admitEnvelope(envelope, declaredEnvelope(annotations), { id, flow: ast.action })\n // The ceiling the declaration named, read off its bag exactly as a\n // called flow's is. An action that named none keeps the enclosing grant\n // and adds nothing to its key, so every declaration written before the\n // literal existed keys exactly where it did.\n const ceiling = sorted(Context.get(annotations, Annotations.Capabilities))\n const dropped = ceiling.filter((capability) => !coveredCapability(stack, capability))\n if (dropped.length > 0) {\n observedDiagnostics.push(\n new GraphBuildError({\n code: \"capability_outside_grant\",\n node: id,\n path: dropped,\n message: `Action \"${ast.action}\" at \"${id}\" requires ${dropped.join(\", \")}, which the calling ` +\n \"flow does not provably grant. Execution intersects this declaration with every caller ceiling.\"\n })\n )\n }\n record({\n id,\n kind: ast._tag,\n dependencies,\n capabilities,\n capabilityCeilings: [\n ...stack.flatMap((flow) => capabilityCeilings(flow.annotations)),\n ...capabilityCeilings(annotations)\n ],\n effects: declaredEffects(annotations),\n placement: declaredPlacement(annotations),\n priority,\n tier: declared?.tier ?? \"sealed\",\n nondeterministic: declared?.nondeterministic,\n body: {\n _tag: \"ActionCall\",\n action: ast.action,\n tier: declared?.tier ?? \"sealed\",\n declaration: declared === undefined ? undefined : {\n payload: schemaIdentity(declared.payloadSchema),\n success: schemaIdentity(declared.successSchema),\n error: schemaIdentity(declared.errorSchema),\n ...(ceiling.length === 0 ? {} : { capabilities: ceiling }),\n ...(declared.implementationVersion === undefined\n ? {}\n : { implementationVersion: declared.implementationVersion })\n }\n },\n inputs: [...payloadInputs(payload, id), ...inputs],\n ast,\n payload,\n declaredAt: DeclarationSite.declaredAt(declared)\n })\n return\n }\n case \"Succeed\": {\n const value = hydrate(ast.value, substitutions, id)\n const outcome = outcomeTagOf(ast)\n if (outcome !== undefined) {\n const tag = typeof value === \"object\" && value !== null\n ? Object.getOwnPropertyDescriptor(value, \"_tag\")\n : undefined\n if (tag === undefined || !(\"value\" in tag) || tag.value !== outcome) {\n throw new GraphBuildError({\n code: \"invalid_payload\",\n node: id,\n path: [],\n message: `Flow outcome node at \"${id}\" lost its ${outcome} payload.`\n })\n }\n Object.defineProperty(value, OutcomeValueTypeId, {\n configurable: false,\n enumerable: false,\n value: outcome,\n writable: false\n })\n }\n record({\n id,\n kind: ast._tag,\n dependencies,\n capabilities,\n effects: undefined,\n placement: undefined,\n priority,\n tier: \"sealed\",\n body: outcome === undefined ? { _tag: ast._tag } : { _tag: ast._tag, outcome },\n inputs: [...payloadInputs(value, id), ...inputs],\n ast,\n payload: value\n })\n return\n }\n case \"Fail\": {\n // A constant failure is a leaf exactly as `Succeed` is, and its error\n // is hydrated and keyed the same way: two different refusals are two\n // different steps, and one that reads an upstream result depends on it.\n const error = hydrate(ast.error, substitutions, id)\n record({\n id,\n kind: ast._tag,\n dependencies,\n capabilities,\n effects: undefined,\n placement: undefined,\n priority,\n tier: \"sealed\",\n body: { _tag: ast._tag },\n inputs: [...payloadInputs(error, id), ...inputs],\n ast,\n payload: error\n })\n return\n }\n case \"All\": {\n const members = Object.keys(ast.nodes)\n const steps: Array<() => void> = []\n for (const member of members) {\n // This durable address cannot be re-keyed here without coordinating\n // the plan and engine stores. The record-time duplicate check guards\n // arbitrary member names instead.\n const memberId = `${id}.all.${member}`\n steps.push(() => expand(child(ast.nodes[member]!, memberId)))\n steps.push(() => depend(memberId, \"value\"))\n }\n steps.push(() =>\n record({\n id,\n kind: ast._tag,\n dependencies,\n capabilities,\n effects: undefined,\n placement: undefined,\n priority,\n tier: \"sealed\",\n body: { _tag: ast._tag, members },\n inputs,\n ast,\n payload: undefined\n })\n )\n sequence(steps)\n return\n }\n case \"Race\": {\n // A join that settles early is expanded exactly as `All` is: every\n // member is topology the plan shows, and the interpreter decides at\n // run time which of them it waits for.\n const members = Object.keys(ast.nodes)\n const steps: Array<() => void> = []\n for (const member of members) {\n const memberId = `${id}.race.${member}`\n steps.push(() => expand(child(ast.nodes[member]!, memberId)))\n steps.push(() => depend(memberId, \"value\"))\n }\n steps.push(() =>\n record({\n id,\n kind: ast._tag,\n dependencies,\n capabilities,\n effects: undefined,\n placement: undefined,\n priority,\n tier: \"sealed\",\n body: { _tag: ast._tag, mode: ast.mode, count: ast.count, members },\n inputs,\n ast,\n payload: undefined\n })\n )\n sequence(steps)\n return\n }\n case \"Map\": {\n observeIdentity(id, \"mapper\", ast.mapper)\n const first = `${id}.map`\n sequence([\n () => expand(child(ast.first, first)),\n () => depend(first, \"value\"),\n () =>\n record({\n id,\n kind: ast._tag,\n dependencies,\n capabilities,\n effects: undefined,\n placement: undefined,\n priority,\n tier: \"sealed\",\n body: { _tag: ast._tag, mapper: ast.mapper },\n inputs,\n ast,\n payload: undefined\n })\n ])\n return\n }\n case \"AndThen\": {\n observeIdentity(id, \"continuation\", ast.continuation)\n const first = `${id}.andThen`\n sequence([\n () => expand(child(ast.first, first)),\n () => depend(first, \"value\"),\n () => {\n // The continuation builder runs only after the first subtree is\n // fully observed, exactly where the recursive walk evaluated it.\n const next = ast.next ?? continuation(ast, id, first)\n if (next === undefined) return\n const thenId = `${id}.then`\n sequence([\n () =>\n expand(child(next, thenId, {\n prerequisite: first,\n // Explicit andThen sequences every descendant, not only the\n // result/join node. bindPlanned remains a dependency builder:\n // independent members can run while a referenced producer runs.\n // The first subtree already carries the outer barriers, so\n // its success transitively gates every nested descendant.\n barriers: ast.next === undefined ? request.barriers : [first]\n })),\n () => depend(thenId, \"value\")\n ])\n },\n () =>\n record({\n id,\n kind: ast._tag,\n dependencies,\n capabilities,\n effects: undefined,\n placement: undefined,\n priority,\n tier: \"sealed\",\n body: { _tag: ast._tag, continuation: ast.continuation, static: ast.next !== undefined },\n inputs,\n ast,\n payload: undefined\n })\n ])\n return\n }\n case \"Branch\": {\n observeIdentity(id, \"predicate\", ast.predicate)\n const first = `${id}.branch`\n // DECIDED: each Branch AST carries its own\n // subject token. An outer subject captured inside a nested arm must\n // retain the outer binding; one shared token silently rebound it to\n // the inner branch's subject.\n const arms = new Map([...substitutions, [ast.subject, first]])\n sequence([\n () => expand(child(ast.first, first)),\n () => depend(first, \"value\"),\n () => expand(child(ast.then, `${id}.then`, { substitutions: arms, prerequisite: first })),\n () => depend(`${id}.then`, \"value\"),\n () => expand(child(ast.else, `${id}.else`, { substitutions: arms, prerequisite: first })),\n () => depend(`${id}.else`, \"value\"),\n () =>\n record({\n id,\n kind: ast._tag,\n dependencies,\n capabilities,\n effects: undefined,\n placement: undefined,\n priority,\n tier: \"sealed\",\n body: { _tag: ast._tag, predicate: ast.predicate },\n inputs,\n ast,\n payload: undefined\n })\n ])\n return\n }\n case \"Catch\": {\n if (ast.filter !== undefined) observeIdentity(id, \"filter\", ast.filterIdentity)\n const protectedId = `${id}.protected`\n const failureId = `${id}.failure`\n // DECIDED: each Catch AST carries its own\n // subject token, exactly as each Branch does. An outer error captured\n // inside a nested failure arm must retain the outer binding; one shared\n // token silently rebound it to the inner catch's protected node.\n const recovery = new Map([...substitutions, [ast.subject, protectedId]])\n sequence([\n () => expand(child(ast.protected, protectedId)),\n () => depend(protectedId, \"value\"),\n () => expand(child(ast.failure, failureId, { substitutions: recovery, prerequisite: protectedId })),\n () => {\n dependencies.push(failureId)\n observedEdges.push({ from: protectedId, to: failureId, reason: \"failure\" })\n observedEdges.push({ from: failureId, to: id, reason: \"value\" })\n inputs.push({ _tag: \"Ref\", from: failureId, path: [] })\n },\n () =>\n record({\n id,\n kind: ast._tag,\n dependencies,\n capabilities,\n effects: undefined,\n placement: undefined,\n priority,\n tier: \"sealed\",\n body: { _tag: ast._tag, filter: ast.filter, filterIdentity: ast.filterIdentity },\n inputs,\n ast,\n payload: undefined\n })\n ])\n return\n }\n }\n }\n\n const declaration = flowDeclaration(flowOrNode)\n const root = options.root ?? \"root\"\n if (declaration === undefined) {\n expand({\n ast: (flowOrNode as Node.Any).ast,\n id: root,\n depth: 0,\n capabilities: [],\n placement: undefined,\n envelope: undefined,\n priority: undefined,\n substitutions: new Map(),\n stack: [],\n prerequisite: undefined,\n barriers: []\n })\n } else {\n const entry = hydrate(payload, new Map(), root)\n expandFlowCall({\n id: root,\n depth: 0,\n // The entry is a call to the flow itself that no author wrote, so its\n // AST is synthesized here rather than recorded by `Node.flowCall`, which\n // would replace a payload's non-JSON values with their plain-object\n // copies. What a body was planned with stays what the entry node shows.\n ast: { _tag: \"FlowCall\", flow: declaration._tag, mode: \"inline\", payload: entry },\n flow: declaration._tag,\n mode: \"inline\",\n declaration,\n payload: entry,\n capabilities: sorted(Context.get(declaration.annotations, Annotations.Capabilities)),\n // Nothing encloses the entry, so its own declared placement is what the\n // body it splices has to be satisfiable under, not a constraint on it.\n // Its declared envelope reads the same way: the entry is the top of the\n // authority chain, so it grants rather than narrows.\n placement: undefined,\n envelope: undefined,\n priority: undefined,\n substitutions: new Map(),\n stack: [],\n barriers: [],\n dependencies: [],\n inputs: []\n })\n }\n // The walk itself: pop until every stacked step has run. A refusal thrown\n // by any step propagates out of the build unchanged.\n while (operations.length > 0) operations.pop()!()\n\n return {\n nodes: observed,\n edges: observedEdges,\n diagnostics: observedDiagnostics\n }\n}\n\n/**\n * The observed nodes, children before the parents that consume them.\n *\n * @since 0.1.0\n * @category accessors\n */\nexport const nodes = (graph: Graph): ReadonlyArray<GraphNode> => graph.nodes\n\n/**\n * The dependency edges, in the order they were observed.\n *\n * @since 0.1.0\n * @category accessors\n */\nexport const edges = (graph: Graph): ReadonlyArray<Edge> => graph.edges\n\n/**\n * States that a file this runtime is about to evaluate holds bytes read from\n * another, so the declarations inside it are reported at the file an author\n * can open.\n *\n * A host that verifies a flow's source evaluates THE BYTES IT MEASURED, and\n * the only way to evaluate bytes here is to write them somewhere and import\n * that path: `@smthrs/registry` `Executable` writes them as a scratch sibling\n * of the entry and removes it when the load is over. Without this, every node\n * of an agent-authored flow names that scratch file, and a reader offered its\n * path is offered a file nothing holds (D-068).\n *\n * The loader states this BEFORE it imports, because a declaration captures its\n * site while the module is evaluated and never rewrites it. Both sides hold\n * the same module: a loaded flow is recognized by this package's own type id,\n * so a graph file resolving a second copy of `@smthrs/flow` is refused as not\n * a flow at all rather than registered with a site nothing corrected.\n *\n * @since 0.1.0\n * @category constructors\n */\nexport const evaluatedFrom = (evaluated: string, entry: string): void => DeclarationSite.evaluatedFrom(evaluated, entry)\n\n/**\n * The drafts, in node order, ready for `Plan.compile` or `Plan.append`\n * unchanged.\n *\n * A graph with a FATAL diagnostic is inspectable but intentionally not\n * compilable: returning its partial drafts would turn missing topology into a\n * valid plan. This accessor therefore throws the first fatal build refusal, and\n * it is the ONLY way to reach the drafts. The built graph holds nodes, and a\n * draft is the node's own {@link GraphNode.draft}.\n *\n * An advisory refusal does not withhold the drafts. The one advisory code is\n * `capability_outside_grant`, where the callee runs with LESS authority than it\n * asked for: the author needs to see it, and the graph it describes is exactly\n * the graph that will run.\n *\n * @since 0.1.0\n * @category accessors\n */\nexport const drafts = (graph: Graph): ReadonlyArray<Plan.NodeDraft> => {\n const refusal = graph.diagnostics.find(isFatalDiagnostic)\n if (refusal !== undefined) throw refusal\n return graph.nodes.map((node) => node.draft)\n}\n\n/**\n * Recoverable topology issues recorded during the build, such as a missing\n * continuation builder or a continuation that did not produce a node. Fatal\n * refusals, including computing on a planned value and recursive inline\n * `.call()`, throw from {@link build} and never appear here.\n *\n * @since 0.1.0\n * @category accessors\n */\nexport const diagnostics = (graph: Graph): ReadonlyArray<GraphBuildError> => graph.diagnostics\n\n/** Serializable declaration inspection. No action or prompt renderer runs.\n * Payload-dependent JavaScript can refuse symbolic inspection; that is a\n * diagnostic, not evidence that the flow itself cannot execute.\n * @category models\n * @since 1.0.0\n */\nexport interface Inspection {\n readonly nodes: ReadonlyArray<Pick<GraphNode, \"id\" | \"kind\" | \"dependencies\"> & { readonly label?: string }>\n readonly edges: ReadonlyArray<Edge>\n readonly steps: ReadonlyArray<{ readonly id: string; readonly label: string }>\n readonly diagnostics: ReadonlyArray<{ readonly code: string; readonly message: string }>\n /** The renderer's source, never rendered with an invented input. */\n readonly prompt?: string\n}\n\n/** Inspect the existing graph model with an unresolved input reference.\n * Run this only in the same guest that loads the declaration: plan-time body\n * code is repository code too. An input-dependent body is reported explicitly\n * without choosing a sample payload. As with Planned values in bodies, use\n * node combinators for branching; JavaScript truthiness is not inspectable.\n * @category constructors\n * @since 1.0.0\n */\nexport const inspect = (flow: Flow.Any): Inspection => {\n const prompt = \"prompt\" in flow && typeof flow.prompt === \"function\"\n ? Function.prototype.toString.call(flow.prompt)\n : undefined\n try {\n const graph = build(flow, Planned.make(\"input\"))\n const nodes = graph.nodes.map((node) => ({\n id: node.id,\n kind: node.kind,\n ...(node.ast._tag === \"FlowCall\" ?\n { label: node.ast.flow }\n : node.ast._tag === \"ActionCall\"\n ? { label: node.ast.action }\n : {}),\n dependencies: node.dependencies\n }))\n // Inline flow calls group the actions beneath them; only boundary calls\n // and actions are steps, so the same work is never displayed twice.\n const steps = graph.nodes.flatMap((node) =>\n node.ast._tag === \"ActionCall\" ?\n [{ id: node.id, label: node.ast.action }]\n : node.ast._tag === \"FlowCall\" && node.ast.mode !== \"inline\"\n ? [{ id: node.id, label: node.ast.flow }]\n : []\n )\n return {\n nodes,\n edges: graph.edges,\n steps,\n diagnostics: graph.diagnostics.map(({ code, message }) => ({ code, message })),\n ...(prompt === undefined ? {} : { prompt })\n }\n } catch (error) {\n return {\n // The declaration itself is a known boundary even when its internals\n // require real input. Do not publish a fictitious empty execution.\n nodes: [{ id: \"root\", kind: \"FlowCall\", label: flow._tag, dependencies: [] }],\n edges: [],\n steps: [{ id: \"root\", label: flow._tag }],\n diagnostics: [{\n code: error instanceof GraphBuildError\n ? error.code === \"planned_value_computed\" ? \"declaration_requires_input\" : error.code\n : \"declaration_inspection_failed\",\n message: error instanceof Error ? error.message : String(error)\n }],\n ...(prompt === undefined ? {} : { prompt })\n }\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAyDA,iBAA4B;AAC5B,cAAyB;AACzB,6BAAmD;AACnD,kBAA6B;AAC7B,WAAsB;AAEtB,cAAyB;AACzB,cAAyB;AACzB,aAAwB;AACxB,gBAA2B;AAC3B,aAAwB;AAExB,oBAAuC;AACvC,kBAA6B;AAC7B,+BAAmC;AAEnC,IAAAA,iBAAqC;AACrC,sBAAiC;AACjC,2BAAsD;AAoLtD,MAAM,eAAiC,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,GAAG,cAAc,WAAW;AAGzF,MAAM,SAAS,CAAC,WAAoD,CAAC,GAAG,IAAI,IAAI,MAAM,CAAC,EAAE,KAAK;AAG9F,MAAM,kBAAkB,CAAC,UACvB,UAAU,YAAY,OAAO,eAAAC,MAAU,IAAI,QAA+B;AAG5E,MAAM,oBAAoB,CAAC,UACzB,UAAU,YAAY,OAAO,cAAAC,MAAY,IAAI,QAAwC;AAGvF,MAAM,kBAAkB,CAAC,gBACvB,OAAO,eAAe,QAAQ,UAAU,aAAa,YAAY,kBAAkB,CAAC;AAGtF,MAAM,oBAAoB,CAAC,gBACzB,OAAO,eAAe,QAAQ,UAAU,aAAa,YAAY,SAAS,CAAC;AAG7E,MAAM,mBAAmB,CAAC,gBACxB,OAAO,eAAe,QAAQ,UAAU,aAAa,YAAY,cAAc,CAAC;AAWlF,MAAM,iBAAiB,CACrB,UACA,SACW;AACX,QAAM,KAAK,IAAI,KAAK,IAAI,SAAS,KAAK,EAAE;AACxC,UAAQ,SAAS,MAAM;AAAA,IACrB,KAAK;AACH,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AO,KAAK,KAAK,CAAC;AAAA,MACxC,aAAa,CAAC;AAAA,QACZ,MAAM,iBAAiB,yCACnB,MAAM,SAAS,2BAA2B,+BAA+B,MAAM,OAC/E;AAAA,QACJ,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAAA,MAChE,CAAC;AAAA,MACD,GAAI,WAAW,SAAY,CAAC,IAAI,EAAE,OAAO;AAAA,IAC3C;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["/**\n * Graph building: a flow declaration plus a real payload, walked once into the\n * drafts a plan is compiled from.\n *\n * This is the plan phase of `docs/concepts/bodies-and-plans.md` and nothing\n * else \u2014 no I/O, no execution, no elaboration. {@link build} evaluates the\n * body with the REAL payload, because a body's own payload is data\n * (`docs/concepts/flows-and-actions.md`), and evaluates every\n * continuation and branch arm exactly once against a STRICT\n * {@link module:Planned.Planned} placeholder, because a step result does not\n * exist yet. A body that computes on a placeholder therefore fails here,\n * naming the node, rather than baking `NaN` into a plan.\n *\n * Fatal refusals stay fatal. Computing on a planned value throws its\n * `GraphBuildError` immediately, as does recursively expanding an inline\n * `.call()`, because either case makes the requested graph invalid. Recoverable\n * topology loss, such as a missing or invalid continuation, is reported in\n * {@link Graph.diagnostics} so the remaining graph can still be inspected.\n *\n * The walk is stack-safe by construction: topology and payloads are traversed\n * with explicit stacks, never native recursion, and each carries a nesting\n * bound. Topology past the bound is a typed `graph_too_deep` refusal, a\n * payload past it is `payload_too_deep`, and a payload containing itself is\n * `cyclic_payload` \u2014 all three fail loudly where unbounded recursion would\n * overflow the native stack without a typed error.\n *\n * Composition follows the same note: `Other.call(payload)` splices the\n * callee's body into this graph with the capabilities of the two declarations\n * intersected, and a flow that calls itself inline throws with the trampoline\n * (`docs/concepts/trampoline-rounds.md`) and the child boundary as the two\n * ways out. A callee whose declared placement the enclosing flow does not carry\n * throws for the same reason and names the same way out, because inline\n * expansion is the claim that these steps run in the caller's execution.\n * `Other.child(payload)` is that boundary: one leaf node here, its own\n * execution when the graph is driven. A branch expands BOTH arms, so the\n * exit condition and the handoff site are visible topology before anything\n * runs, and the predicate rides the branch's key material as a digest.\n *\n * What comes out is `@smthrs/plan` shaped: {@link Graph.drafts} feeds\n * `Plan.compile` and `Plan.append` unchanged, and the `Ref`/`Pending` inputs a\n * node's key material names are what the compiler turns into dependency\n * digests and the plan turns into edges. Structural node ids are derived only\n * from traversal positions and do not enter a plan draft's hashed value, so\n * editing a mapper re-keys exactly what reads it. The interpreter does use an\n * `ActionCall` id as durable dispatch-site material: it is the replay-stable\n * discriminator that keeps identical declarations at distinct graph\n * positions out of one arrival-ordered ordinal scope.\n *\n * Adapted from the agent repo's `@smthrs/core` `Graph.ts`. The lenient\n * placeholder, the model-shaped `Dynamic` node, the lane-merge elaboration,\n * and the conflict pass do not come across: the placeholder is strict here,\n * a model call is an ordinary action, and write overlap is resolved by\n * `Plan.compile`, which owns that verdict.\n *\n * @since 0.1.0\n */\n\nimport * as Capability from \"@smthrs/capability/Capability\"\nimport * as Effects from \"@smthrs/plan/Effects\"\nimport { GraphBuildError, isFatalDiagnostic } from \"@smthrs/plan/GraphBuildError\"\nimport * as KeyMaterial from \"@smthrs/plan/KeyMaterial\"\nimport * as Node from \"@smthrs/plan/Node\"\nimport type * as Plan from \"@smthrs/plan/Plan\"\nimport * as Planned from \"@smthrs/plan/Planned\"\nimport * as Context from \"effect/Context\"\nimport * as Option from \"effect/Option\"\nimport * as Predicate from \"effect/Predicate\"\nimport * as Schema from \"effect/Schema\"\nimport type * as Action from \"./Action/Action.ts\"\nimport { TypeId as ActionTypeId } from \"./Action/TypeId.ts\"\nimport * as Annotations from \"./Flow/Annotations.ts\"\nimport { capabilityCeilings } from \"./Flow/CapabilityCeiling.ts\"\nimport type * as Flow from \"./Flow/Flow.ts\"\nimport { TypeId as FlowTypeId } from \"./Flow/TypeId.ts\"\nimport * as DeclarationSite from \"./internal/DeclarationSite.ts\"\nimport { OutcomeNodeTypeId, OutcomeValueTypeId } from \"./internal/OutcomeMarker.ts\"\n\ntype OutcomeTag = \"Done\" | \"To\" | \"Park\"\n\n/**\n * Why one node depends on another: `value` consumes a result, `continuation`\n * is the sequencing edge a builder or a branch arm records against the\n * upstream node it was evaluated with.\n *\n * @since 0.1.0\n * @category models\n */\nexport type EdgeReason = \"value\" | \"continuation\" | \"failure\"\n\n/**\n * A dependency edge, pointing from the node that produces to the node that\n * consumes.\n *\n * @since 0.1.0\n * @category models\n */\nexport interface Edge {\n readonly from: string\n readonly to: string\n readonly reason: EdgeReason\n}\n\n/**\n * One observed node: its structural address, the AST variant it came from, and\n * the {@link module:Plan.NodeDraft} the plan is compiled from.\n *\n * `kind` is the authoring variant, not the plan's node kind \u2014 every draft a\n * graph produces is a plan `step`.\n *\n * @since 0.1.0\n * @category models\n */\nexport interface GraphNode {\n readonly id: string\n readonly kind: Node.Ast[\"_tag\"]\n readonly dependencies: ReadonlyArray<string>\n readonly capabilities: ReadonlyArray<string>\n readonly capabilityCeilings: ReadonlyArray<ReadonlyArray<string>>\n readonly placement: unknown\n readonly draft: Plan.NodeDraft\n /**\n * The authoring node this graph node was observed at.\n *\n * Key material digests a mapper, a predicate, and a callee's schemas; it\n * cannot carry them, because a digest is not a function. A driver that has\n * the real values in hand needs the functions themselves, so the AST rides\n * along: {@link module:Node.mapper}, {@link module:Node.predicate}, and the\n * member names of an `All` are read off it. The entry node a flow is entered\n * as is the call the graph synthesized, carrying the real payload rather than\n * the inert form an authored call records.\n */\n readonly ast: Node.Ast\n /**\n * What this node passes on, hydrated: real data where the author wrote data,\n * and a {@link module:Planned.Planned} placeholder where a step result goes.\n * It is the call payload of an `ActionCall` or a `FlowCall`, the value of a\n * `Succeed`, the error of a `Fail`, and `undefined` for every other variant,\n * which passes nothing of its own.\n */\n readonly payload: unknown\n /**\n * Where the declaration this node was observed at was written, when the\n * runtime's stack format says so.\n *\n * Provenance, never identity: it is carried on the declaration as a\n * non-enumerable property, so it is outside key material and a node keyed\n * with it is byte-identical to the same node keyed without it. A node with\n * no declaration to read \u2014 a map, a combination, an untagged succeed \u2014 has\n * none, and so does a declaration made inside the framework itself.\n */\n readonly declaredAt?: DeclarationSite.DeclaredAt | undefined\n}\n\n/**\n * What a pure per-node layer resolver is told. It is the identity of the\n * implementation a node would run against \u2014 hosts, services, permission\n * implementations \u2014 never a layer value or a runtime handle.\n *\n * @since 0.1.0\n * @category models\n */\nexport interface LayerRequest {\n readonly nodeId: string\n readonly kind: Node.Ast[\"_tag\"]\n readonly capabilities: ReadonlyArray<string>\n readonly effects: Annotations.Effects | undefined\n readonly placement: unknown\n}\n\n/**\n * The knobs {@link build} takes. `resolveLayers` is invoked once per node and\n * must be pure: planning performs no I/O, and a resolver that read the world\n * would make a plan a function of more than its declarations.\n *\n * @since 0.1.0\n * @category models\n */\nexport interface BuildOptions {\n readonly resolveLayers?: ((request: LayerRequest) => Iterable<string>) | undefined\n /**\n * `stable` refuses process-local flow bodies, mappers, predicates, and\n * continuation builders before drafts can be compiled or actions driven.\n * Declare every semantic capture with `Node.capture`; include an explicit\n * implementation version for imported behavior not represented by the\n * callback source. The default, `process-local`, supports inspection and\n * experimentation but does not promise reproducible plan identity.\n *\n * This validates callback identity only. Action implementations and resolved\n * layers still need their own semantic identity contract.\n */\n readonly callbackIdentity?: \"stable\" | \"process-local\" | undefined\n /**\n * The address the entry node is recorded under, `root` by default. A plan\n * grows by appending, and `Plan.append` refuses an id it already holds, so an\n * elaboration built for an existing plan names its own root.\n */\n readonly root?: string | undefined\n}\n\n/**\n * A built graph: the nodes in dependency order, the edges between them, and the\n * refusals that were recoverable enough to report rather than throw.\n *\n * DECIDED: the drafts are NOT a field here. They\n * are derived from `nodes`, and the derivation carries a refusal \u2014 a graph with\n * diagnostics is inspectable but not compilable \u2014 so {@link drafts} is the only\n * way to ask for them. A field beside the accessor was a second, silent answer\n * to the same question: reading `graph.drafts` handed back the truncated drafts\n * of an incomplete graph while `Graph.drafts(graph)` threw on it. Effect keeps\n * data interfaces plain and puts the policy in the accessor, so the field goes\n * rather than growing a getter that throws from inside a `readonly` record.\n *\n * @since 0.1.0\n * @category models\n */\nexport interface Graph {\n readonly nodes: ReadonlyArray<GraphNode>\n readonly edges: ReadonlyArray<Edge>\n readonly diagnostics: ReadonlyArray<GraphBuildError>\n}\n\n/**\n * The declared-action fields graph building reads. Only `Action.make`'s\n * declared form produces an `ActionCall`, so a call node's declaration is\n * one of these whenever the side table still holds it.\n *\n * @private\n */\ninterface ActionDeclaration {\n readonly name: string\n readonly implementationVersion?: string | undefined\n readonly payloadSchema: Schema.Top\n readonly successSchema: Schema.Top\n readonly errorSchema: Schema.Top\n readonly tier: Action.Tier\n readonly nondeterministic: true | undefined\n readonly annotations: Context.Context<never>\n}\n\n/**\n * The inert record `Node`'s AST keeps where a planned placeholder was.\n *\n * @private\n */\ninterface PlannedRecord {\n readonly node: string\n readonly path: ReadonlyArray<string>\n}\n\n/**\n * What a node that declared nothing contributes: it claims no path either way,\n * so `expected` is the honest default.\n *\n * @private\n */\nconst emptyEffects: Plan.NodeEffects = { reads: [], writes: [], boundaryMode: \"expected\" }\n\n/** @private */\nconst sorted = (values: Iterable<string>): ReadonlyArray<string> => [...new Set(values)].sort()\n\n/** @private */\nconst flowDeclaration = (value: unknown): Flow.Any | undefined =>\n Predicate.hasProperty(value, FlowTypeId) ? value as unknown as Flow.Any : undefined\n\n/** @private */\nconst actionDeclaration = (value: unknown): ActionDeclaration | undefined =>\n Predicate.hasProperty(value, ActionTypeId) ? value as unknown as ActionDeclaration : undefined\n\n/** @private */\nconst declaredEffects = (annotations: Context.Context<never>): Annotations.Effects | undefined =>\n Option.getOrUndefined(Context.getOption(annotations, Annotations.EffectsDeclaration))\n\n/** @private */\nconst declaredPlacement = (annotations: Context.Context<never>): unknown =>\n Option.getOrUndefined(Context.getOption(annotations, Annotations.Placement))\n\n/** @private */\nconst declaredEnvelope = (annotations: Context.Context<never>): Effects.Declaration | undefined =>\n Option.getOrUndefined(Context.getOption(annotations, Annotations.EffectEnvelope))\n\n/**\n * What an author reads when a declaration claimed more authority than the one\n * enclosing it granted. Each of the three states the claim, names the flow\n * whose envelope it escaped, and says the one thing that fixes it, because an\n * author who widened an envelope by accident needs the narrowing, not a\n * classification.\n *\n * @private\n */\nconst refusalMessage = (\n narrowed: Extract<Effects.NarrowResult, { readonly ok: false }>,\n site: { readonly id: string; readonly flow: string }\n): string => {\n const at = `\"${site.flow}\" at \"${site.id}\"`\n switch (narrowed.code) {\n case \"effect_outside_envelope\":\n return `Flow ${at} declares ${narrowed.paths.length === 1 ? \"a path\" : \"paths\"} its caller's effect ` +\n `envelope does not cover: ${narrowed.paths.join(\", \")}. Widen the caller's declared effects to cover ` +\n \"them, or narrow this declaration to what the envelope already allows.\"\n case \"effect_mode_widening\":\n return `Flow ${at} declares an expected effect mode inside a hermetic envelope. A hermetic envelope is ` +\n \"the claim that every effect beneath it is declared, so the callee has to declare a hermetic mode too.\"\n case \"effect_tier_widening\":\n return `Flow ${at} declares an effect tier its caller's envelope does not permit. A tier may only narrow ` +\n \"from irreversible to compensable to sealed, so raise the caller's tier or lower this one.\"\n }\n}\n\n/**\n * The declaration identity that enters a call node's hashed body: what the\n * callee accepts and produces, so a schema change re-keys the call.\n *\n * The identity is JSON-Schema-SHAPED, and that is its stated limit. Two\n * schemas whose decoders disagree can serialize to the same document, because\n * an effect transformation carries behaviour a JSON Schema document does not\n * describe. Changing only a codec's behaviour therefore does NOT re-key the\n * call, and a cached or recorded result computed under the old codec is\n * replayed under the new one. No fingerprint can close this automatically:\n * effect codecs are not serializable, so the identity would have to be\n * author-supplied. Until a declaration carries one, an author who changes a\n * transformation and needs the call re-keyed renames the declaration.\n * `@smthrs/core` carries the same algorithm and the same limit.\n *\n * @private\n */\nconst schemaIdentity = (schema: Schema.Top): unknown => {\n const cached = schemaDocuments.get(schema)\n if (cached !== undefined) return cached\n const document = Schema.toJsonSchemaDocument(schema, { onExcessProperty: \"error\" })\n schemaDocuments.set(schema, document)\n return document\n}\n\n/**\n * One document per schema object. A document is a pure function of the\n * schema's AST and schemas are immutable, so every node and every build that\n * names the same declaration reuses the document rather than regenerating it.\n *\n * @private\n */\nconst schemaDocuments = new WeakMap<Schema.Top, unknown>()\n\n/** @private */\nconst isPlainObject = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null &&\n (Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null)\n\n/**\n * The reference a value stands for, whether it is a live placeholder \u2014 a real\n * payload may carry one, naming a node an earlier generation already planned \u2014\n * or the inert record an AST payload kept.\n *\n * @private\n */\nconst referenceOf = (value: unknown): PlannedRecord | undefined => {\n const live = Planned.reference(value)\n if (live !== undefined) return live\n return Node.plannedReference(value)\n}\n\n/** @private */\nconst outcomeTagOf = (ast: Node.Ast): OutcomeTag | undefined => {\n const descriptor = Object.getOwnPropertyDescriptor(ast, OutcomeNodeTypeId)\n if (descriptor === undefined || !(\"value\" in descriptor)) return undefined\n const value = descriptor.value\n return value === \"Done\" || value === \"To\" || value === \"Park\" ? value : undefined\n}\n\n/**\n * Rebuilds the strict placeholder a reference names, so a spliced body sees\n * the same refusals an inline body does.\n *\n * @private\n */\nconst placeholder = (reference: PlannedRecord, node: string): unknown =>\n reference.path.reduce<unknown>(\n (value, key) => (value as Record<string, unknown>)[key],\n Planned.make<unknown>(node)\n )\n\n/**\n * The nesting bound the build enforces on authored topology. The walk itself\n * is iterative and cannot overflow the native stack, so the bound is policy:\n * topology a thousand combinators deep is a generated artifact, and refusing\n * it with a typed `graph_too_deep` names the fix \u2014 `.child()` boundaries or\n * trampoline handoffs \u2014 where unbounded acceptance would only defer the\n * failure to whatever walks the plan next.\n *\n * It is EXPORTED so a composition that unrolls its own topology, as\n * `@smthrs/patterns` does for a bounded loop, refuses at the same number the\n * build enforces instead of restating it and drifting.\n *\n * @since 0.1.0\n * @category models\n */\nexport const maximumGraphDepth = 1_000\n\n/**\n * The nesting bound the build enforces on payload data, for the same reason\n * {@link maximumGraphDepth} bounds topology: hydration, hashing, and reference\n * scanning walk iteratively, and the bound turns a pathologically deep payload\n * into a typed `payload_too_deep` refusal instead of an unbounded walk over\n * data a plan would have to hash and store level by level.\n *\n * @private\n */\nconst maximumPayloadDepth = 1_000\n\n/**\n * How one payload walk behaves: where it is walking, for refusal attribution;\n * how a placeholder-like leaf resolves; and the member order of a plain\n * object.\n *\n * @private\n */\ninterface PayloadWalk {\n readonly at: string\n readonly resolve: (value: unknown) => { readonly value: unknown } | undefined\n readonly keysOf: (keys: ReadonlyArray<string>) => ReadonlyArray<string>\n}\n\n/**\n * One container being walked: the source, the copy being filled, and the\n * member position reached. `keys` is `undefined` for an\n * array, whose members are positional.\n *\n * @private\n */\ninterface PayloadFrame {\n readonly source: Record<string, unknown> | ReadonlyArray<unknown>\n readonly keys: ReadonlyArray<string> | undefined\n readonly members: ReadonlyArray<unknown>\n readonly output: Record<string, unknown> | Array<unknown>\n index: number\n}\n\n/** @private */\nconst container = (\n value: unknown,\n at: string\n): Record<string, unknown> | ReadonlyArray<unknown> | undefined => {\n if (Array.isArray(value)) return value\n if (typeof value !== \"object\" || value === null) return undefined\n try {\n return isPlainObject(value) ? value : undefined\n } catch {\n throw new GraphBuildError({\n code: \"invalid_payload\",\n node: at,\n path: [],\n message: `Payload at \"${at}\" does not expose an inert object prototype.`\n })\n }\n}\n\n/**\n * Walks one payload with an explicit stack. Real recursion would let a deep\n * payload overflow the native stack instead of failing loudly, so depth is a\n * typed refusal here: a value already on the ancestor chain is\n * `cyclic_payload`, and nesting past {@link maximumPayloadDepth} is\n * `payload_too_deep`. Values that are neither placeholders nor plain data\n * pass through untraversed to the key canonicalizer, which is the one\n * component entitled to refuse them.\n *\n * Rebuilding writes members with a null-prototype target and\n * `defineProperty`, never `output[key] = \u2026`: `__proto__` routes through\n * `Object.prototype`'s accessor, so an own `__proto__` field whose value is a\n * primitive would be silently DROPPED and one whose value is an object would\n * reparent the copy instead of being recorded on it. A payload may carry that\n * key \u2014 `JSON.parse` produces it as an own data property \u2014 and both outcomes\n * are wrong here: a hydrated payload would be planned and run with a field\n * its author wrote missing, and two payloads that differ only in that field\n * would hash to one key. `@smthrs/plan`'s AST cloner answers this the\n * same way.\n *\n * @private\n */\nconst walkPayload = (root: unknown, walk: PayloadWalk): unknown => {\n const resolvedRoot = walk.resolve(root)\n if (resolvedRoot !== undefined) return resolvedRoot.value\n const rootContainer = container(root, walk.at)\n if (rootContainer === undefined) return root\n const open = (source: Record<string, unknown> | ReadonlyArray<unknown>): PayloadFrame => {\n const descriptors = (() => {\n try {\n return Object.getOwnPropertyDescriptors(source)\n } catch {\n throw new GraphBuildError({\n code: \"invalid_payload\",\n node: walk.at,\n path: [],\n message: `Payload at \"${walk.at}\" does not expose inert own properties.`\n })\n }\n })()\n if (Array.isArray(source)) {\n const members = Array.from({ length: source.length }, (_, index) => {\n const descriptor = descriptors[String(index)]\n if (descriptor === undefined) return undefined\n if (!(\"value\" in descriptor)) {\n throw new GraphBuildError({\n code: \"invalid_payload\",\n node: walk.at,\n path: [String(index)],\n message: `Payload at \"${walk.at}\" contains an accessor at index ${index}. Pass inert data.`\n })\n }\n return descriptor.value\n })\n return { source, keys: undefined, members, output: [], index: 0 }\n }\n const keys = walk.keysOf(\n Object.keys(descriptors).filter((key) => descriptors[key]?.enumerable === true)\n )\n const members = keys.map((key) => {\n const descriptor = descriptors[key]!\n if (!(\"value\" in descriptor)) {\n throw new GraphBuildError({\n code: \"invalid_payload\",\n node: walk.at,\n path: [key],\n message: `Payload at \"${walk.at}\" contains accessor property \"${key}\". Pass inert data.`\n })\n }\n return descriptor.value\n })\n return {\n source,\n keys,\n members,\n output: Object.create(null) as Record<string, unknown>,\n index: 0\n }\n }\n const rootFrame = open(rootContainer)\n const frames: Array<PayloadFrame> = [rootFrame]\n const ancestors = new Set<object>([rootContainer])\n while (frames.length > 0) {\n const frame = frames[frames.length - 1]!\n if (frame.index >= frame.members.length) {\n frames.pop()\n ancestors.delete(frame.source)\n continue\n }\n const position = frame.index\n frame.index = position + 1\n const key = frame.keys?.[position]\n const member = frame.members[position]\n const place = (produced: unknown): void => {\n if (key === undefined) {\n const members = frame.output as Array<unknown>\n members.push(produced)\n return\n }\n Object.defineProperty(frame.output, key, {\n configurable: true,\n enumerable: true,\n value: produced,\n writable: true\n })\n }\n const resolved = walk.resolve(member)\n if (resolved !== undefined) {\n place(resolved.value)\n continue\n }\n const nested = container(member, walk.at)\n if (nested === undefined) {\n place(member)\n continue\n }\n if (ancestors.has(nested)) {\n throw new GraphBuildError({\n code: \"cyclic_payload\",\n node: walk.at,\n path: [],\n message: `Payload at \"${walk.at}\" contains itself, so no plan can hash or serialize it. Pass acyclic data.`\n })\n }\n if (frames.length >= maximumPayloadDepth) {\n throw new GraphBuildError({\n code: \"payload_too_deep\",\n node: walk.at,\n path: [],\n message: `Payload at \"${walk.at}\" nests more than ${maximumPayloadDepth} levels deep. ` +\n \"Flatten the payload: a plan hashes and stores every level of it.\"\n })\n }\n const opened = open(nested)\n place(opened.output)\n ancestors.add(nested)\n frames.push(opened)\n }\n return rootFrame.output\n}\n\n/**\n * Turns an AST payload back into what a body must see: real data where the\n * caller wrote data, strict placeholders where it passed a step result. The\n * substitution rewrites a branch's own subject token to its upstream node, and\n * a catch's own subject token to the node it protects, which are those arms'\n * subjects by construction.\n *\n * @private\n */\nconst hydrate = (value: unknown, substitutions: ReadonlyMap<string, string>, at: string): unknown =>\n walkPayload(value, {\n at,\n keysOf: (keys) => keys,\n resolve: (member) => {\n const reference = referenceOf(member)\n return reference === undefined\n ? undefined\n : { value: placeholder(reference, substitutions.get(reference.node) ?? reference.node) }\n }\n })\n\n/**\n * The hashed form of a payload: placeholders keep their property path and drop\n * the node they came from, because the node id is a lookup address and the\n * dependency itself is named by a separate `Ref`. The same walk collects every\n * upstream result the payload reads into `found`, in sorted-key order, so a\n * payload is canonicalized once rather than walked again for its references.\n *\n * @private\n */\nconst literal = (value: unknown, found: Array<PlannedRecord>, at: string): unknown =>\n walkPayload(value, {\n at,\n keysOf: (keys) => [...keys].sort(),\n resolve: (member) => {\n const reference = Planned.reference(member)\n if (reference === undefined) return undefined\n found.push(reference)\n return { value: { _tag: \"PlannedInput\", path: [...reference.path] } }\n }\n })\n\n/**\n * Whether an inline call would place the callee somewhere the enclosing flow\n * cannot run it.\n *\n * A placement directive is opaque to this package \u2014 `Annotations.Placement` is\n * `Schema.Unknown`, and interpreting it is a scheduler's job \u2014 so the only\n * verdict available here is identity: the same directive is satisfiable, a\n * different one is not. The local comparison has the structural semantics of a\n * canonicalized literal without serializing it: arrays compare by length and\n * element, objects by their own enumerable keys independent of key order, and\n * primitives by `Object.is`. That makes `NaN` equal to itself and cheaply keeps\n * `-0` distinct from `0`. A visited-pair map terminates cyclic object graphs.\n *\n * Identity is claimed only over data the comparison can read inertly. Two\n * distinct objects are identical only when both are plain \u2014 an ordinary object\n * literal or a null-prototype object, or two arrays \u2014 and only through own data\n * properties: a `Date`, `Map`, `RegExp`, class instance, or function is\n * identical to itself by reference and to nothing else, and an accessor-backed\n * key is identical to nothing at all, because reading it would run author code\n * during graph building. Every one of those is a REFUSAL to prove identity, so\n * the call is pushed to an explicit `.child()` boundary rather than admitted\n * inline against a placement nobody checked. A `Proxy` over a plain object\n * still observes the key and descriptor reads; making the directive inert\n * before it is compared is the remaining half of that hardening.\n *\n * Identity over a CYCLIC directive is bisimulation: the visited-pair map makes\n * two directives identical when they unfold to the same infinite tree, so a\n * self-cycle and a two-node cycle of the same shape are the same directive.\n * Cycle lengths that share no factor pair off against each other for their\n * least common multiple of comparisons, which is what\n * {@link maxComparisonPairs} bounds.\n *\n * DECIDED: an enclosing flow that declares NO\n * placement is unconstrained and satisfies any callee, rather than satisfying\n * only a callee that declares none. Inline expansion runs the callee's steps in\n * the caller's execution, so the constraint that matters is the one the caller\n * already carries; refusing an undeclared caller would make `Flow.Placement`\n * mandatory on every flow in a call chain to keep `.call()` usable.\n *\n * @private\n */\nconst structuralIdentity = (left: unknown, right: unknown): boolean => {\n const pending: Array<readonly [unknown, unknown]> = [[left, right]]\n const visited = new WeakMap<object, WeakSet<object>>()\n let examined = 0\n try {\n while (pending.length > 0) {\n const [left, right] = pending.pop()!\n if (++examined > maxComparisonPairs) return false\n if (Object.is(left, right)) continue\n if (left !== Object(left)) return false\n if (right !== Object(right)) return false\n const leftObject = left as object\n const rightObject = right as object\n const leftIsArray = Array.isArray(leftObject)\n if (leftIsArray !== Array.isArray(rightObject)) return false\n if (\n leftIsArray && (leftObject as ReadonlyArray<unknown>).length !== (rightObject as ReadonlyArray<unknown>).length\n ) {\n return false\n }\n const seen = visited.get(leftObject) ?? new WeakSet<object>()\n if (seen.has(rightObject)) continue\n seen.add(rightObject)\n visited.set(leftObject, seen)\n if (!leftIsArray && !(isPlainObject(leftObject) && isPlainObject(rightObject))) return false\n const leftKeys = Reflect.ownKeys(leftObject).filter((key) =>\n Object.prototype.propertyIsEnumerable.call(leftObject, key)\n )\n const rightKeys = Reflect.ownKeys(rightObject).filter((key) =>\n Object.prototype.propertyIsEnumerable.call(rightObject, key)\n )\n if (leftKeys.length !== rightKeys.length) return false\n for (const key of leftKeys) {\n if (!Object.prototype.propertyIsEnumerable.call(rightObject, key)) return false\n // Descriptors rather than `Reflect.get`: a getter is author code, and\n // graph building must not run it.\n const leftMember = Object.getOwnPropertyDescriptor(leftObject, key)!\n const rightMember = Object.getOwnPropertyDescriptor(rightObject, key)!\n if (!(\"value\" in leftMember) || !(\"value\" in rightMember)) return false\n pending.push([leftMember.value, rightMember.value])\n }\n }\n } catch {\n // Every reflection above is a Proxy trap, and a trap is author code that\n // may throw. Graph building must not fail with whatever it threw, so an\n // unreadable directive gets the verdict every other one gets: identity is\n // not proved, and the call goes to an explicit `.child()` boundary.\n return false\n }\n return true\n}\n\n/**\n * The most value pairs one placement comparison examines before giving up.\n *\n * A directive is author data walked at planning time, so the comparison needs a\n * ceiling that does not depend on how large or how cyclic that data is.\n * Exhausting the ceiling is a refusal to prove identity, not a claim that the\n * two directives differ.\n *\n * @private\n */\nconst maxComparisonPairs = 100_000\n\n/** @private */\nconst placementConflicts = (enclosing: unknown, callee: unknown): boolean =>\n enclosing !== undefined && callee !== undefined && !structuralIdentity(enclosing, callee)\n\n/** The most characters one rendered placement contributes to a diagnostic. */\nconst maxPlacementChars = 240\n\n/** How many levels of a placement a diagnostic renders before eliding. */\nconst maxPlacementDepth = 4\n\n/**\n * How many members of one array or object a diagnostic renders.\n *\n * An array's cost is its LENGTH, not its member count: `new Array(100_000)` owns\n * no properties and still renders a hundred thousand separators without this\n * bound, so a directive a byte long becomes a diagnostic megabytes long.\n */\nconst maxPlacementMembers = 32\n\n/**\n * A bounded, inert rendering of a placement directive, for the refusal that\n * names it.\n *\n * An author who declared two placements needs to see WHICH two the build\n * compared and how they differ, so the refusal prints both. The directive is\n * arbitrary author data, so this holds to exactly the discipline\n * {@link structuralIdentity} holds to: own enumerable data properties only,\n * never an accessor, plain objects and arrays walked and everything else named\n * by kind, under a depth bound, a cycle guard, and a length bound so a large\n * directive cannot become the whole message. Array indices are read as\n * descriptors rather than iterated, because iteration invokes an index getter;\n * a hole renders as `<hole>`. Both arrays and objects render at most\n * {@link maxPlacementMembers} members and mark the rest `<more>`, so the work\n * is bounded before the string is truncated rather than after. Object members\n * are sorted, so two directives that differ only in key order render\n * identically, matching the comparison that admitted them. It never throws.\n *\n * @private\n */\nconst renderPlacement = (value: unknown): string => {\n const render = (value: unknown, depth: number, seen: ReadonlyArray<object>): string => {\n if (typeof value === \"string\") return JSON.stringify(value)\n if (typeof value === \"bigint\") return `${value}n`\n if (Object(value) !== value) return String(value)\n const object = value as object\n if (seen.includes(object)) return \"<cycle>\"\n if (depth === maxPlacementDepth) return \"<elided>\"\n const nested = [...seen, object]\n if (Array.isArray(object)) {\n const length = (object as ReadonlyArray<unknown>).length\n const shown = Math.min(length, maxPlacementMembers)\n const members: Array<string> = []\n for (let index = 0; index < shown; index++) {\n // `Array.prototype.map` invokes an index getter, so indices are read as\n // descriptors here for the same reason keys are below.\n const member = Object.getOwnPropertyDescriptor(object, String(index))\n members.push(\n member === undefined\n ? \"<hole>\"\n : \"value\" in member\n ? render(member.value, depth + 1, nested)\n : \"<accessor>\"\n )\n }\n if (length > shown) members.push(\"<more>\")\n return `[${members.join(\",\")}]`\n }\n if (!isPlainObject(object)) return Object.prototype.toString.call(object)\n const keys = Reflect.ownKeys(object)\n .filter((key) => Object.prototype.propertyIsEnumerable.call(object, key))\n .sort((left, right) => String(left).localeCompare(String(right)))\n // Select the bounded prefix before rendering values. Rendering every\n // member and slicing afterward still traverses the entire omitted forest.\n const members = keys.slice(0, maxPlacementMembers)\n .map((key) => {\n const member = Object.getOwnPropertyDescriptor(object, key)!\n const rendered = \"value\" in member ? render(member.value, depth + 1, nested) : \"<accessor>\"\n return `${String(key)}:${rendered}`\n })\n .sort()\n const shown = keys.length > maxPlacementMembers\n ? [...members, \"<more>\"]\n : members\n return `{${shown.join(\",\")}}`\n }\n\n try {\n const rendered = render(value, 0, [])\n return rendered.length <= maxPlacementChars\n ? rendered\n : `${rendered.slice(0, maxPlacementChars)} [${rendered.length - maxPlacementChars} characters dropped]`\n } catch {\n return \"<unrenderable>\"\n }\n}\n\n/**\n * The `Literal` a payload hashes as, followed by one `Ref` per distinct\n * upstream result it reads.\n *\n * @private\n */\nconst payloadInputs = (payload: unknown, at: string): ReadonlyArray<KeyMaterial.InputRef> => {\n const found: Array<PlannedRecord> = []\n const inputs: Array<KeyMaterial.InputRef> = [{ _tag: \"Literal\", value: literal(payload, found, at) }]\n const seen = new Set<string>()\n for (const reference of found) {\n const identity = JSON.stringify([reference.node, ...reference.path])\n if (seen.has(identity)) continue\n seen.add(identity)\n inputs.push({ _tag: \"Ref\", from: reference.node, path: [...reference.path] })\n }\n return inputs\n}\n\n/**\n * What one visit needs to know: where it is, how deeply it is nested, what it\n * may do, where it runs, which node the enclosing branch's subject stands\n * for, which flows are already being spliced, and the upstream node it\n * continues from.\n *\n * @private\n */\ninterface Visit {\n readonly ast: Node.Ast\n readonly id: string\n /**\n * How many visits enclose this one, checked against\n * {@link maximumGraphDepth}. The walk itself is an explicit operation stack\n * and cannot overflow, so the count exists to refuse pathological topology\n * with a typed error rather than accept it unbounded.\n */\n readonly depth: number\n readonly capabilities: ReadonlyArray<string>\n /**\n * The placement of the flow whose body this visit is inside, which an inline\n * call has to be satisfiable under.\n */\n readonly placement: unknown\n /**\n * The effect authority in force here: the nearest enclosing declaration that\n * was ACCEPTED, so a refused one does not widen what its siblings are checked\n * against. `undefined` means nothing above this node declared an envelope,\n * which is unconstrained rather than empty.\n */\n readonly envelope: Effects.Declaration | undefined\n /**\n * The scheduling priority in force here: the nearest enclosing node's, unless\n * this node states its own. It rides the walk rather than the AST because\n * inheritance is lexical \u2014 annotating a container prioritizes everything\n * beneath it that stayed silent.\n */\n readonly priority: number | undefined\n readonly substitutions: ReadonlyMap<string, string>\n readonly stack: ReadonlyArray<Flow.Any>\n readonly prerequisite: string | undefined\n /** Explicit andThen success barriers inherited by the entire subtree. */\n readonly barriers: ReadonlyArray<string>\n}\n\n/**\n * Builds the graph of a flow declaration, or of a bare node, by walking the\n * AST once.\n *\n * A flow is entered as a call to itself: the returned graph's `root` node is\n * that call, carrying the flow's declared effects, placement, and\n * capabilities, and its body spliced beneath it. Every flow has a body, so the\n * only inline call this leaves as a leaf is one whose declaration did not\n * survive serialization beside its AST.\n *\n * @since 0.1.0\n * @category constructors\n */\nexport const build = (\n flowOrNode: Flow.Any | Node.Any,\n payload?: unknown,\n options: BuildOptions = {}\n): Graph => {\n const observed: Array<GraphNode> = []\n const observedIds = new Set<string>()\n const observedEdges: Array<Edge> = []\n const observedDiagnostics: Array<GraphBuildError> = []\n\n const observeIdentity = (node: string, field: string, identity: Node.FunctionIdentity | undefined): void => {\n if (\n options.callbackIdentity !== \"stable\" ||\n (identity !== undefined && identity.algorithm !== \"sha256-source-ephemeral/v4\")\n ) return\n observedDiagnostics.push(\n new GraphBuildError({\n code: \"unstable_callback\",\n node,\n path: [field],\n message:\n `Callback ${field} at \"${node}\" has ${identity === undefined ? \"unavailable\" : \"process-local\"} identity ` +\n \"and cannot enter a stable graph. \" +\n \"Use Node.capture with every semantic capture, including the version of imported implementation behavior.\"\n })\n )\n }\n\n /**\n * The explicit walk stack. Every step is a thunk; expanding a node pushes\n * its steps in reverse so they pop in authoring order, which keeps the\n * observed nodes, edges, and diagnostics in exactly the order a recursive\n * walk would produce while making depth a data structure instead of native\n * stack frames a deep graph could exhaust.\n */\n const operations: Array<() => void> = []\n\n /** Stacks steps to run in the order written, ahead of everything stacked. */\n const sequence = (steps: ReadonlyArray<() => void>): void => {\n for (let index = steps.length - 1; index >= 0; index--) operations.push(steps[index]!)\n }\n\n const record = (entry: {\n readonly id: string\n readonly kind: Node.Ast[\"_tag\"]\n readonly dependencies: ReadonlyArray<string>\n readonly capabilities: ReadonlyArray<string>\n readonly effects: Annotations.Effects | undefined\n readonly placement: unknown\n readonly priority: number | undefined\n readonly tier: KeyMaterial.KeyMaterial[\"kind\"]\n readonly nondeterministic?: true | undefined\n readonly body: unknown\n readonly capabilityCeilings?: ReadonlyArray<ReadonlyArray<string>>\n readonly inputs: ReadonlyArray<KeyMaterial.InputRef>\n readonly ast: Node.Ast\n readonly payload: unknown\n readonly declaredAt?: DeclarationSite.DeclaredAt | undefined\n }): void => {\n if (observedIds.has(entry.id)) {\n throw new GraphBuildError({\n code: \"duplicate_node\",\n node: entry.id,\n path: [],\n message: `Node id \"${entry.id}\" is durable dispatch identity, so two nodes may not share one. ` +\n \"Two structural addresses in this graph collided, most often because a Node.all member name \" +\n \"contains the separator a nested address also produces. Rename one of them.\"\n })\n }\n observedIds.add(entry.id)\n const material: KeyMaterial.KeyMaterial = {\n version: KeyMaterial.version,\n kind: entry.tier,\n body: entry.capabilityCeilings?.length\n ? { ...entry.body as object, capabilityCeilings: entry.capabilityCeilings }\n : entry.body,\n inputs: entry.inputs,\n layers: sorted(\n options.resolveLayers?.({\n nodeId: entry.id,\n kind: entry.kind,\n capabilities: entry.capabilities,\n effects: entry.effects,\n placement: entry.placement\n }) ?? []\n ),\n capabilities: entry.capabilities,\n ...(entry.nondeterministic === undefined ? {} : { nondeterministic: entry.nondeterministic }),\n ...(entry.effects === undefined ? {} : { effects: entry.effects }),\n ...(entry.placement === undefined ? {} : { placement: entry.placement })\n }\n observed.push({\n id: entry.id,\n kind: entry.kind,\n dependencies: entry.dependencies,\n capabilities: entry.capabilities,\n capabilityCeilings: entry.capabilityCeilings ?? [],\n placement: entry.placement,\n // Priority reaches the compiled plan through the draft and stays OUT of\n // `material`: it orders ready work without changing what the work\n // produces, so raising it must not re-key a step.\n draft: {\n id: entry.id,\n material,\n effects: entry.effects ?? emptyEffects,\n ...(entry.priority === undefined ? {} : { priority: entry.priority })\n },\n ast: entry.ast,\n payload: entry.payload,\n ...(entry.declaredAt === undefined ? {} : { declaredAt: entry.declaredAt })\n })\n }\n\n /**\n * An envelope is graph-owned and reaches every node it encloses as the same\n * object, so it is read into its prepared form once and each enclosed\n * declaration is checked against that: a wide envelope costs its size once\n * per build rather than once per node that narrows it.\n */\n const preparedEnvelopes = new Map<Effects.Declaration, Effects.PreparedEnvelope>()\n\n /**\n * Checks one declaration against the envelope enclosing it, recording the\n * refusal and answering whether the declaration may become the envelope for\n * what it encloses in turn. A refused declaration must NOT replace the last\n * accepted one: widening beneath it would then be measured against the very\n * claim that was just rejected.\n */\n const admitEnvelope = (\n enclosing: Effects.Declaration | undefined,\n declared: Effects.Declaration | undefined,\n site: { readonly id: string; readonly flow: string }\n ): Effects.Declaration | undefined => {\n if (declared === undefined) return enclosing\n if (enclosing === undefined) return declared\n let prepared = preparedEnvelopes.get(enclosing)\n if (prepared === undefined) {\n prepared = Effects.prepareEnvelope(enclosing)\n preparedEnvelopes.set(enclosing, prepared)\n }\n const narrowed = Effects.narrowPrepared(prepared, declared)\n if (narrowed.ok) return declared\n observedDiagnostics.push(\n new GraphBuildError({\n code: narrowed.code,\n node: site.id,\n path: [...narrowed.paths],\n message: refusalMessage(narrowed, site)\n })\n )\n return enclosing\n }\n\n /**\n * Expands the node a flow call becomes, shared by the entry point and by\n * every `FlowCall` in a body.\n */\n const coveredCapability = (stack: ReadonlyArray<Flow.Any>, text: string): boolean => {\n const groups = stack.flatMap((flow) => capabilityCeilings(flow.annotations))\n if (groups.length === 0) return true\n const candidate = Capability.parsePattern(text)\n if (Option.isNone(candidate)) return false\n return groups.every((group) =>\n group.some((text) => {\n const grant = Capability.parsePattern(text)\n return Option.isSome(grant) && Capability.subsumes(grant.value, candidate.value)\n })\n )\n }\n\n const expandFlowCall = (call: {\n readonly id: string\n readonly depth: number\n readonly ast: Node.Ast\n readonly flow: string\n readonly mode: Node.CallMode\n readonly declaration: Flow.Any | undefined\n readonly payload: unknown\n readonly capabilities: ReadonlyArray<string>\n /** The placement of the flow this call is written inside. */\n readonly placement: unknown\n /** The effect authority in force at this call, which the callee must narrow. */\n readonly envelope: Effects.Declaration | undefined\n /** The priority in force at this call, already including the call's own. */\n readonly priority: number | undefined\n readonly substitutions: ReadonlyMap<string, string>\n readonly stack: ReadonlyArray<Flow.Any>\n readonly barriers: ReadonlyArray<string>\n readonly dependencies: Array<string>\n readonly inputs: ReadonlyArray<KeyMaterial.InputRef>\n }): void => {\n const annotations = call.declaration?.annotations ?? Context.empty()\n const dependencies = call.dependencies\n const inputs: Array<KeyMaterial.InputRef> = [...payloadInputs(call.payload, call.id), ...call.inputs]\n const target = call.mode === \"inline\" ? call.declaration : undefined\n const ceiling = sorted(capabilityCeilings(annotations)[0] ?? call.capabilities)\n const placement = declaredPlacement(annotations)\n const envelope = declaredEnvelope(annotations)\n // The authority checks are recorded, not thrown: a graph whose callee\n // claimed too much is still worth inspecting, and the author needs every\n // over-claim in the composition at once rather than the first one.\n //\n // They run for EVERY call mode. An explicit `.child()` boundary and a\n // trampoline handoff give the callee its own execution, not its own\n // authority: whoever writes the call is still the one granting it, which is\n // the rule `@smthrs/core`'s graph applies to a call whose body it does not\n // splice.\n const calleeEnvelope = admitEnvelope(call.envelope, envelope, { id: call.id, flow: call.flow })\n const dropped = ceiling.filter((capability) => !coveredCapability(call.stack, capability))\n if (dropped.length > 0) {\n observedDiagnostics.push(\n new GraphBuildError({\n code: \"capability_outside_grant\",\n node: call.id,\n path: dropped,\n message: `Flow \"${call.flow}\" at \"${call.id}\" requires ${dropped.join(\", \")}, which the calling flow ` +\n \"does not provably grant. Execution intersects this declaration with every caller ceiling.\"\n })\n )\n }\n // The placement refusal precedes the recursion one only in position: an\n // inline call the caller cannot host is invalid whether or not the callee's\n // declaration survived to be spliced, because inline expansion is the claim\n // that these steps run in the caller's execution.\n if (call.mode === \"inline\" && placementConflicts(call.placement, placement)) {\n throw new GraphBuildError({\n code: \"placement_requires_boundary\",\n node: call.id,\n path: [],\n message: `Flow \"${call.flow}\" is called inline at \"${call.id}\", but its declared placement ` +\n `${renderPlacement(placement)} is not structurally identical to the enclosing flow's ` +\n `${renderPlacement(call.placement)}. An inline .call() runs in the caller's execution, so use ` +\n `${call.flow}.child(payload) to give it its own.`\n })\n }\n const recordCall = (): void => {\n const bodyIdentity = call.declaration === undefined ? undefined : Node.functionIdentity(call.declaration.body)\n observeIdentity(call.id, \"body\", bodyIdentity)\n record({\n id: call.id,\n kind: \"FlowCall\",\n dependencies,\n capabilities: call.capabilities,\n capabilityCeilings: [\n ...call.stack.flatMap((flow) => capabilityCeilings(flow.annotations)),\n ...capabilityCeilings(annotations)\n ],\n effects: declaredEffects(annotations),\n placement,\n priority: call.priority,\n // A declared envelope states how reversible the flow beneath it is, so\n // it is the call's tier. A flow that declared none keeps the sealed\n // default every call has always carried, which is what keeps every\n // existing flow's key exactly where it was.\n tier: envelope?.tier ?? \"sealed\",\n body: {\n _tag: \"FlowCall\",\n flow: call.flow,\n mode: call.mode,\n declaration: call.declaration === undefined ? undefined : {\n payload: schemaIdentity(call.declaration.payloadSchema),\n success: schemaIdentity(call.declaration.successSchema),\n error: schemaIdentity(call.declaration.errorSchema),\n capabilities: ceiling,\n // A spliced body re-keys this call through the `Ref` on the node it\n // produced. A call the graph keeps as a LEAF \u2014 an explicit boundary,\n // a handoff \u2014 has no such node, and its own digest is the only thing\n // an edited body can move.\n body: bodyIdentity\n }\n },\n inputs,\n ast: call.ast,\n payload: call.payload,\n declaredAt: DeclarationSite.declaredAt(call.declaration)\n })\n }\n if (target === undefined) {\n recordCall()\n return\n }\n if (call.stack.includes(target)) {\n throw new GraphBuildError({\n code: \"recursion_requires_boundary\",\n node: call.id,\n path: [],\n message: `Flow \"${call.flow}\" cannot call itself inline at \"${call.id}\". ` +\n `Use ${call.flow}.to(payload) to hand off to the next round, or .child(payload) for an explicit boundary.`\n })\n }\n const built = target.body(call.payload)\n const spliced = `${call.id}.flow`\n sequence([\n () =>\n expand({\n ast: built.ast,\n id: spliced,\n depth: call.depth + 1,\n capabilities: ceiling.filter((capability) => coveredCapability(call.stack, capability)),\n // Inside the spliced body the callee's own placement is the one to\n // satisfy; a callee that declared none keeps running under the\n // caller's.\n placement: placement ?? call.placement,\n envelope: calleeEnvelope,\n priority: call.priority,\n substitutions: call.substitutions,\n stack: [...call.stack, target],\n prerequisite: undefined,\n barriers: call.barriers\n }),\n () => {\n dependencies.push(spliced)\n observedEdges.push({ from: spliced, to: call.id, reason: \"value\" })\n inputs.push({ _tag: \"Ref\", from: spliced, path: [] })\n },\n recordCall\n ])\n }\n\n /**\n * The continuation of an `AndThen`, evaluated exactly once against the\n * placeholder standing for its upstream result. A continuation that is gone\n * \u2014 an AST that crossed a serialization boundary \u2014 or that answered with\n * something other than a node leaves the remainder out and says so, because\n * a graph missing that recoverable step is still worth inspecting. Computing\n * on the placeholder is a fatal build refusal and propagates unchanged.\n */\n const continuation = (\n ast: Extract<Node.Ast, { readonly _tag: \"AndThen\" }>,\n id: string,\n subject: string\n ): Node.Ast | undefined => {\n const builder = Node.continuation(ast)\n if (builder === undefined) {\n observedDiagnostics.push(\n new GraphBuildError({\n code: \"invalid_continuation\",\n node: id,\n path: [],\n message: `Node.bindPlanned at \"${id}\" no longer holds its continuation builder, so its continuation is ` +\n \"missing from the graph. An AST that crossed a serialization boundary left that side table behind.\"\n })\n )\n return undefined\n }\n const built = builder(Planned.make<unknown>(subject))\n if (Node.isNode(built)) return built.ast\n observedDiagnostics.push(\n new GraphBuildError({\n code: \"invalid_continuation\",\n node: id,\n path: [],\n message: `Node.bindPlanned at \"${id}\" did not produce a Node, so its continuation is missing from the graph.`\n })\n )\n return undefined\n }\n\n const expand = (request: Visit): void => {\n if (request.depth > maximumGraphDepth) {\n throw new GraphBuildError({\n code: \"graph_too_deep\",\n node: request.id,\n path: [],\n message: `The graph nests more than ${maximumGraphDepth} levels deep. ` +\n \"Split the flow with .child() boundaries or trampoline handoffs so one execution plans a bounded graph.\"\n })\n }\n const { ast, capabilities, depth, envelope, id, placement, stack, substitutions } = request\n // A node's own priority wins; otherwise it inherits the enclosing one.\n const priority = ast.priority ?? request.priority\n const dependencies: Array<string> = []\n const inputs: Array<KeyMaterial.InputRef> = []\n const depend = (from: string, reason: EdgeReason): void => {\n dependencies.push(from)\n observedEdges.push({ from, to: id, reason })\n inputs.push(reason === \"continuation\" ? { _tag: \"Pending\", from } : { _tag: \"Ref\", from, path: [] })\n }\n const child = (childAst: Node.Ast, childId: string, options: {\n readonly substitutions?: ReadonlyMap<string, string>\n readonly prerequisite?: string | undefined\n readonly barriers?: ReadonlyArray<string>\n } = {}): Visit => ({\n ast: childAst,\n id: childId,\n depth: depth + 1,\n capabilities,\n placement,\n envelope,\n priority,\n substitutions: options.substitutions ?? substitutions,\n stack,\n prerequisite: options.prerequisite,\n barriers: options.barriers ?? request.barriers\n })\n\n if (request.prerequisite !== undefined) depend(request.prerequisite, \"continuation\")\n for (const barrier of request.barriers) {\n if (barrier !== request.prerequisite) depend(barrier, \"continuation\")\n }\n\n switch (ast._tag) {\n case \"FlowCall\": {\n expandFlowCall({\n id,\n depth,\n ast,\n flow: ast.flow,\n mode: ast.mode,\n declaration: flowDeclaration(Node.declaration(ast)),\n payload: hydrate(ast.payload, substitutions, id),\n capabilities,\n placement,\n envelope,\n priority,\n substitutions,\n stack,\n barriers: request.barriers,\n dependencies,\n inputs\n })\n return\n }\n case \"ActionCall\": {\n const declared = actionDeclaration(Node.declaration(ast))\n const annotations = declared?.annotations ?? Context.empty()\n const payload = hydrate(ast.payload, substitutions, id)\n // An action is a leaf, so its declaration cannot become an envelope for\n // anything; it is only checked against the one it sits inside.\n admitEnvelope(envelope, declaredEnvelope(annotations), { id, flow: ast.action })\n // The ceiling the declaration named, read off its bag exactly as a\n // called flow's is. An action that named none keeps the enclosing grant\n // and adds nothing to its key, so every declaration written before the\n // literal existed keys exactly where it did.\n const ceiling = sorted(Context.get(annotations, Annotations.Capabilities))\n const dropped = ceiling.filter((capability) => !coveredCapability(stack, capability))\n if (dropped.length > 0) {\n observedDiagnostics.push(\n new GraphBuildError({\n code: \"capability_outside_grant\",\n node: id,\n path: dropped,\n message: `Action \"${ast.action}\" at \"${id}\" requires ${dropped.join(\", \")}, which the calling ` +\n \"flow does not provably grant. Execution intersects this declaration with every caller ceiling.\"\n })\n )\n }\n record({\n id,\n kind: ast._tag,\n dependencies,\n capabilities,\n capabilityCeilings: [\n ...stack.flatMap((flow) => capabilityCeilings(flow.annotations)),\n ...capabilityCeilings(annotations)\n ],\n effects: declaredEffects(annotations),\n placement: declaredPlacement(annotations),\n priority,\n tier: declared?.tier ?? \"sealed\",\n nondeterministic: declared?.nondeterministic,\n body: {\n _tag: \"ActionCall\",\n action: ast.action,\n tier: declared?.tier ?? \"sealed\",\n declaration: declared === undefined ? undefined : {\n payload: schemaIdentity(declared.payloadSchema),\n success: schemaIdentity(declared.successSchema),\n error: schemaIdentity(declared.errorSchema),\n ...(ceiling.length === 0 ? {} : { capabilities: ceiling }),\n ...(declared.implementationVersion === undefined\n ? {}\n : { implementationVersion: declared.implementationVersion })\n }\n },\n inputs: [...payloadInputs(payload, id), ...inputs],\n ast,\n payload,\n declaredAt: DeclarationSite.declaredAt(declared)\n })\n return\n }\n case \"Succeed\": {\n const value = hydrate(ast.value, substitutions, id)\n const outcome = outcomeTagOf(ast)\n if (outcome !== undefined) {\n const tag = typeof value === \"object\" && value !== null\n ? Object.getOwnPropertyDescriptor(value, \"_tag\")\n : undefined\n if (tag === undefined || !(\"value\" in tag) || tag.value !== outcome) {\n throw new GraphBuildError({\n code: \"invalid_payload\",\n node: id,\n path: [],\n message: `Flow outcome node at \"${id}\" lost its ${outcome} payload.`\n })\n }\n Object.defineProperty(value, OutcomeValueTypeId, {\n configurable: false,\n enumerable: false,\n value: outcome,\n writable: false\n })\n }\n record({\n id,\n kind: ast._tag,\n dependencies,\n capabilities,\n effects: undefined,\n placement: undefined,\n priority,\n tier: \"sealed\",\n body: outcome === undefined ? { _tag: ast._tag } : { _tag: ast._tag, outcome },\n inputs: [...payloadInputs(value, id), ...inputs],\n ast,\n payload: value\n })\n return\n }\n case \"Fail\": {\n // A constant failure is a leaf exactly as `Succeed` is, and its error\n // is hydrated and keyed the same way: two different refusals are two\n // different steps, and one that reads an upstream result depends on it.\n const error = hydrate(ast.error, substitutions, id)\n record({\n id,\n kind: ast._tag,\n dependencies,\n capabilities,\n effects: undefined,\n placement: undefined,\n priority,\n tier: \"sealed\",\n body: { _tag: ast._tag },\n inputs: [...payloadInputs(error, id), ...inputs],\n ast,\n payload: error\n })\n return\n }\n case \"All\": {\n const members = Object.keys(ast.nodes)\n const steps: Array<() => void> = []\n for (const member of members) {\n // This durable address cannot be re-keyed here without coordinating\n // the plan and engine stores. The record-time duplicate check guards\n // arbitrary member names instead.\n const memberId = `${id}.all.${member}`\n steps.push(() => expand(child(ast.nodes[member]!, memberId)))\n steps.push(() => depend(memberId, \"value\"))\n }\n steps.push(() =>\n record({\n id,\n kind: ast._tag,\n dependencies,\n capabilities,\n effects: undefined,\n placement: undefined,\n priority,\n tier: \"sealed\",\n body: { _tag: ast._tag, members },\n inputs,\n ast,\n payload: undefined\n })\n )\n sequence(steps)\n return\n }\n case \"Race\": {\n // A join that settles early is expanded exactly as `All` is: every\n // member is topology the plan shows, and the interpreter decides at\n // run time which of them it waits for.\n const members = Object.keys(ast.nodes)\n const steps: Array<() => void> = []\n for (const member of members) {\n const memberId = `${id}.race.${member}`\n steps.push(() => expand(child(ast.nodes[member]!, memberId)))\n steps.push(() => depend(memberId, \"value\"))\n }\n steps.push(() =>\n record({\n id,\n kind: ast._tag,\n dependencies,\n capabilities,\n effects: undefined,\n placement: undefined,\n priority,\n tier: \"sealed\",\n body: { _tag: ast._tag, mode: ast.mode, count: ast.count, members },\n inputs,\n ast,\n payload: undefined\n })\n )\n sequence(steps)\n return\n }\n case \"Map\": {\n observeIdentity(id, \"mapper\", ast.mapper)\n const first = `${id}.map`\n sequence([\n () => expand(child(ast.first, first)),\n () => depend(first, \"value\"),\n () =>\n record({\n id,\n kind: ast._tag,\n dependencies,\n capabilities,\n effects: undefined,\n placement: undefined,\n priority,\n tier: \"sealed\",\n body: { _tag: ast._tag, mapper: ast.mapper },\n inputs,\n ast,\n payload: undefined\n })\n ])\n return\n }\n case \"AndThen\": {\n observeIdentity(id, \"continuation\", ast.continuation)\n const first = `${id}.andThen`\n sequence([\n () => expand(child(ast.first, first)),\n () => depend(first, \"value\"),\n () => {\n // The continuation builder runs only after the first subtree is\n // fully observed, exactly where the recursive walk evaluated it.\n const next = ast.next ?? continuation(ast, id, first)\n if (next === undefined) return\n const thenId = `${id}.then`\n sequence([\n () =>\n expand(child(next, thenId, {\n prerequisite: first,\n // Explicit andThen sequences every descendant, not only the\n // result/join node. bindPlanned remains a dependency builder:\n // independent members can run while a referenced producer runs.\n // The first subtree already carries the outer barriers, so\n // its success transitively gates every nested descendant.\n barriers: ast.next === undefined ? request.barriers : [first]\n })),\n () => depend(thenId, \"value\")\n ])\n },\n () =>\n record({\n id,\n kind: ast._tag,\n dependencies,\n capabilities,\n effects: undefined,\n placement: undefined,\n priority,\n tier: \"sealed\",\n body: { _tag: ast._tag, continuation: ast.continuation, static: ast.next !== undefined },\n inputs,\n ast,\n payload: undefined\n })\n ])\n return\n }\n case \"Branch\": {\n observeIdentity(id, \"predicate\", ast.predicate)\n const first = `${id}.branch`\n // DECIDED: each Branch AST carries its own\n // subject token. An outer subject captured inside a nested arm must\n // retain the outer binding; one shared token silently rebound it to\n // the inner branch's subject.\n const arms = new Map([...substitutions, [ast.subject, first]])\n sequence([\n () => expand(child(ast.first, first)),\n () => depend(first, \"value\"),\n () => expand(child(ast.then, `${id}.then`, { substitutions: arms, prerequisite: first })),\n () => depend(`${id}.then`, \"value\"),\n () => expand(child(ast.else, `${id}.else`, { substitutions: arms, prerequisite: first })),\n () => depend(`${id}.else`, \"value\"),\n () =>\n record({\n id,\n kind: ast._tag,\n dependencies,\n capabilities,\n effects: undefined,\n placement: undefined,\n priority,\n tier: \"sealed\",\n body: { _tag: ast._tag, predicate: ast.predicate },\n inputs,\n ast,\n payload: undefined\n })\n ])\n return\n }\n case \"Catch\": {\n if (ast.filter !== undefined) observeIdentity(id, \"filter\", ast.filterIdentity)\n const protectedId = `${id}.protected`\n const failureId = `${id}.failure`\n // DECIDED: each Catch AST carries its own\n // subject token, exactly as each Branch does. An outer error captured\n // inside a nested failure arm must retain the outer binding; one shared\n // token silently rebound it to the inner catch's protected node.\n const recovery = new Map([...substitutions, [ast.subject, protectedId]])\n sequence([\n () => expand(child(ast.protected, protectedId)),\n () => depend(protectedId, \"value\"),\n () => expand(child(ast.failure, failureId, { substitutions: recovery, prerequisite: protectedId })),\n () => {\n dependencies.push(failureId)\n observedEdges.push({ from: protectedId, to: failureId, reason: \"failure\" })\n observedEdges.push({ from: failureId, to: id, reason: \"value\" })\n inputs.push({ _tag: \"Ref\", from: failureId, path: [] })\n },\n () =>\n record({\n id,\n kind: ast._tag,\n dependencies,\n capabilities,\n effects: undefined,\n placement: undefined,\n priority,\n tier: \"sealed\",\n body: { _tag: ast._tag, filter: ast.filter, filterIdentity: ast.filterIdentity },\n inputs,\n ast,\n payload: undefined\n })\n ])\n return\n }\n }\n }\n\n const declaration = flowDeclaration(flowOrNode)\n const root = options.root ?? \"root\"\n if (declaration === undefined) {\n expand({\n ast: (flowOrNode as Node.Any).ast,\n id: root,\n depth: 0,\n capabilities: [],\n placement: undefined,\n envelope: undefined,\n priority: undefined,\n substitutions: new Map(),\n stack: [],\n prerequisite: undefined,\n barriers: []\n })\n } else {\n const entry = hydrate(payload, new Map(), root)\n expandFlowCall({\n id: root,\n depth: 0,\n // The entry is a call to the flow itself that no author wrote, so its\n // AST is synthesized here rather than recorded by `Node.flowCall`, which\n // would replace a payload's non-JSON values with their plain-object\n // copies. What a body was planned with stays what the entry node shows.\n ast: { _tag: \"FlowCall\", flow: declaration._tag, mode: \"inline\", payload: entry },\n flow: declaration._tag,\n mode: \"inline\",\n declaration,\n payload: entry,\n capabilities: sorted(Context.get(declaration.annotations, Annotations.Capabilities)),\n // Nothing encloses the entry, so its own declared placement is what the\n // body it splices has to be satisfiable under, not a constraint on it.\n // Its declared envelope reads the same way: the entry is the top of the\n // authority chain, so it grants rather than narrows.\n placement: undefined,\n envelope: undefined,\n priority: undefined,\n substitutions: new Map(),\n stack: [],\n barriers: [],\n dependencies: [],\n inputs: []\n })\n }\n // The walk itself: pop until every stacked step has run. A refusal thrown\n // by any step propagates out of the build unchanged.\n while (operations.length > 0) operations.pop()!()\n\n return {\n nodes: observed,\n edges: observedEdges,\n diagnostics: observedDiagnostics\n }\n}\n\n/**\n * The observed nodes, children before the parents that consume them.\n *\n * @since 0.1.0\n * @category accessors\n */\nexport const nodes = (graph: Graph): ReadonlyArray<GraphNode> => graph.nodes\n\n/**\n * The dependency edges, in the order they were observed.\n *\n * @since 0.1.0\n * @category accessors\n */\nexport const edges = (graph: Graph): ReadonlyArray<Edge> => graph.edges\n\n/**\n * States that a file this runtime is about to evaluate holds bytes read from\n * another, so the declarations inside it are reported at the file an author\n * can open.\n *\n * A host that verifies a flow's source evaluates THE BYTES IT MEASURED, and\n * the only way to evaluate bytes here is to write them somewhere and import\n * that path: `@smthrs/registry` `Executable` writes them as a scratch sibling\n * of the entry and removes it when the load is over. Without this, every node\n * of an agent-authored flow names that scratch file, and a reader offered its\n * path is offered a file nothing holds (D-068).\n *\n * The loader states this BEFORE it imports, because a declaration captures its\n * site while the module is evaluated and never rewrites it. Both sides hold\n * the same module: a loaded flow is recognized by this package's own type id,\n * so a graph file resolving a second copy of `@smthrs/flow` is refused as not\n * a flow at all rather than registered with a site nothing corrected.\n *\n * @since 0.1.0\n * @category constructors\n */\nexport const evaluatedFrom = (evaluated: string, entry: string): void => DeclarationSite.evaluatedFrom(evaluated, entry)\n\n/**\n * The drafts, in node order, ready for `Plan.compile` or `Plan.append`\n * unchanged.\n *\n * A graph with a FATAL diagnostic is inspectable but intentionally not\n * compilable: returning its partial drafts would turn missing topology into a\n * valid plan. This accessor therefore throws the first fatal build refusal, and\n * it is the ONLY way to reach the drafts. The built graph holds nodes, and a\n * draft is the node's own {@link GraphNode.draft}.\n *\n * An advisory refusal does not withhold the drafts. The one advisory code is\n * `capability_outside_grant`, where the callee runs with LESS authority than it\n * asked for: the author needs to see it, and the graph it describes is exactly\n * the graph that will run.\n *\n * @since 0.1.0\n * @category accessors\n */\nexport const drafts = (graph: Graph): ReadonlyArray<Plan.NodeDraft> => {\n const refusal = graph.diagnostics.find(isFatalDiagnostic)\n if (refusal !== undefined) throw refusal\n return graph.nodes.map((node) => node.draft)\n}\n\n/**\n * Recoverable topology issues recorded during the build, such as a missing\n * continuation builder or a continuation that did not produce a node. Fatal\n * refusals, including computing on a planned value and recursive inline\n * `.call()`, throw from {@link build} and never appear here.\n *\n * @since 0.1.0\n * @category accessors\n */\nexport const diagnostics = (graph: Graph): ReadonlyArray<GraphBuildError> => graph.diagnostics\n\n/** Serializable declaration inspection. No action or prompt renderer runs.\n * Payload-dependent JavaScript can refuse symbolic inspection; that is a\n * diagnostic, not evidence that the flow itself cannot execute.\n * @category models\n * @since 1.0.0\n */\nexport interface Inspection {\n readonly nodes: ReadonlyArray<Pick<GraphNode, \"id\" | \"kind\" | \"dependencies\"> & { readonly label?: string }>\n readonly edges: ReadonlyArray<Edge>\n readonly steps: ReadonlyArray<{ readonly id: string; readonly label: string }>\n readonly diagnostics: ReadonlyArray<{ readonly code: string; readonly message: string }>\n /** The renderer's source, never rendered with an invented input. */\n readonly prompt?: string\n}\n\n/** Inspect the existing graph model with an unresolved input reference.\n * Run this only in the same guest that loads the declaration: plan-time body\n * code is repository code too. An input-dependent body is reported explicitly\n * without choosing a sample payload. As with Planned values in bodies, use\n * node combinators for branching; JavaScript truthiness is not inspectable.\n * @category constructors\n * @since 1.0.0\n */\nexport const inspect = (flow: Flow.Any): Inspection => {\n const prompt = \"prompt\" in flow && typeof flow.prompt === \"function\"\n ? Function.prototype.toString.call(flow.prompt)\n : undefined\n // The prompt source belongs to the declaration, so it rides on every\n // inspection, whether or not the graph could be built.\n const withPrompt = (inspection: Omit<Inspection, \"prompt\">): Inspection =>\n prompt === undefined ? inspection : { ...inspection, prompt }\n try {\n const graph = build(flow, Planned.make(\"input\"))\n const nodes = graph.nodes.map((node) => ({\n id: node.id,\n kind: node.kind,\n ...(node.ast._tag === \"FlowCall\" ?\n { label: node.ast.flow }\n : node.ast._tag === \"ActionCall\"\n ? { label: node.ast.action }\n : {}),\n dependencies: node.dependencies\n }))\n // Inline flow calls group the actions beneath them; only boundary calls\n // and actions are steps, so the same work is never displayed twice.\n const steps = graph.nodes.flatMap((node) =>\n node.ast._tag === \"ActionCall\" ?\n [{ id: node.id, label: node.ast.action }]\n : node.ast._tag === \"FlowCall\" && node.ast.mode !== \"inline\"\n ? [{ id: node.id, label: node.ast.flow }]\n : []\n )\n return withPrompt({\n nodes,\n edges: graph.edges,\n steps,\n diagnostics: graph.diagnostics.map(({ code, message }) => ({ code, message }))\n })\n } catch (error) {\n return withPrompt({\n // The declaration itself is a known boundary even when its internals\n // require real input. Do not publish a fictitious empty execution.\n nodes: [{ id: \"root\", kind: \"FlowCall\", label: flow._tag, dependencies: [] }],\n edges: [],\n steps: [{ id: \"root\", label: flow._tag }],\n diagnostics: [{\n code: error instanceof GraphBuildError\n ? error.code === \"planned_value_computed\" ? \"declaration_requires_input\" : error.code\n : \"declaration_inspection_failed\",\n message: error instanceof Error ? error.message : String(error)\n }]\n })\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAyDA,iBAA4B;AAC5B,cAAyB;AACzB,6BAAmD;AACnD,kBAA6B;AAC7B,WAAsB;AAEtB,cAAyB;AACzB,cAAyB;AACzB,aAAwB;AACxB,gBAA2B;AAC3B,aAAwB;AAExB,oBAAuC;AACvC,kBAA6B;AAC7B,+BAAmC;AAEnC,IAAAA,iBAAqC;AACrC,sBAAiC;AACjC,2BAAsD;AAoLtD,MAAM,eAAiC,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,GAAG,cAAc,WAAW;AAGzF,MAAM,SAAS,CAAC,WAAoD,CAAC,GAAG,IAAI,IAAI,MAAM,CAAC,EAAE,KAAK;AAG9F,MAAM,kBAAkB,CAAC,UACvB,UAAU,YAAY,OAAO,eAAAC,MAAU,IAAI,QAA+B;AAG5E,MAAM,oBAAoB,CAAC,UACzB,UAAU,YAAY,OAAO,cAAAC,MAAY,IAAI,QAAwC;AAGvF,MAAM,kBAAkB,CAAC,gBACvB,OAAO,eAAe,QAAQ,UAAU,aAAa,YAAY,kBAAkB,CAAC;AAGtF,MAAM,oBAAoB,CAAC,gBACzB,OAAO,eAAe,QAAQ,UAAU,aAAa,YAAY,SAAS,CAAC;AAG7E,MAAM,mBAAmB,CAAC,gBACxB,OAAO,eAAe,QAAQ,UAAU,aAAa,YAAY,cAAc,CAAC;AAWlF,MAAM,iBAAiB,CACrB,UACA,SACW;AACX,QAAM,KAAK,IAAI,KAAK,IAAI,SAAS,KAAK,EAAE;AACxC,UAAQ,SAAS,MAAM;AAAA,IACrB,KAAK;AACH,aAAO,QAAQ,EAAE,aAAa,SAAS,MAAM,WAAW,IAAI,WAAW,O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AAC;AAAA,MACxC,aAAa,CAAC;AAAA,QACZ,MAAM,iBAAiB,yCACnB,MAAM,SAAS,2BAA2B,+BAA+B,MAAM,OAC/E;AAAA,QACJ,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAAA,MAChE,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AACF;",
6
6
  "names": ["import_TypeId", "FlowTypeId", "ActionTypeId", "members", "left", "right", "value", "shown", "text", "options", "payload", "nodes"]
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Graph.d.ts","sourceRoot":"","sources":["../../src/Graph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AAIH,OAAO,EAAE,eAAe,EAAqB,MAAM,8BAA8B,CAAA;AAEjF,OAAO,KAAK,IAAI,MAAM,mBAAmB,CAAA;AACzC,OAAO,KAAK,KAAK,IAAI,MAAM,mBAAmB,CAAA;AAQ9C,OAAO,KAAK,WAAW,MAAM,uBAAuB,CAAA;AAEpD,OAAO,KAAK,KAAK,IAAI,MAAM,gBAAgB,CAAA;AAE3C,OAAO,KAAK,eAAe,MAAM,+BAA+B,CAAA;AAKhE;;;;;;;GAOG;AACH,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,cAAc,GAAG,SAAS,CAAA;AAE7D;;;;;;GAMG;AACH,MAAM,WAAW,IAAI;IACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAA;CAC5B;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;IAC/B,QAAQ,CAAC,YAAY,EAAE,aAAa,CAAC,MAA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