{"version":3,"sources":["../src/indexes/auto-derive.ts","../src/core/edge-match-identity-value.ts","../src/core/define-graph.ts"],"names":["getEmbeddingIndex","isEmbeddingSchema","ConfigurationError","validateTargetMapEntries","isEdgeTargetMap","isEdgeType","isEdgeTypeWithEndpoints","normalizeTargetMap","hasOwnKey","z","createDataKeyedBag","DEPLOYMENT_CONTRIBUTION_GRAPH_ID","assertGraphAnnotations","cloneAndFreezeGraphAnnotations","assertClaimAxisSafe","assertWhereFieldDeclared"],"mappings":";;;;;;;;;;;AAkDO,SAAS,wBACd,KAAA,EACmC;AACnC,EAAA,MAAM,MAAgC,EAAC;AACvC,EAAA,KAAA,MAAW,YAAA,IAAgB,MAAA,CAAO,MAAA,CAAO,KAAK,CAAA,EAAG;AAC/C,IAAA,MAAM,OAAO,YAAA,CAAa,IAAA;AAC1B,IAAA,MAAM,KAAA,GAAQ,eAAA,CAAgB,IAAA,CAAK,MAAM,CAAA;AACzC,IAAA,IAAI,UAAU,MAAA,EAAW;AACzB,IAAA,KAAA,MAAW,CAAC,SAAA,EAAW,WAAW,KAAK,MAAA,CAAO,OAAA,CAAQ,KAAK,CAAA,EAAG;AAC5D,MAAA,MAAM,MAAA,GAAS,mBAAmB,WAAW,CAAA;AAC7C,MAAA,IAAI,WAAW,MAAA,EAAW;AAC1B,MAAA,MAAM,UAAA,GAAa,wBAAwB,WAAW,CAAA;AACtD,MAAA,IAAI,eAAe,MAAA,EAAW;AAC9B,MAAA,GAAA,CAAI,KAAK,gBAAA,CAAiB,IAAA,CAAK,MAAM,SAAA,EAAW,UAAA,EAAY,MAAM,CAAC,CAAA;AAAA,IACrE;AAAA,EACF;AACA,EAAA,OAAO,GAAA;AACT;AAOO,SAAS,kBAAA,CACd,UACA,WAAA,EAC6B;AAC7B,EAAA,IAAI,WAAA,CAAY,MAAA,KAAW,CAAA,EAAG,OAAO,QAAA;AACrC,EAAA,MAAM,kBAAA,uBAAyB,GAAA,EAAY;AAC3C,EAAA,KAAA,MAAW,eAAe,Q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AAA,MAAM,IAAA,GAAO,MAAA,KAAW,MAAA,GAAS,OAAA,GAAU,OAAA;AAC3C,EAAA,MAAM,UAAA,GACJ,WAAW,MAAA,GACT,CAAA,MAAA,EAAS,YAAY,IAAI,CAAA,UAAA,EAAa,WAAA,CAAY,IAAI,CAAA,kEAAA,CAAA,GAEtD,CAAA,+EAAA,CAAA;AAEJ,EAAA,MAAM,IAAIA,oCAAA;AAAA,IACR,CAAA,OAAA,EAAU,YAAY,IAAI,CAAA,aAAA,EAAgB,MAAM,CAAA,OAAA,EAAU,WAAA,CAAY,IAAI,CAAA,2CAAA,EAC5B,IAAI,CAAA,EAAA,CAAA;AAAA,IAClD;AAAA,MACE,WAAW,WAAA,CAAY,IAAA;AAAA,MACvB,gBAAgB,WAAA,CAAY,IAAA;AAAA,MAC5B,cAAA,EAAgB,CAAC,GAAG,eAAe;AAAA,KACrC;AAAA,IACA,EAAE,UAAA;AAAW,GACf;AACF;AASO,SAAS,WAAW,KAAA,EAAmC;AAC5D,EAAA,OACE,OAAO,UAAU,QAAA,IACjB,KAAA,KAAU,QACV,eAAA,IAAmB,KAAA,IAClB,KAAA,CAAkC,eAAe,CAAA,KAAM,IAAA;AAE5D;AAKO,SAAS,aACd,KAAA,EACwC;AACxC,EAAA,OAAO,MAAA,CAAO,IAAA,CAAK,KAAA,CAAM,KAAK,CAAA;AAChC;AAKO,SAAS,aACd,KAAA,EACwC;AACxC,EAAA,OAAO,MAAA,CAAO,IAAA,CAAK,KAAA,CAAM,KAAK,CAAA;AAChC;AAMO,SAAS,WAAA,CAAY,OAAiB,IAAA,EAAuB;AAClE,EAAA,OAAO,MAAA,CAAO,MAAA,CAAO,KAAA,CAAM,KAAA,EAAO,IAAI,KAAK,MAAA,CAAO,MAAA,CAAO,KAAA,CAAM,KAAA,EAAO,IAAI,CAAA;AAC5E","file":"chunk-7D2ZLF4O.cjs","sourcesContent":["/**\n * Auto-derive vector index declarations from `embedding()` brands on\n * node schemas.\n *\n * Walks each node's top-level Zod shape, finds fields wrapped in\n * `embedding(dimensions, opts)` (including `.optional()` /\n * `.nullable()` wrappers), and emits one `VectorIndexDeclaration` per\n * (kind, field) pair. The declaration carries the resolved index\n * configuration from the embedding brand — metric, indexType, HNSW /\n * IVFFlat params — so the materializer doesn't need to reach back into\n * the Zod schema.\n *\n * Auto-derivation is intentionally limited to TOP-LEVEL embedding\n * fields. Embeddings nested inside object properties are out of scope\n * for v1 — vector slots are materialized as flat `(kind, fieldPath)`\n * storage units, and top-level fields keep that contract explicit.\n *\n * Explicit `defineVectorIndex(node, fieldPath, opts)` declarations\n * passed via `defineGraph({ indexes })` take precedence — when an\n * explicit declaration matches the same (kind, fieldPath) as an\n * auto-derived one, the explicit version wins. This lets consumers\n * override defaults without losing auto-derivation for other fields.\n */\n\nimport { type z } from \"zod\";\n\nimport {\n  getEmbeddingIndex,\n  isEmbeddingSchema,\n  type ResolvedEmbeddingIndex,\n} from \"../core/embedding\";\nimport { type NodeRegistration } from \"../core/types\";\nimport { type IndexDeclaration, type VectorIndexDeclaration } from \"./types\";\n\n/**\n * Auto-derive vector index declarations from embedding brands on a\n * map of node registrations. Returns one declaration per\n * (kind, top-level field) pair. Empty array when no embeddings found.\n *\n * Cross-graph status-table disambiguation does NOT happen here — the\n * declaration name stays clean (`tg_vec_{kind}_{field}_{metric}`) so\n * `pg_indexes` and result-entry inspection are readable. The\n * materializer composes a graph-scoped key (`${graphId}::${name}`)\n * for status-table identity, applied uniformly to both auto-derived\n * and explicit `VectorIndexDeclaration` entries — see\n * `vectorStatusKey` in `store/materialize-indexes.ts`. This keeps\n * the disambiguation rule in one place that BOTH paths go through,\n * rather than depending on the auto-derive caller to produce a\n * graph-scoped name.\n */\nexport function autoDeriveVectorIndexes(\n  nodes: Record<string, NodeRegistration>,\n): readonly VectorIndexDeclaration[] {\n  const out: VectorIndexDeclaration[] = [];\n  for (const registration of Object.values(nodes)) {\n    const node = registration.type;\n    const shape = readObjectShape(node.schema);\n    if (shape === undefined) continue;\n    for (const [fieldName, fieldSchema] of Object.entries(shape)) {\n      const config = readEmbeddingIndex(fieldSchema);\n      if (config === undefined) continue;\n      const dimensions = readEmbeddingDimensions(fieldSchema);\n      if (dimensions === undefined) continue;\n      out.push(buildAutoDerived(node.kind, fieldName, dimensions, config));\n    }\n  }\n  return out;\n}\n\n/**\n * Merge auto-derived declarations with explicit ones, preferring\n * explicit on (kind, fieldPath) collisions. Returns a flat list of all\n * indexes; non-vector entries from `explicit` pass through unchanged.\n */\nexport function mergeVectorIndexes(\n  explicit: readonly IndexDeclaration[],\n  autoDerived: readonly VectorIndexDeclaration[],\n): readonly IndexDeclaration[] {\n  if (autoDerived.length === 0) return explicit;\n  const explicitVectorKeys = new Set<string>();\n  for (const declaration of explicit) {\n    if (declaration.entity === \"vector\") {\n      explicitVectorKeys.add(`${declaration.kind}|${declaration.fieldPath}`);\n    }\n  }\n  const filteredAuto = autoDerived.filter(\n    (entry) => !explicitVectorKeys.has(`${entry.kind}|${entry.fieldPath}`),\n  );\n  return [...explicit, ...filteredAuto];\n}\n\n/**\n * Generate the deterministic vector index name. The visible prefix\n * `tg_vec_<kind>_<field>_<metric>` keeps it scannable in result-entry\n * inspection and the `typegraph_index_materializations` table.\n *\n * Cross-graph disambiguation is handled separately at the\n * materialization boundary (see `vectorStatusKey`) so the declaration\n * name doesn't need to carry `graphId` — the same auto-derived name\n * is reusable across graphs and the materializer composes a\n * graph-scoped status key for both auto-derived and explicit entries\n * uniformly.\n */\nfunction buildAutoDerived(\n  kind: string,\n  fieldName: string,\n  dimensions: number,\n  config: ResolvedEmbeddingIndex,\n): VectorIndexDeclaration {\n  const fieldPath = fieldName;\n  return Object.freeze({\n    entity: \"vector\" as const,\n    name: `tg_vec_${sanitize(kind)}_${sanitize(fieldName)}_${config.metric}`,\n    kind,\n    fieldPath,\n    dimensions,\n    metric: config.metric,\n    indexType: config.indexType,\n    indexParams: Object.freeze({\n      m: config.m,\n      efConstruction: config.efConstruction,\n      lists: config.lists,\n    }),\n  });\n}\n\nfunction sanitize(value: string): string {\n  return value.replaceAll(/[^a-zA-Z0-9]/g, \"_\").toLowerCase();\n}\n\nfunction readObjectShape(\n  schema: z.ZodType,\n): Record<string, z.ZodType> | undefined {\n  if ((schema as { type?: string }).type !== \"object\") return undefined;\n  const shape = (schema.def as { shape?: Record<string, z.ZodType> }).shape;\n  return shape;\n}\n\nfunction readEmbeddingIndex(\n  schema: z.ZodType,\n): ResolvedEmbeddingIndex | undefined {\n  for (const candidate of unwrapChain(schema)) {\n    const config = getEmbeddingIndex(candidate);\n    if (config !== undefined) return config;\n  }\n  return undefined;\n}\n\nfunction readEmbeddingDimensions(schema: z.ZodType): number | undefined {\n  for (const candidate of unwrapChain(schema)) {\n    if (isEmbeddingSchema(candidate)) {\n      return (candidate as unknown as Record<string, number>)[\n        \"_embeddingDimensions\"\n      ];\n    }\n  }\n  return undefined;\n}\n\n/**\n * Yield the schema and every reachable inner schema by repeatedly\n * applying `.unwrap()` (Zod 4 optional/nullable/default) and\n * `.def.innerType` (some wrappers). Cycle-guarded by depth and\n * reference identity. Generators stop at the first non-unwrappable\n * schema OR after 8 levels — deeper wrapping is pathological and not\n * worth supporting.\n */\nfunction* unwrapChain(schema: z.ZodType): Generator<z.ZodType, void, void> {\n  const seen = new Set<z.ZodType>();\n  let current: z.ZodType | undefined = schema;\n  let depth = 0;\n  while (current !== undefined && !seen.has(current) && depth < 8) {\n    seen.add(current);\n    yield current;\n    current = unwrapOnce(current);\n    depth++;\n  }\n}\n\nfunction unwrapOnce(schema: z.ZodType): z.ZodType | undefined {\n  // Zod 4 wrappers expose `.unwrap()` on optional/nullable/default.\n  const candidate = schema as unknown as { unwrap?: () => z.ZodType };\n  if (typeof candidate.unwrap === \"function\") return candidate.unwrap();\n  // Some wrappers expose the inner schema via `.def.innerType`.\n  return (schema as unknown as { def?: { innerType?: z.ZodType } }).def\n    ?.innerType;\n}\n","/** Whether one value can participate in a durable edge match identity. */\nexport function isPortableEdgeMatchIdentityValue(value: unknown): boolean {\n  return (\n    value === undefined ||\n    value === null ||\n    typeof value === \"string\" ||\n    typeof value === \"boolean\" ||\n    (typeof value === \"number\" && Number.isFinite(value))\n  );\n}\n","import { z } from \"zod\";\n\nimport { DEPLOYMENT_CONTRIBUTION_GRAPH_ID } from \"../backend/table-contribution\";\nimport { assertWhereFieldDeclared } from \"../constraints\";\nimport { ConfigurationError } from \"../errors/index\";\nimport { type GraphExtension } from \"../graph-extension/extension-types\";\nimport {\n  autoDeriveVectorIndexes,\n  mergeVectorIndexes,\n} from \"../indexes/auto-derive\";\nimport { type IndexDeclaration } from \"../indexes/types\";\nimport { type OntologyRelation } from \"../ontology/types\";\nimport { assertClaimAxisSafe } from \"../store/claims/axis\";\nimport { createDataKeyedBag, hasOwnKey } from \"../utils/object\";\nimport {\n  isEdgeTargetMap,\n  normalizeTargetMap,\n  validateTargetMapEntries,\n} from \"./edge-endpoints\";\nimport { isPortableEdgeMatchIdentityValue } from \"./edge-match-identity-value\";\nimport {\n  assertGraphAnnotations,\n  cloneAndFreezeGraphAnnotations,\n} from \"./json-value\";\nimport {\n  type AnyEdgeRegistration,\n  type AnyEdgeType,\n  type DeleteBehavior,\n  type EdgeRegistration,\n  type EdgeTargets,\n  type EdgeTypeWithEndpoints,\n  type GraphAnnotations,\n  type GraphDefaults,\n  isEdgeType,\n  isEdgeTypeWithEndpoints,\n  type KindEntity,\n  type NodeRegistration,\n  type NodeType,\n  type TemporalMode,\n} from \"./types\";\n\n// ============================================================\n// Graph Definition Brand Symbol\n// ============================================================\n\n/** Brand key for GraphDef */\nconst GRAPH_DEF_BRAND = \"__graphDef\" as const;\n\n// ============================================================\n// Edge Entry Types\n// ============================================================\n\n/**\n * An edge entry in the graph definition.\n * Can be:\n * - EdgeType directly (constrained or unconstrained)\n * - EdgeRegistration object (always works, can override/narrow defaults)\n */\ntype EdgeEntry = EdgeRegistration | AnyEdgeType;\n\n/**\n * Normalized edge map type - all entries become EdgeRegistration.\n * For bare EdgeTypes, constrained endpoints are extracted from the type;\n * unconstrained edges fall back to all node types in the graph.\n */\ntype NormalizedEdges<\n  TNodes extends Record<string, NodeRegistration>,\n  TEdges extends Record<string, EdgeEntry>,\n> = {\n  [K in keyof TEdges]: TEdges[K] extends EdgeRegistration ? TEdges[K]\n  : TEdges[K] extends AnyEdgeType ?\n    EdgeRegistration<\n      TEdges[K],\n      TEdges[K][\"from\"] extends readonly (infer N extends NodeType)[] ? N\n      : TNodes[keyof TNodes][\"type\"],\n      TEdges[K][\"to\"] extends readonly (infer N extends NodeType)[] ? N\n      : TEdges[K][\"to\"] extends (\n        Record<string, readonly (infer N extends NodeType)[]>\n      ) ?\n        N\n      : TNodes[keyof TNodes][\"type\"],\n      TEdges[K][\"to\"] extends EdgeTargets ? TEdges[K][\"to\"]\n      : readonly TNodes[keyof TNodes][\"type\"][]\n    >\n  : never;\n};\n\n// ============================================================\n// Edge Normalization Functions\n// ============================================================\n\n/**\n * Validates that an EdgeRegistration's constraints don't widen beyond\n * the edge type's built-in domain/range constraints.\n */\nfunction validateConstraintNarrowing(\n  name: string,\n  edgeType: EdgeTypeWithEndpoints,\n  registration: EdgeRegistration,\n): void {\n  const builtInFromNames = new Set(edgeType.from.map((node) => node.kind));\n  for (const fromNode of registration.from) {\n    if (!builtInFromNames.has(fromNode.kind)) {\n      throw new ConfigurationError(\n        `Edge \"${name}\" registration has 'from' kind \"${fromNode.kind}\" ` +\n          `not in edge's built-in domain: [${[...builtInFromNames].join(\", \")}]`,\n        {\n          edgeName: name,\n          invalidFrom: fromNode.kind,\n          allowedFrom: [...builtInFromNames],\n        },\n        {\n          suggestion: `Edge registration can only narrow, not widen, the edge type's built-in constraints.`,\n        },\n      );\n    }\n  }\n\n  if (!Array.isArray(registration.to)) {\n    validateTargetMapEntries(name, registration.from, registration.to);\n  }\n\n  const builtInIsMap = isEdgeTargetMap(edgeType.to);\n  const registrationIsMap = isEdgeTargetMap(registration.to);\n\n  for (const fromNode of registration.from) {\n    const allowedTargets =\n      builtInIsMap ?\n        new Set<string>(\n          (edgeType.to[fromNode.kind] ?? []).map(\n            (node: NodeType): string => node.kind,\n          ),\n        )\n      : new Set<string>(\n          (edgeType.to as readonly NodeType[]).map(\n            (node: NodeType): string => node.kind,\n          ),\n        );\n\n    const declaredTargets: readonly NodeType[] =\n      registrationIsMap ?\n        (registration.to[fromNode.kind] ?? [])\n      : (registration.to as readonly NodeType[]);\n\n    for (const targetNode of declaredTargets) {\n      if (!allowedTargets.has(targetNode.kind)) {\n        const message =\n          builtInIsMap ?\n            registrationIsMap ?\n              `Edge \"${name}\" registration has target kind \"${targetNode.kind}\" for source \"${fromNode.kind}\" not in edge's built-in mapping: [${[...allowedTargets].join(\", \")}]`\n            : `Edge \"${name}\" registration has 'to' kind \"${targetNode.kind}\" for source \"${fromNode.kind}\" not in edge's built-in source-dependent targets: [${[...allowedTargets].join(\", \")}]. An array-valued registration must not erase built-in endpoint correlation.`\n          : `Edge \"${name}\" registration has 'to' kind \"${targetNode.kind}\" not in edge's built-in range: [${[...allowedTargets].join(\", \")}]`;\n\n        throw new ConfigurationError(\n          message,\n          {\n            edgeName: name,\n            sourceKind: fromNode.kind,\n            invalidTo: targetNode.kind,\n            allowedTo: [...allowedTargets],\n          },\n          {\n            suggestion: `Edge registration can only narrow, not widen, the edge type's built-in constraints.`,\n          },\n        );\n      }\n    }\n  }\n}\n\n/**\n * Normalizes a single edge entry to EdgeRegistration.\n */\nfunction normalizeEdgeEntry(\n  name: string,\n  entry: EdgeEntry,\n  allNodeTypes: readonly NodeType[],\n): AnyEdgeRegistration {\n  if (isEdgeType(entry)) {\n    if (isEdgeTypeWithEndpoints(entry)) {\n      // EdgeType with from/to — convert to EdgeRegistration\n      return { type: entry, from: entry.from, to: entry.to };\n    }\n    // Unconstrained EdgeType — allow any→any\n    return { type: entry, from: allNodeTypes, to: allNodeTypes };\n  }\n\n  let normalizedRegistration: AnyEdgeRegistration = entry;\n  if (!Array.isArray(entry.to)) {\n    validateTargetMapEntries(name, entry.from, entry.to);\n    normalizedRegistration = { ...entry, to: normalizeTargetMap(entry.to) };\n  }\n\n  // Validate narrowing if edge has built-in constraints\n  if (isEdgeTypeWithEndpoints(normalizedRegistration.type)) {\n    validateConstraintNarrowing(\n      name,\n      normalizedRegistration.type,\n      normalizedRegistration,\n    );\n  }\n\n  return canonicalizeMatchIdentity(name, normalizedRegistration);\n}\n\n/**\n * Validates and canonicalizes the optional graph-local edge identity.\n *\n * Identity fields are persisted as a set, so declaration order is not\n * semantic. The copied registration also ensures defineGraph never mutates a\n * caller-owned registration while establishing its canonical form.\n */\nfunction canonicalizeMatchIdentity(\n  edgeName: string,\n  registration: EdgeRegistration,\n): EdgeRegistration {\n  const identity = registration.matchIdentity;\n  if (identity === undefined) return registration;\n\n  if (typeof identity.name !== \"string\" || identity.name.length === 0) {\n    throw new ConfigurationError(\n      `Edge \"${edgeName}\" match identity name must be a non-empty string.`,\n      { edgeName },\n    );\n  }\n  const identityFields: unknown = identity.fields;\n  if (!Array.isArray(identityFields)) {\n    throw new ConfigurationError(\n      `Edge \"${edgeName}\" match identity fields must be an array.`,\n      { edgeName, identityName: identity.name },\n    );\n  }\n\n  const rawShape = (registration.type.schema as { shape?: unknown }).shape;\n  const shape =\n    typeof rawShape === \"object\" && rawShape !== null ?\n      (rawShape as Readonly<Record<string, unknown>>)\n    : undefined;\n  if (shape === undefined) {\n    throw new ConfigurationError(\n      `Edge \"${edgeName}\" match identity cannot be validated because its schema is not an object schema.`,\n      { edgeName, identityName: identity.name },\n    );\n  }\n\n  const fields: string[] = [];\n  const seen = new Set<string>();\n  for (const field of identityFields) {\n    if (typeof field !== \"string\") {\n      throw new ConfigurationError(\n        `Edge \"${edgeName}\" match identity fields must be strings.`,\n        { edgeName, identityName: identity.name },\n      );\n    }\n    if (seen.has(field)) {\n      throw new ConfigurationError(\n        `Edge \"${edgeName}\" match identity repeats field \"${field}\".`,\n        { edgeName, identityName: identity.name, field },\n      );\n    }\n    seen.add(field);\n    fields.push(field);\n    if (!hasOwnKey(shape, field)) {\n      throw new ConfigurationError(\n        `Edge \"${edgeName}\" match identity references undeclared field \"${field}\".`,\n        { edgeName, identityName: identity.name, field },\n      );\n    }\n    if (!isPortableMatchIdentityFieldSchema(shape[field])) {\n      throw new ConfigurationError(\n        `Edge \"${edgeName}\" match identity field \"${field}\" must persist as a JSON scalar.`,\n        {\n          code: \"EDGE_MATCH_IDENTITY_VALUE_NOT_SCALAR\",\n          edgeName,\n          identityName: identity.name,\n          field,\n        },\n        {\n          suggestion:\n            \"Use a string, finite number, boolean, portable literal or enum, or an optional/nullable/readonly/default/catch/prefault wrapper or union whose output stays inside those scalar types.\",\n        },\n      );\n    }\n  }\n\n  return {\n    ...registration,\n    matchIdentity: {\n      name: identity.name,\n      fields: fields.toSorted(),\n    },\n  };\n}\n\nfunction isPortableMatchIdentityFieldSchema(fieldSchema: unknown): boolean {\n  if (!(fieldSchema instanceof z.ZodType)) return false;\n  if (\n    fieldSchema instanceof z.ZodString ||\n    fieldSchema instanceof z.ZodNumber ||\n    fieldSchema instanceof z.ZodBoolean ||\n    fieldSchema instanceof z.ZodNull\n  )\n    return true;\n  if (fieldSchema instanceof z.ZodLiteral) {\n    return [...fieldSchema.values].every((value) =>\n      isPortableEdgeMatchIdentityValue(value),\n    );\n  }\n  if (fieldSchema instanceof z.ZodEnum) {\n    return Object.values(fieldSchema.enum).every((value) =>\n      isPortableEdgeMatchIdentityValue(value),\n    );\n  }\n  if (fieldSchema instanceof z.ZodUnion) {\n    return fieldSchema.options.every((option) =>\n      isPortableMatchIdentityFieldSchema(option),\n    );\n  }\n  if (\n    fieldSchema instanceof z.ZodOptional ||\n    fieldSchema instanceof z.ZodNullable ||\n    fieldSchema instanceof z.ZodReadonly ||\n    fieldSchema instanceof z.ZodNonOptional ||\n    fieldSchema instanceof z.ZodDefault ||\n    fieldSchema instanceof z.ZodCatch ||\n    fieldSchema instanceof z.ZodPrefault\n  ) {\n    return isPortableMatchIdentityFieldSchema(fieldSchema.unwrap());\n  }\n  return false;\n}\n\n/**\n * Normalizes all edge entries to EdgeRegistration.\n *\n * The accumulator is a {@link createDataKeyedBag}: its keys are EDGE KIND\n * NAMES, which are data. `isValidKindName` admits `__proto__` exactly as it\n * admits `toString`, and a graph literal written with a computed key\n * (`edges: { [\"__proto__\"]: knows }`) carries it as an own key — so\n * `result[name] = …` into a `{}` literal would reach `Object.prototype`'s\n * `__proto__` setter, reparent the accumulator, and drop the declared edge.\n * `config.nodes` needs no such treatment: it is passed through by reference,\n * never re-accumulated.\n */\nfunction normalizeEdges(\n  edges: Record<string, EdgeEntry>,\n  allNodeTypes: readonly NodeType[],\n): Record<string, AnyEdgeRegistration> {\n  const result = createDataKeyedBag<AnyEdgeRegistration>();\n  for (const [name, entry] of Object.entries(edges)) {\n    result[name] = normalizeEdgeEntry(name, entry, allNodeTypes);\n  }\n  // Spread at the boundary: this becomes `graph.edges` on the returned (and\n  // publicly reachable) `GraphDef`. See `createDataKeyedBag` in\n  // ../utils/object.ts.\n  return { ...result };\n}\n\n// ============================================================\n// Graph Definition Configuration\n// ============================================================\n\n/** Durable graph-level configuration for the TypeGraph Identity Profile. */\nexport type GraphIdentityConfig = Readonly<{\n  /** Whether equal ids in different kinds implicitly join one identity class. */\n  sameIdAcrossKinds: \"fold\" | \"ignore\";\n}>;\n\n/**\n * Configuration for defineGraph.\n */\ntype GraphDefConfig<\n  TNodes extends Record<string, NodeRegistration>,\n  TEdges extends Record<string, EdgeEntry>,\n  TOntology extends readonly OntologyRelation[],\n  TIdentity extends GraphIdentityConfig | undefined,\n> = Readonly<{\n  /** Unique identifier for this graph */\n  id: string;\n  /** Consumer-owned JSON metadata describing the graph as a whole. */\n  annotations?: GraphAnnotations;\n  /** Node registrations */\n  nodes: TNodes;\n  /** Edge registrations or EdgeTypes with built-in domain/range */\n  edges: TEdges;\n  /** Ontology relations */\n  ontology?: TOntology;\n  /** Graph-wide defaults */\n  defaults?: GraphDefaults;\n  /** Enables the TypeGraph Identity Profile for this graph. */\n  identity?: TIdentity;\n  /**\n   * Index declarations attached to this graph.\n   *\n   * Accepts the outputs of `defineNodeIndex` / `defineEdgeIndex` (which\n   * already return `IndexDeclaration` values) or pre-built declarations\n   * reconstructed from a stored schema or graph extension.\n   *\n   * Validated at definition time: every index must reference a `kind`\n   * that exists in `nodes` / `edges`, and index `name`s must be unique\n   * within the graph.\n   *\n   * Index DDL is **not** generated by `defineGraph`. Indexes flow into\n   * `SerializedSchema.indexes` so they can later be materialized via\n   * `store.materializeIndexes()` — lifting the storage concern out of\n   * the schema-version commit path.\n   */\n  indexes?: readonly IndexDeclaration[];\n}>;\n\n// ============================================================\n// Graph Definition Type\n// ============================================================\n\n/**\n * A graph definition.\n *\n * This is a compile-time artifact that describes the structure of a graph.\n * Use `createStore()` to create a runtime store from this definition.\n */\nexport type GraphDef<\n  TNodes extends Record<string, NodeRegistration> = Record<\n    string,\n    NodeRegistration\n  >,\n  TEdges extends Record<string, EdgeRegistration> = Record<\n    string,\n    EdgeRegistration\n  >,\n  TOntology extends readonly OntologyRelation[] = readonly OntologyRelation[],\n  TIdentity extends GraphIdentityConfig | undefined =\n    GraphIdentityConfig | undefined,\n> = Readonly<{\n  [GRAPH_DEF_BRAND]: true;\n  id: string;\n  /** Consumer-owned JSON metadata describing the graph as a whole. */\n  annotations: GraphAnnotations | undefined;\n  nodes: TNodes;\n  edges: TEdges;\n  ontology: TOntology;\n  /** Durable graph-level opt-in to the TypeGraph Identity Profile. */\n  identity: TIdentity;\n  defaults: Readonly<{\n    onNodeDelete: DeleteBehavior;\n    temporalMode: TemporalMode;\n  }>;\n  /**\n   * Index declarations attached to this graph. Preserves whatever the\n   * caller passed to `defineGraph` (including an explicit empty array)\n   * for introspection purposes.\n   *\n   * The serialized canonical form is order-canonicalized (sorted by\n   * `name`) and treats `undefined` and `[]` as the same \"no slice\" form\n   * — an empty array does not bump the schema hash, since indexes are\n   * an unordered set keyed by name and `[]` carries no semantic meaning\n   * that an absent slice doesn't.\n   */\n  indexes: readonly IndexDeclaration[] | undefined;\n  /**\n   * Graph extension this graph was merged with, if any. Set by\n   * `mergeGraphExtension`; never set by `defineGraph` directly.\n   * Exists solely so re-serialization is stable — the rest of the\n   * system reads the merged kinds through `nodes` / `edges` /\n   * `ontology` and never inspects this field. Absent on graphs that\n   * have never been extended; legacy graphs hash byte-identically.\n   */\n  extension: GraphExtension | undefined;\n  /**\n   * Soft-deprecated kind names attached to this graph. Set by the\n   * loader from the persisted schema and by `store.deprecateKinds(...)`\n   * / `store.undeprecateKinds(...)`. A purely informational signal\n   * surfaced for introspection — does not gate reads, writes, or\n   * queries. Defaults to the empty set on freshly-defined graphs.\n   */\n  deprecatedKinds: ReadonlySet<string>;\n}>;\n\n// ============================================================\n// Type Helpers\n// ============================================================\n\n/**\n * Extract node kind names from a GraphDef.\n */\nexport type NodeKinds<G extends GraphDef> = keyof G[\"nodes\"] & string;\n\n/**\n * Extract edge kind names from a GraphDef.\n */\nexport type EdgeKinds<G extends GraphDef> = keyof G[\"edges\"] & string;\n\n/**\n * Get a NodeType from a GraphDef by kind name.\n */\nexport type GetNodeType<\n  G extends GraphDef,\n  K extends NodeKinds<G>,\n> = G[\"nodes\"][K][\"type\"];\n\n/**\n * Get an EdgeType from a GraphDef by kind name.\n */\nexport type GetEdgeType<\n  G extends GraphDef,\n  K extends EdgeKinds<G>,\n> = G[\"edges\"][K][\"type\"];\n\n/**\n * Get all NodeTypes from a GraphDef.\n */\nexport type AllNodeTypes<G extends GraphDef> = {\n  [K in NodeKinds<G>]: G[\"nodes\"][K][\"type\"];\n}[NodeKinds<G>];\n\n/**\n * Get all EdgeTypes from a GraphDef.\n */\nexport type AllEdgeTypes<G extends GraphDef> = {\n  [K in EdgeKinds<G>]: G[\"edges\"][K][\"type\"];\n}[EdgeKinds<G>];\n\n// ============================================================\n// Define Graph Function\n// ============================================================\n\n/**\n * Creates a graph definition.\n *\n * @example\n * ```typescript\n * const graph = defineGraph({\n *   id: \"my_graph\",\n *   nodes: {\n *     Person: { type: Person },\n *     Company: { type: Company },\n *   },\n *   edges: {\n *     // Traditional EdgeRegistration syntax\n *     worksAt: {\n *       type: worksAt,\n *       from: [Person],\n *       to: [Company],\n *       cardinality: \"many\",\n *     },\n *     // Or use EdgeType directly if it has from/to defined\n *     knows,  // EdgeType with built-in domain/range\n *   },\n *   ontology: [\n *     subClassOf(Company, Organization),\n *     disjointWith(Person, Organization),\n *   ],\n *   defaults: {\n *     onNodeDelete: \"restrict\",\n *     temporalMode: \"current\",\n *   },\n * });\n * ```\n */\nexport function defineGraph<\n  const TNodes extends Record<string, NodeRegistration<NodeType>>,\n  const TEdges extends Record<string, EdgeEntry>,\n  const TOntology extends readonly OntologyRelation[],\n  const TIdentity extends GraphIdentityConfig | undefined = undefined,\n>(\n  config: GraphDefConfig<TNodes, TEdges, TOntology, TIdentity>,\n): GraphDef<TNodes, NormalizedEdges<TNodes, TEdges>, TOntology, TIdentity> {\n  if (config.id === DEPLOYMENT_CONTRIBUTION_GRAPH_ID) {\n    throw new ConfigurationError(\n      `Graph id \"${config.id}\" is reserved for deployment contribution markers.`,\n      { code: \"RESERVED_GRAPH_ID\" },\n    );\n  }\n  return defineGraphUnchecked(config);\n}\n\nfunction defineGraphUnchecked<\n  const TNodes extends Record<string, NodeRegistration<NodeType>>,\n  const TEdges extends Record<string, EdgeEntry>,\n  const TOntology extends readonly OntologyRelation[],\n  const TIdentity extends GraphIdentityConfig | undefined = undefined,\n>(\n  config: GraphDefConfig<TNodes, TEdges, TOntology, TIdentity>,\n): GraphDef<TNodes, NormalizedEdges<TNodes, TEdges>, TOntology, TIdentity> {\n  const defaults = {\n    onNodeDelete: config.defaults?.onNodeDelete ?? \"restrict\",\n    temporalMode: config.defaults?.temporalMode ?? \"current\",\n  } as const;\n\n  if (config.annotations !== undefined) {\n    assertGraphAnnotations(config.annotations, `Graph \"${config.id}\"`);\n  }\n  const annotations =\n    config.annotations === undefined ?\n      undefined\n    : cloneAndFreezeGraphAnnotations(config.annotations);\n\n  const allNodeTypes = Object.values(config.nodes).map((reg) => reg.type);\n  const normalizedEdges = normalizeEdges(config.edges, allNodeTypes);\n  assertClaimNamesAreSafe(config.nodes);\n  assertUniqueConstraintsAreDeclared(config.nodes);\n  // Vector indexes are auto-derived from `embedding()` brands on node\n  // schemas (see `autoDeriveVectorIndexes`). Explicit declarations\n  // passed via `defineGraph({ indexes })` win on (kind, fieldPath)\n  // collisions so consumers can override defaults — see\n  // `mergeVectorIndexes`. The merged list flows through\n  // `normalizeIndexes` for the standard kind-registered + unique-name\n  // checks.\n  //\n  // Preservation rule: if the consumer never passed `indexes` at all\n  // AND no embedding brands exist, leave `graph.indexes` undefined to\n  // keep the introspection surface stable for legacy graphs. If the\n  // consumer passed an explicit `[]`, surface it as `[]` (not\n  // `undefined`) to match the contract pinned by the\n  // \"preserves an explicit empty indexes array\" test.\n  const autoVectorIndexes = autoDeriveVectorIndexes(config.nodes);\n  const explicitProvided = config.indexes !== undefined;\n  const mergedIndexes = mergeVectorIndexes(\n    config.indexes ?? [],\n    autoVectorIndexes,\n  );\n  const indexes =\n    !explicitProvided && mergedIndexes.length === 0 ?\n      undefined\n    : normalizeIndexes(mergedIndexes, config.nodes, normalizedEdges);\n\n  return Object.freeze({\n    [GRAPH_DEF_BRAND]: true as const,\n    id: config.id,\n    annotations,\n    nodes: config.nodes,\n    edges: normalizedEdges,\n    ontology: config.ontology ?? ([] as unknown as TOntology),\n    identity: config.identity as TIdentity,\n    defaults,\n    indexes,\n    extension: undefined,\n    deprecatedKinds: EMPTY_DEPRECATED_KINDS,\n  }) as GraphDef<TNodes, NormalizedEdges<TNodes, TEdges>, TOntology, TIdentity>;\n}\n\n/**\n * @internal Marks a graph definition as framework-owned rather than\n * application-authored.\n *\n * It builds exactly what {@link defineGraph} builds — the name records the\n * caller, it does not reserve anything. There is NO reserved id namespace and\n * no id validation anywhere: an application may define a graph at any id a\n * framework-owned graph uses, the merge-provenance sidecar's\n * `<target>::merge-provenance` convention included. That convention is\n * protected at RUNTIME instead, by the ownership checks in the single gateway\n * that opens a sidecar (`openProvenanceStore`), which refuses an id occupied by\n * anything it cannot prove it owns.\n */\nexport function defineInternalGraph<\n  const TNodes extends Record<string, NodeRegistration<NodeType>>,\n  const TEdges extends Record<string, EdgeEntry>,\n  const TOntology extends readonly OntologyRelation[],\n  const TIdentity extends GraphIdentityConfig | undefined = undefined,\n>(\n  config: GraphDefConfig<TNodes, TEdges, TOntology, TIdentity>,\n): GraphDef<TNodes, NormalizedEdges<TNodes, TEdges>, TOntology, TIdentity> {\n  return defineGraphUnchecked(config);\n}\n\n// Sharing one frozen empty Set keeps the canonical-form hash stable\n// across graphs that never deprecate any kinds.\nconst EMPTY_DEPRECATED_KINDS: ReadonlySet<string> = Object.freeze(\n  new Set<string>(),\n);\n\n// ============================================================\n// Unique Constraint Validation\n// ============================================================\n\n/**\n * Refuses any kind name or constraint name that could spell a reserved claim\n * axis.\n *\n * A node kind and a unique constraint name are both written verbatim into the\n * claim rows a write of that kind reserves, and the axes that are NOT kinds —\n * the disjoint pair axis, and the reserved constraint name its rows carry — are\n * built from a code point neither may contain. `defineGraph` is where that is\n * enforced for the whole graph: `defineNode` already refuses it for kinds it\n * builds, but the graph-extension compiler builds registrations without going\n * through it, and constraint names never pass `defineNode` at all.\n */\nfunction assertClaimNamesAreSafe(\n  nodes: Record<string, NodeRegistration>,\n): void {\n  for (const registration of Object.values(nodes)) {\n    assertClaimAxisSafe(registration.type.kind, \"Node kind\");\n    for (const constraint of registration.unique ?? []) {\n      assertClaimAxisSafe(constraint.name, \"Unique constraint\");\n    }\n  }\n}\n\n/**\n * Refuses any uniqueness constraint whose `where` clause names a field its kind\n * does not declare.\n *\n * `defineGraph` is the one gate every constraint passes before a write can\n * evaluate it — the store reads constraints off `registration.unique`, and the\n * only other way a registration is built is `mergeGraphExtension`, whose\n * documents `validateGraphExtension` already refuses on the same grounds\n * (`UNKNOWN_UNIQUE_WHERE_FIELD`). Validating here therefore covers every write\n * path at once, instead of at each `checkWherePredicate` call site.\n *\n * Typed callers are already guarded by `UniqueConstraintPredicateBuilder`,\n * which declares exactly the schema's fields; this is the runtime half, for\n * untyped callers whose typo would otherwise produce a constraint that quietly\n * never applies.\n */\nfunction assertUniqueConstraintsAreDeclared(\n  nodes: Record<string, NodeRegistration>,\n): void {\n  for (const registration of Object.values(nodes)) {\n    const constraints = registration.unique;\n    if (constraints === undefined || constraints.length === 0) continue;\n\n    const rawShape = (registration.type.schema as { shape?: unknown }).shape;\n    const shape =\n      typeof rawShape === \"object\" && rawShape !== null ?\n        (rawShape as Readonly<Record<string, unknown>>)\n      : undefined;\n\n    for (const constraint of constraints) {\n      // A schema exposing no `.shape` is not an object schema, so there is no\n      // declared-field set to check the clause against. Skipping the check\n      // silently would disable this guard for exactly the callers it was\n      // written for — untyped ones, who are also the only callers who can put\n      // a non-`ZodObject` here (`defineNode` / `defineEdge` and the\n      // graph-extension compiler all produce `z.object(...)`). So the clause is\n      // REFUSED rather than left unvalidated.\n      //\n      // Narrowly: only a constraint that actually carries a `where` is refused.\n      // A plain `unique: [{ fields }]` needs no shape to be meaningful — it\n      // names props by key and evaluates fine against a non-object schema — and\n      // refusing it would break a working, if unusual, untyped graph for no\n      // safety gain.\n      if (shape === undefined) {\n        if (constraint.where === undefined) continue;\n        throw new ConfigurationError(\n          `Unique constraint \"${constraint.name}\" on node kind \"${registration.type.kind}\" has a \\`where\\` clause, but the kind's schema is not an object schema, so its declared fields cannot be checked.`,\n          {\n            kind: registration.type.kind,\n            constraintName: constraint.name,\n          },\n          {\n            suggestion: `Declare the kind with an object schema (\\`z.object({ ... })\\`) so the \\`where\\` clause can be validated, or drop the \\`where\\` clause.`,\n          },\n        );\n      }\n\n      assertWhereFieldDeclared(registration.type.kind, constraint, shape);\n    }\n  }\n}\n\n// ============================================================\n// Index Normalization\n// ============================================================\n\n/**\n * Validates the `indexes` config slice:\n *\n * - Every index references a kind that exists in the graph's `nodes`\n *   (for node indexes) or `edges` (for edge indexes).\n * - Index `name`s are unique within the graph.\n */\nfunction normalizeIndexes(\n  inputs: readonly IndexDeclaration[],\n  nodes: Record<string, NodeRegistration>,\n  edges: Record<string, EdgeRegistration>,\n): readonly IndexDeclaration[] {\n  if (inputs.length === 0) {\n    return [];\n  }\n\n  const nodeKinds = collectKinds(nodes);\n  const edgeKinds = collectKinds(edges);\n  const seenNames = new Set<string>();\n\n  for (const declaration of inputs) {\n    if (declaration.entity === \"node\" || declaration.entity === \"vector\") {\n      // Vector indexes attach to node kinds (the embedding lives on a\n      // node field). Validation reuses the node-kind check.\n      assertKindRegistered(declaration, nodeKinds, \"node\");\n    } else {\n      assertKindRegistered(declaration, edgeKinds, \"edge\");\n    }\n\n    if (seenNames.has(declaration.name)) {\n      throw new ConfigurationError(\n        `Duplicate index name \"${declaration.name}\" in defineGraph({ indexes }). ` +\n          `Index names must be unique within a graph.`,\n        { indexName: declaration.name },\n        {\n          suggestion: `Pass an explicit { name: \"...\" } to disambiguate.`,\n        },\n      );\n    }\n    seenNames.add(declaration.name);\n  }\n\n  return inputs;\n}\n\nfunction collectKinds(\n  registrations: Record<string, { type: { kind: string } }>,\n): ReadonlySet<string> {\n  const kinds = new Set<string>();\n  for (const registration of Object.values(registrations)) {\n    kinds.add(registration.type.kind);\n  }\n  return kinds;\n}\n\nfunction assertKindRegistered(\n  declaration: IndexDeclaration,\n  registeredKinds: ReadonlySet<string>,\n  entity: KindEntity,\n): void {\n  if (registeredKinds.has(declaration.kind)) return;\n\n  const slot = entity === \"node\" ? \"nodes\" : \"edges\";\n  const suggestion =\n    entity === \"node\" ?\n      `Add { ${declaration.kind}: { type: ${declaration.kind} } } to defineGraph({ nodes }) ` +\n      `or remove the index from \"indexes\".`\n    : `Register the edge in defineGraph({ edges }) or remove the index from \"indexes\".`;\n\n  throw new ConfigurationError(\n    `Index \"${declaration.name}\" references ${entity} kind \"${declaration.kind}\" ` +\n      `which is not registered in this graph's \"${slot}\".`,\n    {\n      indexName: declaration.name,\n      referencedKind: declaration.kind,\n      availableKinds: [...registeredKinds],\n    },\n    { suggestion },\n  );\n}\n\n// ============================================================\n// Graph Definition Utilities\n// ============================================================\n\n/**\n * Checks if a value is a GraphDef.\n */\nexport function isGraphDef(value: unknown): value is GraphDef {\n  return (\n    typeof value === \"object\" &&\n    value !== null &&\n    GRAPH_DEF_BRAND in value &&\n    (value as Record<string, unknown>)[GRAPH_DEF_BRAND] === true\n  );\n}\n\n/**\n * Gets all node kind names from a GraphDef.\n */\nexport function getNodeKinds<G extends GraphDef>(\n  graph: G,\n): readonly (keyof G[\"nodes\"] & string)[] {\n  return Object.keys(graph.nodes);\n}\n\n/**\n * Gets all edge kind names from a GraphDef.\n */\nexport function getEdgeKinds<G extends GraphDef>(\n  graph: G,\n): readonly (keyof G[\"edges\"] & string)[] {\n  return Object.keys(graph.edges);\n}\n\n/**\n * Returns true when `name` is registered as either a node or edge kind\n * on the given graph.\n */\nexport function isKnownKind(graph: GraphDef, name: string): boolean {\n  return Object.hasOwn(graph.nodes, name) || Object.hasOwn(graph.edges, name);\n}\n"]}