@tangle-network/agent-runtime 3.0.43 → 4.0.0

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.
Files changed (70) hide show
  1. package/dist/{activation-CiUbW1QE.d.ts → activation-B49A14V5.d.ts} +2 -2
  2. package/dist/{activation-1YUy4GWu.js → activation-BiQYCayd.js} +2 -2
  3. package/dist/{activation-1YUy4GWu.js.map → activation-BiQYCayd.js.map} +1 -1
  4. package/dist/agent.d.ts +1 -1
  5. package/dist/agent.js +4 -4
  6. package/dist/{coordination-manager-DXOwLu9T.js → coordination-manager-C-ZoeZ73.js} +6 -6
  7. package/dist/{coordination-manager-DXOwLu9T.js.map → coordination-manager-C-ZoeZ73.js.map} +1 -1
  8. package/dist/{coordination-map-routing-2_hUlTnz.js → coordination-map-routing-SnsZp287.js} +2 -2
  9. package/dist/{coordination-map-routing-2_hUlTnz.js.map → coordination-map-routing-SnsZp287.js.map} +1 -1
  10. package/dist/{delegate-CAvTMCk0.js → delegate-d9HcOFC5.js} +2 -2
  11. package/dist/{delegate-CAvTMCk0.js.map → delegate-d9HcOFC5.js.map} +1 -1
  12. package/dist/durable.d.ts +1 -1
  13. package/dist/durable.js +7 -7
  14. package/dist/{graph-C7Xthj-4.js → graph-C_Z0Ua10.js} +6 -6
  15. package/dist/{graph-C7Xthj-4.js.map → graph-C_Z0Ua10.js.map} +1 -1
  16. package/dist/{graph-registry-EGeo_moB.js → graph-registry-BU7pcrUW.js} +1 -1
  17. package/dist/{graph-registry-BoaUV5g8.js → graph-registry-CI1o16DH.js} +3 -3
  18. package/dist/{graph-registry-BoaUV5g8.js.map → graph-registry-CI1o16DH.js.map} +1 -1
  19. package/dist/{improve-BZpoezFh.js → improve-B4v4S8jY.js} +7 -7
  20. package/dist/{improve-BZpoezFh.js.map → improve-B4v4S8jY.js.map} +1 -1
  21. package/dist/index.d.ts +3 -3
  22. package/dist/index.js +9 -9
  23. package/dist/intelligence.d.ts +2 -2
  24. package/dist/intelligence.js +5 -5
  25. package/dist/{jsonl-file-CbxMVnUj.js → jsonl-file-CvPuwM0a.js} +5 -2
  26. package/dist/jsonl-file-CvPuwM0a.js.map +1 -0
  27. package/dist/kernel.d.ts +1 -1
  28. package/dist/kernel.js +12 -12
  29. package/dist/{loop-runner-Dmjf2IY6.d.ts → loop-runner-DKvA0JJr.d.ts} +2 -2
  30. package/dist/{loop-runner-BchibTTn.js → loop-runner-DMZkwlND.js} +2 -2
  31. package/dist/{loop-runner-BchibTTn.js.map → loop-runner-DMZkwlND.js.map} +1 -1
  32. package/dist/loop-runner-bin.d.ts +1 -1
  33. package/dist/loop-runner-bin.js +1 -1
  34. package/dist/mcp/bin.js +3 -3
  35. package/dist/mcp/index.d.ts +1 -1
  36. package/dist/mcp/index.js +5 -5
  37. package/dist/profiles.d.ts +1 -1
  38. package/dist/{provision-supervisor-BtDnk11d.js → provision-supervisor-Cjs4SQ9Q.js} +5 -5
  39. package/dist/{provision-supervisor-BtDnk11d.js.map → provision-supervisor-Cjs4SQ9Q.js.map} +1 -1
  40. package/dist/{run-cancellation-DEW04dun.js → run-cancellation-CGgk54Md.js} +3 -3
  41. package/dist/{run-cancellation-DEW04dun.js.map → run-cancellation-CGgk54Md.js.map} +1 -1
  42. package/dist/{runtime-CKoChP6L.js → runtime-BmxmsaNz.js} +15 -15
  43. package/dist/{runtime-CKoChP6L.js.map → runtime-BmxmsaNz.js.map} +1 -1
  44. package/dist/{scope-Bg1uCsPR.js → scope-CJ7xtrs8.js} +127 -69
  45. package/dist/scope-CJ7xtrs8.js.map +1 -0
  46. package/dist/{search-executor-CJ5y2-b8.js → search-executor-DSB6XAl1.js} +3 -3
  47. package/dist/{search-executor-CJ5y2-b8.js.map → search-executor-DSB6XAl1.js.map} +1 -1
  48. package/dist/{server-zdmmyP7r.js → server-FWT2Nt_w.js} +3 -3
  49. package/dist/{server-zdmmyP7r.js.map → server-FWT2Nt_w.js.map} +1 -1
  50. package/dist/{structural-rollout-CH9b7K9B.js → structural-rollout-Bl23HSOd.js} +3 -3
  51. package/dist/{structural-rollout-CH9b7K9B.js.map → structural-rollout-Bl23HSOd.js.map} +1 -1
  52. package/dist/{supervise-472pyfgQ.js → supervise-MAzd0hOk.js} +93 -41
  53. package/dist/supervise-MAzd0hOk.js.map +1 -0
  54. package/dist/{supervision-discovery-CD350Iar.js → supervision-discovery-6EtvKCsU.js} +3 -3
  55. package/dist/{supervision-discovery-CD350Iar.js.map → supervision-discovery-6EtvKCsU.js.map} +1 -1
  56. package/dist/{supervisor-BDOWzyCC.js → supervisor-CwANBb9-.js} +10 -3
  57. package/dist/supervisor-CwANBb9-.js.map +1 -0
  58. package/dist/testing.d.ts +1 -1
  59. package/dist/testing.js +11 -11
  60. package/dist/{top-web-CNTJBqFy.js → top-web-CZP3RRhD.js} +5 -5
  61. package/dist/{top-web-CNTJBqFy.js.map → top-web-CZP3RRhD.js.map} +1 -1
  62. package/dist/tui/bin.js +3 -3
  63. package/dist/tui/index.d.ts +1 -1
  64. package/dist/tui/index.js +2 -2
  65. package/dist/{types-tG_tps7N.d.ts → types-ooyUaxq_.d.ts} +18 -3
  66. package/package.json +2 -2
  67. package/dist/jsonl-file-CbxMVnUj.js.map +0 -1
  68. package/dist/scope-Bg1uCsPR.js.map +0 -1
  69. package/dist/supervise-472pyfgQ.js.map +0 -1
  70. package/dist/supervisor-BDOWzyCC.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"graph-registry-BoaUV5g8.js","names":[],"sources":["../src/runtime/supervise/graph-file-schema.ts","../src/runtime/supervise/graph-parameters.ts","../src/runtime/supervise/graph-registry.ts"],"sourcesContent":["import { z } from 'zod'\nimport { resolveJsonPointer } from '../../mcp/tools/coordination-map-routing'\nimport type { RouteWhen } from '../../mcp/tools/coordination-route-contracts'\n\nconst scalar = z.union([z.string(), z.number().finite(), z.boolean(), z.null()])\nconst pointer = z.string().regex(/^(?:\\/(?:[^~]|~[01])*)*$/)\nconst matchBase = { node: z.string().min(1).optional(), pointer }\nconst equals = z.strictObject({ ...matchBase, equals: scalar })\nconst oneOf = z.strictObject({ ...matchBase, in: z.array(scalar) })\nconst exists = z.strictObject({ ...matchBase, exists: z.boolean() })\nconst match = z.union([equals, oneOf, exists])\n\n/** The same data grammar as routes; no executable expressions or additional operators. */\nexport const graphRouteWhenSchema = z.union([match, z.strictObject({ all: z.array(match).min(1) })])\n\nconst parameter = z.strictObject({\n default: z.unknown().optional(),\n type: z.enum(['string', 'number', 'integer', 'boolean', 'object', 'array', 'null']).optional(),\n})\nconst command = z.strictObject({\n command: z.string().min(1),\n timeoutMs: z.number().int().positive().optional(),\n})\nconst nonnegativeInteger = z.number().int().nonnegative()\n\n/** Authoring envelope. Canonical profiles and topology are validated by their existing owners. */\nexport const graphFileSchema = z.strictObject({\n digest: z.string().min(1).optional(),\n graph: z.string().min(1).optional(),\n describe: z.string().optional(),\n params: z.record(z.string().min(1), parameter).optional(),\n nodes: z\n .array(\n z.strictObject({\n id: z.string().min(1),\n profile: z.record(z.string(), z.unknown()).optional(),\n seat: z.union([z.string().min(1), z.array(z.string().min(1)).min(1)]).optional(),\n needs: z.array(z.string().min(1)).optional(),\n }),\n )\n .min(1),\n entry: z\n .array(\n z.union([z.string().min(1), z.strictObject({ node: z.string().min(1), task: z.unknown() })]),\n )\n .min(1)\n .optional(),\n edges: z.array(z.record(z.string(), z.unknown())),\n gates: z.array(z.unknown()).optional(),\n budget: z.strictObject({\n maxIterations: nonnegativeInteger,\n maxTokens: nonnegativeInteger,\n maxUsd: z.number().finite().nonnegative().optional(),\n deadlineMs: nonnegativeInteger.optional(),\n resources: z\n .record(z.string(), z.strictObject({ unit: z.string().min(1), limit: nonnegativeInteger }))\n .optional(),\n }),\n check: z\n .union([\n equals.extend({ describe: z.string().optional() }),\n oneOf.extend({ describe: z.string().optional() }),\n exists.extend({ describe: z.string().optional() }),\n z.strictObject({ describe: z.string().optional(), all: z.array(match).min(1) }),\n z.strictObject({ describe: z.string().optional(), command }),\n ])\n .optional(),\n deliverable: z\n .strictObject({\n describe: z.string().optional(),\n checkRef: z.string().min(1),\n command: command.optional(),\n when: graphRouteWhenSchema.optional(),\n })\n .optional(),\n on: z.unknown().optional(),\n})\n\n/** Judge the flow's terminal-output map with RouteWhen's own JSON-pointer semantics. */\nexport function checkGraphRoute(when: RouteWhen, output: unknown): boolean {\n return ('all' in when ? when.all : [when]).every((condition) => {\n let document = output\n if (condition.node !== undefined) {\n if (!output || typeof output !== 'object' || !Object.hasOwn(output, condition.node))\n return false\n document = (output as Record<string, unknown>)[condition.node]\n }\n const selected = resolveJsonPointer(document, condition.pointer)\n if ('exists' in condition) return selected.found === condition.exists\n if (!selected.found) return false\n return 'equals' in condition\n ? selected.value === condition.equals\n : condition.in.some((value) => value === selected.value)\n })\n}\n","import { z } from 'zod'\nimport { ValidationError } from '../../errors'\n\nexport interface GraphParameterBindings {\n readonly params?: Readonly<Record<string, unknown>>\n readonly trigger?: Readonly<Record<string, unknown>>\n}\n\nconst triggerPart = z.strictObject({ trigger: z.array(z.string()).min(1) })\nconst literalPart = z.strictObject({ literal: z.string() })\n/** Explicit authored trigger slots in compiled graph data. An empty list marks fully bound data. */\nexport const graphTriggerBindingsSchema = z.array(\n z\n .strictObject({\n path: z.array(z.union([z.string(), z.number().int().nonnegative()])).min(1),\n mode: z.enum(['value', 'text']),\n parts: z.array(z.union([literalPart, triggerPart])).min(1),\n })\n .superRefine((slot, context) => {\n if (\n !slot.parts.some((part) => 'trigger' in part) ||\n (slot.mode === 'value' && (slot.parts.length !== 1 || !('trigger' in slot.parts[0]!)))\n )\n context.addIssue({\n code: 'custom',\n message: 'binding requires authored trigger parts; value slots require one trigger',\n })\n }),\n)\n/** @useDeclaredType */\nexport type GraphTriggerBinding = z.infer<typeof graphTriggerBindingsSchema>[number]\n\ntype Part = GraphTriggerBinding['parts'][number]\n\nfunction readBinding(\n namespace: keyof GraphParameterBindings,\n keys: readonly string[],\n bindings: GraphParameterBindings,\n): unknown {\n let found: unknown = bindings[namespace]\n for (const key of keys) {\n if (!found || typeof found !== 'object' || !Object.hasOwn(found, key))\n throw new ValidationError(`graph parameters: missing ${[namespace, ...keys].join('.')}`)\n found = (found as Record<string, unknown>)[key]\n }\n if (found === undefined)\n throw new ValidationError(`graph parameters: missing ${[namespace, ...keys].join('.')}`)\n return structuredClone(found)\n}\n\nfunction textValue(value: unknown, expression: string): string {\n if (value !== null && typeof value === 'object')\n throw new ValidationError(`graph parameters: ${expression} needs a whole JSON slot`)\n return String(value)\n}\n\nfunction pendingText(parts: readonly Part[]): string {\n return parts\n .map((part) => ('literal' in part ? part.literal : `\\${trigger.${part.trigger.join('.')}}`))\n .join('')\n}\n\n/** Compile authored slots once. Inserted values are data, never recursively parsed templates. */\nexport function compileGraphParameters(\n value: unknown,\n bindings: GraphParameterBindings,\n options: { readonly defer?: readonly (keyof GraphParameterBindings)[] } = {},\n): { value: unknown; triggerBindings: GraphTriggerBinding[] } {\n const visiting = new Set<object>()\n const triggerBindings: GraphTriggerBinding[] = []\n const bind = (item: unknown, path: Array<string | number>): unknown => {\n if (typeof item === 'string') {\n if (item.replace(/\\$\\{[^{}]+\\}/g, '').includes('${'))\n throw new ValidationError('graph parameters: malformed reference')\n const whole = /^\\$\\{([^{}]+)\\}$/.exec(item)\n const parts: Part[] = []\n let cursor = 0\n let wholeValue: unknown\n let boundWhole = false\n for (const match of item.matchAll(/\\$\\{([^{}]+)\\}/g)) {\n if (match.index > cursor) parts.push({ literal: item.slice(cursor, match.index) })\n const [namespace, ...keys] = match[1]!.split('.')\n if ((namespace !== 'params' && namespace !== 'trigger') || keys.length === 0)\n throw new ValidationError(`graph parameters: unsupported reference \\${${match[1]}}`)\n if (options.defer?.includes(namespace)) {\n if (namespace === 'trigger') parts.push({ trigger: keys })\n else parts.push({ literal: match[0] })\n } else {\n const found = readBinding(namespace, keys, bindings)\n if (whole) {\n wholeValue = found\n boundWhole = true\n } else parts.push({ literal: textValue(found, match[1]!) })\n }\n cursor = match.index + match[0].length\n }\n if (boundWhole) return wholeValue\n if (cursor === 0) return item\n if (cursor < item.length) parts.push({ literal: item.slice(cursor) })\n if (parts.some((part) => 'trigger' in part))\n triggerBindings.push({ path, mode: whole ? 'value' : 'text', parts })\n return pendingText(parts)\n }\n if (!item || typeof item !== 'object') return item\n if (visiting.has(item)) throw new ValidationError('graph parameters: cyclic data is not JSON')\n visiting.add(item)\n const bound = Array.isArray(item)\n ? item.map((child, index) => bind(child, [...path, index]))\n : Object.fromEntries(\n Object.entries(item).map(([key, child]) => [key, bind(child, [...path, key])]),\n )\n visiting.delete(item)\n return bound\n }\n return { value: bind(value, []), triggerBindings }\n}\n\n/** Legacy authored-data binding. Compiled graphs use bindCompiledGraphTriggers instead. */\nexport function bindGraphParameters(\n value: unknown,\n bindings: GraphParameterBindings,\n options: { readonly defer?: readonly (keyof GraphParameterBindings)[] } = {},\n): unknown {\n return compileGraphParameters(value, bindings, options).value\n}\n\n/** Check provenance against the exact provisional values without reading trigger data. */\nexport function assertGraphTriggerBindings(\n value: unknown,\n slots: readonly GraphTriggerBinding[],\n): void {\n const seen = new Set<string>()\n for (const slot of graphTriggerBindingsSchema.parse(slots)) {\n const key = JSON.stringify(slot.path.map(String))\n if (seen.has(key)) throw new ValidationError('graph parameters: duplicate trigger binding path')\n seen.add(key)\n let found: unknown = value\n for (const key of slot.path) {\n if (!found || typeof found !== 'object' || !Object.hasOwn(found, key))\n throw new ValidationError('graph parameters: trigger binding path does not exist')\n found = (found as Record<string | number, unknown>)[key]\n }\n if (found !== pendingText(slot.parts))\n throw new ValidationError(\n 'graph parameters: trigger binding does not match its provisional value',\n )\n }\n}\n\n/** Only explicitly recorded authored slots bind. Literal parameter/trigger values are untouched. */\nexport function bindCompiledGraphTriggers<T>(\n value: T,\n slots: readonly GraphTriggerBinding[],\n trigger: GraphParameterBindings['trigger'],\n): T {\n assertGraphTriggerBindings(value, slots)\n const bound = structuredClone(value)\n for (const slot of slots) {\n let parent = bound as Record<string | number, unknown>\n for (const key of slot.path.slice(0, -1)) parent = parent[key] as typeof parent\n parent[slot.path.at(-1)!] =\n slot.mode === 'value'\n ? readBinding('trigger', (slot.parts[0]! as { trigger: string[] }).trigger, { trigger })\n : slot.parts\n .map((part) =>\n 'literal' in part\n ? part.literal\n : textValue(\n readBinding('trigger', part.trigger, { trigger }),\n `trigger.${part.trigger.join('.')}`,\n ),\n )\n .join('')\n }\n return bound\n}\n","/**\n * `graph-registry` — the designer's memory: graphs and their outcomes as files.\n *\n * The AgentGraph algebra makes a graph PLAIN DATA (nodes with pinned profiles,\n * edges with registry-versioned directives, a budget, a deliverable\n * description), which is the property that lets a graph be stored, replayed\n * byte-identical, and mutated like code. This module is the thin durable layer\n * on top: one JSONL record per run, the exact graph content-addressed beside\n * it. The natural home is a SANDBOX WORKSPACE — the platform's snapshot story\n * (Firecracker restore, warm leases, `continuity: 'resume'`) then makes the\n * registry the agent's compounding execution memory across runs: a rerun over\n * the same sandbox finds every graph the designer ever ran, what each cost,\n * and whether it delivered.\n *\n * ORACLES STAY ENVIRONMENT-OWNED. `DeliverableSpec.check` is a function and is\n * deliberately NOT stored: a stored graph keeps the deliverable's `describe`\n * and an optional `checkRef`, and replay re-binds the check from the caller's\n * environment. This is the graph contract's own doctrine — graders are\n * environment, never workers — applied to persistence.\n *\n * Scoring is a documented heuristic, not a learned model: delivered beats\n * failed, then cheaper (tokens, then iterations), then most recent. A designer\n * that needs better selection replaces `pickBest`, not the records.\n */\n\nimport { mkdir, readdir, readFile } from 'node:fs/promises'\nimport { join } from 'node:path'\nimport type { AgentProfile } from '@tangle-network/agent-interface'\nimport { sha256 } from '../../content-digest'\nimport {\n isNoEntError,\n readCommittedJsonFile,\n upsertCommittedJsonLine,\n withJsonlFileLock,\n} from '../../durable/jsonl-file'\nimport { ValidationError } from '../../errors'\nimport { writeAtomicDurableFile } from './durable-file'\nimport type { AgentGraph, GraphEdge } from './graph'\nimport { checkGraphRoute } from './graph-file-schema'\nimport {\n bindCompiledGraphTriggers,\n bindGraphParameters,\n type GraphTriggerBinding,\n} from './graph-parameters'\n\nexport type { GraphTriggerBinding } from './graph-parameters'\n\nimport type { GraphFromStoredOptions } from './stored-graph-check'\n\nexport type { GraphCommandCheck, GraphFromStoredOptions } from './stored-graph-check'\n\n/** @inline */\ninterface StoredGraphContent {\n readonly digest: string\n /** Authored trigger-slot provenance; present (even empty) on compiled loader output. */\n readonly triggerBindings?: readonly GraphTriggerBinding[]\n readonly nodes: ReadonlyArray<{ readonly id: string; readonly profile: AgentProfile }>\n readonly deliverable: Pick<\n AgentGraph['deliverable'],\n 'describe' | 'checkRef' | 'command' | 'when'\n >\n /** A flow graph's entry and gates; absent for any other graph. */\n readonly entry?: AgentGraph['entry']\n readonly gates?: AgentGraph['gates']\n}\n\n/** A graph as stored. Observed imports retain unknown directives and budgets;\n * they describe what happened and cannot be replayed as executable graphs. */\nexport type StoredGraph = StoredGraphContent &\n (\n | {\n readonly observed?: false\n readonly edges: ReadonlyArray<GraphEdge>\n readonly budget: AgentGraph['budget']\n }\n | {\n readonly observed: true\n readonly edges: ReadonlyArray<\n | GraphEdge\n | {\n readonly from: string\n readonly to: string\n }\n >\n readonly budget?: AgentGraph['budget']\n }\n )\n\n/** Editable graph data; registration computes its digest when it is omitted. */\nexport type StoredGraphInput = Omit<\n Extract<StoredGraph, { readonly observed?: false }>,\n 'digest'\n> & {\n readonly digest?: string\n}\n\n/** One run or an explicitly incomplete observation of a graph, for one task shape. */\nexport interface GraphRunRecord {\n /** Content-address of the exact graph that ran. */\n readonly graphDigest: string\n /** Digest of the normalized task shape the designer computed for lookup. */\n readonly taskDigest: string\n readonly startedAt: string\n /** Absent while running or when completion was not established. */\n readonly finishedAt?: string\n readonly outcome:\n | { readonly kind: 'delivered'; readonly summary?: string }\n | { readonly kind: 'no-winner'; readonly reason?: string }\n | { readonly kind: 'unknown' | 'running'; readonly reason: string }\n /** Measured accounting; running observations are to date. Unknown channels omitted. */\n readonly cost: {\n readonly iterations?: number\n readonly tokens?: number\n readonly usd?: number\n readonly ms?: number\n readonly inputTokens?: number\n readonly outputTokens?: number\n readonly humanMessages?: number\n readonly leadMessages?: number\n /** Elapsed wall time from the task start to an independently verified merge. */\n readonly mergeMs?: number\n }\n /** Metered ledger size, absent when a source exposes relationships without traversals. */\n readonly traversals?: number\n readonly exhaustedEdges?: ReadonlyArray<string>\n /** Explicit source metadata, never classified from transcript or PR prose. */\n readonly taskType?: 'feature' | 'bugfix' | 'consolidation' | 'investigation' | 'ops'\n /** Stable run identity; re-ingesting this source replaces its observation. */\n readonly source?: { readonly kind: string; readonly id: string; readonly url?: string }\n readonly observedAt?: string\n /** Link to the canonical trace run; execution trees remain trace-owned. */\n readonly traceRunId?: string\n /** Canonical ordered adjacency. This is not a graph-isomorphism claim. */\n readonly topologyDigest?: string\n readonly evidence?: ReadonlyArray<{\n readonly kind: string\n readonly url: string\n readonly at?: string\n }>\n readonly nodeUsage?: ReadonlyArray<{\n readonly nodeId: string\n readonly sourceId?: string\n readonly startedAt?: string\n /** Latest recorded activity, not a claim that the node finished. */\n readonly lastRecordAt?: string\n readonly finishedAt?: string\n readonly inputTokens?: number\n readonly outputTokens?: number\n readonly humanMessages?: number\n readonly leadMessages?: number\n }>\n /** Missing or partial evidence, including incomplete accounting channels. */\n readonly unknowns?: ReadonlyArray<string>\n}\n\nexport interface GraphRegistryDir {\n readonly root: string\n}\n\nconst RECORDS_FILE = 'records.jsonl'\nconst GRAPHS_DIR = 'graphs'\n\n/** Canonical serialization for content-addressing: stable key order, sorted. */\nfunction canonicalJson(value: unknown): string {\n if (Array.isArray(value)) return `[${value.map(canonicalJson).join(',')}]`\n if (value && typeof value === 'object') {\n const entries = Object.entries(value as Record<string, unknown>)\n .filter(([, v]) => v !== undefined)\n .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))\n return `{${entries.map(([k, v]) => `${JSON.stringify(k)}:${canonicalJson(v)}`).join(',')}}`\n }\n return JSON.stringify(value)\n}\n\n/** Digest of the exact graph (nodes + edges + budget + deliverable describe, and a flow graph's\n * entry and gates). An absent key is not serialized, so a graph without `entry` keeps the digest\n * it had before flow graphs were stored. */\nexport function graphDigest(graph: Omit<StoredGraph, 'digest'>): string {\n return sha256(canonicalJson(graph))\n}\n\n/** Digest of the normalized task shape a designer looks records up by. */\nexport function taskShapeDigest(taskShape: Record<string, unknown>): string {\n return sha256(canonicalJson(taskShape))\n}\n\n/** Digest of a runnable graph exactly as the registry stores it — the value\n * `recordGraphRun` demands. Callers recording real runs hash through this,\n * never hand-rolled, so a record always matches its graph. */\nexport function digestOfGraph(graph: AgentGraph): string {\n return storeGraph(graph).digest\n}\n\nfunction storeGraph(graph: AgentGraph): StoredGraph {\n const { describe, checkRef, command, when } = graph.deliverable\n const content = {\n nodes: graph.nodes,\n edges: graph.edges,\n budget: graph.budget,\n ...(graph.triggerBindings === undefined ? {} : { triggerBindings: graph.triggerBindings }),\n deliverable: {\n ...(describe ? { describe } : {}),\n ...(checkRef ? { checkRef } : {}),\n ...(command ? { command } : {}),\n ...(when ? { when } : {}),\n },\n ...(graph.entry === undefined ? {} : { entry: graph.entry }),\n ...(graph.gates === undefined ? {} : { gates: graph.gates }),\n }\n return { digest: graphDigest(content), ...content }\n}\n\nfunction assertRecord(record: GraphRunRecord): void {\n if (typeof record.graphDigest !== 'string' || record.graphDigest.length === 0)\n throw new ValidationError('graph-registry: record.graphDigest is required')\n if (typeof record.taskDigest !== 'string' || record.taskDigest.length === 0)\n throw new ValidationError('graph-registry: record.taskDigest is required')\n if (!Number.isFinite(Date.parse(record.startedAt)))\n throw new ValidationError('graph-registry: record.startedAt must be a timestamp')\n if (!['delivered', 'no-winner', 'unknown', 'running'].includes(record.outcome.kind))\n throw new ValidationError('graph-registry: invalid record.outcome.kind')\n if (\n (record.outcome.kind === 'delivered' || record.outcome.kind === 'no-winner') &&\n (!record.finishedAt || !Number.isFinite(Date.parse(record.finishedAt)))\n )\n throw new ValidationError('graph-registry: terminal outcomes require record.finishedAt')\n if (\n (record.outcome.kind === 'unknown' || record.outcome.kind === 'running') &&\n !record.outcome.reason\n )\n throw new ValidationError('graph-registry: incomplete outcomes require a reason')\n if (record.source && (!record.source.kind || !record.source.id))\n throw new ValidationError('graph-registry: source.kind and source.id are required')\n if (\n record.finishedAt &&\n (!Number.isFinite(Date.parse(record.finishedAt)) ||\n Date.parse(record.finishedAt) < Date.parse(record.startedAt))\n )\n throw new ValidationError('graph-registry: finishedAt precedes startedAt or is invalid')\n for (const [channel, value] of Object.entries(record.cost)) {\n if (value !== undefined && (typeof value !== 'number' || !Number.isFinite(value) || value < 0))\n throw new ValidationError(`graph-registry: invalid cost.${channel}`)\n }\n}\n\nfunction recordKey(record: GraphRunRecord): string {\n assertRecord(record)\n if (record.source) return JSON.stringify(['source', record.source.kind, record.source.id])\n return JSON.stringify([record.taskDigest, record.graphDigest, record.startedAt])\n}\n\n/** Open (or lazily create) a registry rooted at a workspace directory. The\n * directory is the sandbox workspace; snapshots carry it across runs. */\nexport function graphRegistry(root: string): GraphRegistryDir {\n if (!root || root.trim().length === 0)\n throw new ValidationError('graphRegistry: root directory is required')\n return { root }\n}\n\n/** Append one run record; the exact graph is content-addressed beside it.\n * Idempotent per (taskDigest, graphDigest, startedAt): a replayed append with\n * the same key replaces the prior row rather than duplicating it. */\nexport async function recordGraphRun(\n reg: GraphRegistryDir,\n graph: AgentGraph,\n record: GraphRunRecord,\n): Promise<StoredGraph> {\n const stored = storeGraph(graph)\n return recordStoredGraphRun(reg, stored, record)\n}\n\n/** Store an executable graph or an observed external topology in the same registry.\n * Imported observations retain their source identity and never authorize replay.\n * A reader refreshing facts can preserve independently joined labels; an explicit\n * correction leaves preserveLabels unset and replaces the record. */\nexport async function recordStoredGraphRun(\n reg: GraphRegistryDir,\n definition: StoredGraph | StoredGraphInput,\n record?: GraphRunRecord,\n options: { readonly preserveLabels?: boolean } = {},\n): Promise<StoredGraph> {\n const { digest, ...content } = definition\n const stored = { ...content, digest: digest ?? graphDigest(content) } as StoredGraph\n if (stored.observed && !record)\n throw new ValidationError('graph-registry: observed graphs require a source run identity')\n if (record) {\n assertRecord(record)\n if (stored.observed && !record.source)\n throw new ValidationError('graph-registry: observed graphs require a source run identity')\n if (!stored.observed && !record.finishedAt)\n throw new ValidationError('graph-registry: native graph runs require a completion timestamp')\n if (\n (!stored.observed || record.traversals !== undefined) &&\n (!Number.isSafeInteger(record.traversals) || record.traversals! < 0)\n )\n throw new ValidationError(\n 'graph-registry: native graphs require metered traversals; observed counts must be non-negative integers',\n )\n if (stored.digest !== record.graphDigest) {\n throw new ValidationError(\n `graph-registry: record.graphDigest ${record.graphDigest} does not match the supplied graph (${stored.digest}) — record the graph that actually ran`,\n )\n }\n }\n if (graphDigest(content) !== stored.digest)\n throw new ValidationError('graph-registry: stored graph content does not match its digest')\n await mkdir(join(reg.root, GRAPHS_DIR), { recursive: true })\n const file = join(reg.root, RECORDS_FILE)\n return withJsonlFileLock(file, async (canonicalPath) => {\n if (!record) {\n await persistGraph(reg, stored)\n return stored\n }\n let persisted = record\n if (options.preserveLabels && record.source) {\n const prior = (await readCommittedJsonFile<GraphRunRecord>(canonicalPath)).find(\n (row) => row.source?.kind === record.source!.kind && row.source.id === record.source!.id,\n )\n if (prior) {\n const taskType = record.taskType ?? prior.taskType\n const priorTerminal =\n prior.outcome.kind === 'delivered' || prior.outcome.kind === 'no-winner'\n const incomingUnassessed =\n record.outcome.kind === 'unknown' || record.outcome.kind === 'running'\n if (priorTerminal && incomingUnassessed && prior.startedAt !== record.startedAt)\n throw new ValidationError(\n 'graph-registry: preserving labels requires the same task start and source identity',\n )\n const evidence = [...(prior.evidence ?? []), ...(record.evidence ?? [])]\n persisted = {\n ...record,\n ...(taskType ? { taskType } : {}),\n ...(record.unknowns\n ? {\n unknowns: record.unknowns.filter(\n (reason) => !(taskType && reason === 'task type not explicitly labeled'),\n ),\n }\n : {}),\n ...(evidence.length\n ? {\n evidence: [\n ...new Map(evidence.map((entry) => [canonicalJson(entry), entry])).values(),\n ],\n }\n : {}),\n ...(priorTerminal && incomingUnassessed\n ? {\n outcome: prior.outcome,\n finishedAt: prior.finishedAt,\n cost: {\n ...record.cost,\n ...(prior.cost.ms === undefined ? {} : { ms: prior.cost.ms }),\n ...(prior.cost.mergeMs === undefined ? {} : { mergeMs: prior.cost.mergeMs }),\n },\n }\n : {}),\n }\n }\n }\n assertRecord(persisted)\n await persistGraph(reg, stored)\n await upsertCommittedJsonLine(canonicalPath, persisted, recordKey)\n return stored\n })\n}\n\nasync function persistGraph(reg: GraphRegistryDir, stored: StoredGraph): Promise<void> {\n const revisionPath = join(reg.root, GRAPHS_DIR, `${stored.digest}.json`)\n try {\n const { digest: existingDigest, ...existing } = JSON.parse(\n await readFile(revisionPath, 'utf8'),\n ) as StoredGraph\n if (existingDigest !== stored.digest || graphDigest(existing) !== stored.digest)\n throw new ValidationError(\n 'graph-registry: stored graph revision is immutable but its content differs',\n )\n } catch (error) {\n if (!isNoEntError(error)) throw error\n // Content-addressed revisions are immutable. Rewriting one on every run adds\n // an unnecessary durable publication to the record lock's critical section.\n writeAtomicDurableFile(revisionPath, JSON.stringify(stored), { preserveMode: true })\n }\n}\n\n/** All records, newest last. */\nexport async function listGraphRuns(reg: GraphRegistryDir): Promise<GraphRunRecord[]> {\n return readCommittedJsonFile<GraphRunRecord>(join(reg.root, RECORDS_FILE))\n}\n\n/** Filters over the existing graph run records. Missing source kind is native. */\nexport interface GraphRunQuery {\n readonly taskDigest?: string\n readonly taskType?: GraphRunRecord['taskType'] | 'unknown'\n readonly topologyDigest?: string\n readonly sourceKind?: string\n}\n\nfunction observedTopology(record: GraphRunRecord): string {\n return record.topologyDigest ?? (record.source ? 'unknown' : record.graphDigest)\n}\n\n/** Records for one task shape or deterministic label query, newest last. */\nexport async function graphRunsFor(\n reg: GraphRegistryDir,\n query: string | GraphRunQuery = {},\n): Promise<GraphRunRecord[]> {\n const filters = typeof query === 'string' ? { taskDigest: query } : query\n return (await listGraphRuns(reg)).filter(\n (row) =>\n (filters.taskDigest === undefined || row.taskDigest === filters.taskDigest) &&\n (filters.taskType === undefined || (row.taskType ?? 'unknown') === filters.taskType) &&\n (filters.topologyDigest === undefined || observedTopology(row) === filters.topologyDigest) &&\n (filters.sourceKind === undefined || (row.source?.kind ?? 'native') === filters.sourceKind),\n )\n}\n\n/** Descriptive task-type/topology measurements, with every population explicit.\n * Unknown and running runs never enter the assessed denominator or medians. */\nexport interface GraphCorpusGroup {\n readonly taskType: NonNullable<GraphRunRecord['taskType']> | 'unknown'\n readonly topologyDigest: string\n readonly delivered: number\n readonly assessed: number\n readonly unknown: number\n readonly deliveredRate: number | null\n readonly medianWallMs: number | null\n readonly wallMsCount: number\n readonly medianMergeMs: number | null\n readonly mergeMsCount: number\n readonly medianTokens: number | null\n readonly tokenCount: number\n readonly medianHumanMessages: number | null\n readonly humanMessageCount: number\n readonly runs: readonly GraphRunRecord[]\n}\n\n/** The registry's observational view. It neither authorizes replay nor proves a causal win. */\nexport interface GraphCorpusSummary {\n readonly recordCount: number\n readonly groups: readonly GraphCorpusGroup[]\n}\n\nfunction medianKnown(values: readonly (number | undefined)[]): {\n median: number | null\n count: number\n} {\n const known = values\n .filter((value): value is number => value !== undefined && Number.isFinite(value) && value >= 0)\n .sort((a, b) => a - b)\n const middle = Math.floor(known.length / 2)\n return {\n count: known.length,\n median:\n known.length === 0\n ? null\n : known.length % 2\n ? known[middle]!\n : (known[middle - 1]! + known[middle]!) / 2,\n }\n}\n\n// The single observational policy used by both query and pickBestGraph. Native\n// selection below remains unchanged; this policy is an explicit descriptive opt-in.\nfunction observedGraphSummary(records: readonly GraphRunRecord[]): GraphCorpusSummary {\n const groups = new Map<string, GraphRunRecord[]>()\n for (const record of records) {\n const key = JSON.stringify([record.taskType ?? 'unknown', observedTopology(record)])\n const rows = groups.get(key)\n if (rows) rows.push(record)\n else groups.set(key, [record])\n }\n const summaries: GraphCorpusGroup[] = [...groups.values()].map((runs) => {\n const assessed = runs.filter(\n (run) => run.outcome.kind === 'delivered' || run.outcome.kind === 'no-winner',\n )\n const delivered = assessed.filter((run) => run.outcome.kind === 'delivered')\n const wall = medianKnown(assessed.map((run) => run.cost.ms))\n const merge = medianKnown(\n delivered\n .filter((run) => run.evidence?.some((entry) => entry.kind === 'pr-merged'))\n .map((run) => run.cost.mergeMs),\n )\n const tokens = medianKnown(assessed.map((run) => run.cost.tokens))\n const human = medianKnown(assessed.map((run) => run.cost.humanMessages))\n return {\n taskType: runs[0]!.taskType ?? 'unknown',\n topologyDigest: observedTopology(runs[0]!),\n delivered: delivered.length,\n assessed: assessed.length,\n unknown: runs.length - assessed.length,\n deliveredRate: assessed.length ? delivered.length / assessed.length : null,\n medianWallMs: wall.median,\n wallMsCount: wall.count,\n medianMergeMs: merge.median,\n mergeMsCount: merge.count,\n medianTokens: tokens.median,\n tokenCount: tokens.count,\n medianHumanMessages: human.median,\n humanMessageCount: human.count,\n runs,\n }\n })\n summaries.sort((a, b) => {\n const delivered = (b.deliveredRate ?? -1) - (a.deliveredRate ?? -1)\n if (delivered) return delivered\n for (const key of ['medianWallMs', 'medianTokens', 'medianHumanMessages'] as const) {\n if (a[key] === b[key]) continue\n if (a[key] === null) return 1\n if (b[key] === null) return -1\n return a[key]! - b[key]!\n }\n return a.taskType.localeCompare(b.taskType) || a.topologyDigest.localeCompare(b.topologyDigest)\n })\n return { recordCount: records.length, groups: summaries }\n}\n\n/** Query and rank the same registry records using the opt-in observational\n * policy: delivery rate, wall time, tokens, then human messages; unknowns last. */\nexport async function graphCorpusSummary(\n reg: GraphRegistryDir,\n query: GraphRunQuery = {},\n): Promise<GraphCorpusSummary> {\n return observedGraphSummary(await graphRunsFor(reg, query))\n}\n\nexport type GraphSelection =\n | { readonly kind: 'replay'; readonly graph: StoredGraph; readonly record: GraphRunRecord }\n | { readonly kind: 'author'; readonly reason: string }\n\n/** The documented heuristic: delivered beats failed; among delivered, cheaper\n * (tokens, then iterations) wins; ties go to the most recent. */\nexport function pickBestGraph(\n records: ReadonlyArray<GraphRunRecord>,\n options: { readonly policy?: 'native' | 'observed' } = {},\n): GraphRunRecord | undefined {\n if (options.policy === 'observed') {\n const group = observedGraphSummary(records).groups[0]\n return group && pickBestGraph(group.runs)\n }\n const delivered = records.filter((row) => row.outcome.kind === 'delivered')\n if (delivered.length === 0) return undefined\n const better = (a: GraphRunRecord, b: GraphRunRecord): GraphRunRecord => {\n const aTokens = a.cost.tokens ?? Number.POSITIVE_INFINITY\n const bTokens = b.cost.tokens ?? Number.POSITIVE_INFINITY\n if (aTokens !== bTokens) return aTokens < bTokens ? a : b\n const aIter = a.cost.iterations ?? Number.POSITIVE_INFINITY\n const bIter = b.cost.iterations ?? Number.POSITIVE_INFINITY\n if (aIter !== bIter) return aIter < bIter ? a : b\n return a.finishedAt! >= b.finishedAt! ? a : b\n }\n return delivered.reduce((best, row) => (better(best, row) === best ? best : row))\n}\n\n/** Load a stored graph by digest. */\nexport async function loadGraph(\n reg: GraphRegistryDir,\n digest: string,\n): Promise<StoredGraph | undefined> {\n try {\n return JSON.parse(\n await readFile(join(reg.root, GRAPHS_DIR, `${digest}.json`), 'utf8'),\n ) as StoredGraph\n } catch {\n return undefined\n }\n}\n\n/** The designer's lookup: replay the known-good graph for this task shape, or\n * author a new one — with the reason stated either way (the decision is data). */\nexport async function lookupGraph(\n reg: GraphRegistryDir,\n taskDigest: string,\n): Promise<GraphSelection> {\n const records = await graphRunsFor(reg, taskDigest)\n const candidates: GraphRunRecord[] = []\n const loaded = new Map<string, StoredGraph | undefined>()\n for (const record of records) {\n if (!loaded.has(record.graphDigest))\n loaded.set(record.graphDigest, await loadGraph(reg, record.graphDigest))\n const graph = loaded.get(record.graphDigest)\n if (!graph?.observed) candidates.push(record)\n }\n if (records.length && !candidates.length)\n return {\n kind: 'author',\n reason: 'only observed topologies are available; author an executable graph',\n }\n const best = pickBestGraph(candidates)\n if (best) {\n const graph = await loadGraph(reg, best.graphDigest)\n if (graph) return { kind: 'replay', graph, record: best }\n return {\n kind: 'author',\n reason: `best record's graph ${best.graphDigest.slice(0, 12)} is missing from the registry`,\n }\n }\n return {\n kind: 'author',\n reason:\n records.length === 0\n ? 'first run for this task shape'\n : 'no graph delivered for this task shape yet',\n }\n}\n\n/** Rehydrate a stored graph, binding trigger data and an environment-owned named check. */\nexport function graphFromStored(\n stored: StoredGraph | StoredGraphInput,\n environment: AgentGraph['deliverable']['check'] | GraphFromStoredOptions = {},\n): AgentGraph {\n if (stored.observed)\n throw new ValidationError('graphFromStored: observed topology cannot be replayed')\n const {\n digest: _digest,\n observed: _observed,\n triggerBindings: _triggerBindings,\n deliverable,\n ...topology\n } = (\n stored.triggerBindings !== undefined\n ? bindCompiledGraphTriggers(\n stored,\n stored.triggerBindings,\n typeof environment === 'function' ? undefined : (environment.trigger ?? {}),\n )\n : typeof environment === 'function'\n ? stored\n : bindGraphParameters(stored, { trigger: environment.trigger ?? {} })\n ) as typeof stored\n const selected =\n typeof environment === 'function'\n ? environment\n : environment.checks && Object.hasOwn(environment.checks, deliverable.checkRef ?? '')\n ? environment.checks[deliverable.checkRef!]\n : deliverable.checkRef === 'command'\n ? deliverable.command\n : deliverable.checkRef === 'route' && deliverable.when\n ? (((out, context) =>\n context\n ? context.originalVerdict?.valid !== false\n : checkGraphRoute(\n deliverable.when!,\n out,\n )) satisfies AgentGraph['deliverable']['check'])\n : undefined\n if (!selected)\n throw new ValidationError(\n `graphFromStored: unknown checkRef ${deliverable.checkRef ?? '(missing)'}`,\n )\n const materialized = stored.triggerBindings === undefined ? {} : { triggerBindings: [] as const }\n if (typeof selected === 'function') {\n const { command: _command, ...description } = deliverable\n return { ...topology, ...materialized, deliverable: { ...description, check: selected } }\n }\n const command =\n selected === deliverable.command\n ? selected\n : (bindGraphParameters(selected, {\n trigger: (environment as GraphFromStoredOptions).trigger ?? {},\n }) as typeof selected)\n return {\n ...topology,\n ...materialized,\n deliverable: {\n ...deliverable,\n command,\n check: () => false, // runGraph binds the independent command authority before execution.\n },\n }\n}\n\n/** Digests present on disk (integrity probe for tests and audits). */\nexport async function storedGraphDigests(reg: GraphRegistryDir): Promise<string[]> {\n try {\n return (await readdir(join(reg.root, GRAPHS_DIR)))\n .filter((name) => name.endsWith('.json'))\n .map((name) => name.slice(0, -'.json'.length))\n .sort()\n } catch {\n return []\n }\n}\n"],"mappings":";;;;;;;;AAIA,MAAM,SAAS,EAAE,MAAM;CAAC,EAAE,OAAO;CAAG,EAAE,OAAO,CAAC,CAAC,OAAO;CAAG,EAAE,QAAQ;CAAG,EAAE,KAAK;AAAC,CAAC;AAC/E,MAAM,UAAU,EAAE,OAAO,CAAC,CAAC,MAAM,0BAA0B;AAC3D,MAAM,YAAY;CAAE,MAAM,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;CAAG;AAAQ;AAChE,MAAM,SAAS,EAAE,aAAa;CAAE,GAAG;CAAW,QAAQ;AAAO,CAAC;AAC9D,MAAM,QAAQ,EAAE,aAAa;CAAE,GAAG;CAAW,IAAI,EAAE,MAAM,MAAM;AAAE,CAAC;AAClE,MAAM,SAAS,EAAE,aAAa;CAAE,GAAG;CAAW,QAAQ,EAAE,QAAQ;AAAE,CAAC;AACnE,MAAM,QAAQ,EAAE,MAAM;CAAC;CAAQ;CAAO;AAAM,CAAC;;AAG7C,MAAa,uBAAuB,EAAE,MAAM,CAAC,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,KAAK,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;AAEnG,MAAM,YAAY,EAAE,aAAa;CAC/B,SAAS,EAAE,QAAQ,CAAC,CAAC,SAAS;CAC9B,MAAM,EAAE,KAAK;EAAC;EAAU;EAAU;EAAW;EAAW;EAAU;EAAS;CAAM,CAAC,CAAC,CAAC,SAAS;AAC/F,CAAC;AACD,MAAM,UAAU,EAAE,aAAa;CAC7B,SAAS,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CACzB,WAAW,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC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,aAAa;EACf;CACF;AACF;;AAGA,eAAsB,mBAAmB,KAA0C;CACjF,IAAI;EACF,QAAQ,MAAM,QAAQ,KAAK,IAAI,MAAM,UAAU,CAAC,EAAA,CAC7C,QAAQ,SAAS,KAAK,SAAS,OAAO,CAAC,CAAC,CACxC,KAAK,SAAS,KAAK,MAAM,GAAG,EAAe,CAAC,CAAC,CAC7C,KAAK;CACV,QAAQ;EACN,OAAO,CAAC;CACV;AACF"}
1
+ {"version":3,"file":"graph-registry-CI1o16DH.js","names":[],"sources":["../src/runtime/supervise/graph-file-schema.ts","../src/runtime/supervise/graph-parameters.ts","../src/runtime/supervise/graph-registry.ts"],"sourcesContent":["import { z } from 'zod'\nimport { resolveJsonPointer } from '../../mcp/tools/coordination-map-routing'\nimport type { RouteWhen } from '../../mcp/tools/coordination-route-contracts'\n\nconst scalar = z.union([z.string(), z.number().finite(), z.boolean(), z.null()])\nconst pointer = z.string().regex(/^(?:\\/(?:[^~]|~[01])*)*$/)\nconst matchBase = { node: z.string().min(1).optional(), pointer }\nconst equals = z.strictObject({ ...matchBase, equals: scalar })\nconst oneOf = z.strictObject({ ...matchBase, in: z.array(scalar) })\nconst exists = z.strictObject({ ...matchBase, exists: z.boolean() })\nconst match = z.union([equals, oneOf, exists])\n\n/** The same data grammar as routes; no executable expressions or additional operators. */\nexport const graphRouteWhenSchema = z.union([match, z.strictObject({ all: z.array(match).min(1) })])\n\nconst parameter = z.strictObject({\n default: z.unknown().optional(),\n type: z.enum(['string', 'number', 'integer', 'boolean', 'object', 'array', 'null']).optional(),\n})\nconst command = z.strictObject({\n command: z.string().min(1),\n timeoutMs: z.number().int().positive().optional(),\n})\nconst nonnegativeInteger = z.number().int().nonnegative()\n\n/** Authoring envelope. Canonical profiles and topology are validated by their existing owners. */\nexport const graphFileSchema = z.strictObject({\n digest: z.string().min(1).optional(),\n graph: z.string().min(1).optional(),\n describe: z.string().optional(),\n params: z.record(z.string().min(1), parameter).optional(),\n nodes: z\n .array(\n z.strictObject({\n id: z.string().min(1),\n profile: z.record(z.string(), z.unknown()).optional(),\n seat: z.union([z.string().min(1), z.array(z.string().min(1)).min(1)]).optional(),\n needs: z.array(z.string().min(1)).optional(),\n }),\n )\n .min(1),\n entry: z\n .array(\n z.union([z.string().min(1), z.strictObject({ node: z.string().min(1), task: z.unknown() })]),\n )\n .min(1)\n .optional(),\n edges: z.array(z.record(z.string(), z.unknown())),\n gates: z.array(z.unknown()).optional(),\n budget: z.strictObject({\n maxIterations: nonnegativeInteger,\n maxTokens: nonnegativeInteger,\n maxUsd: z.number().finite().nonnegative().optional(),\n deadlineMs: nonnegativeInteger.optional(),\n resources: z\n .record(z.string(), z.strictObject({ unit: z.string().min(1), limit: nonnegativeInteger }))\n .optional(),\n }),\n check: z\n .union([\n equals.extend({ describe: z.string().optional() }),\n oneOf.extend({ describe: z.string().optional() }),\n exists.extend({ describe: z.string().optional() }),\n z.strictObject({ describe: z.string().optional(), all: z.array(match).min(1) }),\n z.strictObject({ describe: z.string().optional(), command }),\n ])\n .optional(),\n deliverable: z\n .strictObject({\n describe: z.string().optional(),\n checkRef: z.string().min(1),\n command: command.optional(),\n when: graphRouteWhenSchema.optional(),\n })\n .optional(),\n on: z.unknown().optional(),\n})\n\n/** Judge the flow's terminal-output map with RouteWhen's own JSON-pointer semantics. */\nexport function checkGraphRoute(when: RouteWhen, output: unknown): boolean {\n return ('all' in when ? when.all : [when]).every((condition) => {\n let document = output\n if (condition.node !== undefined) {\n if (!output || typeof output !== 'object' || !Object.hasOwn(output, condition.node))\n return false\n document = (output as Record<string, unknown>)[condition.node]\n }\n const selected = resolveJsonPointer(document, condition.pointer)\n if ('exists' in condition) return selected.found === condition.exists\n if (!selected.found) return false\n return 'equals' in condition\n ? selected.value === condition.equals\n : condition.in.some((value) => value === selected.value)\n })\n}\n","import { z } from 'zod'\nimport { ValidationError } from '../../errors'\n\nexport interface GraphParameterBindings {\n readonly params?: Readonly<Record<string, unknown>>\n readonly trigger?: Readonly<Record<string, unknown>>\n}\n\nconst triggerPart = z.strictObject({ trigger: z.array(z.string()).min(1) })\nconst literalPart = z.strictObject({ literal: z.string() })\n/** Explicit authored trigger slots in compiled graph data. An empty list marks fully bound data. */\nexport const graphTriggerBindingsSchema = z.array(\n z\n .strictObject({\n path: z.array(z.union([z.string(), z.number().int().nonnegative()])).min(1),\n mode: z.enum(['value', 'text']),\n parts: z.array(z.union([literalPart, triggerPart])).min(1),\n })\n .superRefine((slot, context) => {\n if (\n !slot.parts.some((part) => 'trigger' in part) ||\n (slot.mode === 'value' && (slot.parts.length !== 1 || !('trigger' in slot.parts[0]!)))\n )\n context.addIssue({\n code: 'custom',\n message: 'binding requires authored trigger parts; value slots require one trigger',\n })\n }),\n)\n/** @useDeclaredType */\nexport type GraphTriggerBinding = z.infer<typeof graphTriggerBindingsSchema>[number]\n\ntype Part = GraphTriggerBinding['parts'][number]\n\nfunction readBinding(\n namespace: keyof GraphParameterBindings,\n keys: readonly string[],\n bindings: GraphParameterBindings,\n): unknown {\n let found: unknown = bindings[namespace]\n for (const key of keys) {\n if (!found || typeof found !== 'object' || !Object.hasOwn(found, key))\n throw new ValidationError(`graph parameters: missing ${[namespace, ...keys].join('.')}`)\n found = (found as Record<string, unknown>)[key]\n }\n if (found === undefined)\n throw new ValidationError(`graph parameters: missing ${[namespace, ...keys].join('.')}`)\n return structuredClone(found)\n}\n\nfunction textValue(value: unknown, expression: string): string {\n if (value !== null && typeof value === 'object')\n throw new ValidationError(`graph parameters: ${expression} needs a whole JSON slot`)\n return String(value)\n}\n\nfunction pendingText(parts: readonly Part[]): string {\n return parts\n .map((part) => ('literal' in part ? part.literal : `\\${trigger.${part.trigger.join('.')}}`))\n .join('')\n}\n\n/** Compile authored slots once. Inserted values are data, never recursively parsed templates. */\nexport function compileGraphParameters(\n value: unknown,\n bindings: GraphParameterBindings,\n options: { readonly defer?: readonly (keyof GraphParameterBindings)[] } = {},\n): { value: unknown; triggerBindings: GraphTriggerBinding[] } {\n const visiting = new Set<object>()\n const triggerBindings: GraphTriggerBinding[] = []\n const bind = (item: unknown, path: Array<string | number>): unknown => {\n if (typeof item === 'string') {\n if (item.replace(/\\$\\{[^{}]+\\}/g, '').includes('${'))\n throw new ValidationError('graph parameters: malformed reference')\n const whole = /^\\$\\{([^{}]+)\\}$/.exec(item)\n const parts: Part[] = []\n let cursor = 0\n let wholeValue: unknown\n let boundWhole = false\n for (const match of item.matchAll(/\\$\\{([^{}]+)\\}/g)) {\n if (match.index > cursor) parts.push({ literal: item.slice(cursor, match.index) })\n const [namespace, ...keys] = match[1]!.split('.')\n if ((namespace !== 'params' && namespace !== 'trigger') || keys.length === 0)\n throw new ValidationError(`graph parameters: unsupported reference \\${${match[1]}}`)\n if (options.defer?.includes(namespace)) {\n if (namespace === 'trigger') parts.push({ trigger: keys })\n else parts.push({ literal: match[0] })\n } else {\n const found = readBinding(namespace, keys, bindings)\n if (whole) {\n wholeValue = found\n boundWhole = true\n } else parts.push({ literal: textValue(found, match[1]!) })\n }\n cursor = match.index + match[0].length\n }\n if (boundWhole) return wholeValue\n if (cursor === 0) return item\n if (cursor < item.length) parts.push({ literal: item.slice(cursor) })\n if (parts.some((part) => 'trigger' in part))\n triggerBindings.push({ path, mode: whole ? 'value' : 'text', parts })\n return pendingText(parts)\n }\n if (!item || typeof item !== 'object') return item\n if (visiting.has(item)) throw new ValidationError('graph parameters: cyclic data is not JSON')\n visiting.add(item)\n const bound = Array.isArray(item)\n ? item.map((child, index) => bind(child, [...path, index]))\n : Object.fromEntries(\n Object.entries(item).map(([key, child]) => [key, bind(child, [...path, key])]),\n )\n visiting.delete(item)\n return bound\n }\n return { value: bind(value, []), triggerBindings }\n}\n\n/** Legacy authored-data binding. Compiled graphs use bindCompiledGraphTriggers instead. */\nexport function bindGraphParameters(\n value: unknown,\n bindings: GraphParameterBindings,\n options: { readonly defer?: readonly (keyof GraphParameterBindings)[] } = {},\n): unknown {\n return compileGraphParameters(value, bindings, options).value\n}\n\n/** Check provenance against the exact provisional values without reading trigger data. */\nexport function assertGraphTriggerBindings(\n value: unknown,\n slots: readonly GraphTriggerBinding[],\n): void {\n const seen = new Set<string>()\n for (const slot of graphTriggerBindingsSchema.parse(slots)) {\n const key = JSON.stringify(slot.path.map(String))\n if (seen.has(key)) throw new ValidationError('graph parameters: duplicate trigger binding path')\n seen.add(key)\n let found: unknown = value\n for (const key of slot.path) {\n if (!found || typeof found !== 'object' || !Object.hasOwn(found, key))\n throw new ValidationError('graph parameters: trigger binding path does not exist')\n found = (found as Record<string | number, unknown>)[key]\n }\n if (found !== pendingText(slot.parts))\n throw new ValidationError(\n 'graph parameters: trigger binding does not match its provisional value',\n )\n }\n}\n\n/** Only explicitly recorded authored slots bind. Literal parameter/trigger values are untouched. */\nexport function bindCompiledGraphTriggers<T>(\n value: T,\n slots: readonly GraphTriggerBinding[],\n trigger: GraphParameterBindings['trigger'],\n): T {\n assertGraphTriggerBindings(value, slots)\n const bound = structuredClone(value)\n for (const slot of slots) {\n let parent = bound as Record<string | number, unknown>\n for (const key of slot.path.slice(0, -1)) parent = parent[key] as typeof parent\n parent[slot.path.at(-1)!] =\n slot.mode === 'value'\n ? readBinding('trigger', (slot.parts[0]! as { trigger: string[] }).trigger, { trigger })\n : slot.parts\n .map((part) =>\n 'literal' in part\n ? part.literal\n : textValue(\n readBinding('trigger', part.trigger, { trigger }),\n `trigger.${part.trigger.join('.')}`,\n ),\n )\n .join('')\n }\n return bound\n}\n","/**\n * `graph-registry` — the designer's memory: graphs and their outcomes as files.\n *\n * The AgentGraph algebra makes a graph PLAIN DATA (nodes with pinned profiles,\n * edges with registry-versioned directives, a budget, a deliverable\n * description), which is the property that lets a graph be stored, replayed\n * byte-identical, and mutated like code. This module is the thin durable layer\n * on top: one JSONL record per run, the exact graph content-addressed beside\n * it. The natural home is a SANDBOX WORKSPACE — the platform's snapshot story\n * (Firecracker restore, warm leases, `continuity: 'resume'`) then makes the\n * registry the agent's compounding execution memory across runs: a rerun over\n * the same sandbox finds every graph the designer ever ran, what each cost,\n * and whether it delivered.\n *\n * ORACLES STAY ENVIRONMENT-OWNED. `DeliverableSpec.check` is a function and is\n * deliberately NOT stored: a stored graph keeps the deliverable's `describe`\n * and an optional `checkRef`, and replay re-binds the check from the caller's\n * environment. This is the graph contract's own doctrine — graders are\n * environment, never workers — applied to persistence.\n *\n * Scoring is a documented heuristic, not a learned model: delivered beats\n * failed, then cheaper (tokens, then iterations), then most recent. A designer\n * that needs better selection replaces `pickBest`, not the records.\n */\n\nimport { mkdir, readdir, readFile } from 'node:fs/promises'\nimport { join } from 'node:path'\nimport type { AgentProfile } from '@tangle-network/agent-interface'\nimport { sha256 } from '../../content-digest'\nimport {\n isNoEntError,\n readCommittedJsonFile,\n upsertCommittedJsonLine,\n withJsonlFileLock,\n} from '../../durable/jsonl-file'\nimport { ValidationError } from '../../errors'\nimport { writeAtomicDurableFile } from './durable-file'\nimport type { AgentGraph, GraphEdge } from './graph'\nimport { checkGraphRoute } from './graph-file-schema'\nimport {\n bindCompiledGraphTriggers,\n bindGraphParameters,\n type GraphTriggerBinding,\n} from './graph-parameters'\n\nexport type { GraphTriggerBinding } from './graph-parameters'\n\nimport type { GraphFromStoredOptions } from './stored-graph-check'\n\nexport type { GraphCommandCheck, GraphFromStoredOptions } from './stored-graph-check'\n\n/** @inline */\ninterface StoredGraphContent {\n readonly digest: string\n /** Authored trigger-slot provenance; present (even empty) on compiled loader output. */\n readonly triggerBindings?: readonly GraphTriggerBinding[]\n readonly nodes: ReadonlyArray<{ readonly id: string; readonly profile: AgentProfile }>\n readonly deliverable: Pick<\n AgentGraph['deliverable'],\n 'describe' | 'checkRef' | 'command' | 'when'\n >\n /** A flow graph's entry and gates; absent for any other graph. */\n readonly entry?: AgentGraph['entry']\n readonly gates?: AgentGraph['gates']\n}\n\n/** A graph as stored. Observed imports retain unknown directives and budgets;\n * they describe what happened and cannot be replayed as executable graphs. */\nexport type StoredGraph = StoredGraphContent &\n (\n | {\n readonly observed?: false\n readonly edges: ReadonlyArray<GraphEdge>\n readonly budget: AgentGraph['budget']\n }\n | {\n readonly observed: true\n readonly edges: ReadonlyArray<\n | GraphEdge\n | {\n readonly from: string\n readonly to: string\n }\n >\n readonly budget?: AgentGraph['budget']\n }\n )\n\n/** Editable graph data; registration computes its digest when it is omitted. */\nexport type StoredGraphInput = Omit<\n Extract<StoredGraph, { readonly observed?: false }>,\n 'digest'\n> & {\n readonly digest?: string\n}\n\n/** One run or an explicitly incomplete observation of a graph, for one task shape. */\nexport interface GraphRunRecord {\n /** Content-address of the exact graph that ran. */\n readonly graphDigest: string\n /** Digest of the normalized task shape the designer computed for lookup. */\n readonly taskDigest: string\n readonly startedAt: string\n /** Absent while running or when completion was not established. */\n readonly finishedAt?: string\n readonly outcome:\n | { readonly kind: 'delivered'; readonly summary?: string }\n | { readonly kind: 'no-winner'; readonly reason?: string }\n | { readonly kind: 'unknown' | 'running'; readonly reason: string }\n /** Measured accounting; running observations are to date. Unknown channels omitted. */\n readonly cost: {\n readonly iterations?: number\n readonly tokens?: number\n readonly usd?: number\n readonly ms?: number\n readonly inputTokens?: number\n readonly outputTokens?: number\n readonly humanMessages?: number\n readonly leadMessages?: number\n /** Elapsed wall time from the task start to an independently verified merge. */\n readonly mergeMs?: number\n }\n /** Metered ledger size, absent when a source exposes relationships without traversals. */\n readonly traversals?: number\n readonly exhaustedEdges?: ReadonlyArray<string>\n /** Explicit source metadata, never classified from transcript or PR prose. */\n readonly taskType?: 'feature' | 'bugfix' | 'consolidation' | 'investigation' | 'ops'\n /** Stable run identity; re-ingesting this source replaces its observation. */\n readonly source?: { readonly kind: string; readonly id: string; readonly url?: string }\n readonly observedAt?: string\n /** Link to the canonical trace run; execution trees remain trace-owned. */\n readonly traceRunId?: string\n /** Canonical ordered adjacency. This is not a graph-isomorphism claim. */\n readonly topologyDigest?: string\n readonly evidence?: ReadonlyArray<{\n readonly kind: string\n readonly url: string\n readonly at?: string\n }>\n readonly nodeUsage?: ReadonlyArray<{\n readonly nodeId: string\n readonly sourceId?: string\n readonly startedAt?: string\n /** Latest recorded activity, not a claim that the node finished. */\n readonly lastRecordAt?: string\n readonly finishedAt?: string\n readonly inputTokens?: number\n readonly outputTokens?: number\n readonly humanMessages?: number\n readonly leadMessages?: number\n }>\n /** Missing or partial evidence, including incomplete accounting channels. */\n readonly unknowns?: ReadonlyArray<string>\n}\n\nexport interface GraphRegistryDir {\n readonly root: string\n}\n\nconst RECORDS_FILE = 'records.jsonl'\nconst GRAPHS_DIR = 'graphs'\n\n/** Canonical serialization for content-addressing: stable key order, sorted. */\nfunction canonicalJson(value: unknown): string {\n if (Array.isArray(value)) return `[${value.map(canonicalJson).join(',')}]`\n if (value && typeof value === 'object') {\n const entries = Object.entries(value as Record<string, unknown>)\n .filter(([, v]) => v !== undefined)\n .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))\n return `{${entries.map(([k, v]) => `${JSON.stringify(k)}:${canonicalJson(v)}`).join(',')}}`\n }\n return JSON.stringify(value)\n}\n\n/** Digest of the exact graph (nodes + edges + budget + deliverable describe, and a flow graph's\n * entry and gates). An absent key is not serialized, so a graph without `entry` keeps the digest\n * it had before flow graphs were stored. */\nexport function graphDigest(graph: Omit<StoredGraph, 'digest'>): string {\n return sha256(canonicalJson(graph))\n}\n\n/** Digest of the normalized task shape a designer looks records up by. */\nexport function taskShapeDigest(taskShape: Record<string, unknown>): string {\n return sha256(canonicalJson(taskShape))\n}\n\n/** Digest of a runnable graph exactly as the registry stores it — the value\n * `recordGraphRun` demands. Callers recording real runs hash through this,\n * never hand-rolled, so a record always matches its graph. */\nexport function digestOfGraph(graph: AgentGraph): string {\n return storeGraph(graph).digest\n}\n\nfunction storeGraph(graph: AgentGraph): StoredGraph {\n const { describe, checkRef, command, when } = graph.deliverable\n const content = {\n nodes: graph.nodes,\n edges: graph.edges,\n budget: graph.budget,\n ...(graph.triggerBindings === undefined ? {} : { triggerBindings: graph.triggerBindings }),\n deliverable: {\n ...(describe ? { describe } : {}),\n ...(checkRef ? { checkRef } : {}),\n ...(command ? { command } : {}),\n ...(when ? { when } : {}),\n },\n ...(graph.entry === undefined ? {} : { entry: graph.entry }),\n ...(graph.gates === undefined ? {} : { gates: graph.gates }),\n }\n return { digest: graphDigest(content), ...content }\n}\n\nfunction assertRecord(record: GraphRunRecord): void {\n if (typeof record.graphDigest !== 'string' || record.graphDigest.length === 0)\n throw new ValidationError('graph-registry: record.graphDigest is required')\n if (typeof record.taskDigest !== 'string' || record.taskDigest.length === 0)\n throw new ValidationError('graph-registry: record.taskDigest is required')\n if (!Number.isFinite(Date.parse(record.startedAt)))\n throw new ValidationError('graph-registry: record.startedAt must be a timestamp')\n if (!['delivered', 'no-winner', 'unknown', 'running'].includes(record.outcome.kind))\n throw new ValidationError('graph-registry: invalid record.outcome.kind')\n if (\n (record.outcome.kind === 'delivered' || record.outcome.kind === 'no-winner') &&\n (!record.finishedAt || !Number.isFinite(Date.parse(record.finishedAt)))\n )\n throw new ValidationError('graph-registry: terminal outcomes require record.finishedAt')\n if (\n (record.outcome.kind === 'unknown' || record.outcome.kind === 'running') &&\n !record.outcome.reason\n )\n throw new ValidationError('graph-registry: incomplete outcomes require a reason')\n if (record.source && (!record.source.kind || !record.source.id))\n throw new ValidationError('graph-registry: source.kind and source.id are required')\n if (\n record.finishedAt &&\n (!Number.isFinite(Date.parse(record.finishedAt)) ||\n Date.parse(record.finishedAt) < Date.parse(record.startedAt))\n )\n throw new ValidationError('graph-registry: finishedAt precedes startedAt or is invalid')\n for (const [channel, value] of Object.entries(record.cost)) {\n if (value !== undefined && (typeof value !== 'number' || !Number.isFinite(value) || value < 0))\n throw new ValidationError(`graph-registry: invalid cost.${channel}`)\n }\n}\n\nfunction recordKey(record: GraphRunRecord): string {\n assertRecord(record)\n if (record.source) return JSON.stringify(['source', record.source.kind, record.source.id])\n return JSON.stringify([record.taskDigest, record.graphDigest, record.startedAt])\n}\n\n/** Open (or lazily create) a registry rooted at a workspace directory. The\n * directory is the sandbox workspace; snapshots carry it across runs. */\nexport function graphRegistry(root: string): GraphRegistryDir {\n if (!root || root.trim().length === 0)\n throw new ValidationError('graphRegistry: root directory is required')\n return { root }\n}\n\n/** Append one run record; the exact graph is content-addressed beside it.\n * Idempotent per (taskDigest, graphDigest, startedAt): a replayed append with\n * the same key replaces the prior row rather than duplicating it. */\nexport async function recordGraphRun(\n reg: GraphRegistryDir,\n graph: AgentGraph,\n record: GraphRunRecord,\n): Promise<StoredGraph> {\n const stored = storeGraph(graph)\n return recordStoredGraphRun(reg, stored, record)\n}\n\n/** Store an executable graph or an observed external topology in the same registry.\n * Imported observations retain their source identity and never authorize replay.\n * A reader refreshing facts can preserve independently joined labels; an explicit\n * correction leaves preserveLabels unset and replaces the record. */\nexport async function recordStoredGraphRun(\n reg: GraphRegistryDir,\n definition: StoredGraph | StoredGraphInput,\n record?: GraphRunRecord,\n options: { readonly preserveLabels?: boolean } = {},\n): Promise<StoredGraph> {\n const { digest, ...content } = definition\n const stored = { ...content, digest: digest ?? graphDigest(content) } as StoredGraph\n if (stored.observed && !record)\n throw new ValidationError('graph-registry: observed graphs require a source run identity')\n if (record) {\n assertRecord(record)\n if (stored.observed && !record.source)\n throw new ValidationError('graph-registry: observed graphs require a source run identity')\n if (!stored.observed && !record.finishedAt)\n throw new ValidationError('graph-registry: native graph runs require a completion timestamp')\n if (\n (!stored.observed || record.traversals !== undefined) &&\n (!Number.isSafeInteger(record.traversals) || record.traversals! < 0)\n )\n throw new ValidationError(\n 'graph-registry: native graphs require metered traversals; observed counts must be non-negative integers',\n )\n if (stored.digest !== record.graphDigest) {\n throw new ValidationError(\n `graph-registry: record.graphDigest ${record.graphDigest} does not match the supplied graph (${stored.digest}) — record the graph that actually ran`,\n )\n }\n }\n if (graphDigest(content) !== stored.digest)\n throw new ValidationError('graph-registry: stored graph content does not match its digest')\n await mkdir(join(reg.root, GRAPHS_DIR), { recursive: true })\n const file = join(reg.root, RECORDS_FILE)\n return withJsonlFileLock(file, async (canonicalPath) => {\n if (!record) {\n await persistGraph(reg, stored)\n return stored\n }\n let persisted = record\n if (options.preserveLabels && record.source) {\n const prior = (await readCommittedJsonFile<GraphRunRecord>(canonicalPath)).find(\n (row) => row.source?.kind === record.source!.kind && row.source.id === record.source!.id,\n )\n if (prior) {\n const taskType = record.taskType ?? prior.taskType\n const priorTerminal =\n prior.outcome.kind === 'delivered' || prior.outcome.kind === 'no-winner'\n const incomingUnassessed =\n record.outcome.kind === 'unknown' || record.outcome.kind === 'running'\n if (priorTerminal && incomingUnassessed && prior.startedAt !== record.startedAt)\n throw new ValidationError(\n 'graph-registry: preserving labels requires the same task start and source identity',\n )\n const evidence = [...(prior.evidence ?? []), ...(record.evidence ?? [])]\n persisted = {\n ...record,\n ...(taskType ? { taskType } : {}),\n ...(record.unknowns\n ? {\n unknowns: record.unknowns.filter(\n (reason) => !(taskType && reason === 'task type not explicitly labeled'),\n ),\n }\n : {}),\n ...(evidence.length\n ? {\n evidence: [\n ...new Map(evidence.map((entry) => [canonicalJson(entry), entry])).values(),\n ],\n }\n : {}),\n ...(priorTerminal && incomingUnassessed\n ? {\n outcome: prior.outcome,\n finishedAt: prior.finishedAt,\n cost: {\n ...record.cost,\n ...(prior.cost.ms === undefined ? {} : { ms: prior.cost.ms }),\n ...(prior.cost.mergeMs === undefined ? {} : { mergeMs: prior.cost.mergeMs }),\n },\n }\n : {}),\n }\n }\n }\n assertRecord(persisted)\n await persistGraph(reg, stored)\n await upsertCommittedJsonLine(canonicalPath, persisted, recordKey)\n return stored\n })\n}\n\nasync function persistGraph(reg: GraphRegistryDir, stored: StoredGraph): Promise<void> {\n const revisionPath = join(reg.root, GRAPHS_DIR, `${stored.digest}.json`)\n try {\n const { digest: existingDigest, ...existing } = JSON.parse(\n await readFile(revisionPath, 'utf8'),\n ) as StoredGraph\n if (existingDigest !== stored.digest || graphDigest(existing) !== stored.digest)\n throw new ValidationError(\n 'graph-registry: stored graph revision is immutable but its content differs',\n )\n } catch (error) {\n if (!isNoEntError(error)) throw error\n // Content-addressed revisions are immutable. Rewriting one on every run adds\n // an unnecessary durable publication to the record lock's critical section.\n writeAtomicDurableFile(revisionPath, JSON.stringify(stored), { preserveMode: true })\n }\n}\n\n/** All records, newest last. */\nexport async function listGraphRuns(reg: GraphRegistryDir): Promise<GraphRunRecord[]> {\n return readCommittedJsonFile<GraphRunRecord>(join(reg.root, RECORDS_FILE))\n}\n\n/** Filters over the existing graph run records. Missing source kind is native. */\nexport interface GraphRunQuery {\n readonly taskDigest?: string\n readonly taskType?: GraphRunRecord['taskType'] | 'unknown'\n readonly topologyDigest?: string\n readonly sourceKind?: string\n}\n\nfunction observedTopology(record: GraphRunRecord): string {\n return record.topologyDigest ?? (record.source ? 'unknown' : record.graphDigest)\n}\n\n/** Records for one task shape or deterministic label query, newest last. */\nexport async function graphRunsFor(\n reg: GraphRegistryDir,\n query: string | GraphRunQuery = {},\n): Promise<GraphRunRecord[]> {\n const filters = typeof query === 'string' ? { taskDigest: query } : query\n return (await listGraphRuns(reg)).filter(\n (row) =>\n (filters.taskDigest === undefined || row.taskDigest === filters.taskDigest) &&\n (filters.taskType === undefined || (row.taskType ?? 'unknown') === filters.taskType) &&\n (filters.topologyDigest === undefined || observedTopology(row) === filters.topologyDigest) &&\n (filters.sourceKind === undefined || (row.source?.kind ?? 'native') === filters.sourceKind),\n )\n}\n\n/** Descriptive task-type/topology measurements, with every population explicit.\n * Unknown and running runs never enter the assessed denominator or medians. */\nexport interface GraphCorpusGroup {\n readonly taskType: NonNullable<GraphRunRecord['taskType']> | 'unknown'\n readonly topologyDigest: string\n readonly delivered: number\n readonly assessed: number\n readonly unknown: number\n readonly deliveredRate: number | null\n readonly medianWallMs: number | null\n readonly wallMsCount: number\n readonly medianMergeMs: number | null\n readonly mergeMsCount: number\n readonly medianTokens: number | null\n readonly tokenCount: number\n readonly medianHumanMessages: number | null\n readonly humanMessageCount: number\n readonly runs: readonly GraphRunRecord[]\n}\n\n/** The registry's observational view. It neither authorizes replay nor proves a causal win. */\nexport interface GraphCorpusSummary {\n readonly recordCount: number\n readonly groups: readonly GraphCorpusGroup[]\n}\n\nfunction medianKnown(values: readonly (number | undefined)[]): {\n median: number | null\n count: number\n} {\n const known = values\n .filter((value): value is number => value !== undefined && Number.isFinite(value) && value >= 0)\n .sort((a, b) => a - b)\n const middle = Math.floor(known.length / 2)\n return {\n count: known.length,\n median:\n known.length === 0\n ? null\n : known.length % 2\n ? known[middle]!\n : (known[middle - 1]! + known[middle]!) / 2,\n }\n}\n\n// The single observational policy used by both query and pickBestGraph. Native\n// selection below remains unchanged; this policy is an explicit descriptive opt-in.\nfunction observedGraphSummary(records: readonly GraphRunRecord[]): GraphCorpusSummary {\n const groups = new Map<string, GraphRunRecord[]>()\n for (const record of records) {\n const key = JSON.stringify([record.taskType ?? 'unknown', observedTopology(record)])\n const rows = groups.get(key)\n if (rows) rows.push(record)\n else groups.set(key, [record])\n }\n const summaries: GraphCorpusGroup[] = [...groups.values()].map((runs) => {\n const assessed = runs.filter(\n (run) => run.outcome.kind === 'delivered' || run.outcome.kind === 'no-winner',\n )\n const delivered = assessed.filter((run) => run.outcome.kind === 'delivered')\n const wall = medianKnown(assessed.map((run) => run.cost.ms))\n const merge = medianKnown(\n delivered\n .filter((run) => run.evidence?.some((entry) => entry.kind === 'pr-merged'))\n .map((run) => run.cost.mergeMs),\n )\n const tokens = medianKnown(assessed.map((run) => run.cost.tokens))\n const human = medianKnown(assessed.map((run) => run.cost.humanMessages))\n return {\n taskType: runs[0]!.taskType ?? 'unknown',\n topologyDigest: observedTopology(runs[0]!),\n delivered: delivered.length,\n assessed: assessed.length,\n unknown: runs.length - assessed.length,\n deliveredRate: assessed.length ? delivered.length / assessed.length : null,\n medianWallMs: wall.median,\n wallMsCount: wall.count,\n medianMergeMs: merge.median,\n mergeMsCount: merge.count,\n medianTokens: tokens.median,\n tokenCount: tokens.count,\n medianHumanMessages: human.median,\n humanMessageCount: human.count,\n runs,\n }\n })\n summaries.sort((a, b) => {\n const delivered = (b.deliveredRate ?? -1) - (a.deliveredRate ?? -1)\n if (delivered) return delivered\n for (const key of ['medianWallMs', 'medianTokens', 'medianHumanMessages'] as const) {\n if (a[key] === b[key]) continue\n if (a[key] === null) return 1\n if (b[key] === null) return -1\n return a[key]! - b[key]!\n }\n return a.taskType.localeCompare(b.taskType) || a.topologyDigest.localeCompare(b.topologyDigest)\n })\n return { recordCount: records.length, groups: summaries }\n}\n\n/** Query and rank the same registry records using the opt-in observational\n * policy: delivery rate, wall time, tokens, then human messages; unknowns last. */\nexport async function graphCorpusSummary(\n reg: GraphRegistryDir,\n query: GraphRunQuery = {},\n): Promise<GraphCorpusSummary> {\n return observedGraphSummary(await graphRunsFor(reg, query))\n}\n\nexport type GraphSelection =\n | { readonly kind: 'replay'; readonly graph: StoredGraph; readonly record: GraphRunRecord }\n | { readonly kind: 'author'; readonly reason: string }\n\n/** The documented heuristic: delivered beats failed; among delivered, cheaper\n * (tokens, then iterations) wins; ties go to the most recent. */\nexport function pickBestGraph(\n records: ReadonlyArray<GraphRunRecord>,\n options: { readonly policy?: 'native' | 'observed' } = {},\n): GraphRunRecord | undefined {\n if (options.policy === 'observed') {\n const group = observedGraphSummary(records).groups[0]\n return group && pickBestGraph(group.runs)\n }\n const delivered = records.filter((row) => row.outcome.kind === 'delivered')\n if (delivered.length === 0) return undefined\n const better = (a: GraphRunRecord, b: GraphRunRecord): GraphRunRecord => {\n const aTokens = a.cost.tokens ?? Number.POSITIVE_INFINITY\n const bTokens = b.cost.tokens ?? Number.POSITIVE_INFINITY\n if (aTokens !== bTokens) return aTokens < bTokens ? a : b\n const aIter = a.cost.iterations ?? Number.POSITIVE_INFINITY\n const bIter = b.cost.iterations ?? Number.POSITIVE_INFINITY\n if (aIter !== bIter) return aIter < bIter ? a : b\n return a.finishedAt! >= b.finishedAt! ? a : b\n }\n return delivered.reduce((best, row) => (better(best, row) === best ? best : row))\n}\n\n/** Load a stored graph by digest. */\nexport async function loadGraph(\n reg: GraphRegistryDir,\n digest: string,\n): Promise<StoredGraph | undefined> {\n try {\n return JSON.parse(\n await readFile(join(reg.root, GRAPHS_DIR, `${digest}.json`), 'utf8'),\n ) as StoredGraph\n } catch {\n return undefined\n }\n}\n\n/** The designer's lookup: replay the known-good graph for this task shape, or\n * author a new one — with the reason stated either way (the decision is data). */\nexport async function lookupGraph(\n reg: GraphRegistryDir,\n taskDigest: string,\n): Promise<GraphSelection> {\n const records = await graphRunsFor(reg, taskDigest)\n const candidates: GraphRunRecord[] = []\n const loaded = new Map<string, StoredGraph | undefined>()\n for (const record of records) {\n if (!loaded.has(record.graphDigest))\n loaded.set(record.graphDigest, await loadGraph(reg, record.graphDigest))\n const graph = loaded.get(record.graphDigest)\n if (!graph?.observed) candidates.push(record)\n }\n if (records.length && !candidates.length)\n return {\n kind: 'author',\n reason: 'only observed topologies are available; author an executable graph',\n }\n const best = pickBestGraph(candidates)\n if (best) {\n const graph = await loadGraph(reg, best.graphDigest)\n if (graph) return { kind: 'replay', graph, record: best }\n return {\n kind: 'author',\n reason: `best record's graph ${best.graphDigest.slice(0, 12)} is missing from the registry`,\n }\n }\n return {\n kind: 'author',\n reason:\n records.length === 0\n ? 'first run for this task shape'\n : 'no graph delivered for this task shape yet',\n }\n}\n\n/** Rehydrate a stored graph, binding trigger data and an environment-owned named check. */\nexport function graphFromStored(\n stored: StoredGraph | StoredGraphInput,\n environment: AgentGraph['deliverable']['check'] | GraphFromStoredOptions = {},\n): AgentGraph {\n if (stored.observed)\n throw new ValidationError('graphFromStored: observed topology cannot be replayed')\n const {\n digest: _digest,\n observed: _observed,\n triggerBindings: _triggerBindings,\n deliverable,\n ...topology\n } = (\n stored.triggerBindings !== undefined\n ? bindCompiledGraphTriggers(\n stored,\n stored.triggerBindings,\n typeof environment === 'function' ? undefined : (environment.trigger ?? {}),\n )\n : typeof environment === 'function'\n ? stored\n : bindGraphParameters(stored, { trigger: environment.trigger ?? {} })\n ) as typeof stored\n const selected =\n typeof environment === 'function'\n ? environment\n : environment.checks && Object.hasOwn(environment.checks, deliverable.checkRef ?? '')\n ? environment.checks[deliverable.checkRef!]\n : deliverable.checkRef === 'command'\n ? deliverable.command\n : deliverable.checkRef === 'route' && deliverable.when\n ? (((out, context) =>\n context\n ? context.originalVerdict?.valid !== false\n : checkGraphRoute(\n deliverable.when!,\n out,\n )) satisfies AgentGraph['deliverable']['check'])\n : undefined\n if (!selected)\n throw new ValidationError(\n `graphFromStored: unknown checkRef ${deliverable.checkRef ?? '(missing)'}`,\n )\n const materialized = stored.triggerBindings === undefined ? {} : { triggerBindings: [] as const }\n if (typeof selected === 'function') {\n const { command: _command, ...description } = deliverable\n return { ...topology, ...materialized, deliverable: { ...description, check: selected } }\n }\n const command =\n selected === deliverable.command\n ? selected\n : (bindGraphParameters(selected, {\n trigger: (environment as GraphFromStoredOptions).trigger ?? {},\n }) as typeof selected)\n return {\n ...topology,\n ...materialized,\n deliverable: {\n ...deliverable,\n command,\n check: () => false, // runGraph binds the independent command authority before execution.\n },\n }\n}\n\n/** Digests present on disk (integrity probe for tests and audits). */\nexport async function storedGraphDigests(reg: GraphRegistryDir): Promise<string[]> {\n try {\n return (await readdir(join(reg.root, GRAPHS_DIR)))\n .filter((name) => name.endsWith('.json'))\n .map((name) => name.slice(0, -'.json'.length))\n .sort()\n } catch {\n return []\n }\n}\n"],"mappings":";;;;;;;;AAIA,MAAM,SAAS,EAAE,MAAM;CAAC,EAAE,OAAO;CAAG,EAAE,OAAO,CAAC,CAAC,OAAO;CAAG,EAAE,QAAQ;CAAG,EAAE,KAAK;AAAC,CAAC;AAC/E,MAAM,UAAU,EAAE,OAAO,CAAC,CAAC,MAAM,0BAA0B;AAC3D,MAAM,YAAY;CAAE,MAAM,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;CAAG;AAAQ;AAChE,MAAM,SAAS,EAAE,aAAa;CAAE,GAAG;CAAW,QAAQ;AAAO,CAAC;AAC9D,MAAM,QAAQ,EAAE,aAAa;CAAE,GAAG;CAAW,IAAI,EAAE,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O,YAAY,YAC/B,YAAY,aAAa,YACvB,YAAY,UACZ,YAAY,aAAa,WAAW,YAAY,SAC3C,KAAK,YACN,UACI,QAAQ,iBAAiB,UAAU,QACnC,gBACE,YAAY,MACZ,GACF,KACN,KAAA;CACZ,IAAI,CAAC,UACH,MAAM,IAAI,gBACR,qCAAqC,YAAY,YAAY,aAC/D;CACF,MAAM,eAAe,OAAO,oBAAoB,KAAA,IAAY,CAAC,IAAI,EAAE,iBAAiB,CAAC,EAAW;CAChG,IAAI,OAAO,aAAa,YAAY;EAClC,MAAM,EAAE,SAAS,UAAU,GAAG,gBAAgB;EAC9C,OAAO;GAAE,GAAG;GAAU,GAAG;GAAc,aAAa;IAAE,GAAG;IAAa,OAAO;GAAS;EAAE;CAC1F;CACA,MAAM,UACJ,aAAa,YAAY,UACrB,WACC,oBAAoB,UAAU,EAC7B,SAAU,YAAuC,WAAW,CAAC,EAC/D,CAAC;CACP,OAAO;EACL,GAAG;EACH,GAAG;EACH,aAAa;GACX,GAAG;GACH;GACA,aAAa;EACf;CACF;AACF;;AAGA,eAAsB,mBAAmB,KAA0C;CACjF,IAAI;EACF,QAAQ,MAAM,QAAQ,KAAK,IAAI,MAAM,UAAU,CAAC,EAAA,CAC7C,QAAQ,SAAS,KAAK,SAAS,OAAO,CAAC,CAAC,CACxC,KAAK,SAAS,KAAK,MAAM,GAAG,EAAe,CAAC,CAAC,CAC7C,KAAK;CACV,QAAQ;EACN,OAAO,CAAC;CACV;AACF"}
@@ -1,13 +1,13 @@
1
- import { ca as runAbortable, sa as linkAbort } from "./scope-Bg1uCsPR.js";
1
+ import { da as runAbortable, ua as linkAbort } from "./scope-CJ7xtrs8.js";
2
2
  import { i as ConfigError } from "./errors-AzSuGI23.js";
3
- import { F as collectAgentTurn, I as streamAgentTurn } from "./structural-rollout-CH9b7K9B.js";
3
+ import { F as collectAgentTurn, I as streamAgentTurn } from "./structural-rollout-Bl23HSOd.js";
4
4
  import { L as immutableCandidateValue, N as canonicalCandidateDigest$1, St as armDeadlineTimer, z as sha256Bytes$1 } from "./workspace-streams-8ALHaZzx.js";
5
- import { d as detachedSnapshot, l as sha256 } from "./jsonl-file-CbxMVnUj.js";
6
- import { C as createExecutor, Gt as terminateProcessTreeAndConfirm, Vt as runSettledCommand } from "./supervisor-BDOWzyCC.js";
5
+ import { d as detachedSnapshot, l as sha256 } from "./jsonl-file-CvPuwM0a.js";
6
+ import { C as createExecutor, Gt as terminateProcessTreeAndConfirm, Vt as runSettledCommand } from "./supervisor-CwANBb9-.js";
7
7
  import { a as concreteProfileModel, t as assertExecutableAgentProfile } from "./model-policy-JOcg3NRs.js";
8
8
  import { i as syncDurableDirectory, r as publishExclusiveDurableFile } from "./durable-file-DstVeHcj.js";
9
- import { C as serializeRolloutPolicy, S as normalizeRolloutPolicy, w as structuralRolloutPolicyFromProfile, x as applyRolloutPolicyToProfile } from "./activation-1YUy4GWu.js";
10
- import { a as reconcileInterruptedSearchCalls, b as improveSearchCost, c as searchExecutor, d as taggedLedger, i as isSearchEnvironmentFault, n as assertSearchLanes, s as searchCallTags, v as decideClosedSearch } from "./search-executor-CJ5y2-b8.js";
9
+ import { C as serializeRolloutPolicy, S as normalizeRolloutPolicy, w as structuralRolloutPolicyFromProfile, x as applyRolloutPolicyToProfile } from "./activation-BiQYCayd.js";
10
+ import { a as reconcileInterruptedSearchCalls, b as improveSearchCost, c as searchExecutor, d as taggedLedger, i as isSearchEnvironmentFault, n as assertSearchLanes, s as searchCallTags, v as decideClosedSearch } from "./search-executor-DSB6XAl1.js";
11
11
  import { agentProfileEnvironmentSchema, agentProfileSchema, agentProfileTrainingSchema, agentTrainingDatasetIdentitySchema, agentTrainingParametersSchema, agentTrainingReceiptSchema, agentTrainingTaskKey, agentTrainingTaskSchema, applyAgentProfileDiff, canonicalAgentProfileDigest, canonicalCandidateBytes, diffAgentProfiles, sha256DigestSchema, snapshotAgentProfile, trainedModelIdForArtifact } from "@tangle-network/agent-interface";
12
12
  import { canonicalJson, makeProposalFinding } from "@tangle-network/agent-eval";
13
13
  import { redact } from "@tangle-network/agent-eval/traces";
@@ -3034,4 +3034,4 @@ async function improve(profileOrCode, opts) {
3034
3034
  }
3035
3035
  export { assertProfileTrainingIsHeldOut as a, withMethodRuntimeControls as c, commandVerifier as d, addRuntimeUsage as f, assertCandidateValidator as i, rethrowAfterCleanup as l, isUsageAmount as m, createCommandProfileTrainer as n, parseExecutionRef as o, createRuntimeUsageTotals as p, searchMethod as r, privateValuePaths as s, improve as t, agenticGenerator as u };
3036
3036
 
3037
- //# sourceMappingURL=improve-BZpoezFh.js.map
3037
+ //# sourceMappingURL=improve-B4v4S8jY.js.map