{"version":3,"sources":["../src/store/row-mappers.ts","../src/store/constraints.ts","../src/store/durable-edge-batch.ts","../src/store/edge-match-key.ts","../src/store/operations/edge-batch-validation.ts","../src/store/operations/autocommit-single-statement.ts","../src/store/operations/edge-write-pipeline.ts","../src/store/operations/write-fences.ts","../src/store/operations/write-session.ts","../src/store/operations/write-executor.ts","../src/store/operations/write-plan.ts","../src/store/resolved-mutation-set.ts","../src/store/validity-end.ts","../src/store/operations/already-exists.ts","../src/store/operations/atomic-mutation-program.ts","../src/store/operations/node-operations.ts"],"names":["rowPropsToObject","filterReservedKeys","RESERVED_NODE_KEYS","RESERVED_EDGE_KEYS","nodeClaimSites","isLiveNodeRow","checkDisjointness","EDGE_CARDINALITY_SPECS","error","checkUniqueEdge","checkCardinality","CompilerInvariantError","createDataKeyedBag","readOwnProperty","ConfigurationError","ValidationError","encodeTupleKey","isPortableEdgeMatchIdentityValue","deriveBackend","isBundledRootAutocommitEligible","isSchemaFencedInsertEligible","getEmbeddingFields","getSearchableFields","supportsNodeInsertProjectionRequirements","claimEdgeCardinality","purgeEdgeClaims","assertsStoredLowerBound","assertsStoredUpperBound","planNodeCreateClaims","createNodeWriteContext","nodeInsertDispatch","edgeInsertDispatch","supportsNodeCreatePlan","withNodeCreateClaims","executeAuthoritativeGraphCommand","refuseNodeCreateClaimError","applyNodeInsertSyncFans","runInsertIfAbsent","supportsNodeInsertProjections","runInsertNoReturn","withNodeCreateClaimsBatch","runInsertBatchReturning","applyNodeInsertSyncFansBatch","runInsertBatch","applyNodeUpdate","applyNodeSoftDelete","applyNodeHardDelete","applyNodeResurrect","applyNodeSetUpdate","applyResolvedNodeUpdateBatch","claimEdgeCardinalityBatch","requireDefined","runInWriteTransaction","runHookedWriteOperation","uncapturedGraphWriteLock","resolveAtomicMutationPrograms","DatabaseOperationError","ENTITY_ALREADY_EXISTS_CODE","supportsAtomicBatch","diagnoseFusedSchemaFenceNoRow","hasOwnKey","supportsAtomicNodeClaimFamily","supportsAtomicNodeProjections","KindNotFoundError","NodeConstraintNotFoundError","nodeClaimEntries","uniquenessProbeKinds","validateNodeProps","validateStatedValidityLowerBound","validateOptionalCanonicalIsoDate","assertOrderedValidityWindow","checkUniquenessConstraints","createUniquenessContext","resolveNodeFulltextProjection","resolveNodeEmbeddingProjections","resolveNodeEmbeddingProjectionTransitions","canonicalEqual","NodeNotFoundError","nowIso","preservesImmutableLowerBound","resolveStampedValidityLowerBound","assertWritableValidityWindow","row","bindExtraIfReachable","BATCH_POINT_READ","UNIQUE_SIDECAR_BATCH","groupNodeUniquenessProbes","generateId","rephaseAtomicNodeClaimPlan","UniquenessError","supportsAtomicNodeClaims","memoizeLeasedSchemaFence","chunk","refKey","isUniquenessClaimEntry","probeUniqueKey","hasLeasedSchemaFence","lockSchemaVersionForStoreWrite","z","compareAndSetAbsent","assertJsonValue","missingRequiredExtras","resolveBackendFulltext","refuseFulltextUnavailable","assertFulltextMember","getNodeRowsByIds","resolvedNodeUpdateBatchFitsBindBudget","resolvedNodeUniqueSidecarBatchIsReachable","resolvedNodeUpdatePreservesClaimKeys","AtomicNodeDeleteRestrictedRefusalError","RestrictedDeleteError","checkWherePredicate","computeUniqueKey","NodeIndexNotFoundError","getDialect","resolveJsonPointer","createSqlSchema","DEFAULT_SQL_SCHEMA","sql","compileNodeIndexFieldKeys","compileIndexWhere","asCompiledRowsSql"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,SAAS,gBAAmB,KAAA,EAA4C;AACtE,EAAA,OAAO,KAAA,KAAU,OAAO,MAAA,GAAY,KAAA;AACtC;AASO,SAAS,UAAU,GAAA,EAAoB;AAC5C,EAAA,MAAM,QAAA,GAAWA,kCAAA,CAAiB,GAAA,CAAI,KAAK,CAAA;AAC3C,EAAA,MAAM,KAAA,GAAQC,oCAAA,CAAmB,QAAA,EAAUC,oCAAkB,CAAA;AAC7D,EAAA,OAAO;AAAA,IACL,MAAM,GAAA,CAAI,IAAA;AAAA,IACV,IAAI,GAAA,CAAI,EA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eA,gCAAA,CAAe,OAAA,CAAQ,WAAW,CAAC,CAAA;AACxD,MAAA,OAAA,CAAQ,KAAK,CAAA,GAAI,EAAE,MAAM,YAAA,CAAa,IAAA,EAAM,QAAQ,OAAA,EAAQ;AAAA,IAC9D;AAEA,IAAA,OAAO,OAAA;AAAA,EACT;AAEA,EAAA,IAAI;AACF,IAAA,OAAO,MAAM,OAAA,EAAQ;AAAA,EACvB,SAAS,KAAA,EAAO;AACd,IAAA,IAAI,EAAE,KAAA,YAAiBsC,iCAAA,CAAA,EAAkB,MAAM,KAAA;AAC/C,IAAA,OAAO,OAAA,EAAQ;AAAA,EACjB;AACF","file":"chunk-IFTYHOEE.cjs","sourcesContent":["/**\n * Row Mappers for Store\n *\n * Transforms database rows into typed Node and Edge objects.\n */\nimport {\n  type EdgeRow as BackendEdgeRow,\n  type NodeRow as BackendNodeRow,\n  rowPropsToObject,\n} from \"../backend/types\";\nimport {\n  filterReservedKeys,\n  RESERVED_EDGE_KEYS,\n  RESERVED_NODE_KEYS,\n} from \"./reserved-keys\";\nimport { type Edge, type EdgeMeta, type Node, type NodeMeta } from \"./types\";\n\n/**\n * Raw node row from database (without graph_id).\n * Derived from BackendNodeRow so BackendNodeRow is assignable without casts.\n */\nexport type NodeRow = Omit<BackendNodeRow, \"graph_id\">;\n\n/**\n * Raw edge row from database (without graph_id).\n * Derived from BackendEdgeRow so BackendEdgeRow is assignable without casts.\n */\nexport type EdgeRow = Omit<BackendEdgeRow, \"graph_id\">;\n\n/**\n * Converts null to undefined for consistent typing.\n * Database backends return null for missing values, but our types use undefined.\n */\nfunction nullToUndefined<T>(value: T | null | undefined): T | undefined {\n  return value === null ? undefined : value;\n}\n\n/**\n * Transforms a database row into a typed Node object.\n *\n * Props are spread at top level, metadata goes under `meta`.\n * Reserved keys (id, kind, meta) in props are filtered out to prevent collisions.\n * Null values from database are normalized to undefined.\n */\nexport function rowToNode(row: NodeRow): Node {\n  const rawProps = rowPropsToObject(row.props);\n  const props = filterReservedKeys(rawProps, RESERVED_NODE_KEYS);\n  return {\n    kind: row.kind,\n    id: row.id as Node[\"id\"],\n    meta: rowToNodeMeta(row),\n    ...props,\n  };\n}\n\nexport function rowToNodeMeta(\n  row: Pick<\n    NodeRow,\n    | \"version\"\n    | \"valid_from\"\n    | \"valid_to\"\n    | \"created_at\"\n    | \"updated_at\"\n    | \"deleted_at\"\n  >,\n): NodeMeta {\n  return {\n    version: row.version,\n    validFrom: nullToUndefined(row.valid_from),\n    validTo: nullToUndefined(row.valid_to),\n    createdAt: row.created_at,\n    updatedAt: row.updated_at,\n    deletedAt: nullToUndefined(row.deleted_at),\n  };\n}\n\n/**\n * Transforms a database row into a typed Edge object.\n *\n * Props are spread at top level, metadata goes under `meta`.\n * Reserved keys in props are filtered out to prevent collisions.\n * Null values from database are normalized to undefined.\n */\nexport function rowToEdge(row: EdgeRow): Edge {\n  const rawProps = rowPropsToObject(row.props);\n  const props = filterReservedKeys(rawProps, RESERVED_EDGE_KEYS);\n  return {\n    id: row.id,\n    kind: row.kind,\n    fromKind: row.from_kind,\n    fromId: row.from_id,\n    toKind: row.to_kind,\n    toId: row.to_id,\n    meta: rowToEdgeMeta(row),\n    ...props,\n  } as Edge;\n}\n\nexport function rowToEdgeMeta(\n  row: Pick<\n    EdgeRow,\n    \"valid_from\" | \"valid_to\" | \"created_at\" | \"updated_at\" | \"deleted_at\"\n  >,\n): EdgeMeta {\n  return {\n    validFrom: nullToUndefined(row.valid_from),\n    validTo: nullToUndefined(row.valid_to),\n    createdAt: row.created_at,\n    updatedAt: row.updated_at,\n    deletedAt: nullToUndefined(row.deleted_at),\n  };\n}\n","/**\n * Constraint Checking for Store Operations\n *\n * Handles checking disjointness and cardinality constraints.\n *\n * ## The invariant these probes depend on\n *\n * **A declared constraint's probe and the write it guards commit under one\n * per-graph mutual exclusion, on every backend.** Every check in this module is\n * an APPLICATION probe: it reads, decides, and returns, and the caller then\n * writes. Nothing in the schema re-decides at write time, because for each of\n * these constraints the available key covers a different axis than the\n * constraint declares:\n *\n * - edge cardinality `one` / `unique` / `oneActive` is a predicate over\n *   `(kind, from)` or `(kind, from, to)`, while the edges table's only\n *   uniqueness is its `(graph_id, id)` primary key;\n * - disjointness is a predicate over `(graph_id, id)` ACROSS kinds, while the\n *   nodes primary key is `(graph_id, kind, id)` — the same id under a disjoint\n *   kind is a different row by construction;\n * - `scope: \"kindWithSubClasses\"` uniqueness probes the root kind and every\n *   descendant. Its claim is now reserved at the scope's AXIS — the subclass\n *   component's minimum — so sibling kinds contend for one row and the uniques\n *   primary key does fence them (see {@link file://./claims/node-claims.ts});\n *   the lock is kept because the probe still reads kinds the key does not\n *   cover, including rows written before the axis existed.\n *\n * So the probe is only as good as the serialization around it. SQLite supplies\n * that for free (`BEGIN IMMEDIATE` admits one writer per database). PostgreSQL\n * supplied it only when history or revision tracking was enabled, because only\n * those took the per-graph advisory lock — leaving a default PostgreSQL store\n * open to two writers that both read \"no conflict\" and both commit.\n * {@link edgeWriteNeedsConstraintFence} / {@link nodeWriteNeedsConstraintFence}\n * are what the write paths ask so they take that same per-graph lock whenever\n * one of these probes is in play, and only then.\n */\nimport { type GraphEntityReadBackend, isLiveNodeRow } from \"../backend/types\";\nimport {\n  checkCardinality,\n  checkDisjointness,\n  checkUniqueEdge,\n} from \"../constraints\";\nimport { type GraphDef } from \"../core/define-graph\";\nimport { type Cardinality, type UniqueConstraint } from \"../core/types\";\nimport { type KindRegistry } from \"../registry/kind-registry\";\nimport { type ConstraintFenceReason } from \"./claims/backing\";\nimport { EDGE_CARDINALITY_SPECS } from \"./claims/edge-claims\";\nimport { nodeClaimSites } from \"./claims/sites\";\n\nexport { type ConstraintFenceReason } from \"./claims/backing\";\n\n/**\n * Context for constraint operations.\n *\n * The backend is the graph-entity READ facet rather than the backend union:\n * every check in this module is an application probe that reads, decides and\n * returns, and the CALLER does the writing. Naming the facet is what lets a\n * probe run inside a write frame, whose row-work handle exposes reads only,\n * and it states in the type that no check here writes.\n */\nexport type ConstraintContext = Readonly<{\n  graphId: string;\n  registry: KindRegistry;\n  backend: GraphEntityReadBackend;\n}>;\n\n/**\n * The constraint that makes an edge write of this cardinality constrained, or\n * `undefined` when it is not.\n *\n * `many` declares no constraint, so its create runs no cardinality probe and\n * must NOT pay for the lock — the fence is for writes that check something, not\n * for writes in general. Every other cardinality counts or existence-tests\n * sibling edges before inserting, and nothing in the schema repeats that test.\n *\n * The one owner of this classification: `checkCardinalityConstraint`'s `many`\n * arm and this predicate are the same decision seen from two sides, and a\n * second inline `!== \"many\"` at a write path would be the copy that drifts.\n */\nexport function edgeWriteNeedsConstraintFence(\n  cardinality: Cardinality,\n): ConstraintFenceReason | undefined {\n  return cardinality === \"many\" ? undefined : \"edgeCardinality\";\n}\n\n/**\n * The constraint that makes a node write of this kind constrained, or\n * `undefined` when it is not. A kind can qualify on both counts; the reason\n * reported is the first that applies, which is enough to name the class in a\n * refusal.\n *\n * Two probe families qualify, and they are reached by different operations:\n *\n * - **Disjointness** is probed only where a node comes into existence under a\n *   kind — the create/resurrect preparation. An in-place update cannot change a\n *   node's kind, so it re-derives no cross-kind verdict and needs no fence for\n *   this reason.\n * - **Shared-scope uniqueness** is probed by create AND update. It qualifies\n *   only when the constraint's scope actually spans more than the node's own\n *   kind: a single-kind scope probes exactly the `(graph_id, node_kind,\n *   constraint_name, key)` row that the claim then reserves, so the uniques\n *   primary key IS the fence and the write needs no other.\n *\n * The whole answer is a PROJECTION of {@link nodeClaimSites}, not a second\n * spelling of it: that list already decided, per family, whether the site's\n * axis spans kinds beyond the writer's own — in order to decide where its claim\n * is written and when — and this reads that same decision back, reporting the\n * first site carrying it. Disjointness sites come first in that list, so a kind\n * qualifying on both counts keeps reporting the class it reports today, which\n * is what the refusal payload names.\n *\n * Deliberately typed over `\"create\" | \"update\"` alone, never the third\n * {@link NodeClaimOperation} `\"resurrect\"`: this projection feeds the per-graph\n * LOCK, whose trigger set this workstream leaves byte-identical to HEAD's, and\n * a resurrect's disjointness claim needs none — `insertUnique`'s own\n * `INSERT … ON CONFLICT … RETURNING` fences it, the same primary key that\n * already fences an own-kind uniqueness claim with no lock. `nodeClaimEntries`\n * reads `nodeClaimSites` at `\"resurrect\"` directly (see\n * `claims/node-claims.ts:planNodeClaimReinsert`) without going through this\n * projection at all.\n */\nexport function nodeWriteNeedsConstraintFence(\n  registry: KindRegistry,\n  kind: string,\n  uniqueConstraints: readonly UniqueConstraint[],\n  operation: \"create\" | \"update\",\n): ConstraintFenceReason | undefined {\n  return nodeClaimSites(registry, kind, uniqueConstraints, operation).find(\n    (site) => site.needsLockFence,\n  )?.refusalReason;\n}\n\n/**\n * THE graph-level answer to \"does writing into this graph owe a claim that must\n * precede the row it gates?\", folded over the SAME per-kind functions the write\n * paths consult — a node kind any of whose claim sites is `pre-insert` under\n * either operation, or an edge kind whose cardinality is not `many`.\n *\n * It exists for `importGraph`, which takes no per-graph lock and therefore\n * cannot declare `fencesConstraintProbe`: that option carries a second decision\n * — take the lock — and holding a per-graph mutex for a whole bulk load is a\n * different change with a different owner. The CONSUMPTION is split; the\n * definition is not.\n *\n * BOTH operations are folded because an import performs both, and the answer is\n * needed before the payload is inspected. That makes the fold coarser than the\n * per-row seam on purpose: a payload whose every row fails its constraints'\n * `where` predicates owes nothing, yet the import is refused. That is the price\n * of answering up front — and answering up front is what makes the refusal\n * deterministic across a chunked stream, which imports per chunk and would\n * otherwise fail on chunk k with k-1 chunks already committed.\n *\n * It lives here rather than beside {@link nodeClaimSites} because it also folds\n * {@link edgeWriteNeedsConstraintFence}, and this module is the one that already\n * sees both per-kind predicates.\n */\nexport function graphOwesClaims(\n  graph: GraphDef,\n  registry: KindRegistry,\n): ConstraintFenceReason | undefined {\n  for (const [kind, registration] of Object.entries(graph.nodes)) {\n    for (const operation of [\"create\", \"update\"] as const) {\n      const gating = nodeClaimSites(\n        registry,\n        kind,\n        registration.unique ?? [],\n        operation,\n      ).find((site) => site.placement === \"pre-insert\");\n      if (gating !== undefined) return gating.refusalReason;\n    }\n  }\n  for (const registration of Object.values(graph.edges)) {\n    const reason = edgeWriteNeedsConstraintFence(\n      registration.cardinality ?? \"many\",\n    );\n    if (reason !== undefined) return reason;\n  }\n  return undefined;\n}\n\n/**\n * Checks disjointness constraints for a node.\n *\n * Ensures that a node with a given ID doesn't exist in any disjoint kinds.\n *\n * @throws ValidationError if disjointness constraint is violated\n */\nexport async function checkDisjointnessConstraint(\n  ctx: ConstraintContext,\n  kind: string,\n  id: string,\n): Promise<void> {\n  // Get all kinds that are disjoint with this kind\n  const disjointKinds = ctx.registry.getDisjointKinds(kind);\n\n  // For each disjoint kind, check if a node with this ID exists\n  for (const disjointKind of disjointKinds) {\n    const existing = await ctx.backend.getNode(ctx.graphId, disjointKind, id);\n    if (existing !== undefined && isLiveNodeRow(existing)) {\n      const error = checkDisjointness(id, kind, [disjointKind], ctx.registry);\n      if (error) throw error;\n    }\n  }\n}\n\n/**\n * Checks cardinality constraints for an edge.\n *\n * Reads {@link EDGE_CARDINALITY_SPECS} rather than re-spelling each\n * cardinality's rules: which endpoints the axis covers (`keyShape`), whether an\n * edge born already ended joins the population at all (`claimsWhenBornEnded`)\n * and whether the population is the live one or the active one\n * (`holderLiveness`) are the same three facts the claim's SQL reads. A probe\n * that spelled its own copy would be the drift that accepts a write the fence\n * then refuses (or the reverse).\n *\n * @throws CardinalityError if cardinality constraint is violated\n */\nexport async function checkCardinalityConstraint(\n  ctx: ConstraintContext,\n  edgeKind: string,\n  cardinality: Cardinality,\n  fromKind: string,\n  fromId: string,\n  toKind: string,\n  toId: string,\n  validTo: string | undefined,\n): Promise<void> {\n  if (cardinality === \"many\") return;\n  const spec = EDGE_CARDINALITY_SPECS[cardinality];\n\n  // An edge born ended never joins an active-only population, so it has\n  // nothing to check and nothing to claim.\n  if (!spec.claimsWhenBornEnded && validTo !== undefined) return;\n\n  if (spec.keyShape === \"fromAndTo\") {\n    const exists = await ctx.backend.edgeExistsBetween({\n      graphId: ctx.graphId,\n      edgeKind,\n      fromKind,\n      fromId,\n      toKind,\n      toId,\n    });\n    const error = checkUniqueEdge(\n      edgeKind,\n      fromKind,\n      fromId,\n      toKind,\n      toId,\n      exists ? 1 : 0,\n    );\n    if (error) throw error;\n    return;\n  }\n\n  const count = await ctx.backend.countEdgesFrom({\n    graphId: ctx.graphId,\n    edgeKind,\n    fromKind,\n    fromId,\n    activeOnly: spec.holderLiveness === \"liveAndActive\",\n  });\n  const error = checkCardinality(\n    edgeKind,\n    fromKind,\n    fromId,\n    cardinality,\n    count,\n    count > 0,\n  );\n  if (error) throw error;\n}\n","import type { EdgeRow, InsertEdgeParams } from \"../backend/types\";\nimport { CompilerInvariantError } from \"../errors\";\n\nexport type DurableEdgeBatchOutcome = \"created\" | \"conflict\";\n\n/**\n * Matches a durable batch's returned rows back to attempted inputs in input\n * order. Counts, rather than a set, preserve duplicate-id multiplicity.\n */\nexport function classifyDurableEdgeBatchOutcomes(\n  params: readonly InsertEdgeParams[],\n  rows: readonly Pick<EdgeRow, \"id\">[],\n): readonly DurableEdgeBatchOutcome[] {\n  const returnedCounts = new Map<string, number>();\n  for (const row of rows) {\n    returnedCounts.set(row.id, (returnedCounts.get(row.id) ?? 0) + 1);\n  }\n\n  const outcomes = params.map((item): DurableEdgeBatchOutcome => {\n    const count = returnedCounts.get(item.id) ?? 0;\n    if (count === 0) return \"conflict\";\n    returnedCounts.set(item.id, count - 1);\n    return \"created\";\n  });\n  const unexpectedIds = [...returnedCounts]\n    .filter(([, count]) => count > 0)\n    .map(([id]) => id);\n  if (unexpectedIds.length > 0) {\n    throw new CompilerInvariantError(\n      \"A durable edge batch returned rows that were not attempted.\",\n      { unexpectedIds },\n    );\n  }\n  return outcomes;\n}\n","/**\n * Canonical identity keys for edge endpoint matching.\n *\n * The key deliberately contains the complete directed endpoint tuple and every\n * declared match field. It is an injective JSON array encoding, not a hash, so\n * callers can use it as the durable owner key without accepting collisions.\n */\nimport type { EdgeMatchIdentityStorage } from \"../backend/types\";\nimport { isPortableEdgeMatchIdentityValue } from \"../core/edge-match-identity-value\";\nimport type { EdgeMatchIdentity } from \"../core/types\";\nimport { ConfigurationError, ValidationError } from \"../errors\";\nimport { createDataKeyedBag, readOwnProperty } from \"../utils/object\";\nimport { encodeTupleKey } from \"../utils/tuple-key\";\n\nconst ABSENT_PERSISTED_JSON_VALUE = \"\\u001D\";\nconst MAX_EDGE_MATCH_IDENTITY_INDEX_BYTES = 2000;\nconst TEXT_ENCODER = new TextEncoder();\n\nfunction normalizeEdgeMatchIdentityProps(\n  props: Readonly<Record<string, unknown>>,\n  identity: EdgeMatchIdentity,\n  scope: Readonly<{ graphId: string; edgeKind: string }>,\n): Record<string, unknown> {\n  const identityProps = createDataKeyedBag<unknown>();\n  for (const field of identity.fields) {\n    identityProps[field] = readOwnProperty(props, field);\n  }\n  try {\n    return normalizePersistedEdgeMatchProps(identityProps);\n  } catch (error) {\n    throw new ConfigurationError(\n      `Edge match identity \"${identity.name}\" contains a value that cannot be persisted as JSON.`,\n      {\n        code: \"EDGE_MATCH_IDENTITY_VALUE_NOT_SCALAR\",\n        graphId: scope.graphId,\n        edgeKind: scope.edgeKind,\n        identityName: identity.name,\n        fields: identity.fields,\n      },\n      {\n        cause: error,\n        suggestion:\n          \"Use absent, null, string, finite-number, or boolean values for durable identity fields and properties.\",\n      },\n    );\n  }\n}\n\nexport type EdgeMatchKeyInput = Readonly<{\n  fromKind: string;\n  fromId: string;\n  toKind: string;\n  toId: string;\n  props: Readonly<Record<string, unknown>>;\n  matchOn: readonly string[];\n}>;\n\n/** Returns the property bag as JSON persistence will retain it. */\nexport function normalizePersistedEdgeMatchProps(\n  props: Readonly<Record<string, unknown>>,\n): Record<string, unknown> {\n  try {\n    // eslint-disable-next-line unicorn/prefer-structured-clone -- intentionally applies JSON persistence semantics\n    return JSON.parse(JSON.stringify(props)) as Record<string, unknown>;\n  } catch (error) {\n    throw new ValidationError(\n      \"Edge properties used for endpoint matching must be persistable JSON.\",\n      {\n        operation: \"create\",\n        issues: [\n          {\n            path: \"properties\",\n            message:\n              \"Use JSON-compatible values; BigInt and other non-JSON values cannot be matched or persisted.\",\n          },\n        ],\n      },\n      { cause: error },\n    );\n  }\n}\n\n/** Canonical representation of one persisted JSON value. */\nexport function canonicalPersistedJsonValue(value: unknown): string {\n  if (value === undefined) return ABSENT_PERSISTED_JSON_VALUE;\n  // eslint-disable-next-line unicorn/prefer-structured-clone -- intentionally applies JSON persistence semantics\n  return canonicalizeJsonValue(JSON.parse(JSON.stringify(value)));\n}\n\nfunction canonicalizeJsonValue(value: unknown): string {\n  if (value === null || typeof value !== \"object\") return JSON.stringify(value);\n  if (Array.isArray(value)) {\n    return `[${value.map((item) => canonicalizeJsonValue(item)).join(\",\")}]`;\n  }\n  const entries = Object.keys(value)\n    .toSorted()\n    .map(\n      (key) =>\n        `${JSON.stringify(key)}:${canonicalizeJsonValue(\n          (value as Record<string, unknown>)[key],\n        )}`,\n    );\n  return `{${entries.join(\",\")}}`;\n}\n\n/** Creates the canonical owner key for a directed edge match identity. */\nfunction buildEdgeMatchKeyFromPersistedProps(\n  input: EdgeMatchKeyInput,\n  persistedProps: Readonly<Record<string, unknown>>,\n): string {\n  const fields = [...new Set(input.matchOn)].toSorted();\n  return encodeTupleKey([\n    input.fromKind,\n    input.fromId,\n    input.toKind,\n    input.toId,\n    ...fields.flatMap((field) => [\n      field,\n      canonicalPersistedJsonValue(readOwnProperty(persistedProps, field)),\n    ]),\n  ]);\n}\n\n/** Creates the canonical owner key for a directed edge match identity. */\nexport function buildEdgeMatchKey(input: EdgeMatchKeyInput): string {\n  return buildEdgeMatchKeyFromPersistedProps(\n    input,\n    normalizePersistedEdgeMatchProps(input.props),\n  );\n}\n\n/** Resolves the persisted identity pair every edge writer must apply. */\nexport function resolveEdgeMatchIdentityStorage(\n  identity: EdgeMatchIdentity | undefined,\n  input: Omit<EdgeMatchKeyInput, \"matchOn\">,\n  scope: Readonly<{ graphId: string; edgeKind: string }>,\n): EdgeMatchIdentityStorage | undefined {\n  if (identity === undefined) return undefined;\n  const nonScalarFields = identity.fields.filter(\n    (field) =>\n      !isPortableEdgeMatchIdentityValue(readOwnProperty(input.props, field)),\n  );\n  if (nonScalarFields.length > 0) {\n    throw new ConfigurationError(\n      `Edge match identity \"${identity.name}\" must use JSON scalar fields.`,\n      {\n        code: \"EDGE_MATCH_IDENTITY_VALUE_NOT_SCALAR\",\n        graphId: scope.graphId,\n        edgeKind: scope.edgeKind,\n        identityName: identity.name,\n        fields: nonScalarFields,\n      },\n      {\n        suggestion:\n          \"Use absent, null, string, finite-number, or boolean values for durable identity fields.\",\n      },\n    );\n  }\n  const persistedProps = normalizeEdgeMatchIdentityProps(\n    input.props,\n    identity,\n    scope,\n  );\n  const key = buildEdgeMatchKeyFromPersistedProps(\n    {\n      ...input,\n      matchOn: identity.fields,\n    },\n    persistedProps,\n  );\n  // PostgreSQL's btree tuple limit is lower than the unbounded TEXT type used\n  // by both adapters. Apply one backend-independent budget to the complete\n  // unique tuple so SQLite cannot accept an identity a PostgreSQL store would\n  // later refuse with SQLSTATE 54000.\n  const indexTuple = encodeTupleKey([\n    scope.graphId,\n    scope.edgeKind,\n    identity.name,\n    key,\n  ]);\n  const indexBytes = TEXT_ENCODER.encode(indexTuple).byteLength;\n  if (indexBytes > MAX_EDGE_MATCH_IDENTITY_INDEX_BYTES) {\n    throw new ConfigurationError(\n      `Edge match identity \"${identity.name}\" for kind \"${scope.edgeKind}\" exceeds the portable storage limit.`,\n      {\n        code: \"EDGE_MATCH_IDENTITY_KEY_TOO_LARGE\",\n        graphId: scope.graphId,\n        edgeKind: scope.edgeKind,\n        identityName: identity.name,\n        indexBytes,\n        maxIndexBytes: MAX_EDGE_MATCH_IDENTITY_INDEX_BYTES,\n      },\n      {\n        suggestion:\n          \"Declare smaller primitive identity fields instead of embedding large values in a durable edge identity.\",\n      },\n    );\n  }\n  return {\n    name: identity.name,\n    key,\n  };\n}\n\n/**\n * Decides whether an edge props update would rewrite its durable identity.\n *\n * Every update entry point consumes this decision instead of re-spelling the\n * persisted-JSON comparison. The returned error is also the shared refusal,\n * allowing collection writes to throw it while interchange records it against\n * one imported row.\n */\nexport function edgeMatchIdentityUpdateRefusal(\n  input: Readonly<{\n    identity: EdgeMatchIdentity | undefined;\n    kind: string;\n    id: string;\n    beforeProps: Readonly<Record<string, unknown>>;\n    afterProps: Readonly<Record<string, unknown>>;\n  }>,\n): ValidationError | undefined {\n  const changedFields =\n    input.identity?.fields.filter(\n      (field) =>\n        canonicalPersistedJsonValue(\n          readOwnProperty(input.beforeProps, field),\n        ) !==\n        canonicalPersistedJsonValue(readOwnProperty(input.afterProps, field)),\n    ) ?? [];\n  if (changedFields.length === 0) return undefined;\n\n  return new ValidationError(\n    `Edge kind \"${input.kind}\" match identity fields are immutable: ${changedFields.join(\", \")}`,\n    {\n      kind: input.kind,\n      operation: \"update\",\n      id: input.id,\n      issues: changedFields.map((field) => ({\n        path: field,\n        message: `Field \"${field}\" belongs to match identity \"${input.identity?.name ?? \"unknown\"}\" and cannot be updated`,\n      })),\n    },\n  );\n}\n","/**\n * The in-batch cardinality accounting an edge batch validates against.\n *\n * A batch decides every row before it writes any of them, so a probe that read\n * only the database would let two rows of one batch each see \"no conflict\" and\n * both land — the in-batch collision. This wrapper is the state that closes\n * that: it overlays the reads a cardinality probe makes (`countEdgesFrom`,\n * `edgeExistsBetween`) with the rows the batch has already accepted, so row\n * k+1's probe sees rows 1..k and refuses per ROW rather than at the flush.\n *\n * It lives in its own module because it has two callers that reach it from\n * different directions: the store's batch create path\n * ({@link file://./edge-operations.ts prepareEdgeBatchCreates}) and\n * `interchange/import`'s edge slice. One owner of in-batch cardinality\n * accounting, not two implementations — a second copy is exactly how import's\n * edge path came to have none at all.\n *\n * It is a read overlay only. The CLAIM is issued against the real backend, once\n * per batch, by the caller — a claim against this wrapper would still reach the\n * real target (`deriveBackend` forwards every non-overlaid member) but\n * would be a second, unsorted, per-row claim in addition to the batch's.\n */\nimport { deriveBackend } from \"../../backend/derive-backend\";\nimport {\n  type EdgeRow,\n  type GraphBackend,\n  type InsertEdgeParams,\n} from \"../../backend/types\";\nimport { type Cardinality } from \"../../core/types\";\nimport { encodeTupleKey } from \"../../utils/tuple-key\";\nimport { type WriteTarget } from \"./write-session\";\n\nfunction buildEdgeEndpointCacheKey(\n  graphId: string,\n  kind: string,\n  id: string,\n): string {\n  return encodeTupleKey([graphId, kind, id]);\n}\n\nfunction buildEdgeFromCacheKey(\n  graphId: string,\n  edgeKind: string,\n  fromKind: string,\n  fromId: string,\n): string {\n  return encodeTupleKey([graphId, edgeKind, fromKind, fromId]);\n}\n\nfunction buildEdgeBetweenCacheKey(\n  graphId: string,\n  edgeKind: string,\n  fromKind: string,\n  fromId: string,\n  toKind: string,\n  toId: string,\n): string {\n  return encodeTupleKey([graphId, edgeKind, fromKind, fromId, toKind, toId]);\n}\n\nfunction buildCountEdgesFromCacheKey(\n  params: Parameters<GraphBackend[\"countEdgesFrom\"]>[0],\n): string {\n  const activeOnly = params.activeOnly === true ? \"1\" : \"0\";\n  return encodeTupleKey([\n    params.graphId,\n    params.edgeKind,\n    params.fromKind,\n    params.fromId,\n    activeOnly,\n  ]);\n}\n\nfunction incrementPendingCount(counts: Map<string, number>, key: string): void {\n  const previous = counts.get(key) ?? 0;\n  counts.set(key, previous + 1);\n}\n\nexport function createEdgeBatchValidationBackend(\n  backend: WriteTarget,\n): Readonly<{\n  backend: WriteTarget;\n  registerPendingEdgeForCardinality: (\n    insertParams: InsertEdgeParams,\n    cardinality: Cardinality,\n  ) => void;\n  seedEndpointRow: (\n    graphId: string,\n    kind: string,\n    id: string,\n    row: Awaited<ReturnType<GraphBackend[\"getNode\"]>>,\n  ) => void;\n  /**\n   * Seeds all cardinality probes needed by one batch from a set-oriented edge\n   * read. The request lists are explicit so absent sources and absent pairs\n   * are cached as zero/false too; otherwise the validation loop would still\n   * issue singleton probes for those negative cases.\n   */\n  seedCardinalityRows: (\n    countRequests: readonly Parameters<GraphBackend[\"countEdgesFrom\"]>[0][],\n    uniqueRequests: readonly Parameters<GraphBackend[\"edgeExistsBetween\"]>[0][],\n    rows: readonly EdgeRow[],\n  ) => void;\n}> {\n  const endpointCache = new Map<\n    string,\n    Awaited<ReturnType<GraphBackend[\"getNode\"]>>\n  >();\n  const countEdgesFromCache = new Map<string, number>();\n  const edgeExistsCache = new Map<string, boolean>();\n  const pendingOneCounts = new Map<string, number>();\n  const pendingOneActiveCounts = new Map<string, number>();\n  const pendingUniquePairs = new Set<string>();\n\n  async function getNodeCached(\n    graphId: string,\n    kind: string,\n    id: string,\n  ): Promise<Awaited<ReturnType<GraphBackend[\"getNode\"]>>> {\n    const cacheKey = buildEdgeEndpointCacheKey(graphId, kind, id);\n    if (endpointCache.has(cacheKey)) {\n      return endpointCache.get(cacheKey);\n    }\n    const node = await backend.getNode(graphId, kind, id);\n    endpointCache.set(cacheKey, node);\n    return node;\n  }\n\n  // Lets batch preparation prime the endpoint cache from one getNodes\n  // round trip per (kind) instead of a per-edge getNode probe for each\n  // from/to endpoint — mirrors seedNodeRow in createNodeBatchValidationBackend.\n  // Seeding an absent result (`undefined`) is meaningful — it marks the key\n  // as known-missing so the per-edge check skips the backend read. An\n  // earlier lookup or seed always wins; seeding never overwrites.\n  function seedEndpointRow(\n    graphId: string,\n    kind: string,\n    id: string,\n    row: Awaited<ReturnType<GraphBackend[\"getNode\"]>>,\n  ): void {\n    const cacheKey = buildEdgeEndpointCacheKey(graphId, kind, id);\n    if (endpointCache.has(cacheKey)) return;\n    endpointCache.set(cacheKey, row);\n  }\n\n  async function countEdgesFromCached(\n    params: Parameters<GraphBackend[\"countEdgesFrom\"]>[0],\n  ): Promise<number> {\n    const cacheKey = buildCountEdgesFromCacheKey(params);\n    let baseCount = countEdgesFromCache.get(cacheKey);\n    if (baseCount === undefined) {\n      baseCount = await backend.countEdgesFrom(params);\n      countEdgesFromCache.set(cacheKey, baseCount);\n    }\n    const pendingKey = buildEdgeFromCacheKey(\n      params.graphId,\n      params.edgeKind,\n      params.fromKind,\n      params.fromId,\n    );\n    const pendingCount =\n      params.activeOnly === true ?\n        (pendingOneActiveCounts.get(pendingKey) ?? 0)\n      : (pendingOneCounts.get(pendingKey) ?? 0);\n    return baseCount + pendingCount;\n  }\n\n  async function edgeExistsBetweenCached(\n    params: Parameters<GraphBackend[\"edgeExistsBetween\"]>[0],\n  ): Promise<boolean> {\n    const cacheKey = buildEdgeBetweenCacheKey(\n      params.graphId,\n      params.edgeKind,\n      params.fromKind,\n      params.fromId,\n      params.toKind,\n      params.toId,\n    );\n    if (pendingUniquePairs.has(cacheKey)) {\n      return true;\n    }\n    if (edgeExistsCache.has(cacheKey)) {\n      return edgeExistsCache.get(cacheKey) ?? false;\n    }\n    const exists = await backend.edgeExistsBetween(params);\n    edgeExistsCache.set(cacheKey, exists);\n    return exists;\n  }\n\n  function registerPendingEdgeForCardinality(\n    insertParams: InsertEdgeParams,\n    cardinality: Cardinality,\n  ): void {\n    const fromCacheKey = buildEdgeFromCacheKey(\n      insertParams.graphId,\n      insertParams.kind,\n      insertParams.fromKind,\n      insertParams.fromId,\n    );\n    if (cardinality === \"one\") {\n      incrementPendingCount(pendingOneCounts, fromCacheKey);\n      return;\n    }\n    if (cardinality === \"oneActive\") {\n      if (insertParams.validTo === undefined) {\n        incrementPendingCount(pendingOneActiveCounts, fromCacheKey);\n      }\n      return;\n    }\n    if (cardinality === \"unique\") {\n      const uniqueCacheKey = buildEdgeBetweenCacheKey(\n        insertParams.graphId,\n        insertParams.kind,\n        insertParams.fromKind,\n        insertParams.fromId,\n        insertParams.toKind,\n        insertParams.toId,\n      );\n      pendingUniquePairs.add(uniqueCacheKey);\n    }\n  }\n\n  function seedCardinalityRows(\n    countRequests: readonly Parameters<GraphBackend[\"countEdgesFrom\"]>[0][],\n    uniqueRequests: readonly Parameters<GraphBackend[\"edgeExistsBetween\"]>[0][],\n    rows: readonly EdgeRow[],\n  ): void {\n    const counts = new Map<string, Readonly<{ all: number; active: number }>>();\n    const pairs = new Set<string>();\n    for (const row of rows) {\n      if (row.deleted_at !== undefined) continue;\n      const sourceKey = encodeTupleKey([\n        row.graph_id,\n        row.kind,\n        row.from_kind,\n        row.from_id,\n      ]);\n      const previous = counts.get(sourceKey) ?? { all: 0, active: 0 };\n      counts.set(sourceKey, {\n        all: previous.all + 1,\n        active: previous.active + (row.valid_to === undefined ? 1 : 0),\n      });\n      pairs.add(\n        buildEdgeBetweenCacheKey(\n          row.graph_id,\n          row.kind,\n          row.from_kind,\n          row.from_id,\n          row.to_kind,\n          row.to_id,\n        ),\n      );\n    }\n    for (const params of countRequests) {\n      const sourceKey = encodeTupleKey([\n        params.graphId,\n        params.edgeKind,\n        params.fromKind,\n        params.fromId,\n      ]);\n      const sourceCounts = counts.get(sourceKey);\n      const count =\n        params.activeOnly === true ?\n          (sourceCounts?.active ?? 0)\n        : (sourceCounts?.all ?? 0);\n      countEdgesFromCache.set(buildCountEdgesFromCacheKey(params), count);\n    }\n    for (const params of uniqueRequests) {\n      const exists = pairs.has(\n        buildEdgeBetweenCacheKey(\n          params.graphId,\n          params.edgeKind,\n          params.fromKind,\n          params.fromId,\n          params.toKind,\n          params.toId,\n        ),\n      );\n      edgeExistsCache.set(\n        buildEdgeBetweenCacheKey(\n          params.graphId,\n          params.edgeKind,\n          params.fromKind,\n          params.fromId,\n          params.toKind,\n          params.toId,\n        ),\n        exists,\n      );\n    }\n  }\n\n  const validationBackend = deriveBackend(backend, {\n    getNode: getNodeCached,\n    countEdgesFrom: countEdgesFromCached,\n    edgeExistsBetween: edgeExistsBetweenCached,\n  } satisfies Partial<WriteTarget>);\n\n  return {\n    backend: validationBackend,\n    registerPendingEdgeForCardinality,\n    seedEndpointRow,\n    seedCardinalityRows,\n  };\n}\n","/**\n * The sole classifier for managed writes that may omit an explicit transaction.\n *\n * A qualifying operation has exactly one stateful SQL statement. Its schema\n * fence, and (for edges) endpoint verdict, live inside that statement. Every\n * other managed-write shape retains `runInWriteTransaction`: an option here is\n * either applied by that one statement or this classifier refuses the path.\n */\nimport { type z } from \"zod\";\n\nimport { isBundledRootAutocommitEligible } from \"../../backend/capabilities/autocommit-single-statement\";\nimport { supportsNodeInsertProjectionRequirements } from \"../../backend/capabilities/node-insert-projections\";\nimport { isSchemaFencedInsertEligible } from \"../../backend/capabilities/schema-fenced-insert\";\nimport {\n  type GraphBackend,\n  type TransactionBackend,\n} from \"../../backend/types\";\nimport { getEmbeddingFields } from \"../embedding-sync\";\nimport { getSearchableFields } from \"../fulltext-sync\";\n\n/** Internal signal that a zero-row autocommit attempt needs transactional recovery. */\nexport class AutocommitWriteRequiresTransaction extends Error {\n  constructor() {\n    super(\"The managed autocommit attempt requires transactional recovery.\");\n    this.name = \"AutocommitWriteRequiresTransaction\";\n  }\n}\n\nexport type NodeAutocommitSingleStatementCandidate = Readonly<{\n  backend: GraphBackend | TransactionBackend;\n  schemaVersion: number | undefined;\n  historyEnabled: boolean;\n  revisionTrackingEnabled: boolean;\n  identityEnabled: boolean;\n  idGenerated: boolean;\n  kindRegistered: boolean;\n  uniqueConstraintCount: number;\n  disjointKindCount: number;\n  schema: z.ZodType;\n}>;\n\nexport type EdgeAutocommitSingleStatementCandidate = Readonly<{\n  backend: GraphBackend | TransactionBackend;\n  schemaVersion: number | undefined;\n  historyEnabled: boolean;\n  revisionTrackingEnabled: boolean;\n  kindRegistered: boolean;\n  convergesDynamically: boolean;\n  cardinality: \"many\" | \"one\" | \"unique\" | \"oneActive\";\n}>;\n\nexport type AutocommitSingleStatementCandidate =\n  | Readonly<{\n      kind: \"node\";\n      candidate: NodeAutocommitSingleStatementCandidate;\n    }>\n  | Readonly<{\n      kind: \"edge\";\n      candidate: EdgeAutocommitSingleStatementCandidate;\n    }>;\n\n/**\n * Whether the selected execution boundary can safely carry a schema fence in\n * the write statement. A root backend without interactive transactions may\n * use this only when its bundled-factory provenance proves the whole path is\n * the known one-statement implementation and this operation allows direct\n * root autocommit; derived wrappers intentionally do not inherit that proof.\n */\nfunction canUseSchemaFenceAtExecutionBoundary(\n  backend: GraphBackend | TransactionBackend,\n  rootAutocommitAllowed: boolean,\n): boolean {\n  if (backend.commands.session === \"transaction\") return true;\n  if (backend.capabilities.execution.interactiveTransactions) return true;\n  return rootAutocommitAllowed && isBundledRootAutocommitEligible(backend);\n}\n\n/**\n * The operation-independent proof that the schema fence may be carried by\n * the first INSERT. SQL statement atomicity is the relevant guarantee here;\n * `capabilities.execution.interactiveTransactions` describes interactive transaction support and\n * is one valid boundary, but is not required for a proven bundled-root write.\n */\nexport function canFuseSchemaFenceInFirstWrite(\n  input: AutocommitSingleStatementCandidate,\n): boolean {\n  switch (input.kind) {\n    case \"node\": {\n      const candidate = input.candidate;\n      return (\n        candidate.schemaVersion !== undefined &&\n        canUseSchemaFenceAtExecutionBoundary(\n          candidate.backend,\n          // The id-generation gate on root autocommit exists for an\n          // INTERACTIVE root's durability (a caller-supplied id retried\n          // after an ambiguous failure could duplicate-conflict); an atomic\n          // batch program commits its one fused statement as a unit\n          // regardless of which id it carries, so a batch-tier target\n          // clears this gate for a supplied id too.\n          candidate.idGenerated ||\n            candidate.backend.capabilities.execution.unitOfWork === \"batch\",\n        ) &&\n        isSchemaFencedInsertEligible(candidate.backend) &&\n        !candidate.historyEnabled &&\n        !candidate.revisionTrackingEnabled &&\n        (!candidate.identityEnabled || candidate.idGenerated) &&\n        candidate.kindRegistered &&\n        candidate.uniqueConstraintCount === 0 &&\n        candidate.disjointKindCount === 0 &&\n        (candidate.idGenerated ?\n          candidate.backend.insertNodeWithSchemaFence !== undefined\n        : candidate.backend.insertNodeIfAbsentWithSchemaFence !== undefined)\n      );\n    }\n\n    case \"edge\": {\n      const candidate = input.candidate;\n      return (\n        candidate.schemaVersion !== undefined &&\n        canUseSchemaFenceAtExecutionBoundary(candidate.backend, true) &&\n        isSchemaFencedInsertEligible(candidate.backend) &&\n        !candidate.historyEnabled &&\n        !candidate.revisionTrackingEnabled &&\n        candidate.kindRegistered &&\n        !candidate.convergesDynamically &&\n        candidate.cardinality === \"many\"\n      );\n    }\n  }\n}\n\n/**\n * Returns true only for a bundled root's fully fused, one-statement write.\n *\n * This deliberately does not infer an opt-in from capability names or from a\n * custom backend implementing the fused members: a custom proxy can introduce\n * arbitrary work around a member call. The private root provenance is the\n * contract that makes direct autocommit safe.\n *\n * `runAutocommitSingleStatementWritePlan`, the one caller, never passes a\n * `schemaFenceInFirstWrite` option through to its row-work — it trusts this\n * classifier's name literally: the one statement row-work emits IS the\n * schema fence. That is true only when `isSchemaFencedInsertEligible` also\n * holds for `candidate.backend`, the same gate `canFuseSchemaFenceInFirstWrite`\n * reads for the transactional fused write. Without it, a `mechanism: \"row\"`\n * bundled root would take this shortcut anyway (nothing else here reads\n * `writeFence` mechanism), row-work would fall through to its ordinary,\n * unfenced INSERT (the fused member's in-statement lock clause is empty\n * under `row`, and this path never calls `lockSchemaVersionForStoreWrite`\n * either), and the write would complete with no schema-version check at all.\n */\nexport function isAutocommitSingleStatementWrite(\n  input: AutocommitSingleStatementCandidate,\n): boolean {\n  switch (input.kind) {\n    case \"node\": {\n      const candidate = input.candidate;\n      return (\n        candidate.schemaVersion !== undefined &&\n        isBundledRootAutocommitEligible(candidate.backend) &&\n        isSchemaFencedInsertEligible(candidate.backend) &&\n        !candidate.historyEnabled &&\n        !candidate.revisionTrackingEnabled &&\n        !candidate.identityEnabled &&\n        // Unlike `canFuseSchemaFenceInFirstWrite`'s root-autocommit test,\n        // this `idGenerated` stays strict for every target, batch-tier\n        // included: the eligibility check below proves only\n        // `insertNodeWithSchemaFence` (the fresh-id INSERT, no duplicate\n        // check), never `insertNodeIfAbsentWithSchemaFence`. A supplied id\n        // needs the if-absent statement's duplicate handling regardless of\n        // unitOfWork, so it takes `runHookedWritePlan`'s route instead,\n        // where `canFuseSchemaFenceInFirstWrite` already selects the\n        // correct statement per id.\n        candidate.idGenerated &&\n        candidate.kindRegistered &&\n        candidate.uniqueConstraintCount === 0 &&\n        candidate.disjointKindCount === 0 &&\n        ((\n          getEmbeddingFields(candidate.schema).length > 0 ||\n          getSearchableFields(candidate.schema).length > 0\n        ) ?\n          supportsNodeInsertProjectionRequirements(candidate.backend, {\n            embedding: getEmbeddingFields(candidate.schema).length > 0,\n            fulltext: getSearchableFields(candidate.schema).length > 0,\n          })\n        : candidate.backend.insertNodeWithSchemaFence !== undefined)\n      );\n    }\n\n    case \"edge\": {\n      const candidate = input.candidate;\n      return (\n        candidate.schemaVersion !== undefined &&\n        isBundledRootAutocommitEligible(candidate.backend) &&\n        isSchemaFencedInsertEligible(candidate.backend) &&\n        !candidate.historyEnabled &&\n        !candidate.revisionTrackingEnabled &&\n        candidate.kindRegistered &&\n        !candidate.convergesDynamically &&\n        candidate.cardinality === \"many\"\n      );\n    }\n  }\n}\n","/**\n * Composable edge write steps — the edge counterpart of\n * `node-write-pipeline.ts`.\n *\n * An edge mutation is a row write plus the CLAIM its declared cardinality owes.\n * Edges reserve no uniqueness entries, carry no fulltext rows and hold no\n * embeddings, so there are no sync fans to keep in step with the row — but the\n * cardinality claim is a sidecar in every sense that matters: it is written to a\n * different relation, in a fixed position relative to the row (before the write\n * it fences, after the write it cleans up), and a path that applied the row\n * without it would leave the constraint enforced by nothing but a probe. That is\n * why the claim travels ON the work record and is issued HERE rather than by the\n * operations module that decided it: the decision is a pure function of the\n * verdict the caller reached, and the write is a backend member only a step may\n * spell.\n *\n * The insert shapes are NOT here: `insert-dispatch.ts` already owns \"which of\n * the four insert members this backend supports\", for edges as much as for\n * nodes, and a pass-through step would be a second owner of that decision.\n *\n * The steps assume they run inside a write transaction (see\n * {@link runInWriteTransaction}); they perform no transaction management of\n * their own.\n */\nimport { type ClaimsVerdictThunk } from \"../../backend/capabilities/resolve\";\nimport {\n  type BackendValidityEndMutation,\n  type ClaimEdgeCardinalityParams,\n  type EdgeRow,\n  type GraphBackend,\n  type TransactionBackend,\n  type UpdateEdgeParams,\n} from \"../../backend/types\";\nimport { claimEdgeCardinality, purgeEdgeClaims } from \"../claims/edge-claims\";\nimport { type GraphWriteLock } from \"../recorded-capture/clock\";\nimport { type WriteParamsDraft } from \"./write-fences\";\n\ntype Backend = GraphBackend | TransactionBackend;\n\n/**\n * The graph-scoped state the edge write steps need.\n *\n * `lock` is compile-time evidence that the per-graph write-lock discipline was\n * satisfied BEFORE any row work (see {@link GraphWriteLock}), exactly as\n * {@link NodeWriteContext} requires it: the pipeline performs no locking of its\n * own, so requiring the token here makes \"row write before lock\" a type error\n * at the call site instead of a lock-order inversion in review. There is no\n * registry, because an edge write resolves no schema and no constraints — the\n * caller validated the props before the transaction opened.\n *\n * `claimsVerdict` is the `claims` bundle's memoized, at-most-once verdict\n * thunk (ruling B7 refinement 2), called at each site below that issues or\n * releases an edge-cardinality claim.\n */\nexport type EdgeWriteContext = Readonly<{\n  graphId: string;\n  lock: GraphWriteLock;\n  claimsVerdict: ClaimsVerdictThunk;\n}>;\n\n/** Builds an {@link EdgeWriteContext} — the one constructor every call site shares. */\nexport function createEdgeWriteContext(\n  graphId: string,\n  lock: GraphWriteLock,\n  claimsVerdict: ClaimsVerdictThunk,\n): EdgeWriteContext {\n  return { graphId, lock, claimsVerdict };\n}\n\n/**\n * One edge update, minus every predicate the write's verdicts read.\n *\n * The asserted identity components and the asserted validity lower bound are\n * NOT here: they are the write's fences, applied by\n * `EDGE_UPDATE_FENCE_APPLIERS` into the draft this step is handed alongside\n * the work. An update that forgot to carry a bound its verdict consumed\n * therefore cannot be spelled — the fence record's keys are required — while\n * the work stays exactly \"what this write intends to change\".\n */\nexport type EdgeUpdateWork = Readonly<{\n  id: string;\n  props: Record<string, unknown>;\n  /** See {@link UpdateEdgeParams.validFrom}: stored on the resurrecting leg. */\n  validFrom?: string | null;\n  clearDeleted?: boolean;\n  /**\n   * The cardinality claim this update owes, present only when the write\n   * RE-ADMITS the row to the population its cardinality constrains — a\n   * resurrection, or a reopened `oneActive` window. Built by the caller (a pure\n   * function of the verdict it reached) and ISSUED here, at its PRE-INSERT\n   * placement: the probe that authorised the write read a population no key\n   * fences, so the claim row is what refuses a peer that read the same\n   * population, and a claim issued after the row it fences is not a fence.\n   */\n  claim?: ClaimEdgeCardinalityParams;\n}> &\n  // The window END is the SAME discriminated pair `UpdateEdgeParams` declares,\n  // not a re-spelling with two independent optionals: \"state an end\" and \"clear\n  // the end\" are mutually exclusive, and reusing the union is what makes the\n  // spread below type-check without the step re-asserting the exclusivity.\n  BackendValidityEndMutation;\n\n/**\n * Applies an edge update: the fenced UPDATE, and nothing else.\n *\n * Both halves of the statement's `WHERE` arrive as the draft — the identity\n * components the caller ASSERTED and, when its verdict read one, the stored\n * lower bound — so the row this writes is provably the row that was judged.\n * The step does not decide which of them to carry; the appliers did, from the\n * fence record the caller had to state.\n *\n * A zero-row result is NOT interpreted here. The backend's\n * `DatabaseOperationError` propagates unchanged, because the two callers of\n * this step read \"matched nothing\" differently — the store re-reads and either\n * converges or refuses ({@link withUnmatchedEdgeUpdateRefusal}), interchange\n * import records a per-row conflict and continues — and a fused unit owns row\n * plus fences plus sidecars, not one error policy for every caller.\n */\nexport async function applyEdgeUpdate(\n  ctx: EdgeWriteContext,\n  args: EdgeUpdateWork & WriteParamsDraft,\n  backend: Backend,\n): Promise<EdgeRow> {\n  const { claim, ...rowWork } = args;\n  if (claim !== undefined) {\n    await claimEdgeCardinality(backend, ctx.claimsVerdict(), claim);\n  }\n  // Every key of the work record and of the fence draft is a field of\n  // `UpdateEdgeParams`, and both are built with the same \"present only when\n  // stated\" discipline the call site used to apply field by field, so the\n  // spread emits exactly the params the hand-built object emitted.\n  const updateParams: UpdateEdgeParams = { graphId: ctx.graphId, ...rowWork };\n  return backend.updateEdge(updateParams);\n}\n\n/**\n * One edge delete, soft or hard.\n *\n * `kind` is the identity this delete ASSERTS the target row already carries\n * (see {@link UpdateEdgeParams.kind}); it rides in the work rather than in a\n * fence record because a delete states nothing else and has no verdict to\n * fence — the statement IS its own recheck.\n */\nexport type EdgeDeleteWork = Readonly<{\n  id: string;\n  kind: string;\n}>;\n\n/** Tombstones one edge, asserting the kind the caller resolved it under. */\nexport function applyEdgeSoftDelete(\n  ctx: EdgeWriteContext,\n  work: EdgeDeleteWork,\n  backend: Backend,\n): Promise<void> {\n  return backend.deleteEdge({\n    graphId: ctx.graphId,\n    id: work.id,\n    kind: work.kind,\n  });\n}\n\n/** Applies one resolved soft-delete set through the backend's batch port. */\nexport async function applyEdgeSoftDeleteBatch(\n  ctx: EdgeWriteContext,\n  work: readonly EdgeDeleteWork[],\n  backend: Backend,\n): Promise<void> {\n  if (work.length === 0) return;\n  const deleteEdgesBatch = backend.deleteEdgesBatch;\n  const kind = work[0]?.kind;\n  if (\n    deleteEdgesBatch === undefined ||\n    kind === undefined ||\n    work.some((item) => item.kind !== kind)\n  ) {\n    for (const item of work) {\n      await applyEdgeSoftDelete(ctx, item, backend);\n    }\n    return;\n  }\n  await deleteEdgesBatch({\n    graphId: ctx.graphId,\n    ids: work.map((item) => item.id),\n    kind,\n  });\n}\n\n/**\n * One edge hard delete: the row, plus whether this kind holds a cardinality\n * claim to give back.\n *\n * The flag is DATA the caller decides from the kind's declaration, not a\n * capability probe: an unconstrained kind never claimed the axis and must pay no\n * statement for releasing one, which is the same rule its create follows.\n */\nexport type EdgeHardDeleteWork = EdgeDeleteWork &\n  Readonly<{ holdsCardinalityClaim: boolean }>;\n\n/**\n * Permanently removes one edge, asserting the same kind, and releases the claim\n * it held.\n *\n * The release is POST-write housekeeping, not a fence: the claim's liveness\n * predicate already reads a row that is about to be gone, so the axis is\n * takeable either way. Dropping the row keeps the relation from growing by one\n * row per hard-deleted constrained edge.\n */\nexport async function applyEdgeHardDelete(\n  ctx: EdgeWriteContext,\n  work: EdgeHardDeleteWork,\n  backend: Backend,\n): Promise<void> {\n  await backend.hardDeleteEdge({\n    graphId: ctx.graphId,\n    id: work.id,\n    kind: work.kind,\n  });\n  if (work.holdsCardinalityClaim) {\n    await purgeEdgeClaims(backend, ctx.claimsVerdict(), ctx.graphId, [work.id]);\n  }\n}\n","/**\n * What a write's verdicts READ, carried into the statement that honors them.\n *\n * Every member of a fence record is the predicate itself, never a flag a\n * caller re-derives one from. That shape already exists in this codebase —\n * `ValidityWindowVerdict.storedLowerBoundFence` hands back the\n * `expectedValidFrom` object rather than a boolean, and its docstring names\n * the over-fencing defect that shape closed — and this module generalizes it\n * per row-work kind.\n *\n * ## Why every key is REQUIRED\n *\n * `{}` is how a fence says \"assert nothing\", and it is the ONLY way to say it.\n * An optional key would reintroduce the absent state that the verdict shape\n * eliminated: \"I forgot to pass the fence\" and \"this write asserts nothing\"\n * would look identical at the call site, and the compiler could not tell them\n * apart either. With the key required, forgetting it is a type error and an\n * unfenced write is a stated decision.\n *\n * ## Why the applier maps are total\n *\n * Each map is `satisfies { [K in keyof F]-?: FenceApplier<F, K> }`, so a fence\n * key without an applier fails compilation. A fence a kind's statement cannot\n * carry is REFUSED by its applier, naming the fence and the kind — applied or\n * refused, never silently dropped.\n */\nimport {\n  assertsStoredLowerBound,\n  assertsStoredUpperBound,\n  type ValidityLowerBoundFence,\n  type ValidityUpperBoundFence,\n} from \"../../utils/date\";\nimport { type EdgeIdentityExpectation } from \"./edge-identity\";\n\n/**\n * The row-work shapes a fence can be applied to. Not {@link RowWorkKind}: a\n * node has two statement families with different fence capabilities (the\n * single-row UPDATE carries `expectedValidFrom`; the set UPDATE has no field\n * for it), and the refusal has to name which one refused.\n */\nexport type WriteFenceKind = \"nodeUpdate\" | \"nodeSetUpdate\" | \"edgeUpdate\";\n\n/**\n * The mutable predicate fields a fence applier may contribute to the write's\n * params. It is a DRAFT, not the params: the applier's whole job is to write\n * the predicate its fence states, and nothing else about the statement is\n * reachable from here.\n */\nexport interface WriteParamsDraft {\n  expectedValidFrom?: string | null;\n  expectedValidTo?: string | null;\n  kind?: string;\n  fromKind?: string;\n  fromId?: string;\n  toKind?: string;\n  toId?: string;\n}\n\n/** A fresh, empty draft — the state \"this write asserts nothing yet\". */\nexport function createWriteParamsDraft(): WriteParamsDraft {\n  return {};\n}\n\n/** Applies one fence key's predicate to the draft. */\ntype FenceApplier<F, K extends keyof F> = (\n  fence: F[K],\n  draft: WriteParamsDraft,\n) => void;\n\n/** A total applier map for a fence record: one applier per key, no key spare. */\nexport type FenceApplierMap<F> = { [K in keyof F]-?: FenceApplier<F, K> };\n\n/** The fences a single-row node UPDATE can carry. */\nexport type NodeUpdateFences = Readonly<{\n  validityLowerBound: ValidityLowerBoundFence;\n}>;\n\n/**\n * The fences a set-based node UPDATE can carry. Same key as\n * {@link NodeUpdateFences}, DIFFERENT applier: `UpdateNodeSetParams` has no\n * `expectedValidFrom` field, so `{}` is the only value this kind can honor.\n */\nexport type NodeSetUpdateFences = Readonly<{\n  validityLowerBound: ValidityLowerBoundFence;\n}>;\n\n/** The fences an edge UPDATE can carry. */\nexport type EdgeUpdateFences = Readonly<{\n  validityLowerBound: ValidityLowerBoundFence;\n  /**\n   * The window END the verdict read. Non-empty only for a reopen that re-admits\n   * the row to a counted population it was excluded from — the `oneActive`\n   * case — because that verdict is the one that consumed the stored `valid_to`.\n   */\n  validityUpperBound: ValidityUpperBoundFence;\n  /** The identity components the caller asserted; each optional INSIDE. */\n  edgeIdentity: EdgeIdentityExpectation;\n}>;\n\n/**\n * Whether an edge update asserts ANY window state — the single owner of the\n * question the unmatched-update diagnosis asks.\n *\n * The diagnosis has to know whether \"no row matched\" could have been the window\n * predicates rather than the identity ones, and it must reach that answer from\n * the same two predicates the appliers consult. Re-deriving it from the emitted\n * params (which the diagnosis never sees) is how the copies drift.\n */\nexport function assertsStoredWindowState(fences: EdgeUpdateFences): boolean {\n  return (\n    assertsStoredLowerBound(fences.validityLowerBound) ||\n    assertsStoredUpperBound(fences.validityUpperBound)\n  );\n}\n\n/**\n * A fence the row work's statement has no field to carry.\n *\n * INTERNAL, with no allocated public error code, following\n * `EdgeUpdateTargetMoved`: no user-stated option can reach it — it fires only\n * when a write path hands a fence to a statement family that cannot express\n * it — so a public code would document a state users cannot produce. It is\n * exported for the tests that pin the refusal, not for callers to catch.\n */\nexport class UnsupportedWriteFenceError extends Error {\n  readonly fence: string;\n  readonly kind: WriteFenceKind;\n\n  constructor(fence: string, kind: WriteFenceKind) {\n    super(\n      `The ${kind} statement cannot carry the \"${fence}\" fence, so the write ` +\n        `is refused rather than run unfenced. Assert nothing ({}) or use a ` +\n        `write shape whose statement carries it.`,\n    );\n    this.name = \"UnsupportedWriteFenceError\";\n    this.fence = fence;\n    this.kind = kind;\n  }\n}\n\n/**\n * Carries the bound the verdict READ into the statement's own predicate.\n *\n * `assertsStoredLowerBound` owns the emptiness test — the same predicate\n * `node-write-pipeline.ts` consults when it builds the update params — so the\n * seam that validates a fence and the step that carries it cannot disagree\n * about what an empty fence is.\n */\nfunction applyValidityLowerBound(\n  fence: ValidityLowerBoundFence,\n  draft: WriteParamsDraft,\n): void {\n  if (!assertsStoredLowerBound(fence)) return;\n  draft.expectedValidFrom = fence.expectedValidFrom;\n}\n\nexport const NODE_UPDATE_FENCE_APPLIERS = {\n  validityLowerBound: applyValidityLowerBound,\n} as const satisfies FenceApplierMap<NodeUpdateFences>;\n\n/**\n * The refusal branch. It is REACHABLE and TYPE-LEGAL: the record's one key is\n * required and `ValidityLowerBoundFence` legitimately carries\n * `expectedValidFrom`, so a caller can hand a set update a stated bound with\n * no cast and no unknown key. There is nowhere to put it in\n * `UpdateNodeSetParams`, so the write is refused rather than run unfenced.\n *\n * No caller reaches it today — the set-update path is props-only — and the\n * guard is what keeps that true when a future set update grows a window.\n */\nexport const NODE_SET_UPDATE_FENCE_APPLIERS = {\n  validityLowerBound: (fence) => {\n    if (!assertsStoredLowerBound(fence)) return;\n    throw new UnsupportedWriteFenceError(\"validityLowerBound\", \"nodeSetUpdate\");\n  },\n} as const satisfies FenceApplierMap<NodeSetUpdateFences>;\n\n/**\n * Carries every identity component the caller ASSERTED into the statement's\n * `WHERE`, so the row an edge update writes is provably the row that was\n * judged. Kind is always asserted; an endpoint component is asserted only when\n * the caller claimed it, because a component nobody claimed must not become a\n * predicate that refuses legitimate writes.\n */\nfunction applyEdgeIdentity(\n  fence: EdgeIdentityExpectation,\n  draft: WriteParamsDraft,\n): void {\n  draft.kind = fence.kind;\n  if (fence.fromKind !== undefined) draft.fromKind = fence.fromKind;\n  if (fence.fromId !== undefined) draft.fromId = fence.fromId;\n  if (fence.toKind !== undefined) draft.toKind = fence.toKind;\n  if (fence.toId !== undefined) draft.toId = fence.toId;\n}\n\n/**\n * Carries the window END the verdict READ, on the same terms as its\n * lower-bound counterpart: present only when the verdict consulted it.\n */\nfunction applyValidityUpperBound(\n  fence: ValidityUpperBoundFence,\n  draft: WriteParamsDraft,\n): void {\n  if (!assertsStoredUpperBound(fence)) return;\n  draft.expectedValidTo = fence.expectedValidTo;\n}\n\nexport const EDGE_UPDATE_FENCE_APPLIERS = {\n  validityLowerBound: applyValidityLowerBound,\n  validityUpperBound: applyValidityUpperBound,\n  edgeIdentity: applyEdgeIdentity,\n} as const satisfies FenceApplierMap<EdgeUpdateFences>;\n\n/**\n * Applies EVERY declared fence of a record to the draft.\n *\n * Iterating the applier map — which the type system pins total over the fence\n * record's keys — is what makes \"accepted, then ignored\" unrepresentable: a\n * key exists on the record only if an applier exists for it, and every applier\n * in the map runs. A per-kind dispatcher that named its keys by hand could\n * silently skip one; this cannot.\n */\nexport function applyWriteFences<F extends object>(\n  appliers: FenceApplierMap<F>,\n  fences: F,\n  draft: WriteParamsDraft,\n): void {\n  for (const key of Object.keys(appliers) as (keyof F)[]) {\n    // One localized widening: indexing the map with a key UNION yields a union\n    // of applier signatures, which TypeScript will not call even though every\n    // member accepts the value indexed out of the record with the same key.\n    // The map's totality is asserted by its `satisfies` clause, so the pairing\n    // is sound; the cast only tells the compiler the keys line up.\n    const applier: (fence: F[keyof F], draft: WriteParamsDraft) => void =\n      appliers[key];\n    applier(fences[key], draft);\n  }\n}\n","/**\n * The only sanctioned surface that mutates graph state.\n *\n * Every method is a FUSED unit — the primary row plus every sidecar that row\n * obliges — so \"a new write path forgot a sidecar\" stops being expressible:\n * there is no row-only primitive for a migrated module to call, because the\n * raw backend members are banned outside the step and sidecar modules the\n * session composes.\n *\n * ## Names\n *\n * Deliberately disjoint from `WRITE_MEMBER_KEYS`. The lint rule that certifies\n * this migration is `no-restricted-syntax`, which is receiver-blind: a session\n * method named `insertNode` would be flagged by the very rule that enforces\n * the seam. Renaming is chosen over a type-aware rule because the alternative\n * is a custom rule package plus type information on the lint program — real\n * infrastructure, bought only to permit a name collision we do not need.\n *\n * ## The type grows per batch, and that is load-bearing\n *\n * A method exists only once the step module it delegates to exists. B0 shipped\n * the eight node methods whose delegates (`node-write-pipeline.ts`'s four\n * steps, `insert-dispatch.ts`'s four insert shapes) were already here; B1b\n * added `reviseNodeSet` in the same commit as `applyNodeSetUpdate`, and B2\n * added the seven edge methods in the same commit as `edge-write-pipeline.ts`.\n * That schedule is what lets this module spell NO banned member call at any\n * commit — which is why it needs no lint exemption on the day it lands or on\n * any day after.\n *\n * ## Four insert shapes, not three\n *\n * `insert-dispatch.ts` exposes `one`, `oneNoReturn`, `batch` and\n * `batchReturning`, and all four are live today. `createNodes` maps to the\n * RETURNING batch; `createNodesNoReturn` maps to the no-return batch.\n * Collapsing the two would make the migrating call sites emit\n * `insertNodesBatchReturning` where they emit `insertNodesBatch` today — a\n * statement change the no-behavior-change invariant forbids.\n */\nimport { type z } from \"zod\";\n\nimport { type UNIQUE_SIDECAR_BATCH } from \"../../backend/capabilities/bundle-registry\";\nimport {\n  supportsNodeCreatePlan,\n  supportsNodeInsertProjections,\n} from \"../../backend/capabilities/node-insert-projections\";\nimport {\n  type BundleVerdictOf,\n  type ClaimsVerdictThunk,\n} from \"../../backend/capabilities/resolve\";\nimport { executeAuthoritativeGraphCommand } from \"../../backend/command-contract\";\nimport {\n  type BackendIdentity,\n  type ClaimEdgeCardinalityParams,\n  type DurableEdgeBatchMembers,\n  type EdgeCreateCommand,\n  type EdgeCreateCommandResult,\n  type EdgeRow,\n  type FulltextOperationBackend,\n  type GraphBackend,\n  type GraphEntityReadBackend,\n  type InsertEdgeParams,\n  type InsertNodeParams,\n  type LiveNodeRow,\n  type NodeCreateCommand,\n  type NodeInsertProjection,\n  type NodeRow,\n  type QueryExecutionBackend,\n  type RawQueryExecutionBackend,\n  type RawStatementExecutionBackend,\n  type ResolvedNodeUpdateBatchEntry,\n  type SchemaReadBackend,\n  type SchemaWriteFenceParams,\n  type SqlCompilationBackend,\n  type TombstonedNodeRow,\n  type TransactionBackend,\n  type UniqueConstraintBackend,\n  type VectorOperationBackend,\n} from \"../../backend/types\";\nimport { type DeleteBehavior, type UniqueConstraint } from \"../../core/types\";\nimport { CompilerInvariantError, ConfigurationError } from \"../../errors\";\nimport { type KindRegistry } from \"../../registry/kind-registry\";\nimport { type Assert, type Equal } from \"../../utils/type-assert\";\nimport {\n  claimEdgeCardinality,\n  claimEdgeCardinalityBatch,\n} from \"../claims/edge-claims\";\nimport {\n  type NodeClaimItem,\n  type NodeCreateClaimPlan,\n  planNodeCreateClaims,\n  refuseNodeCreateClaimError,\n  withNodeCreateClaims,\n  withNodeCreateClaimsBatch,\n} from \"../claims/node-claims\";\nimport {\n  edgeInsertDispatch,\n  nodeInsertDispatch,\n  runInsertBatch,\n  runInsertBatchReturning,\n  runInsertIfAbsent,\n  runInsertNoReturn,\n} from \"../insert-dispatch\";\nimport { type GraphWriteLock } from \"../recorded-capture/clock\";\nimport { AutocommitWriteRequiresTransaction } from \"./autocommit-single-statement\";\nimport {\n  applyEdgeHardDelete,\n  applyEdgeSoftDelete,\n  applyEdgeSoftDeleteBatch,\n  applyEdgeUpdate,\n  createEdgeWriteContext,\n  type EdgeDeleteWork,\n  type EdgeHardDeleteWork,\n  type EdgeUpdateWork,\n} from \"./edge-write-pipeline\";\nimport {\n  applyNodeHardDelete,\n  applyNodeInsertSyncFans,\n  applyNodeInsertSyncFansBatch,\n  applyNodeResurrect,\n  applyNodeSetUpdate,\n  applyNodeSoftDelete,\n  applyNodeUpdate,\n  applyResolvedNodeUpdateBatch,\n  createNodeWriteContext,\n  type NodeDeletePolicy,\n  type NodeSetUpdateResult,\n  type NodeSetUpdateWork,\n  type NodeUpdateTarget,\n} from \"./node-write-pipeline\";\nimport {\n  applyWriteFences,\n  createWriteParamsDraft,\n  EDGE_UPDATE_FENCE_APPLIERS,\n  type EdgeUpdateFences,\n  NODE_SET_UPDATE_FENCE_APPLIERS,\n  NODE_UPDATE_FENCE_APPLIERS,\n  type NodeSetUpdateFences,\n  type NodeUpdateFences,\n} from \"./write-fences\";\nimport { type WriteMemberKey } from \"./write-members\";\n\n/**\n * The backend handle row work receives: a FACET COMPOSITION of the read\n * surfaces, never `Omit<GraphBackend | TransactionBackend, …>`.\n *\n * `Omit` over a union does not distribute — `keyof (A | B)` is the\n * INTERSECTION of the key sets — so an `Omit` here would silently collapse to\n * the members both alternatives have, and every top-level-only member would\n * vanish without anyone saying so. `TransactionBackend` and\n * `TransactionReadBackend` are the existing precedents for stating the\n * composition explicitly.\n *\n * This is a TYPE-ONLY projection. At runtime the executor hands row work the\n * very object `runInWriteTransaction` gave it: a runtime projection would\n * allocate per write and would destroy the `\"transaction\" in target`\n * discrimination the layers above depend on.\n */\nexport type WriteTarget = Readonly<\n  BackendIdentity &\n    GraphEntityReadBackend &\n    SchemaReadBackend &\n    QueryExecutionBackend &\n    SqlCompilationBackend &\n    RawQueryExecutionBackend &\n    RawStatementExecutionBackend &\n    DurableEdgeBatchMembers &\n    Pick<\n      GraphBackend,\n      | \"insertNodeIfAbsent\"\n      | \"insertNodeIfAbsentWithSchemaFence\"\n      | \"insertNodeWithSchemaFence\"\n      | \"commands\"\n    > &\n    Pick<UniqueConstraintBackend, \"checkUnique\" | \"checkUniqueBatch\"> &\n    Pick<\n      GraphBackend,\n      | \"claimEdgeCardinality\"\n      | \"claimEdgeCardinalityGuarded\"\n      | \"claimEdgeCardinalityBatch\"\n      | \"purgeEdgeClaims\"\n      | \"hardDeleteUniquesByConcreteKind\"\n    > &\n    Pick<VectorOperationBackend, \"vectorSearch\"> &\n    Pick<FulltextOperationBackend, \"fulltextSearch\">\n>;\n\n/**\n * THE COUNTED HOLE: widens the row-work projection back to the full backend\n * union.\n *\n * It existed because the migration moved call sites one module at a time while\n * their preparation helpers, constraint probes, uniqueness probes and identity\n * hooks were still typed `GraphBackend | TransactionBackend`; re-typing all of\n * those in the same batch that moved the call sites would have made every batch\n * a whole-module retype. So the widening was EXPLICIT, NAMED and COUNTED, and\n * the ratchet drove the count down as those signatures were re-typed. An `as`\n * cast at each site would have been the same unsoundness with no counter.\n *\n * Four call sites remain for three structural reasons, not migration debt. The\n * planned node and edge create paths inspect the exact row-work receiver before\n * allowing it to carry a schema fence; the node projection fallback must retain\n * the root-vs-transaction discriminator; and `nestedManagedWriteTarget` is the\n * single owner of nested managed-write re-entry. The ratchet records these\n * reasoned escapes rather than pretending a zero that would weaken receiver\n * validation or change nested writes' fence and revision-clock behavior.\n */\nexport function unfencedTarget(\n  target: WriteTarget,\n): GraphBackend | TransactionBackend {\n  return target as GraphBackend | TransactionBackend;\n}\n\n/**\n * Widens a row-work target only when a whole managed write must re-enter the\n * executor against the current transaction receiver. Keeping this as one seam\n * prevents each fallback consumer from minting its own widening escape.\n */\nexport function nestedManagedWriteTarget(\n  target: WriteTarget,\n): GraphBackend | TransactionBackend {\n  return unfencedTarget(target);\n}\n\n/** Refuses a root fallback that would split a fused row and projection write. */\nfunction assertPortableNodeFallbackCanRun(\n  target: WriteTarget,\n  params: InsertNodeParams,\n  projections: readonly NodeInsertProjection[],\n): void {\n  if (projections.length === 0 || !(\"transaction\" in unfencedTarget(target)))\n    return;\n  if (target.capabilities.execution.interactiveTransactions) {\n    throw new AutocommitWriteRequiresTransaction();\n  }\n  throw new ConfigurationError(\n    \"This backend cannot fall back from a fused node projection command without a transaction.\",\n    {\n      code: \"NODE_PROJECTION_TRANSACTION_REQUIRED\",\n      graphId: params.graphId,\n      kind: params.kind,\n    },\n  );\n}\n\n/** The graph-scoped state every session method's step modules need. */\nexport type WriteSessionContext = Readonly<{\n  graphId: string;\n  registry: KindRegistry;\n  /**\n   * The `claims` bundle's memoized, at-most-once verdict thunk (ruling B7\n   * refinement 2). Called at the site that needs it — never hoisted into\n   * store construction, which would resolve it eagerly and break a\n   * contradictory-declaration backend's ability to construct a store at all.\n   */\n  claimsVerdict: ClaimsVerdictThunk;\n  /**\n   * The `uniqueSidecarBatch` bundle's verdict (ruling B8 spec item 2),\n   * resolved once at store construction (or once per import call) and\n   * threaded here for `createNodeWriteContext` — never re-resolved.\n   */\n  uniqueSidecarBatch: BundleVerdictOf<typeof UNIQUE_SIDECAR_BATCH>;\n}>;\n\n/** The derived data a node insert obliges, alongside the row itself. */\ntype NodeInsertSideEffects = Readonly<{\n  kind: string;\n  id: string;\n  schema: z.ZodType;\n  props: Record<string, unknown>;\n  uniqueConstraints: readonly UniqueConstraint[];\n}>;\n\n/**\n * One node insert: the row params, the claims the row owes, and the sidecar\n * inputs, as ONE value. They travel together because they are applied together;\n * a caller cannot hand over the row and keep either half to itself.\n *\n * The claim item is the DECLARATION the claim seam reads its entries from — not\n * the entries themselves — because the seam owns both \"what claims does this row\n * owe\" and \"when is each due\", and a caller that could hand over a prepared\n * entry list could hand over a shorter one.\n */\nexport type NodeCreateWork = Readonly<{\n  params: InsertNodeParams;\n  idGenerated?: boolean | undefined;\n  allowNonTransactionalClaims?: boolean;\n  claim: NodeClaimItem;\n  /** The preparation-time claim decision, shared by fused and fallback paths. */\n  claimPlan: NodeCreateClaimPlan;\n  sideEffects: NodeInsertSideEffects;\n  projections: readonly NodeInsertProjection[];\n}>;\n\n/** Refuses an insert-if-absent unit that would silently drop a node claim. */\nfunction assertClaimFreeInsertIfAbsentWork(\n  ctx: Pick<WriteSessionContext, \"graphId\" | \"registry\">,\n  work: NodeCreateWork,\n): void {\n  const derivedPlan = planNodeCreateClaims(ctx, work.claim);\n  if (\n    derivedPlan.claims.length === 0 &&\n    work.claimPlan.entries.length === 0 &&\n    work.claimPlan.claims.length === 0 &&\n    work.claimPlan.verdicts.length === 0\n  ) {\n    return;\n  }\n  throw new CompilerInvariantError(\n    \"A node insert-if-absent unit cannot carry claims.\",\n    {\n      graphId: work.params.graphId,\n      kind: work.params.kind,\n      id: work.params.id,\n      derivedClaimCount: derivedPlan.claims.length,\n      plannedClaimCount: work.claimPlan.claims.length,\n    },\n  );\n}\n\n/**\n * One node update. The validity lower-bound predicate is NOT here: it is the\n * write's fence, passed separately and required, so an update that forgot to\n * carry the bound its verdict read cannot be spelled.\n */\ntype NodeUpdateWork = Readonly<{\n  schema: z.ZodType;\n  validatedProps: Record<string, unknown>;\n  uniqueConstraints: readonly UniqueConstraint[];\n  validFrom?: string | null;\n  /**\n   * The window end this update states, and the flag that clears one. Declared as\n   * two independent optionals rather than as `BackendValidityEndMutation`'s\n   * discriminated pair, because `applyNodeUpdate` — not this record — is what\n   * resolves them into the mutually exclusive params, and the store's callers\n   * build them with conditional spreads a union cannot narrow.\n   */\n  validTo?: string;\n  clearValidTo?: true;\n}> &\n  NodeUpdateTarget;\n\n/** One node soft delete, including the delete behavior its edges obey. */\ntype NodeDeleteWork = Readonly<{\n  existing: LiveNodeRow;\n  schema: z.ZodType;\n  uniqueConstraints: readonly UniqueConstraint[];\n  onDelete: DeleteBehavior | undefined;\n}>;\n\n/** One node hard delete. */\ntype NodeHardDeleteWork = Readonly<{\n  kind: string;\n  id: string;\n  schema: z.ZodType;\n  onDelete: DeleteBehavior | undefined;\n}>;\n\n/** One node resurrection: reopen a tombstone with its stored props. */\ntype NodeResurrectWork = Readonly<{\n  existing: TombstonedNodeRow;\n  schema: z.ZodType;\n  uniqueConstraints: readonly UniqueConstraint[];\n}>;\n\ntype ResolvedNodeUpdateBatchWork = Readonly<{\n  schema: z.ZodType<Record<string, unknown>>;\n  uniqueConstraints: readonly UniqueConstraint[];\n  entries: readonly ResolvedNodeUpdateBatchEntry[];\n}>;\n\n/**\n * One edge insert: the row params and the cardinality claim the row owes.\n *\n * An edge write obliges no DERIVED data — no uniqueness entries, no fulltext, no\n * embeddings — but a constrained kind owes a claim, and the claim is what fences\n * the axis its declaration spans. It is absent for an unconstrained kind and for\n * a born-ended row whose cardinality does not count it, which is what\n * `edgeCardinalityClaim` decides; the caller states the decision and this\n * surface applies it at its PRE-INSERT placement.\n *\n * The update and delete work records live in `edge-write-pipeline.ts` instead,\n * beside the steps that consume them; these four methods have no step module of\n * their own (they delegate to `insert-dispatch.ts`), so their work record lives\n * here with them.\n */\nexport type EdgeInsertWork = Readonly<{\n  params: InsertEdgeParams;\n  claim: ClaimEdgeCardinalityParams | undefined;\n}>;\n\n/**\n * The claims a batch of edge inserts owes, in the order the batch writer sorts.\n */\nfunction edgeBatchClaims(\n  work: readonly EdgeInsertWork[],\n): readonly ClaimEdgeCardinalityParams[] {\n  return work.flatMap((item) => (item.claim === undefined ? [] : [item.claim]));\n}\n\nexport type NodeWriteSession = Readonly<{\n  // ---- B0: delegates to node-write-pipeline.ts + insert-dispatch.ts\n  createNode: (work: NodeCreateWork) => Promise<NodeRow>;\n  /** A conflict-safe insert for a no-claim create; undefined means occupied. */\n  createNodeIfAbsent: (work: NodeCreateWork) => Promise<NodeRow | undefined>;\n  createNodeIfAbsentWithSchemaFence: (\n    work: NodeCreateWork,\n    schemaFence: SchemaWriteFenceParams,\n  ) => Promise<NodeRow | undefined>;\n  createNodeWithSchemaFence: (\n    work: NodeCreateWork,\n    schemaFence: SchemaWriteFenceParams,\n  ) => Promise<NodeRow | undefined>;\n  createNodeNoReturn: (work: NodeCreateWork) => Promise<void>;\n  createNodes: (work: readonly NodeCreateWork[]) => Promise<readonly NodeRow[]>;\n  createNodesNoReturn: (work: readonly NodeCreateWork[]) => Promise<void>;\n  reviseNode: (\n    work: NodeUpdateWork,\n    fences: NodeUpdateFences,\n  ) => Promise<NodeRow>;\n  retireNode: (\n    work: NodeDeleteWork,\n    policy?: NodeDeletePolicy,\n  ) => Promise<void>;\n  purgeNode: (work: NodeHardDeleteWork) => Promise<void>;\n  reviveNode: (work: NodeResurrectWork) => Promise<NodeRow>;\n\n  // ---- B1b: delegates to node-write-pipeline.ts's applyNodeSetUpdate\n  reviseNodeSet: (\n    work: NodeSetUpdateWork,\n    fences: NodeSetUpdateFences,\n  ) => Promise<NodeSetUpdateResult>;\n  reviseResolvedNodes: (\n    work: ResolvedNodeUpdateBatchWork,\n  ) => Promise<readonly NodeRow[] | undefined>;\n}>;\n\nexport type EdgeWriteSession = Readonly<{\n  // ---- B2: delegates to edge-write-pipeline.ts + insert-dispatch.ts\n  createEdge: (work: EdgeInsertWork) => Promise<EdgeRow>;\n  /**\n   * Executes one prepared endpoint-checked create command. An unsupported\n   * result is an explicit signal for the caller to run the portable fallback.\n   */\n  createEdgeWithPlan: (\n    command: EdgeCreateCommand,\n  ) => Promise<EdgeCreateCommandResult>;\n  createEdgeNoReturn: (work: EdgeInsertWork) => Promise<void>;\n  createEdges: (work: readonly EdgeInsertWork[]) => Promise<readonly EdgeRow[]>;\n  createEdgesDurable?: (\n    work: readonly EdgeInsertWork[],\n  ) => Promise<readonly EdgeRow[]>;\n  createEdgesNoReturn: (work: readonly EdgeInsertWork[]) => Promise<void>;\n  reviseEdge: (\n    work: EdgeUpdateWork,\n    fences: EdgeUpdateFences,\n  ) => Promise<EdgeRow>;\n  retireEdge: (work: EdgeDeleteWork) => Promise<void>;\n  /** Applies one already-resolved soft-delete set through the batch port. */\n  retireEdges: (work: readonly EdgeDeleteWork[]) => Promise<void>;\n  purgeEdge: (work: EdgeHardDeleteWork) => Promise<void>;\n}>;\n\nexport type WriteSession = NodeWriteSession & EdgeWriteSession;\n\nexport type WriteSessionFor<K extends \"node\" | \"edge\" | \"mixed\"> =\n  K extends \"node\" ? NodeWriteSession\n  : K extends \"edge\" ? EdgeWriteSession\n  : WriteSession;\n\n// No session method may collide with a banned backend member name: the lint\n// rule is syntactic and receiver-blind, so a collision would make the rule\n// flag the migration's own call sites.\n// eslint-disable-next-line @typescript-eslint/no-unused-vars -- compile-time assertion\ntype _sessionNamesAreDisjointFromTheBan = Assert<\n  Equal<Extract<keyof WriteSession, WriteMemberKey>, never>\n>;\n\n/**\n * Mints the session for one write frame.\n *\n * `target` is the raw transaction target the executor was handed — the same\n * object row work sees through {@link WriteTarget} — because the step modules\n * this composes take the raw union and probe optional members on it. `lock` is\n * the compile-time evidence that the per-graph write-lock discipline was\n * satisfied before any row work; the session performs no locking of its own.\n */\nexport function createWriteSession(\n  ctx: WriteSessionContext,\n  target: GraphBackend | TransactionBackend,\n  lock: GraphWriteLock,\n): WriteSession {\n  const writeContext = createNodeWriteContext(\n    ctx.graphId,\n    ctx.registry,\n    lock,\n    ctx.claimsVerdict,\n    ctx.uniqueSidecarBatch,\n  );\n  const dispatch = nodeInsertDispatch(target);\n  const edgeContext = createEdgeWriteContext(\n    ctx.graphId,\n    lock,\n    ctx.claimsVerdict,\n  );\n  const edgeDispatch = edgeInsertDispatch(target);\n\n  return {\n    // The pinned coordination order, spelled once per insert shape:\n    // pre-insert claims, the row, post-insert claims, the sync fans. The claim\n    // seam owns the two groups and the compensation between them; this surface\n    // owns only \"the row write it gates is THIS one\".\n    createNode: async (work) => {\n      const claimPlan = work.claimPlan;\n      const insertPlanFused = supportsNodeCreatePlan(target, {\n        params: work.params,\n        idGenerated: work.idGenerated ?? false,\n        mode: { kind: \"ordinary\" },\n        claims: claimPlan.claims,\n        projections: work.projections,\n        allowNonTransactionalClaims: work.allowNonTransactionalClaims,\n      });\n      const insertPortableNode = (): Promise<NodeRow> =>\n        withNodeCreateClaims(writeContext, work.claim, target, () =>\n          dispatch.one(work.params),\n        );\n      const insertPlannedNode = async (): Promise<\n        Readonly<{ row: NodeRow; projectionsFused: boolean }>\n      > => {\n        if (!insertPlanFused) {\n          return { row: await insertPortableNode(), projectionsFused: false };\n        }\n        try {\n          const command: NodeCreateCommand = {\n            kind: \"node.create\",\n            plan: {\n              entity: \"node\",\n              params: work.params,\n              idGenerated: work.idGenerated ?? false,\n              mode: { kind: \"ordinary\" },\n              claims: claimPlan.claims,\n              projections: work.projections,\n            },\n          };\n          const result = await executeAuthoritativeGraphCommand(\n            target.commands,\n            command,\n          );\n          if (result.outcome === \"unsupported\") {\n            assertPortableNodeFallbackCanRun(\n              target,\n              work.params,\n              work.projections,\n            );\n            return {\n              row: await insertPortableNode(),\n              projectionsFused: false,\n            };\n          }\n          if (result.outcome !== \"created\") {\n            throw new CompilerInvariantError(\n              \"An ordinary planned node insert did not return a node row.\",\n              {\n                graphId: work.params.graphId,\n                kind: work.params.kind,\n                id: work.params.id,\n              },\n            );\n          }\n          return { row: result.row, projectionsFused: true };\n        } catch (error) {\n          refuseNodeCreateClaimError(error, claimPlan);\n        }\n      };\n      const { row, projectionsFused } = await insertPlannedNode();\n      await applyNodeInsertSyncFans(\n        writeContext,\n        {\n          ...work.sideEffects,\n          ...(projectionsFused && work.projections.length > 0 ?\n            { projectionsFused: true }\n          : {}),\n        },\n        target,\n      );\n      return row;\n    },\n\n    createNodeIfAbsent: async (work) => {\n      assertClaimFreeInsertIfAbsentWork(ctx, work);\n      const row = await runInsertIfAbsent(dispatch, work.params);\n      if (row === undefined) return;\n      await applyNodeInsertSyncFans(writeContext, work.sideEffects, target);\n      return row;\n    },\n\n    createNodeIfAbsentWithSchemaFence: async (work, schemaFence) => {\n      assertClaimFreeInsertIfAbsentWork(ctx, work);\n      const insert = target.insertNodeIfAbsentWithSchemaFence;\n      if (insert === undefined) return;\n      const row = await insert(work.params, schemaFence);\n      if (row === undefined) return;\n      await applyNodeInsertSyncFans(writeContext, work.sideEffects, target);\n      return row;\n    },\n\n    createNodeWithSchemaFence: async (work, schemaFence) => {\n      const projectionFusionEligible = supportsNodeInsertProjections(\n        target,\n        work.projections,\n      );\n      const inserted = await (async (): Promise<\n        Readonly<{ row: NodeRow | undefined; projectionsFused: boolean }>\n      > => {\n        const insertPortableNode = async (): Promise<NodeRow | undefined> => {\n          const insert = target.insertNodeWithSchemaFence;\n          if (insert === undefined) return;\n          return insert(work.params, schemaFence);\n        };\n        if (projectionFusionEligible) {\n          const command: NodeCreateCommand = {\n            kind: \"node.create\",\n            plan: {\n              entity: \"node\",\n              params: work.params,\n              idGenerated: work.idGenerated ?? false,\n              mode: { kind: \"schema-fenced\", schemaFence },\n              claims: [],\n              projections: work.projections,\n            },\n          };\n          return withNodeCreateClaims(\n            writeContext,\n            work.claim,\n            target,\n            async () => {\n              const result = await executeAuthoritativeGraphCommand(\n                target.commands,\n                command,\n              );\n              if (result.outcome === \"rejected\") {\n                return { row: undefined, projectionsFused: false };\n              }\n              if (result.outcome === \"unsupported\") {\n                assertPortableNodeFallbackCanRun(\n                  target,\n                  work.params,\n                  work.projections,\n                );\n                return {\n                  row: await insertPortableNode(),\n                  projectionsFused: false,\n                };\n              }\n              return { row: result.row, projectionsFused: true };\n            },\n          );\n        }\n        return { row: await insertPortableNode(), projectionsFused: false };\n      })();\n      const { row, projectionsFused } = inserted;\n      if (row === undefined) return;\n      await applyNodeInsertSyncFans(\n        writeContext,\n        {\n          ...work.sideEffects,\n          ...(projectionsFused ? { projectionsFused: true } : {}),\n        },\n        target,\n      );\n      return row;\n    },\n\n    createNodeNoReturn: async (work) => {\n      await withNodeCreateClaims(writeContext, work.claim, target, () =>\n        runInsertNoReturn(dispatch, work.params),\n      );\n      await applyNodeInsertSyncFans(writeContext, work.sideEffects, target);\n    },\n\n    createNodes: async (work) => {\n      const rows = await withNodeCreateClaimsBatch(\n        writeContext,\n        work.map((item) => item.claim),\n        target,\n        () =>\n          runInsertBatchReturning(\n            dispatch,\n            work.map((item) => item.params),\n          ),\n      );\n      await applyNodeInsertSyncFansBatch(\n        writeContext,\n        work.map((item) => item.sideEffects),\n        target,\n      );\n      return rows;\n    },\n\n    createNodesNoReturn: async (work) => {\n      await withNodeCreateClaimsBatch(\n        writeContext,\n        work.map((item) => item.claim),\n        target,\n        () =>\n          runInsertBatch(\n            dispatch,\n            work.map((item) => item.params),\n          ),\n      );\n      await applyNodeInsertSyncFansBatch(\n        writeContext,\n        work.map((item) => item.sideEffects),\n        target,\n      );\n    },\n\n    reviseNode: (work, fences) => {\n      const draft = createWriteParamsDraft();\n      applyWriteFences(NODE_UPDATE_FENCE_APPLIERS, fences, draft);\n      return applyNodeUpdate(writeContext, { ...work, ...draft }, target);\n    },\n\n    retireNode: (work, policy) =>\n      applyNodeSoftDelete(writeContext, work, target, policy),\n\n    purgeNode: (work) => applyNodeHardDelete(writeContext, work, target),\n\n    reviveNode: (work) => applyNodeResurrect(writeContext, work, target),\n\n    reviseNodeSet: (work, fences) => {\n      // The fences are applied for their REFUSAL, not for their contribution:\n      // this kind's one applier throws for a stated bound and writes nothing\n      // for an empty one, so a draft that survives the call is provably empty\n      // and there is no predicate to thread into the statement. Skipping the\n      // call would be this layer re-deciding what the applier decides.\n      applyWriteFences(\n        NODE_SET_UPDATE_FENCE_APPLIERS,\n        fences,\n        createWriteParamsDraft(),\n      );\n      return applyNodeSetUpdate(writeContext, work, target);\n    },\n\n    reviseResolvedNodes: (work) =>\n      applyResolvedNodeUpdateBatch(writeContext, work, target),\n\n    // An edge write obliges no DERIVED data, so these apply no sync fans — but a\n    // constrained kind owes its cardinality claim, at the same PRE-INSERT\n    // placement a node's scope-spanning claim takes and for the same reason: the\n    // probe that authorised the insert read a population no key fences. The\n    // batch issues ONE sorted statement (`claimEdgeCardinalityBatch` orders by\n    // `compareClaimTargets`), so a batch and a peer batch take their row locks\n    // in the same order.\n    createEdge: async (work) => {\n      if (work.claim !== undefined) {\n        await claimEdgeCardinality(target, ctx.claimsVerdict(), work.claim);\n      }\n      return edgeDispatch.one(work.params);\n    },\n\n    createEdgeWithPlan: async (command) => {\n      const result = await executeAuthoritativeGraphCommand(\n        target.commands,\n        command,\n      );\n      if (\n        result.outcome === \"unsupported\" &&\n        result.dimensions.length === 1 &&\n        result.dimensions[0] === \"cardinalityClaim\" &&\n        command.plan.schemaFence === undefined &&\n        command.plan.cardinalityClaim !== undefined\n      ) {\n        await claimEdgeCardinality(\n          target,\n          ctx.claimsVerdict(),\n          command.plan.cardinalityClaim,\n        );\n        const retryCommand: EdgeCreateCommand = {\n          kind: \"edge.create\",\n          plan: {\n            entity: \"edge\",\n            params: command.plan.params,\n          },\n        };\n        const retryResult = await executeAuthoritativeGraphCommand(\n          target.commands,\n          retryCommand,\n        );\n        return retryResult;\n      }\n      return result;\n    },\n\n    createEdgeNoReturn: async (work) => {\n      if (work.claim !== undefined) {\n        await claimEdgeCardinality(target, ctx.claimsVerdict(), work.claim);\n      }\n      await runInsertNoReturn(edgeDispatch, work.params);\n    },\n\n    createEdges: async (work) => {\n      await claimEdgeCardinalityBatch(\n        target,\n        ctx.claimsVerdict(),\n        edgeBatchClaims(work),\n      );\n      return runInsertBatchReturning(\n        edgeDispatch,\n        work.map((item) => item.params),\n      );\n    },\n\n    createEdgesDurable: async (work) => {\n      const insert = target.insertEdgesDurableBatchReturning;\n      if (insert === undefined) {\n        throw new ConfigurationError(\n          \"This backend does not implement the durable edge identity batch command.\",\n          {\n            capability: \"durableEdgeMatchIdentity\",\n            operation: \"insertEdgesDurableBatchReturning\",\n          },\n        );\n      }\n      await claimEdgeCardinalityBatch(\n        target,\n        ctx.claimsVerdict(),\n        edgeBatchClaims(work),\n      );\n      return insert(work.map((item) => item.params));\n    },\n\n    createEdgesNoReturn: async (work) => {\n      await claimEdgeCardinalityBatch(\n        target,\n        ctx.claimsVerdict(),\n        edgeBatchClaims(work),\n      );\n      await runInsertBatch(\n        edgeDispatch,\n        work.map((item) => item.params),\n      );\n    },\n\n    reviseEdge: (work, fences) => {\n      const draft = createWriteParamsDraft();\n      applyWriteFences(EDGE_UPDATE_FENCE_APPLIERS, fences, draft);\n      return applyEdgeUpdate(edgeContext, { ...work, ...draft }, target);\n    },\n\n    retireEdge: (work) => applyEdgeSoftDelete(edgeContext, work, target),\n\n    retireEdges: (work) => applyEdgeSoftDeleteBatch(edgeContext, work, target),\n\n    purgeEdge: (work) => applyEdgeHardDelete(edgeContext, work, target),\n  };\n}\n","/**\n * The one sanctioned caller of `runInWriteTransaction` /\n * `runHookedWriteOperation`.\n *\n * What the executor owns is small and complete: thread the plan's constraint\n * probe into the option `write-transaction.ts` already owns, acquire the\n * identity lock when the plan declares participation, mint the session, and\n * hand row work the read projection. Everything else — whether the per-graph\n * write lock is taken, whether the schema fence is taken, the lock ORDER —\n * stays with the module that owns the state those locks guard. The executor\n * re-spells none of it.\n *\n * Row work therefore cannot run before the locks: `runInWriteTransaction`\n * takes positions 1-2, this takes position 3, and `rowWork` is called after\n * both.\n */\nimport { deriveBackend } from \"../../backend/derive-backend\";\nimport {\n  type GraphBackend,\n  type TransactionBackend,\n} from \"../../backend/types\";\nimport { requireDefined } from \"../../utils/presence\";\nimport {\n  type GraphWriteLock,\n  uncapturedGraphWriteLock,\n} from \"../recorded-capture/clock\";\nimport { type OperationHookContext } from \"../types\";\nimport { AutocommitWriteRequiresTransaction } from \"./autocommit-single-statement\";\nimport { type RowWorkKind, type WritePlan } from \"./write-plan\";\nimport {\n  createWriteSession,\n  type WriteSession,\n  type WriteSessionContext,\n  type WriteSessionFor,\n  type WriteTarget,\n} from \"./write-session\";\nimport {\n  type HookedWriteOperationContext,\n  runHookedWriteOperation,\n  runInWriteTransaction,\n  type WriteTransactionContext,\n  type WriteTransactionMode,\n  type WriteTransactionOptions,\n} from \"./write-transaction\";\n\n/**\n * What a plan-driven write needs beyond the transaction context: the graph's\n * kind registry (the session's step modules resolve schemas and constraints\n * through it) and HOW this caller acquires the identity lock.\n *\n * `identityLock` is absent when the graph has no identity configured — in\n * which case plan builders derive `requiresIdentityLock: false`, so a declared\n * participation with no acquirer is a wiring bug. The executor asserts on it\n * rather than silently skipping the lock: no user-stated option can produce\n * that state, so it is an internal invariant, not a public refusal.\n */\nexport type WritePlanContext = WriteTransactionContext &\n  WriteSessionContext &\n  Readonly<{\n    identityLock?: (target: GraphBackend | TransactionBackend) => Promise<void>;\n  }>;\n\n/** The hooked variant's context: the above plus the hook wrapper. */\nexport type HookedWritePlanContext = WritePlanContext &\n  HookedWriteOperationContext;\n\n/**\n * The transaction options a plan caller may still state.\n *\n * `fencesConstraintProbe` is subtracted because the executor OWNS it — it\n * comes from `plan.constraintProbe` and nowhere else. Subtracting the key\n * makes a doubly-spelled probe a type error at the call site instead of a\n * value the executor's spread silently discards, which is the same\n * \"accepted then dropped\" failure that deleted the lock-plan field. Written as\n * an `Omit` of the existing options type rather than a fresh literal, so an\n * option added to `WriteTransactionOptions` reaches plan callers on its own;\n * today the residue is `didWrite` plus the private first-statement schema\n * fence marker used by the qualifying insert paths.\n */\nexport type WritePlanOptions<T> = Omit<\n  WriteTransactionOptions<T>,\n  \"fencesConstraintProbe\"\n>;\n\n/** Classifies a successful command whose contract guarantees a mutation. */\nexport function writeResultAlwaysChanges(): boolean {\n  return true;\n}\n\n/** Classifies a command that returns its authoritative mutation verdict. */\nexport function booleanWriteResultChanges(result: boolean): boolean {\n  return result;\n}\n\n/**\n * Selects the optimistic update budget without duplicating singleton routing.\n *\n * A one-row update gets two more chances than a bulk partition. Eligible\n * remote roots no longer hold a write transaction across the read and write,\n * where latency makes a race more likely but another singleton retry remains\n * cheap. Bulk partitions keep their smaller budget so contention cannot\n * multiply that cost by an arbitrarily large row set.\n */\nexport function atomicResolvedUpdateAttemptBudget(\n  entryCount: number,\n  bulkAttemptBudget: number,\n): number {\n  return entryCount === 1 ? 4 : bulkAttemptBudget;\n}\n\n/**\n * Mints a second session for THIS write frame over a READ OVERLAY of its\n * target: the frame's own handle, answering some reads from a pending-aware\n * cache and delegating everything else, which is what\n * `createNodeBatchValidationSeams` describes.\n *\n * It exists because a fused step reads and writes through ONE handle.\n * Interchange import's batched slice has to route the uniqueness pre-check\n * inside `reviseNode` through the overlay — so a key an unflushed create\n * earlier in the same slice already reserved degrades to a per-row error\n * instead of colliding at flush — while the write itself lands on the real\n * backend, which is precisely what that overlay does. Handing the leg the\n * frame's session over the raw target would silently drop the pending state,\n * and re-checking uniqueness outside the step would be a second spelling of a\n * decision the step owns.\n *\n * What this TAKES is the reads to answer, not a backend to write through. Row\n * work holds the read-only {@link WriteTarget}, so it cannot produce a\n * writable overlay without widening the very projection this seam exists to\n * keep narrow; the EXECUTOR owns the decoration, over the raw target it\n * already has. `Partial<WriteTarget>` is the exact bound that follows: an\n * overlay may redirect any read row work can see, and no write member at all.\n *\n * What this hands out is the CAPABILITY, not the evidence: the frame's\n * {@link GraphWriteLock} stays inside the executor, so row work still cannot\n * reach a step module directly. All it can obtain is another fused session,\n * whose methods apply the same sidecars and the same fences as the first.\n */\ntype WriteTargetReadOverlay = Partial<WriteTarget>;\n\nexport type OverlaidSessionMint<K extends RowWorkKind = RowWorkKind> = (\n  reads: WriteTargetReadOverlay,\n) => WriteSessionFor<K>;\n\n/** Row work: the only place a plan-driven write may read or write rows. */\nexport type WriteRowWork<K extends RowWorkKind, T> = (\n  session: WriteSessionFor<K>,\n  target: WriteTarget,\n  overlaidSession: OverlaidSessionMint<K>,\n  lock: GraphWriteLock,\n  transactionMode: WriteTransactionMode,\n) => Promise<T>;\n\n/**\n * The frame both entry points run: acquire position 3 when the plan declares\n * identity participation, then call row work with the session and the read\n * projection.\n *\n * ONE spelling, shared. A hooked write and a plain one differ only in what\n * wraps the transaction, so the identity decision — and the moment in the\n * frame it is taken at — must not be written twice.\n */\nfunction planFrame<K extends RowWorkKind, T>(\n  ctx: WritePlanContext,\n  plan: WritePlan<K>,\n  rowWork: WriteRowWork<K, T>,\n) {\n  return async (\n    target: GraphBackend | TransactionBackend,\n    lock: GraphWriteLock,\n    transactionMode: WriteTransactionMode,\n  ): Promise<T> => {\n    if (plan.requiresIdentityLock) {\n      const acquireIdentityLock = requireDefined(\n        ctx.identityLock,\n        \"write plan declares identity participation with no acquirer\",\n      );\n      await acquireIdentityLock(target);\n    }\n    // ONE spelling of \"mint a session for this frame\", used for the frame's own\n    // session and for any overlaid one, so the two cannot be built from\n    // different context or a different lock. The overlaid variant is that\n    // spelling applied to a decorated target — the decoration is the ONLY\n    // difference between them, and the frame's own session pays for no proxy.\n    const mintSessionOver = (\n      sessionTarget: GraphBackend | TransactionBackend,\n    ): WriteSession => createWriteSession(ctx, sessionTarget, lock);\n    const mintOverlaidSession: OverlaidSessionMint<K> = (reads) =>\n      mintSessionOver(deriveBackend(target, reads)) as WriteSessionFor<K>;\n    // The two handles are the SAME object: the session closes over the raw\n    // target (its step modules probe optional members on it), while row work\n    // sees it through the type-only `WriteTarget` projection. One value, two\n    // static views.\n    return rowWork(\n      mintSessionOver(target) as WriteSessionFor<K>,\n      target,\n      mintOverlaidSession,\n      lock,\n      transactionMode,\n    );\n  };\n}\n\n/**\n * The transaction options the executor hands down.\n *\n * `fencesConstraintProbe` is written LAST and from the plan alone, so no\n * caller-supplied residue can shadow it.\n */\nfunction planTransactionOptions<K extends RowWorkKind, T>(\n  plan: WritePlan<K>,\n  options: WritePlanOptions<T> | undefined,\n): WriteTransactionOptions<T> {\n  return { ...options, fencesConstraintProbe: plan.constraintProbe };\n}\n\n/**\n * Runs one managed write under its plan.\n *\n * Retrying under the `\"optimistic-retry\"` tier is `runInWriteTransaction`'s\n * own concern (`write-transaction.ts`), not re-spelled here: that function\n * wraps its whole attempt — opening the transaction, taking the locks, and\n * calling `rowWork` — in `runRetriedUnit` whenever `backend`'s tier requires\n * it, so a retried attempt re-enters this call from the top with brand-new\n * everything.\n */\nexport function runWritePlan<K extends RowWorkKind, T>(\n  ctx: WritePlanContext,\n  plan: WritePlan<K>,\n  backend: GraphBackend | TransactionBackend,\n  rowWork: WriteRowWork<K, T>,\n  options?: WritePlanOptions<T>,\n): Promise<T> {\n  return runInWriteTransaction(\n    ctx,\n    backend,\n    planFrame(ctx, plan, rowWork),\n    planTransactionOptions(plan, options),\n  );\n}\n\n/**\n * Hooked variant: operation hooks WRAP the plan, exactly as\n * `runHookedWriteOperation` wraps the transaction today, so `onOperationEnd`\n * observes a durably committed result. Because `runInWriteTransaction`'s own\n * retry wrapping (see `runWritePlan`'s doc comment) is entirely inside this\n * call, a retry under `\"optimistic-retry\"` is invisible to\n * `onOperationStart`/`onOperationEnd`: they fire exactly once for the\n * operation as a whole, exactly as they do under `\"interactive\"`.\n */\nexport function runHookedWritePlan<K extends RowWorkKind, T>(\n  ctx: HookedWritePlanContext,\n  opContext: OperationHookContext,\n  plan: WritePlan<K>,\n  backend: GraphBackend | TransactionBackend,\n  rowWork: WriteRowWork<K, T>,\n  options?: WritePlanOptions<T>,\n): Promise<T> {\n  return runHookedWriteOperation(\n    ctx,\n    opContext,\n    backend,\n    planFrame(ctx, plan, rowWork),\n    planTransactionOptions(plan, options),\n  );\n}\n\n/**\n * Runs a closed exact-root atomic program inside the ordinary operation-hook\n * boundary.\n *\n * Eligibility and the program's database semantics remain operation-owned.\n * This helper owns only the common composition: hooks begin before dispatch,\n * and `onOperationEnd` observes a program that has already committed.\n */\nexport function runAtomicProgramWithHooks<T>(\n  ctx: HookedWriteOperationContext,\n  opContext: OperationHookContext,\n  program: () => Promise<T>,\n  didWrite?: (result: T) => boolean,\n): Promise<T> {\n  return ctx.withOperationHooks(opContext, program, didWrite);\n}\n\n/**\n * Runs a proven single-statement write directly on a bundled root backend.\n *\n * The eligibility classifier is deliberately outside this generic executor:\n * it owns the operation-specific proof that row work has no claim, sidecar,\n * identity, capture, revision, or recovery statement. This helper owns only\n * the resulting execution shape — no `BEGIN` / `COMMIT` and no transaction\n * target — while preserving the ordinary hook boundary. A completed SQL\n * statement is already durably committed, so `onOperationEnd` remains truthful.\n */\nexport function runAutocommitSingleStatementWritePlan<K extends RowWorkKind, T>(\n  ctx: HookedWritePlanContext,\n  opContext: OperationHookContext,\n  plan: WritePlan<K>,\n  backend: GraphBackend,\n  rowWork: WriteRowWork<K, T>,\n  fallbackOptions?: WritePlanOptions<T>,\n): Promise<T> {\n  return ctx.withOperationHooks(\n    opContext,\n    async () => {\n      try {\n        return await planFrame(ctx, plan, rowWork)(\n          backend,\n          uncapturedGraphWriteLock(),\n          \"none\",\n        );\n      } catch (error) {\n        if (!(error instanceof AutocommitWriteRequiresTransaction)) throw error;\n        return runWritePlan(ctx, plan, backend, rowWork, fallbackOptions);\n      }\n    },\n    fallbackOptions?.didWrite,\n  );\n}\n","/**\n * The inert description of a managed write: what makes it constrained, and\n * whether identity participates in it.\n *\n * A plan is built SYNCHRONOUSLY and reads nothing. That is the invariant this\n * module exists to make structural rather than reviewable: every builder here\n * takes plain data and returns a {@link WritePlan}, never a promise and never\n * a backend, so no decision a write depends on can be made before the write's\n * locks are held. Everything that reads runs inside the executor's row-work\n * callback, which by construction runs after positions 1-3 of the lock order.\n *\n * What a plan deliberately does NOT own is the lock decision. Whether the\n * per-graph write lock is taken is decided by `write-transaction.ts` from\n * `ctx.historyEnabled`, `ctx.revisionTrackingEnabled` and the constraint\n * probe — two of the three are store configuration, not plan input — and\n * whether the schema fence is taken is unconditional for a schema-managed\n * store. A `LockPlan` field could only re-spell a decision it does not own,\n * and would be silently ignored on a non-capture store: exactly the\n * \"accepted, then dropped\" failure this pipeline exists to prevent.\n */\nimport { type ConstraintFenceReason } from \"../constraints\";\n\n/**\n * The row-work family, which determines the session surface handed to row\n * work. A node plan can call only node session methods, an edge plan only edge\n * methods, and the deliberately mixed import plan can call both.\n *\n * `\"mixed\"` is explicit rather than pretending a frame that writes both node\n * and edge rows belongs to one family. Interchange import is its sole caller.\n */\nexport type RowWorkKind = \"node\" | \"edge\" | \"mixed\";\n\n/**\n * Whether identity participates in this write. The executor owns only the lock\n * requirement; fold, detach, and assertion behavior remains typed row work and\n * is deliberately not encoded as inert plan data the executor would ignore.\n *\n * NOTE what this is not: a lock ORDER. There is no `LockPlan`. Positions 1, 2\n * and 5 are decided and acquired by `write-transaction.ts` and the capture\n * overlay, which own the state those locks guard; the plan re-spells none of\n * them.\n */\nexport type WritePlan<K extends RowWorkKind = RowWorkKind> = Readonly<{\n  entity: K;\n  /**\n   * The declared constraint that makes this a constrained write, or\n   * `undefined`. Threaded verbatim into `runInWriteTransaction`'s existing\n   * `fencesConstraintProbe` option — the same value today's call sites pass,\n   * now carried as data instead of spelled at the call.\n   */\n  constraintProbe: ConstraintFenceReason | undefined;\n  requiresIdentityLock: boolean;\n}>;\n\n/** The plan for one node write. */\nexport function nodeWritePlan(\n  constraintProbe: ConstraintFenceReason | undefined,\n  requiresIdentityLock: boolean,\n): WritePlan<\"node\"> {\n  return { entity: \"node\", constraintProbe, requiresIdentityLock };\n}\n\n/**\n * The plan for a batched node write.\n *\n * Owns one decision the single-write builder does not: **a batch is\n * constrained when ANY member is.** One transaction means one fence, so a\n * single constrained member makes the whole write constrained, and the first\n * such member names the class a refusal would report.\n *\n * `node-operations.ts`'s private `nodeBatchFencesConstraintProbe` is the\n * pre-migration spelling of this fold; it is replaced by this builder in the\n * batch that moves those call sites (B1), not left as a second owner.\n */\nexport function nodeBatchWritePlan(\n  constraintProbes: readonly (ConstraintFenceReason | undefined)[],\n  requiresIdentityLock: boolean,\n): WritePlan<\"node\"> {\n  return {\n    entity: \"node\",\n    constraintProbe: constraintProbes.find((probe) => probe !== undefined),\n    requiresIdentityLock,\n  };\n}\n\n/**\n * The plan for one edge write. Edge writes do not participate in identity —\n * identity folds node references, and an edge carries none of its own — so the\n * participation is not a parameter.\n */\nexport function edgeWritePlan(\n  constraintProbe: ConstraintFenceReason | undefined,\n): WritePlan<\"edge\"> {\n  return { entity: \"edge\", constraintProbe, requiresIdentityLock: false };\n}\n\n/** A single frame that deliberately coordinates node and edge writes. */\nexport function mixedWritePlan(\n  constraintProbe: ConstraintFenceReason | undefined,\n  requiresIdentityLock: boolean,\n): WritePlan<\"mixed\"> {\n  return { entity: \"mixed\", constraintProbe, requiresIdentityLock };\n}\n","import {\n  type AtomicEdgeMutationProgramExecutor,\n  type AtomicNodeResolvedMutationSetExecutor,\n  resolveAtomicMutationPrograms,\n} from \"../backend/capabilities/atomic-mutation-program\";\nimport type { GraphBackend, TransactionBackend } from \"../backend/types\";\nimport { DatabaseOperationError } from \"../errors\";\n\ntype ResolvedMutationSetExecutor =\n  AtomicNodeResolvedMutationSetExecutor | AtomicEdgeMutationProgramExecutor;\n\n/**\n * An operation-level atomic attempt. `unsupported` is emitted only before the\n * operation executor is invoked, so it is affirmative evidence that the\n * attempt executed no SQL and the caller may enter the complete portable path.\n */\nexport type ResolvedMutationSetAttempt<T> =\n  | Readonly<{ outcome: \"applied\"; value: T }>\n  | Readonly<{ outcome: \"unsupported\" }>;\n\n/** Constructs the only successful operation-level attempt verdict. */\nexport function appliedResolvedMutationSet<T>(\n  value: T,\n): ResolvedMutationSetAttempt<T> {\n  return { outcome: \"applied\", value };\n}\n\n/** Constructs the no-SQL fallback verdict. */\nexport function unsupportedResolvedMutationSet<\n  T,\n>(): ResolvedMutationSetAttempt<T> {\n  return { outcome: \"unsupported\" };\n}\n\n/**\n * Internal retry signal for a resolved mutation set whose authoritative\n * preconditions moved before its atomic program ran. The collection owns the\n * create/update partition, so only it can honestly re-read and rebuild the\n * complete set; store/backend layers must not reinterpret one stale member in\n * isolation.\n */\nexport class ResolvedMutationSetMoved extends Error {\n  constructor(\n    entity: \"node\" | \"edge\",\n    private readonly executor: ResolvedMutationSetExecutor,\n  ) {\n    super(`Resolved ${entity} mutation set moved before execution.`);\n    this.name = \"ResolvedMutationSetMoved\";\n  }\n\n  /** Only the exact bundled root/executor that minted the signal may retry. */\n  isOwnedBy(\n    entity: \"node\" | \"edge\",\n    backend: GraphBackend | TransactionBackend,\n  ): boolean {\n    const profile = resolveAtomicMutationPrograms(backend);\n    return (\n      (entity === \"node\" ? profile?.mutateNodes : profile?.mutateEdges) ===\n      this.executor\n    );\n  }\n}\n\nconst RESOLVED_MUTATION_SET_ATTEMPTS = 2;\n\n/** Rebuilds the collection-owned partition once after authoritative movement. */\nexport async function runResolvedMutationSetConverging<T>(\n  entity: \"node\" | \"edge\",\n  backend: GraphBackend | TransactionBackend,\n  run: () => Promise<T>,\n  options?: Readonly<{ isMovement?: (error: unknown) => boolean }>,\n): Promise<T> {\n  for (\n    let attempt = 1;\n    attempt <= RESOLVED_MUTATION_SET_ATTEMPTS;\n    attempt += 1\n  ) {\n    try {\n      return await run();\n    } catch (error) {\n      const isOwnedAtomicMovement =\n        error instanceof ResolvedMutationSetMoved &&\n        error.isOwnedBy(entity, backend);\n      if (!isOwnedAtomicMovement && options?.isMovement?.(error) !== true) {\n        throw error;\n      }\n      if (attempt === RESOLVED_MUTATION_SET_ATTEMPTS) {\n        throw new DatabaseOperationError(\n          `Atomic ${entity} upsert set could not be applied to stable rows after ${RESOLVED_MUTATION_SET_ATTEMPTS} attempts.`,\n          { operation: \"update\", entity },\n          { cause: error },\n        );\n      }\n    }\n  }\n  throw new DatabaseOperationError(\n    `Atomic ${entity} upsert set exhausted its retry budget.`,\n    { operation: \"update\", entity },\n  );\n}\n","import type { GraphBackend, TransactionBackend } from \"../backend/types\";\nimport type { KindEntity } from \"../core/types\";\nimport { ConfigurationError, ValidationError } from \"../errors\";\n\nexport type ValidityEndMutationInput = Readonly<{\n  validTo?: string;\n  clearValidTo?: true;\n}>;\n\n/** One owner for the mutually-exclusive validity-end write contract. */\nexport function assertValidityEndMutation(\n  input: ValidityEndMutationInput,\n  context: Readonly<{ entityType: KindEntity; kind: string; id?: string }>,\n): void {\n  if (input.validTo === undefined || input.clearValidTo !== true) return;\n  throw new ValidationError(\n    '\"validTo\" and \"clearValidTo\" are mutually exclusive',\n    {\n      ...context,\n      operation: \"update\",\n      issues: [\n        {\n          path: \"clearValidTo\",\n          message: 'Pass either \"validTo\" or \"clearValidTo\", not both',\n        },\n      ],\n    },\n  );\n}\n\n/** The end a row will hold after applying this mutation. */\nexport function validityEndAfterMutation(\n  input: ValidityEndMutationInput,\n  current: string | undefined,\n): string | undefined {\n  if (input.clearValidTo === true) return undefined;\n  return input.validTo ?? current;\n}\n\n/**\n * Custom backends explicitly opt in to clearing. The store refuses before\n * invoking a backend that has not promised to apply the new state.\n */\nexport function assertClearValidToSupported(\n  backend: GraphBackend | TransactionBackend,\n  entityType: KindEntity,\n): void {\n  if (backend.capabilities.clearValidTo === true) return;\n  throw new ConfigurationError(\n    `This backend does not support clearing ${entityType} validTo`,\n    {\n      code: \"CLEAR_VALID_TO_UNSUPPORTED\",\n      entityType,\n    },\n  );\n}\n","/**\n * The create API's \"this identity is already taken\" refusal, and the one\n * translation that turns a driver's duplicate-key report into it.\n *\n * A create learns an id is taken one of two ways: its own existence probe sees\n * the row, or the engine refuses the INSERT. The engine's report used to escape\n * as a `DrizzleQueryError` whose `.message` is the raw SQL text (issue #410), so\n * one condition surfaced as a typed user error down one path and an opaque system\n * error down the other, and a caller could not branch on it at all. Both paths\n * now raise the SAME error, carrying {@link ENTITY_ALREADY_EXISTS_CODE} on its\n * issue.\n *\n * The engine's path is reached two ways, and the second is not a race:\n *\n *  - A NODE create probes first, but the probe and the INSERT are two statements.\n *    PostgreSQL under its default READ COMMITTED does not serialize two write\n *    transactions, so both can probe an absent row and both can then insert it,\n *    and the loser finds out from the INSERT. SQLite cannot reach this shape:\n *    `BEGIN IMMEDIATE` gives the writer slot to one transaction at a time (pinned\n *    by the business-transaction write-lock cases in\n *    `tests/backends/sqlite/sqlite-backend.test.ts`), so the loser's probe runs\n *    after the winner committed and its verdict stands.\n *  - An EDGE create has no existence probe at all — its id is caller-supplied or\n *    freshly generated — so the engine's refusal is the ONLY report on EVERY\n *    backend, race or no race. That is why the classification covers both\n *    dialects and not just PostgreSQL.\n *\n * The backend does the classification (it owns the relation and constraint names\n * the engine reports); this module owns the store-level judgement of what that\n * classification means to a caller.\n */\nimport { type KindEntity } from \"../../core/types\";\nimport {\n  DatabaseOperationError,\n  ENTITY_ALREADY_EXISTS_CODE,\n  ValidationError,\n} from \"../../errors\";\n\n/** An entity the refused statement tried to create. */\ntype AttemptedCreate = Readonly<{ kind: string; id: string }>;\n\n/** Sentence-initial and mid-sentence names for each entity. */\nconst ENTITY_LABELS = {\n  node: { title: \"Node\", article: \"A node\" },\n  edge: { title: \"Edge\", article: \"An edge\" },\n} as const satisfies Record<\n  KindEntity,\n  Readonly<{ title: string; article: string }>\n>;\n\nfunction alreadyExistsError(\n  entity: KindEntity,\n  kind: string,\n  id: string | undefined,\n  detail: string,\n  cause: unknown,\n): ValidationError {\n  const label = ENTITY_LABELS[entity];\n  return new ValidationError(\n    `${label.title} already exists: ${detail}`,\n    {\n      entityType: entity,\n      kind,\n      operation: \"create\",\n      ...(id === undefined ? {} : { id }),\n      issues: [\n        {\n          path: \"id\",\n          code: ENTITY_ALREADY_EXISTS_CODE,\n          message: `${label.article} with this ID already exists`,\n        },\n      ],\n    },\n    {\n      suggestion: `Use a different ID or update the existing ${entity}.`,\n      ...(cause === undefined ? {} : { cause }),\n    },\n  );\n}\n\n/**\n * The refusal a create raises for a taken id: the probe path's error, and the\n * target of the driver-report translation below.\n */\nexport function createAlreadyExistsError(\n  entity: KindEntity,\n  kind: string,\n  id: string,\n): ValidationError {\n  return alreadyExistsError(entity, kind, id, `${kind}/${id}`, undefined);\n}\n\nfunction isDuplicateKeyInsertError(\n  error: unknown,\n  entity: KindEntity,\n): error is DatabaseOperationError {\n  return (\n    error instanceof DatabaseOperationError &&\n    error.details.operation === \"insert\" &&\n    error.details.entity === entity &&\n    error.details.reason === \"duplicate_key\"\n  );\n}\n\n/**\n * Rethrows a classified duplicate-key insert as {@link createAlreadyExistsError},\n * and anything else untouched.\n *\n * A single insert names the row it lost on exactly. A multi-row one cannot: the\n * engine reports that the statement collided without saying which row did, and\n * the transaction is already aborted, so there is nothing left to probe. The\n * refusal then names the statement instead of inventing an attribution — same\n * error type, same issue code, `details.id` simply absent. The count is the\n * refused STATEMENT's rows, which is the caller's batch only until the backend\n * chunks it, so the message claims no more than that. Every batch here comes\n * from one collection, so the kind is always known.\n */\nfunction rethrowAsAlreadyExists(error: unknown, entity: KindEntity): never {\n  if (!isDuplicateKeyInsertError(error, entity)) throw error;\n  const attempted: readonly AttemptedCreate[] = error.details.attempted ?? [];\n  const first = attempted[0];\n  if (first === undefined) throw error;\n  if (attempted.length === 1) {\n    throw alreadyExistsError(\n      entity,\n      first.kind,\n      first.id,\n      `${first.kind}/${first.id}`,\n      error,\n    );\n  }\n  throw alreadyExistsError(\n    entity,\n    first.kind,\n    undefined,\n    `one of the ${attempted.length} ${first.kind} ids in the refused insert`,\n    error,\n  );\n}\n\n/**\n * Runs an insert (or a group of inserts issued as one unit) and converts a\n * duplicate-key refusal into the create API's already-exists error.\n */\nexport async function withAlreadyExistsTranslation<T>(\n  entity: KindEntity,\n  run: () => Promise<T>,\n): Promise<T> {\n  try {\n    return await run();\n  } catch (error) {\n    rethrowAsAlreadyExists(error, entity);\n  }\n}\n","/**\n * Store-side eligibility for every exact-root semantic mutation program.\n *\n * Each operation owns its static proof here, while exact-root provenance is\n * resolved once through the backend's unified mutation-program profile. SQL\n * lowering and row-state arbitration remain backend responsibilities.\n */\nimport {\n  type AtomicEdgeBatchExecutor as BackendAtomicEdgeBatchExecutor,\n  type AtomicEdgeDeleteBatchExecutor,\n  type AtomicEdgeMutationProgramExecutor,\n  type AtomicEdgeResolvedUpdateBatchExecutor,\n  type AtomicNodeBatchExecutor as BackendAtomicNodeBatchExecutor,\n  type AtomicNodeDeleteBatchExecutor,\n  type AtomicNodeReplacementBatchExecutor,\n  type AtomicNodeResolvedMutationSetExecutor,\n  type AtomicNodeResolvedUpdateBatchExecutor,\n  resolveAtomicMutationPrograms,\n  supportsAtomicNodeClaimFamily,\n  supportsAtomicNodeProjections,\n} from \"../../backend/capabilities/atomic-mutation-program\";\nimport {\n  type GraphBackend,\n  supportsAtomicBatch,\n  type TransactionBackend,\n} from \"../../backend/types\";\nimport type { GraphDef } from \"../../core/define-graph\";\nimport { DatabaseOperationError } from \"../../errors\";\nimport type { KindRegistry } from \"../../registry/kind-registry\";\nimport { hasOwnKey } from \"../../utils/object\";\nimport { getEmbeddingFields } from \"../embedding-sync\";\nimport { getSearchableFields } from \"../fulltext-sync\";\nimport type { CreateEdgeInput, CreateNodeInput } from \"../types\";\nimport { diagnoseFusedSchemaFenceNoRow } from \"./write-transaction\";\n\ntype CommonAtomicMutationEligibility = Readonly<{\n  backend: GraphBackend | TransactionBackend;\n  graph: GraphDef;\n  schemaVersion: number | undefined;\n  historyEnabled: boolean;\n  revisionTrackingEnabled: boolean;\n}>;\n\nfunction resolveAtomicMutationProfile(input: CommonAtomicMutationEligibility) {\n  if (!supportsAtomicBatch(input.backend)) return;\n  if (input.schemaVersion === undefined) return;\n  if (input.historyEnabled || input.revisionTrackingEnabled) return;\n  return resolveAtomicMutationPrograms(input.backend);\n}\n\nfunction atomicNodeProjectionFamilies(\n  registration: NonNullable<GraphDef[\"nodes\"][string]>,\n): readonly (\"embedding\" | \"fulltext\")[] {\n  return [\n    ...(getEmbeddingFields(registration.type.schema).length === 0 ?\n      []\n    : ([\"embedding\"] as const)),\n    ...(getSearchableFields(registration.type.schema).length === 0 ?\n      []\n    : ([\"fulltext\"] as const)),\n  ];\n}\n\n/**\n * Interprets explicit fence evidence from a closed delete program.\n *\n * A matching diagnostic after the program reported no fence row is not\n * success: either state changed between the atomic batch and its diagnostic,\n * or the backend violated the program contract.\n */\nexport async function assertAtomicDeleteSchemaFenceMatched(\n  matched: boolean,\n  ctx: Readonly<{ graphId: string; schemaVersion: number | undefined }>,\n  backend: GraphBackend | TransactionBackend,\n  entity: \"node\" | \"edge\",\n): Promise<void> {\n  if (matched) return;\n  await diagnoseFusedSchemaFenceNoRow(ctx, backend);\n  throw new DatabaseOperationError(\n    \"Atomic delete reported a stale schema fence, but the current schema \" +\n      \"matched during diagnosis. The schema may have changed concurrently, \" +\n      \"or the backend returned inconsistent fence evidence.\",\n    { operation: \"delete\", entity },\n  );\n}\n\nexport type AtomicNodeBatchEligibilityInput = CommonAtomicMutationEligibility &\n  Readonly<{\n    registry: KindRegistry;\n    inputs: readonly CreateNodeInput[];\n    identityEnabled: boolean;\n  }>;\n\n/** The one owner of the static store proof for atomic node creates. */\nexport function resolveAtomicNodeBatchExecutor(\n  input: AtomicNodeBatchEligibilityInput,\n): BackendAtomicNodeBatchExecutor | undefined {\n  if (input.inputs.length === 0 || input.identityEnabled) return;\n  const profile = resolveAtomicMutationProfile(input);\n  if (profile?.createNodes === undefined) return;\n  const claimSupport = profile.createNodes.claimSupport;\n  const projectionSupport = profile.createNodes.projectionSupport;\n\n  const registrations = input.inputs.map((item) => {\n    if (!hasOwnKey(input.graph.nodes, item.kind)) return false;\n    const registration = input.graph.nodes[item.kind];\n    if (registration === undefined) return false;\n    if (\n      input.registry.getDisjointKinds(item.kind).length > 0 &&\n      !supportsAtomicNodeClaimFamily(claimSupport, \"disjointness\")\n    ) {\n      return false;\n    }\n    if (\n      !supportsAtomicNodeProjections(\n        projectionSupport,\n        atomicNodeProjectionFamilies(registration),\n      )\n    ) {\n      return false;\n    }\n    return registration;\n  });\n  if (registrations.includes(false)) return;\n\n  if (\n    registrations.some(\n      (registration) =>\n        registration !== false && (registration.unique ?? []).length > 0,\n    ) &&\n    !supportsAtomicNodeClaimFamily(claimSupport, \"uniqueness\")\n  ) {\n    return;\n  }\n\n  return profile.createNodes;\n}\n\nexport type AtomicNodeReplacementEligibilityInput =\n  CommonAtomicMutationEligibility &\n    Readonly<{\n      registry: KindRegistry;\n      kind: string;\n      entryCount: number;\n      identityEnabled: boolean;\n    }>;\n\n/** The one owner of the static store proof for blind node replacement. */\nexport function resolveAtomicNodeReplacementBatchProgram(\n  input: AtomicNodeReplacementEligibilityInput,\n):\n  | Readonly<{\n      executor: AtomicNodeReplacementBatchExecutor;\n      releaseClaims: boolean;\n    }>\n  | undefined {\n  if (input.entryCount === 0 || input.identityEnabled) return;\n  if (!hasOwnKey(input.graph.nodes, input.kind)) return;\n  const registration = input.graph.nodes[input.kind];\n  if (registration === undefined) return;\n  const executor = resolveAtomicMutationProfile(input)?.replaceNodes;\n  if (executor === undefined) return;\n  const releasedClaimFamilies = new Set(executor.releasedClaimFamilies);\n  const hasDisjointness =\n    input.registry.getDisjointKinds(input.kind).length > 0;\n  const hasUniqueness = (registration.unique ?? []).length > 0;\n  const maxEntries =\n    hasDisjointness || hasUniqueness ?\n      executor.maxEntries.claimed\n    : executor.maxEntries.plain;\n  if (input.entryCount > maxEntries) return;\n  if (\n    hasDisjointness &&\n    (!supportsAtomicNodeClaimFamily(executor.claimSupport, \"disjointness\") ||\n      !releasedClaimFamilies.has(\"disjointness\"))\n  ) {\n    return;\n  }\n  if (\n    hasUniqueness &&\n    (!supportsAtomicNodeClaimFamily(executor.claimSupport, \"uniqueness\") ||\n      !releasedClaimFamilies.has(\"uniqueness\"))\n  ) {\n    return;\n  }\n  if (\n    !supportsAtomicNodeProjections(\n      executor.projectionSupport,\n      atomicNodeProjectionFamilies(registration),\n    )\n  ) {\n    return;\n  }\n  return {\n    executor,\n    releaseClaims: hasDisjointness || hasUniqueness,\n  };\n}\n\nexport type AtomicEdgeBatchEligibilityInput = CommonAtomicMutationEligibility &\n  Readonly<{ inputs: readonly CreateEdgeInput[] }>;\n\nexport type AtomicEdgeBatchExecutor = BackendAtomicEdgeBatchExecutor;\n\nexport type AtomicEdgeConvergenceEligibilityInput =\n  CommonAtomicMutationEligibility &\n    Readonly<{\n      kind: string;\n      matchOn: readonly string[];\n      inputs: readonly Readonly<{\n        validFrom?: string | null;\n        validTo?: string;\n        clearValidTo?: true;\n        onImmutableLowerBound?: \"preserve\" | \"refuse\";\n      }>[];\n      uniqueEntryCount: number;\n      ifExists: \"return\" | \"update\";\n    }>;\n\n/** The one owner of the static proof for durable bulk edge convergence. */\nexport function resolveAtomicEdgeConvergenceExecutor(\n  input: AtomicEdgeConvergenceEligibilityInput,\n): AtomicEdgeMutationProgramExecutor | undefined {\n  if (input.inputs.length === 0 || input.ifExists !== \"return\") return;\n  if (\n    input.inputs.some(\n      (item) =>\n        item.validFrom !== undefined ||\n        item.validTo !== undefined ||\n        item.clearValidTo === true ||\n        item.onImmutableLowerBound !== undefined,\n    )\n  ) {\n    return;\n  }\n  if (!hasOwnKey(input.graph.edges, input.kind)) return;\n  const registration = input.graph.edges[input.kind];\n  if (registration?.matchIdentity === undefined) {\n    return;\n  }\n  if ((registration.cardinality ?? \"many\") !== \"many\") return;\n  const declaredFields = registration.matchIdentity.fields;\n  if (\n    declaredFields.length !== input.matchOn.length ||\n    declaredFields.some((field, index) => field !== input.matchOn[index])\n  ) {\n    return;\n  }\n  const executor = resolveAtomicMutationProfile(input)?.mutateEdges;\n  if (\n    executor === undefined ||\n    input.uniqueEntryCount > executor.maxEntries.durableConvergence\n  ) {\n    return;\n  }\n  return executor;\n}\n\n/** The one owner of the static store proof for atomic edge creates. */\nexport function resolveAtomicEdgeBatchExecutor(\n  input: AtomicEdgeBatchEligibilityInput,\n): AtomicEdgeBatchExecutor | undefined {\n  if (input.inputs.length === 0) return;\n  const profile = resolveAtomicMutationProfile(input);\n  if (profile?.createEdges === undefined) return;\n  if (\n    !input.inputs.every(\n      (item) =>\n        hasOwnKey(input.graph.edges, item.kind) &&\n        input.graph.edges[item.kind] !== undefined,\n    )\n  ) {\n    return;\n  }\n  return profile.createEdges;\n}\n\nexport type AtomicEdgeDeleteBatchEligibilityInput =\n  CommonAtomicMutationEligibility &\n    Readonly<{\n      expectedKind: string;\n      ids: readonly string[];\n    }>;\n\n/** The one owner of the static store proof for atomic edge soft deletes. */\nexport function resolveAtomicEdgeDeleteBatchExecutor(\n  input: AtomicEdgeDeleteBatchEligibilityInput,\n): AtomicEdgeDeleteBatchExecutor | undefined {\n  if (input.ids.length === 0) return;\n  if (!hasOwnKey(input.graph.edges, input.expectedKind)) return;\n  return resolveAtomicMutationProfile(input)?.deleteEdges;\n}\n\nexport type AtomicNodeDeleteBatchEligibilityInput =\n  CommonAtomicMutationEligibility &\n    Readonly<{\n      kind: string;\n      ids: readonly string[];\n      identityEnabled: boolean;\n      registry: KindRegistry;\n    }>;\n\n/** The one owner of the read-free atomic node-delete shape. */\nexport function resolveAtomicNodeDeleteBatchExecutor(\n  input: AtomicNodeDeleteBatchEligibilityInput,\n): AtomicNodeDeleteBatchExecutor | undefined {\n  if (input.ids.length === 0 || input.identityEnabled) return;\n  if (!hasOwnKey(input.graph.nodes, input.kind)) return;\n  const registration = input.graph.nodes[input.kind];\n  if (registration === undefined) return;\n  const executor = resolveAtomicMutationProfile(input)?.deleteNodes;\n  if (executor === undefined) return;\n  const releasedClaimFamilies = new Set(executor.releasedClaimFamilies);\n  if (\n    input.registry.getDisjointKinds(input.kind).length > 0 &&\n    !releasedClaimFamilies.has(\"disjointness\")\n  ) {\n    return;\n  }\n  if (\n    (registration.unique ?? []).length > 0 &&\n    !releasedClaimFamilies.has(\"uniqueness\")\n  ) {\n    return;\n  }\n  if (\n    registration.onDelete !== undefined &&\n    registration.onDelete !== \"restrict\"\n  ) {\n    return;\n  }\n  if (getSearchableFields(registration.type.schema).length > 0) return;\n  if (getEmbeddingFields(registration.type.schema).length > 0) return;\n  return executor;\n}\n\nexport type AtomicNodeResolvedUpdateEligibilityInput =\n  CommonAtomicMutationEligibility &\n    Readonly<{\n      kind: string;\n      entryCount: number;\n      identityEnabled: boolean;\n      registry: KindRegistry;\n    }>;\n\ntype AtomicResolvedNodeKindEligibility = Readonly<{\n  graph: GraphDef;\n  kind: string;\n  identityEnabled: boolean;\n  registry: KindRegistry;\n}>;\n\nfunction isAtomicResolvedNodeKindEligible(\n  input: AtomicResolvedNodeKindEligibility,\n): boolean {\n  if (input.identityEnabled || !hasOwnKey(input.graph.nodes, input.kind)) {\n    return false;\n  }\n  const registration = input.graph.nodes[input.kind];\n  return registration !== undefined && (registration.unique ?? []).length === 0;\n}\n\nfunction supportsAtomicResolvedNodeKindProjections(\n  input: AtomicResolvedNodeKindEligibility,\n  support: AtomicNodeResolvedMutationSetExecutor[\"projectionSupport\"],\n): boolean {\n  const registration = input.graph.nodes[input.kind];\n  return (\n    registration !== undefined &&\n    supportsAtomicNodeProjections(\n      support,\n      atomicNodeProjectionFamilies(registration),\n    )\n  );\n}\n\nfunction isAtomicResolvedEdgeKindEligible(\n  input: Readonly<{ graph: GraphDef; kind: string }>,\n): boolean {\n  if (!hasOwnKey(input.graph.edges, input.kind)) return false;\n  const registration = input.graph.edges[input.kind];\n  return (\n    registration !== undefined &&\n    (registration.cardinality ?? \"many\") === \"many\" &&\n    registration.matchIdentity === undefined\n  );\n}\n\n/** The one owner of the static proof for resolved live-node set updates. */\nexport function resolveAtomicNodeResolvedUpdateBatchExecutor(\n  input: AtomicNodeResolvedUpdateEligibilityInput,\n): AtomicNodeResolvedUpdateBatchExecutor | undefined {\n  if (input.entryCount === 0 || !isAtomicResolvedNodeKindEligible(input)) {\n    return;\n  }\n  const executor = resolveAtomicMutationProfile(input)?.updateNodes;\n  if (\n    executor === undefined ||\n    input.entryCount > executor.maxEntries ||\n    !supportsAtomicResolvedNodeKindProjections(\n      input,\n      executor.projectionSupport,\n    )\n  ) {\n    return;\n  }\n  return executor;\n}\n\nexport type AtomicEdgeResolvedUpdateEligibilityInput =\n  CommonAtomicMutationEligibility &\n    Readonly<{ kind: string; entryCount: number }>;\n\n/** The one owner of the static proof for resolved live-edge set updates. */\nexport function resolveAtomicEdgeResolvedUpdateBatchExecutor(\n  input: AtomicEdgeResolvedUpdateEligibilityInput,\n): AtomicEdgeResolvedUpdateBatchExecutor | undefined {\n  if (input.entryCount === 0 || !isAtomicResolvedEdgeKindEligible(input)) {\n    return;\n  }\n  const executor = resolveAtomicMutationProfile(input)?.updateEdges;\n  if (executor === undefined || input.entryCount > executor.maxEntries) return;\n  return executor;\n}\n\nexport type AtomicNodeResolvedMutationSetEligibilityInput =\n  CommonAtomicMutationEligibility &\n    Readonly<{\n      kind: string;\n      creates: readonly CreateNodeInput[];\n      updateCount: number;\n      identityEnabled: boolean;\n      registry: KindRegistry;\n    }>;\n\n/** The one owner of the static proof for mixed resolved node mutations. */\nexport function resolveAtomicNodeResolvedMutationSetExecutor(\n  input: AtomicNodeResolvedMutationSetEligibilityInput,\n): AtomicNodeResolvedMutationSetExecutor | undefined {\n  const entryCount = input.creates.length + input.updateCount;\n  if (entryCount === 0 || !isAtomicResolvedNodeKindEligible(input)) return;\n  // A mixed set may create rows, so its program must carry disjoint claim\n  // acquisition and refusal. Update-only sets owe no disjoint transition and\n  // are independently eligible through `updateNodes`.\n  if (input.registry.getDisjointKinds(input.kind).length > 0) return;\n  if (\n    input.creates.some(\n      (item) => item.kind !== input.kind || item.id === undefined,\n    )\n  ) {\n    return;\n  }\n  const executor = resolveAtomicMutationProfile(input)?.mutateNodes;\n  if (\n    executor === undefined ||\n    entryCount > executor.maxEntries ||\n    !supportsAtomicResolvedNodeKindProjections(\n      input,\n      executor.projectionSupport,\n    )\n  ) {\n    return;\n  }\n  return executor;\n}\n\nexport type AtomicEdgeResolvedMutationSetEligibilityInput =\n  CommonAtomicMutationEligibility &\n    Readonly<{\n      kind: string;\n      creates: readonly CreateEdgeInput[];\n      updateCount: number;\n    }>;\n\n/** The one owner of the static proof for mixed resolved edge mutations. */\nexport function resolveAtomicEdgeResolvedMutationSetExecutor(\n  input: AtomicEdgeResolvedMutationSetEligibilityInput,\n): AtomicEdgeMutationProgramExecutor | undefined {\n  const entryCount = input.creates.length + input.updateCount;\n  if (entryCount === 0 || !isAtomicResolvedEdgeKindEligible(input)) return;\n  if (\n    input.creates.some(\n      (item) => item.kind !== input.kind || item.id === undefined,\n    )\n  ) {\n    return;\n  }\n  const executor = resolveAtomicMutationProfile(input)?.mutateEdges;\n  if (executor === undefined || entryCount > executor.maxEntries.resolvedSet) {\n    return;\n  }\n  return executor;\n}\n","/**\n * Node Operations for Store\n *\n * Handles node CRUD operations: create, update, delete.\n *\n * ## A write asserts every component its verdict READ\n *\n * `performNodeUpdate` is a probe-and-write pair: it reads the row, decides from\n * what it finds, and then writes. Under PostgreSQL READ COMMITTED a concurrent\n * `hardDelete` + recreate re-resolves `(graph_id, kind, id)` between the two,\n * so anything the decision consumed and the statement does not restate is a\n * decision that can land on a row it was never computed for — and the write\n * reports success. Every value read off the probed row, and where it is\n * asserted:\n *\n *  - `kind` / `id` — the write key itself, restated in every UPDATE's `WHERE`.\n *  - `deleted_at` (which leg runs, and whether to sample a resurrection\n *    instant) — asserted as `deleted_at IS NULL` on the in-place leg and\n *    `IS NOT NULL` on the resurrecting one, so each leg can only hit a row in\n *    the state it was chosen for.\n *  - `valid_from` — asserted via `UpdateNodeParams.expectedValidFrom` WHEN the\n *    window verdict read it ({@link ValidityWindowVerdict}): the caller stated\n *    a `validFrom` to compare against the row's, or a lone `validTo` to invert\n *    against it. A plain `update({ props })` states no window, so the verdict\n *    is independent of the row's bound and the write carries no predicate for\n *    it — the same \"only what it asserted\" rule the edge identity components\n *    follow, and for the same reason: inventing a predicate for a component the\n *    caller made no claim about refuses writes that are legitimate. A\n *    resurrection is judged against the write instant rather than the row's\n *    bound, so it asserts none either; its own tombstone predicate fences it.\n *  - `props` — read twice, as the merge base for the caller's partial update\n *    and as the `oldProps` side of the uniqueness diff — and NOT assertable: a\n *    props blob is TEXT on SQLite and `jsonb` on PostgreSQL, and neither\n *    comparison is stable under key reordering. Bounded instead, two ways: the\n *    sidecar writes are gated on the primary UPDATE's rowcount (see\n *    `applyNodeUpdate`), and\n *    {@link performNodeUpdateWithResurrectionRecovery} re-reads and re-merges\n *    whenever a predicate catches a replaced row.\n *  - the uniques-table row behind `getOrCreateByConstraint` — read to resolve\n *    WHICH node the key names. Not assertable by the node UPDATE (it is a\n *    different table); bounded by the constraint write fence, which makes the\n *    probe and the write it authorizes commit under one per-graph mutual\n *    exclusion. Its `deleted_at`, however, is NOT the owner of \"does this write\n *    resurrect\" — both the single and bulk paths read that from the node row\n *    they are about to write, because one decision with two owners drifts.\n */\nimport { z } from \"zod\";\n\nimport {\n  type AtomicNodeBatchEntry,\n  type AtomicNodeClaimSupport,\n  type AtomicNodeDeleteBatchExecutor,\n  AtomicNodeDeleteRestrictedRefusalError,\n  type AtomicNodeProjection,\n  type AtomicNodeReplacementEntry,\n  type AtomicNodeResolvedUpdateBatchExecutor,\n  supportsAtomicNodeClaims,\n} from \"../../backend/capabilities/atomic-mutation-program\";\nimport { isBundledRootAutocommitEligible } from \"../../backend/capabilities/autocommit-single-statement\";\nimport { bindExtraIfReachable } from \"../../backend/capabilities/bind\";\nimport {\n  BATCH_POINT_READ,\n  type STATEMENT_EXECUTION,\n  UNIQUE_SIDECAR_BATCH,\n} from \"../../backend/capabilities/bundle-registry\";\nimport { resolveBackendFulltext } from \"../../backend/capabilities/fulltext\";\nimport {\n  rephaseAtomicNodeClaimPlan,\n  supportsNodeCreatePlan,\n  supportsNodeInsertProjections,\n} from \"../../backend/capabilities/node-insert-projections\";\nimport {\n  type BundleVerdictOf,\n  type ClaimsVerdictThunk,\n  missingRequiredExtras,\n} from \"../../backend/capabilities/resolve\";\nimport { isSchemaFencedInsertEligible } from \"../../backend/capabilities/schema-fenced-insert\";\nimport { deriveBackend } from \"../../backend/derive-backend\";\nimport { resolvedNodeUpdateBatchFitsBindBudget } from \"../../backend/resolved-node-update-batch\";\nimport {\n  type EdgeRow as BackendEdgeRow,\n  type GraphBackend,\n  type InsertNodeParams,\n  isLiveNodeRow,\n  type NodeInsertProjection,\n  type NodePropertyExpectation,\n  type NodeRow as BackendNodeRow,\n  rowPropsToObject,\n  type TransactionBackend,\n  type UniqueRow,\n} from \"../../backend/types\";\nimport {\n  checkDisjointness,\n  checkWherePredicate,\n  computeUniqueKey,\n} from \"../../constraints\";\nimport { type GraphDef } from \"../../core/define-graph\";\nimport { assertJsonValue } from \"../../core/json-value\";\nimport {\n  type JsonScalar,\n  type JsonValue,\n  type KindEntity,\n  type NodeType,\n  type UniqueConstraint,\n} from \"../../core/types\";\nimport {\n  CompilerInvariantError,\n  ConfigurationError,\n  DatabaseOperationError,\n  KindNotFoundError,\n  NodeConstraintNotFoundError,\n  NodeIndexNotFoundError,\n  NodeNotFoundError,\n  RestrictedDeleteError,\n  UniquenessError,\n  ValidationError,\n} from \"../../errors\";\nimport { validateNodeProps } from \"../../errors/validation\";\nimport { refKey } from \"../../identity/service\";\nimport { type IdentityTarget } from \"../../identity/sql-target\";\nimport {\n  compileIndexWhere,\n  compileNodeIndexFieldKeys,\n  type IndexCompilationContext,\n} from \"../../indexes/compiler\";\nimport { type NodeIndexDeclaration } from \"../../indexes/types\";\nimport { type ValueType } from \"../../query/ast\";\nimport {\n  createSqlSchema,\n  DEFAULT_SQL_SCHEMA,\n  type SqlSchema,\n} from \"../../query/compiler/schema\";\nimport { getDialect } from \"../../query/dialect\";\nimport { type DialectAdapter } from \"../../query/dialect/types\";\nimport { type JsonPointer, resolveJsonPointer } from \"../../query/json-pointer\";\nimport { sql, type SqlFragment } from \"../../query/sql-fragment\";\nimport type { CompiledSelectSql } from \"../../query/sql-intent\";\nimport { asCompiledRowsSql } from \"../../query/sql-intent\";\nimport { type KindRegistry } from \"../../registry/kind-registry\";\nimport { canonicalEqual } from \"../../schema/canonical\";\nimport { chunk } from \"../../utils/array\";\nimport {\n  assertOrderedValidityWindow,\n  assertWritableValidityWindow,\n  nowIso,\n  preservesImmutableLowerBound,\n  resolveStampedValidityLowerBound,\n  validateOptionalCanonicalIsoDate,\n  validateStatedValidityLowerBound,\n} from \"../../utils/date\";\nimport { generateId } from \"../../utils/id\";\nimport { createDataKeyedBag, hasOwnKey } from \"../../utils/object\";\nimport { requireDefined } from \"../../utils/presence\";\nimport { encodeTupleKey } from \"../../utils/tuple-key\";\nimport { type ClaimOwner, uniquenessProbeKinds } from \"../claims/axis\";\nimport {\n  checkUniquenessConstraints,\n  createUniquenessContext,\n  groupNodeUniquenessProbes,\n  isUniquenessClaimEntry,\n  nodeClaimEntries,\n  type NodeClaimItem,\n  type NodeCreateClaimPlan,\n  planNodeCreateClaims,\n  probeUniqueKey,\n  refuseNodeCreateClaimError,\n} from \"../claims/node-claims\";\nimport {\n  resolvedNodeUniqueSidecarBatchIsReachable,\n  resolvedNodeUpdatePreservesClaimKeys,\n} from \"../claims/resolved-node-claims\";\nimport { type UpsertDirtyCheck } from \"../collections/coalesce\";\nimport {\n  type NodeSetUpdateRequest,\n  type NodeUpsertUpdateBatchEntry,\n  type UpsertUpdateNodeInput,\n} from \"../collections/node-collection\";\nimport {\n  checkDisjointnessConstraint,\n  type ConstraintContext,\n  type ConstraintFenceReason,\n  nodeWriteNeedsConstraintFence,\n} from \"../constraints\";\nimport {\n  getEmbeddingFields,\n  resolveNodeEmbeddingProjections,\n  resolveNodeEmbeddingProjectionTransitions,\n} from \"../embedding-sync\";\nimport {\n  assertFulltextMember,\n  getSearchableFields,\n  refuseFulltextUnavailable,\n  resolveNodeFulltextProjection,\n} from \"../fulltext-sync\";\nimport { getNodeRowsByIds } from \"../node-fetch\";\nimport { type GraphWriteLock } from \"../recorded-capture/clock\";\nimport {\n  appliedResolvedMutationSet,\n  type ResolvedMutationSetAttempt,\n  ResolvedMutationSetMoved,\n  unsupportedResolvedMutationSet,\n} from \"../resolved-mutation-set\";\nimport { type NodeRow, rowToNode } from \"../row-mappers\";\nimport {\n  type BulkOperationHookContext,\n  compareAndSetAbsent,\n  type CreateNodeInput,\n  type GetOrCreateAction,\n  type Node,\n  type NodeBulkFindByIndexOptions,\n  type NodeGetOrCreateByConstraintOptions,\n  type OperationHookContext,\n  type UpdateNodeInput,\n} from \"../types\";\nimport {\n  assertClearValidToSupported,\n  assertValidityEndMutation,\n} from \"../validity-end\";\nimport {\n  createAlreadyExistsError,\n  withAlreadyExistsTranslation,\n} from \"./already-exists\";\nimport {\n  assertAtomicDeleteSchemaFenceMatched,\n  resolveAtomicNodeBatchExecutor,\n  resolveAtomicNodeDeleteBatchExecutor,\n  resolveAtomicNodeReplacementBatchProgram,\n  resolveAtomicNodeResolvedMutationSetExecutor,\n  resolveAtomicNodeResolvedUpdateBatchExecutor,\n} from \"./atomic-mutation-program\";\nimport {\n  AutocommitWriteRequiresTransaction,\n  canFuseSchemaFenceInFirstWrite,\n  isAutocommitSingleStatementWrite,\n} from \"./autocommit-single-statement\";\nimport { type NodeInsertSyncItem } from \"./node-write-pipeline\";\nimport {\n  atomicResolvedUpdateAttemptBudget,\n  booleanWriteResultChanges,\n  type HookedWritePlanContext,\n  type OverlaidSessionMint,\n  runAtomicProgramWithHooks,\n  runAutocommitSingleStatementWritePlan,\n  runHookedWritePlan,\n  runWritePlan,\n  writeResultAlwaysChanges,\n} from \"./write-executor\";\nimport { type NodeUpdateFences } from \"./write-fences\";\nimport { nodeBatchWritePlan, nodeWritePlan } from \"./write-plan\";\nimport {\n  type NodeCreateWork,\n  type NodeWriteSession,\n  unfencedTarget,\n  type WriteTarget,\n} from \"./write-session\";\nimport {\n  diagnoseFusedSchemaFenceNoRow,\n  hasLeasedSchemaFence,\n  lockSchemaVersionForStoreWrite,\n  memoizeLeasedSchemaFence,\n  type WriteTransactionMode,\n} from \"./write-transaction\";\n\n// ============================================================\n// Types\n// ============================================================\n\nexport type NodeOperationContext<G extends GraphDef> = Readonly<{\n  graph: G;\n  graphId: string;\n  schemaVersion: number | undefined;\n  historyEnabled: boolean;\n  revisionTrackingEnabled: boolean;\n  coalesceUnchangedUpsertsEnabled: boolean;\n  revisionSchema: SqlSchema;\n  registry: KindRegistry;\n  /**\n   * The `claims` bundle's memoized, at-most-once verdict thunk (ruling B7\n   * refinement 2) — threaded through to `createNodeWriteContext` by\n   * `runWritePlan`'s session mint, and called at the write-session sites that\n   * issue or release a claim.\n   */\n  claimsVerdict: ClaimsVerdictThunk;\n  /** Threaded from `store.ts`'s `#batchPointRead` — never re-resolved here. */\n  batchPointRead: BundleVerdictOf<typeof BATCH_POINT_READ>;\n  /** Threaded from `store.ts`'s `#uniqueSidecarBatch` — never re-resolved here. */\n  uniqueSidecarBatch: BundleVerdictOf<typeof UNIQUE_SIDECAR_BATCH>;\n  /** Threaded from `store.ts`; exact transaction targets bind separately. */\n  statementExecution: BundleVerdictOf<typeof STATEMENT_EXECUTION>;\n  createOperationContext: (\n    operation: \"create\" | \"update\" | \"delete\",\n    entity: KindEntity,\n    kind: string,\n    id: string,\n  ) => OperationHookContext;\n  withOperationHooks: <T>(\n    ctx: OperationHookContext,\n    fn: () => Promise<T>,\n    didWrite?: (result: T) => boolean,\n  ) => Promise<T>;\n  createBulkOperationContext: (\n    operation: \"compareAndSet\" | \"updateWhere\",\n    kind: string,\n  ) => BulkOperationHookContext;\n  withBulkOperationHooks: <T extends Readonly<{ affectedCount: number }>>(\n    ctx: BulkOperationHookContext,\n    fn: () => Promise<T>,\n  ) => Promise<T>;\n  /**\n   * The identity hooks a node write participates in, on {@link IdentityTarget}\n   * — the projection identity STATEMENTS run against — so a fold or a detach\n   * can be issued from inside a write frame, whose handle is the read-only\n   * {@link WriteTarget}. Identity assertions are not node rows: they never\n   * travel through the session, and this is their seam.\n   */\n  identity?: Readonly<{\n    lock: (target: IdentityTarget) => Promise<void>;\n    foldCreated: (\n      target: IdentityTarget,\n      references: readonly Readonly<{ kind: string; id: string }>[],\n    ) => Promise<void>;\n    detachDeleted: (\n      target: IdentityTarget,\n      ref: Readonly<{ kind: string; id: string }>,\n      mode: \"soft\" | \"hard\",\n    ) => Promise<void>;\n    requireValidityEndCompatible: (\n      target: IdentityTarget,\n      ref: Readonly<{ kind: string; id: string }>,\n      validTo: string,\n    ) => Promise<void>;\n  }>;\n}>;\n\ntype NodeCreatePrepared = Readonly<{\n  kind: string;\n  id: string;\n  nodeKind: NodeType;\n  validatedProps: Record<string, unknown>;\n  uniqueConstraints: readonly UniqueConstraint[];\n  claimPlan: NodeCreateClaimPlan;\n  insertParams: InsertNodeParams;\n  /**\n   * `true` when the caller supplied `input.id`. A generated id cannot\n   * already exist under another kind, so identity folding can skip its\n   * cross-kind probe entirely for those rows.\n   */\n  idProvided: boolean;\n  /**\n   * The soft-deleted row occupying this id, or `undefined` when the id is\n   * free. Named for what it can hold rather than what it was read as: the\n   * duplicate-existence probe in {@link finishNodeCreatePreparation} throws\n   * on a LIVE row, so what survives is always a tombstone awaiting\n   * resurrection. Carrying it here is what lets the create path route\n   * insert-vs-resurrect without re-reading the same (graph, kind, id).\n   */\n  tombstone: BackendNodeRow | undefined;\n  /**\n   * This caller-supplied id has no pre/post claims, so a first-party backend\n   * can learn whether the primary-key slot is free from the INSERT itself.\n   */\n  insertIfAbsent: boolean;\n}>;\n\ntype CachedNodeRow = Awaited<ReturnType<GraphBackend[\"getNode\"]>>;\ntype CachedUniqueRow = Awaited<ReturnType<GraphBackend[\"checkUnique\"]>>;\n\n// ============================================================\n// Helper Functions\n// ============================================================\n\n// Own-key membership, matching `store.getNodePropsSchema` and the collections\n// proxy: kind names are arbitrary identifiers, so a `toString`-named kind that\n// is NOT registered would otherwise read the inherited function as its\n// registration and fail with a `TypeError` off `registration.type` instead of\n// the `KindNotFoundError` this guard exists to raise.\nfunction getNodeRegistration<G extends GraphDef>(graph: G, kind: string) {\n  if (!hasOwnKey(graph.nodes, kind)) throw new KindNotFoundError(kind, \"node\");\n  const registration = graph.nodes[kind];\n  if (registration === undefined) throw new KindNotFoundError(kind, \"node\");\n  return registration;\n}\n\n/**\n * WHICH constraint makes this node write one whose probe no database key\n * repeats at write time, so it must take the per-graph write fence — or be\n * refused where no fence exists. The classification itself lives with the\n * constraints ({@link file://../constraints.ts nodeWriteNeedsConstraintFence});\n * this is only the graph-def lookup that feeds it.\n *\n * A kind this graph does not define answers `undefined`: choosing the fence\n * must not become the thing that reports an unknown kind, which the write path\n * raises from inside its hooked transaction where `onError` observes it.\n */\nfunction nodeFencesConstraintProbe<G extends GraphDef>(\n  ctx: Pick<NodeOperationContext<G>, \"graph\" | \"registry\">,\n  kind: string,\n  operation: \"create\" | \"update\",\n): ConstraintFenceReason | undefined {\n  if (!hasOwnKey(ctx.graph.nodes, kind)) return undefined;\n  return nodeWriteNeedsConstraintFence(\n    ctx.registry,\n    kind,\n    getNodeRegistration(ctx.graph, kind).unique ?? [],\n    operation,\n  );\n}\n\n/**\n * The per-item constraint probes a batch write plan folds.\n *\n * \"A batch fences when ANY item does\" is owned by {@link nodeBatchWritePlan};\n * this only supplies the per-item classifications it folds, so the rule has one\n * spelling instead of one here and one in the plan builder.\n */\nfunction nodeBatchConstraintProbes<G extends GraphDef>(\n  ctx: Pick<NodeOperationContext<G>, \"graph\" | \"registry\">,\n  inputs: readonly Readonly<{ kind: string }>[],\n  operation: \"create\" | \"update\",\n): readonly (ConstraintFenceReason | undefined)[] {\n  return inputs.map((input) =>\n    nodeFencesConstraintProbe(ctx, input.kind, operation),\n  );\n}\n\n/**\n * The executor context this module's writes run under: the operation context\n * plus HOW it acquires the identity lock.\n *\n * The plan says WHETHER identity participates; the context says how. A graph\n * with no identity configured supplies no acquirer, and its plans declare no\n * participation — the two are derived from the same `ctx.identity`, which is\n * what makes \"declared participation with no acquirer\" an unreachable wiring\n * bug rather than a silently skipped lock.\n */\nfunction nodeWritePlanContext<G extends GraphDef>(\n  ctx: NodeOperationContext<G>,\n): HookedWritePlanContext {\n  const identity = ctx.identity;\n  if (identity === undefined) return ctx;\n  return { ...ctx, identityLock: identity.lock };\n}\n\n/**\n * The participation a write declares, or `undefined` on a graph with no\n * identity — the one place the `if (identity !== undefined)` that used to be\n * re-spelled at every node write site now lives.\n */\nfunction nodeRequiresIdentityLock<G extends GraphDef>(\n  ctx: NodeOperationContext<G>,\n): boolean {\n  return ctx.identity !== undefined;\n}\n\n/**\n * A generated id cannot already belong to another node, so it cannot take\n * part in identity folding. Keep the identity advisory lock for caller-\n * supplied ids, whose cross-kind collision probe and fold do need it.\n */\nfunction nodeCreateRequiresIdentityLock<G extends GraphDef>(\n  ctx: NodeOperationContext<G>,\n  input: Readonly<{ id?: string }>,\n): boolean {\n  return input.id !== undefined && nodeRequiresIdentityLock(ctx);\n}\n\n/**\n * A schema fence can move into the first INSERT only when it remains the first\n * lock-bearing operation. Claims, identity, recorded capture and revision\n * tracking all acquire a lock before row work, so they deliberately retain the\n * ordinary explicit fence.\n */\n/** Whether any member of a node-create batch can participate in identity. */\nfunction nodeBatchCreateRequiresIdentityLock<G extends GraphDef>(\n  ctx: NodeOperationContext<G>,\n  inputs: readonly Readonly<{ id?: string }>[],\n): boolean {\n  return (\n    nodeRequiresIdentityLock(ctx) &&\n    inputs.some((input) => input.id !== undefined)\n  );\n}\n\nfunction buildNodeCacheKey(graphId: string, kind: string, id: string): string {\n  return encodeTupleKey([graphId, kind, id]);\n}\n\nfunction buildUniqueCacheKey(\n  graphId: string,\n  nodeKind: string,\n  constraintName: string,\n  key: string,\n): string {\n  return encodeTupleKey([graphId, nodeKind, constraintName, key]);\n}\n\nfunction buildInsertNodeParams(\n  graphId: string,\n  kind: string,\n  id: string,\n  props: Record<string, unknown>,\n  validFrom: string | null | undefined,\n  validTo: string | undefined,\n): InsertNodeParams {\n  const insertParams: {\n    graphId: string;\n    kind: string;\n    id: string;\n    props: Record<string, unknown>;\n    validFrom?: string | null;\n    validTo?: string;\n  } = {\n    graphId,\n    kind,\n    id,\n    props,\n  };\n  if (validFrom !== undefined) insertParams.validFrom = validFrom;\n  if (validTo !== undefined) insertParams.validTo = validTo;\n  return insertParams;\n}\n\n/**\n * Materializes the claim row a not-yet-flushed batch member holds, so a later\n * member's probe reads the same shape it would read from the database.\n *\n * It invents no kind: the owner pair comes from the pending registration. The\n * predecessor wrote `concrete_kind: nodeKind` — the axis the probe QUERIED,\n * which the pending writer never supplied — so `Employee \"X\"` followed by\n * `Contractor \"X\"` on one shared-scope key read back as the same owner, the\n * in-batch refusal was suppressed, and the real one arrived at the flush as a\n * whole-batch abort. This is the third renderer of claim ownership; it must\n * agree with the TypeScript predicate and the SQL arms.\n */\nfunction createPendingUniqueRow(\n  graphId: string,\n  nodeKind: string,\n  constraintName: string,\n  key: string,\n  owner: ClaimOwner,\n): UniqueRow {\n  return {\n    graph_id: graphId,\n    node_kind: nodeKind,\n    constraint_name: constraintName,\n    key,\n    node_id: owner.nodeId,\n    concrete_kind: owner.concreteKind,\n    deleted_at: undefined,\n  };\n}\n\nfunction resolveConstraint<G extends GraphDef>(\n  graph: G,\n  kind: string,\n  constraintName: string,\n): UniqueConstraint {\n  const registration = getNodeRegistration(graph, kind);\n  const constraints = registration.unique ?? [];\n  const constraint = constraints.find(\n    (candidate) => candidate.name === constraintName,\n  );\n  if (constraint === undefined) {\n    throw new NodeConstraintNotFoundError(constraintName, kind);\n  }\n  return constraint;\n}\n\n// ============================================================\n// Batch Validation Cache\n//\n// During batch operations, multiple items may reference the same\n// nodes/unique keys. This cache avoids redundant backend lookups\n// and tracks pending (not-yet-flushed) inserts so that later items\n// in the batch can see earlier ones during validation.\n// ============================================================\n\n/**\n * The reads a batch's pending-aware validation answers itself.\n *\n * Published as the OVERLAY SPEC alongside the reader built from it, because\n * two different handles have to carry these answers: the caller reads through\n * `reader`, and interchange import ALSO hands the spec to the executor, which\n * decorates the write frame's own target with it so a session can be minted\n * over the same pending state. A decorated backend alone could not do that —\n * its static type would have to be the full backend union for the session mint\n * to accept it, which is the widening this seam exists to remove — and two\n * independently built overlays would be two spellings of one decision.\n */\nexport type NodeBatchValidationReads = Readonly<\n  Pick<WriteTarget, \"getNode\" | \"checkUnique\">\n>;\n\nexport function createNodeBatchValidationSeams(\n  graphId: string,\n  registry: KindRegistry,\n  backend: WriteTarget,\n): Readonly<{\n  reads: NodeBatchValidationReads;\n  reader: WriteTarget;\n  registerPendingNode: (params: InsertNodeParams) => void;\n  registerPendingUniqueEntries: (\n    kind: string,\n    id: string,\n    props: Record<string, unknown>,\n    constraints: readonly UniqueConstraint[],\n  ) => void;\n  registerAppliedNodeUpdate: (\n    kind: string,\n    id: string,\n    oldProps: Record<string, unknown>,\n    newProps: Record<string, unknown>,\n    constraints: readonly UniqueConstraint[],\n  ) => void;\n  seedNodeRow: (kind: string, id: string, row: CachedNodeRow) => void;\n  seedUniqueRow: (\n    kind: string,\n    constraintName: string,\n    key: string,\n    row: CachedUniqueRow,\n  ) => void;\n}> {\n  const nodeCache = new Map<string, CachedNodeRow>();\n  const pendingNodes = new Map<string, NonNullable<CachedNodeRow>>();\n  const uniqueCache = new Map<string, CachedUniqueRow>();\n  // The pending OWNER PAIR, never the bare id: two batch members sharing an id\n  // under different kinds are two claimants, and an id-keyed cache reads them\n  // as one.\n  const pendingUniqueOwners = new Map<string, ClaimOwner>();\n\n  async function getNodeCached(\n    lookupGraphId: string,\n    kind: string,\n    id: string,\n  ): Promise<CachedNodeRow> {\n    const cacheKey = buildNodeCacheKey(lookupGraphId, kind, id);\n    const pendingNode = pendingNodes.get(cacheKey);\n    if (pendingNode !== undefined) return pendingNode;\n    if (nodeCache.has(cacheKey)) return nodeCache.get(cacheKey);\n    const existing = await backend.getNode(lookupGraphId, kind, id);\n    nodeCache.set(cacheKey, existing);\n    return existing;\n  }\n\n  async function checkUniqueCached(\n    params: Parameters<GraphBackend[\"checkUnique\"]>[0],\n  ): Promise<CachedUniqueRow> {\n    const cacheKey = buildUniqueCacheKey(\n      params.graphId,\n      params.nodeKind,\n      params.constraintName,\n      params.key,\n    );\n    const pendingOwner = pendingUniqueOwners.get(cacheKey);\n    if (pendingOwner !== undefined) {\n      return createPendingUniqueRow(\n        params.graphId,\n        params.nodeKind,\n        params.constraintName,\n        params.key,\n        pendingOwner,\n      );\n    }\n    if (uniqueCache.has(cacheKey)) return uniqueCache.get(cacheKey);\n    const existing = await backend.checkUnique(params);\n    uniqueCache.set(cacheKey, existing);\n    return existing;\n  }\n\n  function registerPendingNode(params: InsertNodeParams): void {\n    const cacheKey = buildNodeCacheKey(params.graphId, params.kind, params.id);\n    pendingNodes.set(cacheKey, {\n      graph_id: params.graphId,\n      kind: params.kind,\n      id: params.id,\n      props: JSON.stringify(params.props),\n      version: 1,\n      // The simulated cached row only needs a NodeRow-shaped valid_from\n      // (string | undefined, never null) for existence/uniqueness checks,\n      // which don't inspect its value — normalize the write protocol's explicit-NULL\n      // sentinel away rather than widen this cache's row shape.\n      valid_from: params.validFrom ?? undefined,\n      valid_to: params.validTo,\n      created_at: \"\",\n      updated_at: \"\",\n      deleted_at: undefined,\n    });\n  }\n\n  // Records the claims a not-yet-flushed create will write, at the AXIS it will\n  // write them: one entry per claim, not one per kind in scope. The fan-out\n  // this replaces existed because the claim used to be written under the\n  // node's own kind while the probe read every kind in scope; now both sides\n  // name the axis, so a second entry would be a second spelling of the same\n  // reservation.\n  function registerPendingUniqueEntries(\n    kind: string,\n    id: string,\n    props: Record<string, unknown>,\n    constraints: readonly UniqueConstraint[],\n  ): void {\n    for (const entry of nodeClaimEntries(\n      registry,\n      kind,\n      id,\n      props,\n      constraints,\n      \"create\",\n    )) {\n      pendingUniqueOwners.set(\n        buildUniqueCacheKey(\n          graphId,\n          entry.axis,\n          entry.constraintName,\n          entry.key,\n        ),\n        { concreteKind: kind, nodeId: id },\n      );\n    }\n  }\n\n  // Reflects a completed in-slice node update in the uniqueness caches so a\n  // later row's pre-check sees the post-update reservation state — the state\n  // the sequential path's per-row backend read would observe. The batch path\n  // primes the caches ONCE before routing, but an in-slice update mutates the\n  // real backend's uniqueness rows directly; without reconciling here a later\n  // create either (a) claims a value this update just freed yet gets rejected\n  // against the stale reservation, or (b) passes the stale \"free\" cache for a\n  // value this update just took and then violates the real constraint at\n  // flush, aborting the whole import. Mirrors the claim transition's key diff:\n  // for each constraint whose key changed, the released old key becomes free\n  // and the reserved new key becomes owned by this node AT ITS AXIS — the one\n  // row the transition actually wrote — while the remaining kinds the probe\n  // reads are recorded as vacant, which they are: the probe that let this\n  // update through visited every one of them.\n  function registerAppliedNodeUpdate(\n    kind: string,\n    id: string,\n    oldProps: Record<string, unknown>,\n    newProps: Record<string, unknown>,\n    constraints: readonly UniqueConstraint[],\n  ): void {\n    const owner: ClaimOwner = { concreteKind: kind, nodeId: id };\n    const oldEntries = new Map(\n      nodeClaimEntries(registry, kind, id, oldProps, constraints, \"update\").map(\n        (entry) => [entry.constraintName, entry],\n      ),\n    );\n    const newEntries = new Map(\n      nodeClaimEntries(registry, kind, id, newProps, constraints, \"update\").map(\n        (entry) => [entry.constraintName, entry],\n      ),\n    );\n\n    for (const constraint of constraints) {\n      const oldEntry = oldEntries.get(constraint.name);\n      const newEntry = newEntries.get(constraint.name);\n      if (oldEntry?.key === newEntry?.key) continue;\n\n      const kindsToCheck = uniquenessProbeKinds(\n        kind,\n        constraint.scope,\n        registry,\n      );\n\n      if (oldEntry !== undefined) {\n        for (const kindToCheck of kindsToCheck) {\n          const cacheKey = buildUniqueCacheKey(\n            graphId,\n            kindToCheck,\n            constraint.name,\n            oldEntry.key,\n          );\n          // This node released the key on the real backend, so it is now\n          // free. Clear any pending reservation and record the known-free\n          // state (overwriting a stale seeded owner) so a later create's\n          // pre-check sees a vacancy instead of a redundant backend read.\n          pendingUniqueOwners.delete(cacheKey);\n          uniqueCache.set(cacheKey, undefined);\n        }\n      }\n      if (newEntry !== undefined) {\n        for (const kindToCheck of kindsToCheck) {\n          const cacheKey = buildUniqueCacheKey(\n            graphId,\n            kindToCheck,\n            constraint.name,\n            newEntry.key,\n          );\n          if (kindToCheck === newEntry.axis) {\n            // This node now holds the key on the real backend. A pending owner\n            // shadows the seeded uniqueCache entry (checkUniqueCached consults\n            // it first), matching registerPendingUniqueEntries' reservation.\n            pendingUniqueOwners.set(cacheKey, owner);\n            continue;\n          }\n          pendingUniqueOwners.delete(cacheKey);\n          uniqueCache.set(cacheKey, undefined);\n        }\n      }\n    }\n  }\n\n  // Seed functions let batch preparation prime the caches from one\n  // getNodes / checkUniqueBatch round trip instead of a per-row probe.\n  // Seeding an absent result (`undefined`) is meaningful — it marks the\n  // key as known-missing so the per-row check skips the backend read.\n  // Existing entries are never overwritten: a pending registration or an\n  // earlier lookup always wins.\n  function seedNodeRow(kind: string, id: string, row: CachedNodeRow): void {\n    const cacheKey = buildNodeCacheKey(graphId, kind, id);\n    if (nodeCache.has(cacheKey)) return;\n    nodeCache.set(cacheKey, row);\n  }\n\n  function seedUniqueRow(\n    kind: string,\n    constraintName: string,\n    key: string,\n    row: CachedUniqueRow,\n  ): void {\n    const cacheKey = buildUniqueCacheKey(graphId, kind, constraintName, key);\n    if (uniqueCache.has(cacheKey)) return;\n    uniqueCache.set(cacheKey, row);\n  }\n\n  const reads: NodeBatchValidationReads = {\n    getNode: getNodeCached,\n    checkUnique: checkUniqueCached,\n  };\n\n  return {\n    reads,\n    reader: deriveBackend(backend, reads),\n    registerPendingNode,\n    registerPendingUniqueEntries,\n    registerAppliedNodeUpdate,\n    seedNodeRow,\n    seedUniqueRow,\n  };\n}\n\n// ============================================================\n// Shared Create Pipeline\n// ============================================================\n\n/**\n * The synchronous half of create preparation: kind resolution, Zod\n * validation, and date validation. Produces everything the async\n * constraint checks need, so batch preparation can validate every input\n * first and then prime the validation caches with batched reads before\n * running {@link finishNodeCreatePreparation} per row.\n */\n/**\n * Internal create options threaded from operations that validated props\n * BEFORE calling into the create path. Never exposed on the public store\n * surface.\n */\ntype NodeCreateInternalOptions = Readonly<{\n  /** `input.props` is already the output of `validateNodeProps`. */\n  propsPreValidated?: boolean;\n}>;\n\n/** Whether create preparation retains application probes or defers them to\n * the authoritative verdict returned by the planned insert statement. */\ntype NodeCreatePreparationMode =\n  \"probe\" | \"authoritative-plan\" | \"atomic-batch\";\n\nexport type NodeCreateDraft = Readonly<{\n  kind: string;\n  id: string;\n  idProvided: boolean;\n  nodeKind: NodeType;\n  uniqueConstraints: readonly UniqueConstraint[];\n  validatedProps: Record<string, unknown>;\n  validFrom: string | null | undefined;\n  validTo: string | undefined;\n}>;\n\nfunction draftNodeCreate<G extends GraphDef>(\n  ctx: NodeOperationContext<G>,\n  input: CreateNodeInput,\n  id: string,\n  options?: NodeCreateInternalOptions,\n): NodeCreateDraft {\n  const kind = input.kind;\n  const registration = getNodeRegistration(ctx.graph, kind);\n  const nodeKind = registration.type;\n\n  // getOrCreate / findByConstraint variants validate props up front (the\n  // key computation needs the PARSED shape), then hand the validated\n  // object here — re-running the full Zod parse on it would double the\n  // validation cost of every create leg for no additional safety (hooks\n  // wrap the transaction and cannot transform inputs in between).\n  const validatedProps =\n    options?.propsPreValidated === true ?\n      input.props\n    : validateNodeProps(nodeKind.schema, input.props, {\n        kind,\n        operation: \"create\",\n      });\n\n  const validFrom = validateStatedValidityLowerBound(\n    input.validFrom,\n    \"validFrom\",\n  );\n  const validTo = validateOptionalCanonicalIsoDate(input.validTo, \"validTo\");\n  // A stated pair must be ordered, and on an insert that is the COMPLETE rule.\n  // A lone historical validTo is NOT an error — it means \"born already ended\"\n  // (see assertWritableValidityWindow), and the insert stores no lower bound for\n  // it rather than one past the stated end, so there is no effective bound left\n  // for this layer to judge. Both create paths (single and batch) draft through\n  // here, so this is the only insert-side check needed.\n  assertOrderedValidityWindow(`${kind} \"${id}\"`, validFrom, validTo);\n\n  return {\n    kind,\n    id,\n    idProvided: input.id !== undefined,\n    nodeKind,\n    uniqueConstraints: registration.unique ?? [],\n    validatedProps,\n    validFrom,\n    validTo,\n  };\n}\n\n/**\n * The async half: existence, disjointness, and uniqueness checks.\n *\n * The existence probe's row is returned on the prepared record so fresh\n * inserts avoid a second read. Resurrection is the rare exception: it\n * re-checks the row immediately before writing because another transaction\n * may have resurrected it after preparation.\n */\nasync function finishNodeCreatePreparation<G extends GraphDef>(\n  ctx: NodeOperationContext<G>,\n  draft: NodeCreateDraft,\n  backend: WriteTarget,\n  allowInsertIfAbsent = true,\n  mode: NodeCreatePreparationMode = \"probe\",\n  preparedClaimPlan?: NodeCreateClaimPlan,\n): Promise<NodeCreatePrepared> {\n  const { kind, id, validatedProps, uniqueConstraints } = draft;\n  const claimPlan =\n    preparedClaimPlan ??\n    planNodeCreateClaims(\n      { graphId: ctx.graphId, registry: ctx.registry },\n      { kind, id, props: validatedProps, constraints: uniqueConstraints },\n    );\n\n  // Claim-free caller ids are the one safe shape for an insert-first path. A\n  // pre-insert claim would have to be compensated when `DO NOTHING` reports an\n  // occupied row; keep that larger transition out of this optimization until it\n  // has its own atomic claim outcome. `nodeClaimEntries` is the single owner of\n  // whether either uniqueness or disjointness applies, so this does not grow a\n  // second spelling of the constraint decision.\n  const insertIfAbsent =\n    allowInsertIfAbsent &&\n    draft.idProvided &&\n    backend.insertNodeIfAbsent !== undefined &&\n    nodeClaimEntries(\n      ctx.registry,\n      kind,\n      id,\n      validatedProps,\n      uniqueConstraints,\n      \"create\",\n    ).length === 0;\n\n  // Generated ids are fresh by construction on the ordinary path. The atomic\n  // path deliberately skips this read for caller ids too: its backend program\n  // owns absent-insert, tombstone-resurrection, and live-duplicate semantics.\n  const existingNode =\n    mode === \"atomic-batch\" ? undefined\n    : draft.idProvided && !insertIfAbsent ?\n      await backend.getNode(ctx.graphId, kind, id)\n    : undefined;\n  if (existingNode && !existingNode.deleted_at) {\n    throw createAlreadyExistsError(\"node\", kind, id);\n  }\n\n  // A fresh row whose claims are going through the transaction-scoped\n  // planned insert gets its ownership verdict from that statement. Keep the\n  // same probes for fallback backends, no-return writes, and tombstones (the\n  // latter route through the resurrection transition rather than this plan).\n  const deferConstraintProbes =\n    (mode === \"authoritative-plan\" || mode === \"atomic-batch\") &&\n    existingNode === undefined &&\n    claimPlan.claims.length > 0;\n  if (mode !== \"atomic-batch\" && !deferConstraintProbes) {\n    const constraintContext: ConstraintContext = {\n      graphId: ctx.graphId,\n      registry: ctx.registry,\n      backend,\n    };\n    // Disjointness is also keyed by the id. A generated id cannot already be\n    // present under a disjoint kind, so its cross-kind reads are the same pure\n    // cost as the same-kind existence probe above.\n    if (draft.idProvided && !insertIfAbsent) {\n      await checkDisjointnessConstraint(constraintContext, kind, id);\n    }\n\n    await checkUniquenessConstraints(\n      createUniquenessContext(\n        ctx.graphId,\n        ctx.registry,\n        backend,\n        ctx.uniqueSidecarBatch,\n      ),\n      kind,\n      id,\n      validatedProps,\n      uniqueConstraints,\n    );\n  }\n\n  return {\n    kind,\n    id,\n    idProvided: draft.idProvided,\n    claimPlan,\n    tombstone: existingNode,\n    insertIfAbsent,\n    nodeKind: draft.nodeKind,\n    validatedProps,\n    uniqueConstraints,\n    insertParams: buildInsertNodeParams(\n      ctx.graphId,\n      kind,\n      id,\n      validatedProps,\n      draft.validFrom,\n      draft.validTo,\n    ),\n  };\n}\n\n/** What a prepared create hands the claim seam and the sync fans. */\nfunction nodeCreateSideEffectItem(\n  prepared: NodeCreatePrepared,\n): NodeInsertSyncItem {\n  return {\n    kind: prepared.kind,\n    id: prepared.id,\n    schema: prepared.nodeKind.schema,\n    props: prepared.validatedProps,\n    uniqueConstraints: prepared.uniqueConstraints,\n  };\n}\n\nfunction nodeCreateClaimItem(prepared: NodeCreatePrepared): NodeClaimItem {\n  return {\n    kind: prepared.kind,\n    id: prepared.id,\n    props: prepared.validatedProps,\n    constraints: prepared.uniqueConstraints,\n  };\n}\n\n/** Resolves every projection owed by a fresh generated-id node in one place. */\nfunction resolveNodeInsertProjections(\n  schema: z.ZodType,\n  props: Record<string, unknown>,\n): readonly NodeInsertProjection[] {\n  const fulltext = resolveNodeFulltextProjection(schema, props);\n  return [\n    ...(fulltext === undefined ? [] : [fulltext]),\n    ...resolveNodeEmbeddingProjections(schema, props),\n  ];\n}\n\n/** Complete projection transitions for an atomic node postimage. */\nfunction resolveAtomicNodeProjections(\n  schema: z.ZodType,\n  props: Record<string, unknown>,\n  options?: Readonly<{ omitEmbeddingDeletes?: boolean }>,\n): readonly AtomicNodeProjection[] {\n  const fulltext = resolveNodeFulltextProjection(schema, props);\n  return [\n    ...(fulltext === undefined ? [] : [fulltext]),\n    ...resolveNodeEmbeddingProjectionTransitions(schema, props, {\n      omitDeletes: options?.omitEmbeddingDeletes === true,\n    }),\n  ];\n}\n\n/**\n * One prepared create as the session's insert unit: the row params, the claims\n * the row owes, and the sidecar inputs, as ONE value.\n *\n * This replaces the `finalizeNodeCreate` / `finalizeNodeCreateBatch` pair and\n * the claim seam the create paths used to open around their own insert. Each was\n * a HALF of a create, callable — and forgettable — on its own; the session takes\n * the whole unit and applies all three in the pinned order (pre-insert claims,\n * row, post-insert claims, sync fans).\n */\nfunction nodeCreateWork(\n  prepared: NodeCreatePrepared,\n  projections: readonly NodeInsertProjection[] = [],\n  allowNonTransactionalClaims = false,\n): NodeCreateWork {\n  return {\n    params: prepared.insertParams,\n    idGenerated: !prepared.idProvided,\n    allowNonTransactionalClaims,\n    claim: nodeCreateClaimItem(prepared),\n    claimPlan: prepared.claimPlan,\n    sideEffects: nodeCreateSideEffectItem(prepared),\n    projections,\n  };\n}\n\n/**\n * The created references identity folding actually has to consider.\n *\n * Folding looks for a live node carrying the SAME id under a DIFFERENT kind.\n * A generated id is fresh — nothing can already hold it — so only\n * caller-supplied ids can participate, and a batch of purely auto-id creates\n * needs no cross-kind probe at all.\n */\nfunction foldReferences(\n  preparedCreates: readonly NodeCreatePrepared[],\n): readonly Readonly<{ kind: string; id: string }>[] {\n  return preparedCreates\n    .filter((prepared) => prepared.idProvided)\n    .map((prepared) => ({ kind: prepared.kind, id: prepared.id }));\n}\n\n// ============================================================\n// Shared Update Pipeline\n//\n// executeNodeUpdate wraps this in operation hooks.\n// executeNodeUpsertUpdate calls it directly (no hooks) for\n// getOrCreate resurrections.\n// ============================================================\n\n/**\n * The exact props an update would persist: the caller's partial input merged\n * over the current props and run through the kind's Zod schema (defaults\n * applied, values normalized). Also returns the resolved registration so\n * callers need not look it up again. Operates on PARSED props so both the write\n * path (which parses the row) and the coalesce dirty-check (which may compare\n * against a batch-local running value, never a row) share one validation.\n */\nfunction computeNodeUpdate<G extends GraphDef>(\n  ctx: NodeOperationContext<G>,\n  kind: string,\n  id: string,\n  existingProps: Record<string, unknown>,\n  inputProps: Partial<Record<string, unknown>>,\n) {\n  const registration = getNodeRegistration(ctx.graph, kind);\n  const validatedProps = validateNodeProps(\n    registration.type.schema,\n    { ...existingProps, ...inputProps },\n    { kind, operation: \"update\", id },\n  );\n  return { registration, validatedProps };\n}\n\n/**\n * Row-based wrapper over {@link computeNodeUpdate} for the write path. Reads the\n * kind/id off the row (a `getNode(kind, id)` result always carries the\n * requested kind), matching {@link resolveEdgeUpdateProps}.\n */\nfunction resolveNodeUpdateProps<G extends GraphDef>(\n  ctx: NodeOperationContext<G>,\n  existing: Pick<NodeRow, \"kind\" | \"id\" | \"props\">,\n  inputProps: Partial<Record<string, unknown>>,\n) {\n  const existingProps = rowPropsToObject(existing.props);\n  const { registration, validatedProps } = computeNodeUpdate(\n    ctx,\n    existing.kind,\n    existing.id,\n    existingProps,\n    inputProps,\n  );\n  return { registration, existingProps, validatedProps };\n}\n\n/**\n * The coalesce dirty-check: returns the props an `upsertById` would persist and\n * whether they equal `existingProps` (so the write can be skipped). Compares on\n * the storage-normalized representation (validated, key-order-independent), so\n * it answers exactly \"would the persisted JSON differ?\". `existingProps` is the\n * PARSED current props — the row's, or the batch-local running value for a\n * repeated id in `bulkUpsertById`.\n */\nexport function nodeUpsertDirtyCheck<G extends GraphDef>(\n  ctx: NodeOperationContext<G>,\n  kind: string,\n  id: string,\n  existingProps: Record<string, unknown>,\n  inputProps: Record<string, unknown>,\n): UpsertDirtyCheck {\n  const { validatedProps } = computeNodeUpdate(\n    ctx,\n    kind,\n    id,\n    existingProps,\n    inputProps,\n  );\n  return {\n    validatedProps,\n    unchanged: canonicalEqual(validatedProps, existingProps),\n  };\n}\n\ntype NodeUpdateExecutionOptions = Readonly<{\n  clearDeleted?: boolean;\n  replacementProps?: Record<string, unknown>;\n}>;\n\nasync function performNodeUpdate<G extends GraphDef>(\n  ctx: NodeOperationContext<G>,\n  input: UpsertUpdateNodeInput,\n  session: NodeWriteSession,\n  target: WriteTarget,\n  options?: NodeUpdateExecutionOptions,\n  resolvedExisting?: BackendNodeRow,\n): Promise<Node> {\n  const { kind, id } = input;\n\n  assertValidityEndMutation(input, { entityType: \"node\", kind, id });\n\n  const existing =\n    resolvedExisting ?? (await target.getNode(ctx.graphId, kind, id));\n  if (!existing) throw new NodeNotFoundError(kind, id);\n\n  const { registration, validatedProps } =\n    options?.replacementProps === undefined ?\n      resolveNodeUpdateProps(ctx, existing, input.props)\n    : {\n        registration: getNodeRegistration(ctx.graph, kind),\n        validatedProps: options.replacementProps,\n      };\n  const nodeKind = registration.type;\n\n  const validTo = validateOptionalCanonicalIsoDate(input.validTo, \"validTo\");\n  // A node resurrection RESETS `valid_from` (see `buildUpdateNode`), so its\n  // effective lower bound is one this write stamps rather than the row's stored\n  // one. The instant is sampled HERE and the bound resolved from it travels to\n  // the backend as an explicit `validFrom`, because the guard has to measure\n  // the bound the write will actually store: left to default, the builder's own\n  // `resolveStampedValidityLowerBound` call would judge the backend's strictly\n  // later sample, and a `validTo` at this instant would pass the guard as\n  // zero-width and land as a different shape a millisecond later (issue #413).\n  // An in-place update keeps the row's stored bound, which no write rewrites and\n  // so needs no prediction.\n  const resurrectionInstant =\n    options?.clearDeleted === true && existing.deleted_at !== undefined ?\n      nowIso()\n    : undefined;\n  // Event materializers may state the source row's lower bound on every\n  // delivery while asking a live update to preserve the bound already stored.\n  // This is explicit create/resurrection-only input, not the old silent drop:\n  // the default remains `\"refuse\"`, and a resurrection still validates and\n  // stores the stated value below.\n  const preservesLiveLowerBound =\n    resurrectionInstant === undefined &&\n    preservesImmutableLowerBound(input.onImmutableLowerBound);\n  const statedValidFrom = validateStatedValidityLowerBound(\n    input.validFrom,\n    \"validFrom\",\n  );\n  const validFrom = preservesLiveLowerBound ? undefined : statedValidFrom;\n  // The bound this resurrection will STORE, decided by the same owner every\n  // insert builder decides through, against the instant sampled above. Asking\n  // the owner rather than assuming `resurrectionInstant` is what makes a\n  // resurrection carrying only a historical `validTo` reach the shape a create\n  // reaches — no lower bound, \"ended at T, start unknown\" — instead of being\n  // refused for inverting against an instant the write would never have stored\n  // (I12). `undefined` here means \"no bound\", which is nothing to invert\n  // against, so the verdict below judges exactly what lands.\n  const resurrectionBound =\n    resurrectionInstant === undefined ? undefined : (\n      resolveStampedValidityLowerBound(validFrom, validTo, resurrectionInstant)\n    );\n  // A resurrection STORES a stated `validFrom` (it rewrites the whole window);\n  // an in-place update never does, so one that differs from the row's stored\n  // bound is refused rather than accepted and dropped.\n  const windowVerdict = assertWritableValidityWindow(\n    `${kind} \"${id}\"`,\n    validFrom,\n    resurrectionInstant === undefined ?\n      {\n        effectiveValidFrom: existing.valid_from,\n        appliesStatedValidFrom: false,\n        effectiveBoundIsStored: true,\n      }\n    : {\n        effectiveValidFrom: resurrectionBound,\n        appliesStatedValidFrom: true,\n        // The bound this write is about to stamp, not one the row holds.\n        effectiveBoundIsStored: false,\n      },\n    validTo,\n  );\n\n  const shared = {\n    schema: nodeKind.schema,\n    validatedProps,\n    uniqueConstraints: registration.unique ?? [],\n    ...(validTo !== undefined && { validTo }),\n    ...(input.clearValidTo === true && { clearValidTo: true as const }),\n  };\n  // The bound the verdict above READ, carried into the UPDATE's own `WHERE` so\n  // the row this writes is the row that was judged. The verdict hands over the\n  // predicate rather than a flag, so both conditions that decide it — did the\n  // verdict consult the effective bound, and WAS that bound the row's stored\n  // one — are answered where they are known. A plain `update({ props })`\n  // states no window, reads no bound, and stays unfenced: the same rule\n  // `UpdateEdgeParams`'s identity components follow, for the same reason. The\n  // resurrecting leg is judged against `resurrectionInstant` and so fences on\n  // `deleted_at IS NOT NULL` alone, converging through the recovery below.\n  //\n  // It is now a REQUIRED argument rather than a spread convention: an update\n  // that forgot to carry the bound its verdict read is a compile error.\n  const fences: NodeUpdateFences = {\n    validityLowerBound: windowVerdict.storedLowerBoundFence,\n  };\n\n  // A resurrecting upsert (clearDeleted) may target a tombstoned row; a plain\n  // update must prove the row live — see NodeUpdateTarget.\n  if (options?.clearDeleted) {\n    // Keyed on the SAME condition the verdict was, because only that condition\n    // produces a verdict to state. With `resurrectionInstant` defined this is\n    // the DECISION, never an absence: omitting the key would let\n    // `buildUpdateNode` re-derive the bound against the backend's own, strictly\n    // later `timestamp`, so the two layers would agree only while the two clocks\n    // do — the #413 hazard, one layer out. `null` is how `UpdateNodeParams`\n    // spells \"store no lower bound\", which is what this decision resolves to for\n    // a resurrection that ends at or before the instant it judged.\n    //\n    // With it UNDEFINED this read found the row live — a peer resurrected it\n    // between the collection's probe and here — so the verdict judged the row's\n    // stored bound and stamped nothing. There is no decision to state, and\n    // stating one anyway would write away a `validFrom` the guard just ACCEPTED\n    // as equal to that stored bound. The statement usually matches no row\n    // (`deleted_at IS NOT NULL`) and the recovery below re-reads, but a peer that\n    // re-tombstones before the UPDATE makes it match, so this leg carries the\n    // stated bound exactly as the in-place leg does.\n    const resurrectionLowerBound =\n      resurrectionInstant === undefined ?\n        validFrom !== undefined && { validFrom }\n        // eslint-disable-next-line unicorn/no-null -- `validFrom: null` means \"store NULL\"; omitting the key means \"decide for me\", and this path has already decided. See UpdateNodeParams.validFrom.\n      : { validFrom: resurrectionBound ?? null };\n    const row = await session.reviseNode(\n      { ...shared, existing, clearDeleted: true, ...resurrectionLowerBound },\n      fences,\n    );\n    return rowToNode(row);\n  }\n\n  if (!isLiveNodeRow(existing)) throw new NodeNotFoundError(kind, id);\n  const row = await session.reviseNode(\n    // An in-place update must not rewrite the stored bound, so it keeps the\n    // conditional spread: `buildUpdateNode` ignores `validFrom` off the\n    // resurrection leg, and stating one here would claim a rewrite that no\n    // statement performs.\n    { ...shared, existing, ...(validFrom !== undefined && { validFrom }) },\n    fences,\n  );\n  return rowToNode(row);\n}\n\n/**\n * How many probe-and-write rounds a node update gets before it stops trying to\n * converge. One retry: enough to absorb a single concurrent recreate, bounded\n * so a peer that keeps replacing the row cannot livelock this caller (the same\n * shape, and the same reasoning, as `getOrCreateByEndpoints`'s bounded loop).\n */\nconst NODE_UPDATE_ATTEMPTS = 2;\n\n/**\n * Runs a node update and CONVERGES on the row that is actually there when a\n * predicated UPDATE matches nothing.\n *\n * `performNodeUpdate` is a probe-and-write pair, and both of the predicates its\n * statement carries beyond `(graph_id, kind, id)` can stop matching between the\n * two under PostgreSQL READ COMMITTED:\n *\n *  - `deleted_at IS NOT NULL` on the resurrecting leg — a peer resurrected the\n *    tombstone first;\n *  - `expectedValidFrom` on the in-place leg — a peer hard-deleted and\n *    recreated the row, so the bound this update's window verdict was computed\n *    against is gone.\n *\n * Both are the SAME event from the caller's side: the row moved under a\n * decision already made. Neither may surface as the zero-row\n * `DatabaseOperationError` the backend raises, which is an internal sentinel\n * and names nothing a caller can act on. So this re-reads and re-derives:\n *\n *  - row gone, or tombstoned where the leg needs a live one — `NodeNotFoundError`,\n *    exactly what the pre-write probe would have thrown;\n *  - row live — retry the whole thing. The retry re-reads, re-merges the\n *    caller's partial props over the CURRENT props, and re-judges the window\n *    against the CURRENT bound, so a stated window that no longer fits is\n *    refused with the same typed `ValidationError` the first attempt would have\n *    raised. A resurrection that lost its race converges to an ordinary update,\n *    which is upsert's documented semantics: the peer owns the new window, this\n *    late writer owns the properties — and a caller that STATED a lower bound\n *    for the resurrection it lost is therefore refused rather than silently\n *    updated without it.\n *\n * Retrying rather than refusing is what keeps the fence from being a behavior\n * regression: the losing writer still lands its properties, on the row that is\n * really there, judged against the bounds that row really carries.\n */\nasync function performNodeUpdateWithResurrectionRecovery<G extends GraphDef>(\n  ctx: NodeOperationContext<G>,\n  input: UpsertUpdateNodeInput,\n  session: NodeWriteSession,\n  target: WriteTarget,\n  options?: NodeUpdateExecutionOptions,\n  resolvedExisting?: BackendNodeRow,\n): Promise<Node> {\n  for (let attempt = 1; attempt <= NODE_UPDATE_ATTEMPTS; attempt += 1) {\n    try {\n      // Only the FIRST attempt may resurrect: reaching a retry means the row is\n      // live, and an ordinary update is what converges on it.\n      return await performNodeUpdate(\n        ctx,\n        input,\n        session,\n        target,\n        attempt === 1 ? options\n        : options?.replacementProps === undefined ? undefined\n        : { replacementProps: options.replacementProps },\n        attempt === 1 ? resolvedExisting : undefined,\n      );\n    } catch (error) {\n      if (!isNodeUpdateNoRowError(error) || attempt === NODE_UPDATE_ATTEMPTS) {\n        throw nodeUpdateRaceError(input, error);\n      }\n      const current = await target.getNode(ctx.graphId, input.kind, input.id);\n      if (current === undefined || current.deleted_at !== undefined) {\n        throw new NodeNotFoundError(input.kind, input.id);\n      }\n    }\n  }\n  // Unreachable: the loop either returns or throws on its last attempt.\n  throw new NodeNotFoundError(input.kind, input.id);\n}\n\n/**\n * The error a caller sees when a node update exhausts its attempts, or fails\n * with something that is not the zero-row sentinel.\n *\n * A non-sentinel error passes through untouched. The sentinel does not: it says\n * \"the statement matched nothing\", which after {@link NODE_UPDATE_ATTEMPTS}\n * rounds means a peer is replacing this row faster than this writer can read\n * it. That is a contention fact, and it is reported as one rather than as a\n * missing node — the node is present, it just is not staying still.\n */\nfunction nodeUpdateRaceError(\n  input: UpsertUpdateNodeInput,\n  error: unknown,\n): unknown {\n  if (!isNodeUpdateNoRowError(error)) return error;\n  return new DatabaseOperationError(\n    `Node update for ${input.kind} \"${input.id}\" could not be applied to a stable row after ${NODE_UPDATE_ATTEMPTS} attempts: the row was removed and recreated between each read and its write. A concurrent writer is replacing this node faster than it can be read; serialize the writers, or retry.`,\n    {\n      operation: \"update\",\n      entity: \"node\",\n      attempted: [{ kind: input.kind, id: input.id }],\n    },\n    { cause: error },\n  );\n}\n\n// ============================================================\n// Shared Batch Preparation\n//\n// Both returning and non-returning batch creates share the same\n// validate-and-register loop. This extracts it.\n// ============================================================\n\n/**\n * Primes the batch validation caches with batched reads: one `getNodes`\n * per kind for existence probes and one `checkUniqueBatch` per\n * (constraint, kind) for uniqueness pre-checks. The per-row checks in\n * {@link finishNodeCreatePreparation} then hit memory instead of issuing\n * one probe per row. Backends without the batch primitives skip priming\n * and keep the per-row fallback.\n */\nexport async function primeBatchValidationCaches(\n  ctx: Readonly<{\n    graphId: string;\n    registry: KindRegistry;\n    batchPointRead: BundleVerdictOf<typeof BATCH_POINT_READ>;\n    uniqueSidecarBatch: BundleVerdictOf<typeof UNIQUE_SIDECAR_BATCH>;\n  }>,\n  drafts: readonly NodeCreateDraft[],\n  backend: WriteTarget,\n  seams: Readonly<{\n    seedNodeRow: (kind: string, id: string, row: CachedNodeRow) => void;\n    seedUniqueRow: (\n      kind: string,\n      constraintName: string,\n      key: string,\n      row: CachedUniqueRow,\n    ) => void;\n  }>,\n): Promise<void> {\n  const boundGetNodes = bindExtraIfReachable(\n    backend,\n    ctx.batchPointRead.extras.getNodes,\n    BATCH_POINT_READ.id,\n  );\n  if (boundGetNodes !== undefined) {\n    const idsByKind = new Map<string, Set<string>>();\n    for (const draft of drafts) {\n      // Generated ids follow the same insert-first contract as the singleton\n      // create path: there is no existing row to classify or resurrect, and a\n      // vanishingly unlikely primary-key collision is authoritatively refused\n      // by the INSERT. Priming those ids performed a guaranteed-empty read and\n      // added one transport exchange to every generated-id bulk create.\n      if (!draft.idProvided) continue;\n      const ids = idsByKind.get(draft.kind) ?? new Set<string>();\n      ids.add(draft.id);\n      idsByKind.set(draft.kind, ids);\n    }\n    for (const [kind, ids] of idsByKind) {\n      const orderedIds = [...ids];\n      const rows = await boundGetNodes.getNodes(ctx.graphId, kind, orderedIds);\n      const rowsById = new Map(rows.map((row) => [row.id, row]));\n      for (const id of orderedIds) {\n        seams.seedNodeRow(kind, id, rowsById.get(id));\n      }\n    }\n  }\n\n  const boundCheckUniqueBatch = bindExtraIfReachable(\n    backend,\n    ctx.uniqueSidecarBatch.extras.checkUniqueBatch,\n    UNIQUE_SIDECAR_BATCH.id,\n  );\n  if (boundCheckUniqueBatch !== undefined) {\n    const groups = groupNodeUniquenessProbes(\n      ctx.registry,\n      drafts.map((draft) => ({\n        kind: draft.kind,\n        entries: nodeClaimEntries(\n          ctx.registry,\n          draft.kind,\n          draft.id,\n          draft.validatedProps,\n          draft.uniqueConstraints,\n          \"create\",\n        ),\n      })),\n    );\n    for (const group of groups) {\n      const rows = await boundCheckUniqueBatch.checkUniqueBatch({\n        graphId: ctx.graphId,\n        nodeKind: group.nodeKind,\n        constraintName: group.constraintName,\n        keys: group.keys,\n      });\n      const rowsByKey = new Map(rows.map((row) => [row.key, row]));\n      for (const key of group.keys) {\n        seams.seedUniqueRow(\n          group.nodeKind,\n          group.constraintName,\n          key,\n          rowsByKey.get(key),\n        );\n      }\n    }\n  }\n}\n\nasync function prepareBatchCreates<G extends GraphDef>(\n  ctx: NodeOperationContext<G>,\n  inputs: readonly CreateNodeInput[],\n  backend: WriteTarget,\n  options?: NodeCreateInternalOptions,\n): Promise<readonly NodeCreatePrepared[]> {\n  const {\n    reader: validationBackend,\n    registerPendingNode,\n    registerPendingUniqueEntries,\n    seedNodeRow,\n    seedUniqueRow,\n  } = createNodeBatchValidationSeams(ctx.graphId, ctx.registry, backend);\n\n  // Pass 1 (synchronous): validate every input and assign ids. This\n  // surfaces a later row's validation error before an earlier row's\n  // constraint error — both fail the whole batch, so ordering across\n  // error categories is not part of the contract.\n  const drafts = inputs.map((input) =>\n    draftNodeCreate(ctx, input, input.id ?? generateId(), options),\n  );\n\n  await primeBatchValidationCaches(ctx, drafts, backend, {\n    seedNodeRow,\n    seedUniqueRow,\n  });\n\n  // Pass 2: per-row constraint checks against the primed caches, in input\n  // order, registering pendings so later rows see earlier ones.\n  const preparedCreates: NodeCreatePrepared[] = [];\n  for (const draft of drafts) {\n    const prepared = await finishNodeCreatePreparation(\n      ctx,\n      draft,\n      validationBackend,\n      false,\n    );\n    preparedCreates.push(prepared);\n    registerPendingNode(prepared.insertParams);\n    registerPendingUniqueEntries(\n      prepared.kind,\n      prepared.id,\n      prepared.validatedProps,\n      prepared.uniqueConstraints,\n    );\n  }\n\n  return preparedCreates;\n}\n\n/**\n * Prepares the closed atomic node-batch shape without any external reads.\n *\n * The draft and claim planners remain the owners of validation and claim\n * semantics. The atomic backend owns row-state semantics, so this preparation\n * records the caller/generated source for every id and rejects duplicate\n * (graph, kind, id) inputs before dispatch.\n */\nasync function prepareAtomicBatchCreates<G extends GraphDef>(\n  ctx: NodeOperationContext<G>,\n  inputs: readonly CreateNodeInput[],\n  backend: WriteTarget,\n  options?: NodeCreateInternalOptions,\n): Promise<readonly NodeCreatePrepared[]> {\n  const drafts = inputs.map((input) =>\n    draftNodeCreate(ctx, input, input.id ?? generateId(), options),\n  );\n\n  const seen = new Set<string>();\n  for (const draft of drafts) {\n    const key = buildNodeCacheKey(ctx.graphId, draft.kind, draft.id);\n    if (seen.has(key)) {\n      throw createAlreadyExistsError(\"node\", draft.kind, draft.id);\n    }\n    seen.add(key);\n  }\n\n  return Promise.all(\n    drafts.map(async (draft) => {\n      const claimPlan = planNodeCreateClaims(\n        { graphId: ctx.graphId, registry: ctx.registry },\n        {\n          kind: draft.kind,\n          id: draft.id,\n          props: draft.validatedProps,\n          constraints: draft.uniqueConstraints,\n        },\n      );\n      return finishNodeCreatePreparation(\n        ctx,\n        draft,\n        backend,\n        false,\n        \"atomic-batch\",\n        claimPlan,\n      );\n    }),\n  );\n}\n\nfunction atomicNodeBatchEntries(\n  preparedCreates: readonly NodeCreatePrepared[],\n  claimSupport: AtomicNodeClaimSupport | undefined,\n): readonly AtomicNodeBatchEntry[] | undefined {\n  const entries: AtomicNodeBatchEntry[] = [];\n  const ownerByClaimTarget = new Map<\n    string,\n    Readonly<{ kind: string; id: string }>\n  >();\n  for (const prepared of preparedCreates) {\n    const projections = resolveAtomicNodeProjections(\n      prepared.nodeKind.schema,\n      prepared.validatedProps,\n      { omitEmbeddingDeletes: !prepared.idProvided },\n    );\n    if (prepared.claimPlan.claims.length === 0) {\n      entries.push({\n        idSource: prepared.idProvided ? \"caller\" : \"generated\",\n        params: prepared.insertParams,\n        projections,\n      });\n      continue;\n    }\n\n    const rephased = rephaseAtomicNodeClaimPlan(\n      {\n        entity: \"node\",\n        params: prepared.insertParams,\n        idGenerated: !prepared.idProvided,\n        mode: { kind: \"ordinary\" },\n        claims: prepared.claimPlan.claims,\n        projections: [],\n      },\n      claimSupport,\n    );\n    if (rephased === undefined) return;\n    for (const claim of rephased.claims) {\n      const targetKey = encodeTupleKey([\n        prepared.insertParams.graphId,\n        claim.axis,\n        claim.constraintName,\n        claim.key,\n      ]);\n      const existingOwner = ownerByClaimTarget.get(targetKey);\n      if (existingOwner !== undefined) {\n        const error = new UniquenessError({\n          constraintName: claim.constraintName,\n          kind: existingOwner.kind,\n          existingId: existingOwner.id,\n          newId: prepared.id,\n          fields:\n            claim.verdict.kind === \"uniqueness\" ? claim.verdict.fields : [],\n          axis: claim.axis,\n        });\n        refuseNodeCreateClaimError(error, prepared.claimPlan);\n      }\n      ownerByClaimTarget.set(targetKey, {\n        kind: prepared.kind,\n        id: prepared.id,\n      });\n    }\n    entries.push({\n      idSource: prepared.idProvided ? \"caller\" : \"generated\",\n      params: prepared.insertParams,\n      claims: rephased.claims,\n      projections,\n    });\n  }\n  if (\n    entries.some(\n      (entry) => !supportsAtomicNodeClaims(claimSupport, entry.claims ?? []),\n    )\n  ) {\n    return;\n  }\n  return entries;\n}\n\n/**\n * Validates a replacement document once for both atomic and portable paths.\n * The portable update carries this complete postimage through its internal\n * replacement marker instead of parsing or merging it again.\n */\nexport function prepareNodeReplacement<G extends GraphDef>(\n  ctx: NodeOperationContext<G>,\n  kind: string,\n  props: Record<string, unknown>,\n): Record<string, unknown> {\n  const schema = getNodeRegistration(ctx.graph, kind).type.schema;\n  return validateNodeProps(schema, props, { kind, operation: \"update\" });\n}\n\n/**\n * Attempts one read-free, schema-fenced replacement program.\n *\n * `unsupported` proves that no SQL ran; the collection then enters the full\n * portable upsert path with the replacement patches prepared above.\n */\nexport async function executeNodeReplacementBatch<G extends GraphDef>(\n  ctx: NodeOperationContext<G>,\n  kind: string,\n  items: readonly Readonly<{ id: string; props: Record<string, unknown> }>[],\n  backend: GraphBackend | TransactionBackend,\n): Promise<ResolvedMutationSetAttempt<readonly Node[]>> {\n  if (items.length === 0) return appliedResolvedMutationSet([]);\n  const program = resolveAtomicNodeReplacementBatchProgram({\n    backend,\n    graph: ctx.graph,\n    registry: ctx.registry,\n    kind,\n    entryCount: items.length,\n    schemaVersion: ctx.schemaVersion,\n    identityEnabled: ctx.identity !== undefined,\n    historyEnabled: ctx.historyEnabled,\n    revisionTrackingEnabled: ctx.revisionTrackingEnabled,\n  });\n  if (program === undefined) return unsupportedResolvedMutationSet();\n  const { executor, releaseClaims } = program;\n\n  const inputs = items.map((item) => ({\n    kind,\n    id: item.id,\n    props: item.props,\n  }));\n  const preparedCreates = await prepareAtomicBatchCreates(\n    ctx,\n    inputs,\n    backend,\n    { propsPreValidated: true },\n  );\n  const createEntries = atomicNodeBatchEntries(\n    preparedCreates,\n    executor.claimSupport,\n  );\n  if (createEntries === undefined) return unsupportedResolvedMutationSet();\n  const entries: readonly AtomicNodeReplacementEntry[] = createEntries.map(\n    ({ params, claims, projections }) => ({\n      params,\n      ...(claims === undefined ? {} : { claims }),\n      ...(projections === undefined ? {} : { projections }),\n    }),\n  );\n  if (executor.accepts?.(entries) === false) {\n    return unsupportedResolvedMutationSet();\n  }\n  const returnedRows = await withAtomicNodeClaimTranslation(\n    preparedCreates,\n    () =>\n      executor({\n        entries,\n        releaseClaims,\n        schemaFence: {\n          graphId: ctx.graphId,\n          expectedVersion: requireDefined(ctx.schemaVersion),\n        },\n      }),\n  );\n  if (returnedRows.length === 0) {\n    await diagnoseAtomicNodeBatchNoRow(ctx, backend, preparedCreates);\n  }\n  if (returnedRows.length !== items.length) {\n    throw new DatabaseOperationError(\n      \"Atomic node replacement returned a partial result.\",\n      {\n        operation: \"upsert\",\n        entity: \"node\",\n        attempted: items.map((item) => ({ kind, id: item.id })),\n      },\n    );\n  }\n  memoizeLeasedSchemaFence(ctx, backend);\n  return appliedResolvedMutationSet(\n    restoreAtomicNodeBatchRows(ctx.graphId, preparedCreates, returnedRows).map(\n      (row) => rowToNode(row),\n    ),\n  );\n}\n\nasync function withAtomicNodeClaimTranslation<TResult>(\n  preparedCreates: readonly NodeCreatePrepared[],\n  execute: () => Promise<TResult>,\n): Promise<TResult> {\n  try {\n    return await execute();\n  } catch (error) {\n    refuseNodeCreateClaimError(error, {\n      entries: preparedCreates.flatMap(\n        (prepared) => prepared.claimPlan.entries,\n      ),\n      claims: preparedCreates.flatMap((prepared) => prepared.claimPlan.claims),\n      verdicts: preparedCreates.flatMap(\n        (prepared) => prepared.claimPlan.verdicts,\n      ),\n    });\n  }\n}\n\n/** Bounds concurrent custom-backend reads on the exceptional diagnosis path. */\nconst ATOMIC_NODE_CLAIM_DIAGNOSTIC_WINDOW_SIZE = 32;\n\ntype AtomicNodeClaimDiagnosticVerdict =\n  Readonly<{ kind: \"clear\" }> | Readonly<{ kind: \"refusal\"; error: unknown }>;\n\nconst ATOMIC_NODE_CLAIM_CLEAR = { kind: \"clear\" } as const;\n\nasync function captureAtomicNodeClaimDiagnosticVerdicts(\n  preparedCreates: readonly NodeCreatePrepared[],\n  diagnose: (prepared: NodeCreatePrepared) => Promise<void>,\n): Promise<readonly AtomicNodeClaimDiagnosticVerdict[]> {\n  return Promise.all(\n    preparedCreates.map(async (prepared) => {\n      try {\n        await diagnose(prepared);\n        return ATOMIC_NODE_CLAIM_CLEAR;\n      } catch (error) {\n        return { kind: \"refusal\" as const, error };\n      }\n    }),\n  );\n}\n\nasync function runAtomicNodeClaimDiagnosticGroups<T>(\n  groups: readonly T[],\n  read: (group: T) => Promise<void>,\n): Promise<void> {\n  for (const window of chunk(\n    groups,\n    ATOMIC_NODE_CLAIM_DIAGNOSTIC_WINDOW_SIZE,\n  )) {\n    await Promise.all(window.map(async (group) => read(group)));\n  }\n}\n\nasync function diagnoseAtomicNodeDisjointness<G extends GraphDef>(\n  ctx: NodeOperationContext<G>,\n  backend: GraphBackend | TransactionBackend,\n  preparedCreates: readonly NodeCreatePrepared[],\n): Promise<readonly AtomicNodeClaimDiagnosticVerdict[]> {\n  const boundGetNodes = bindExtraIfReachable(\n    backend,\n    ctx.batchPointRead.extras.getNodes,\n    BATCH_POINT_READ.id,\n  );\n  const constraintContext: ConstraintContext = {\n    graphId: ctx.graphId,\n    registry: ctx.registry,\n    backend,\n  };\n  if (boundGetNodes === undefined) {\n    return captureAtomicNodeClaimDiagnosticVerdicts(\n      preparedCreates,\n      async (prepared) =>\n        checkDisjointnessConstraint(\n          constraintContext,\n          prepared.kind,\n          prepared.id,\n        ),\n    );\n  }\n\n  type DisjointReadGroup = Readonly<{ kind: string; ids: Set<string> }>;\n  const disjointKindsByInput = preparedCreates.map((prepared) =>\n    ctx.registry.getDisjointKinds(prepared.kind),\n  );\n  const groupsByKind = new Map<string, DisjointReadGroup>();\n  for (const [index, prepared] of preparedCreates.entries()) {\n    for (const kind of requireDefined(disjointKindsByInput[index])) {\n      const group = groupsByKind.get(kind) ?? { kind, ids: new Set<string>() };\n      group.ids.add(prepared.id);\n      groupsByKind.set(kind, group);\n    }\n  }\n\n  const rowsByReference = new Map<string, BackendNodeRow>();\n  await runAtomicNodeClaimDiagnosticGroups(\n    [...groupsByKind.values()],\n    async (group) => {\n      const rows = await boundGetNodes.getNodes(ctx.graphId, group.kind, [\n        ...group.ids,\n      ]);\n      for (const row of rows) {\n        rowsByReference.set(refKey({ kind: row.kind, id: row.id }), row);\n      }\n    },\n  );\n\n  return preparedCreates.map((prepared, index) => {\n    for (const conflictingKind of requireDefined(disjointKindsByInput[index])) {\n      const row = rowsByReference.get(\n        refKey({ kind: conflictingKind, id: prepared.id }),\n      );\n      if (row === undefined || !isLiveNodeRow(row)) continue;\n      const error = checkDisjointness(\n        prepared.id,\n        prepared.kind,\n        [conflictingKind],\n        ctx.registry,\n      );\n      if (error !== undefined) return { kind: \"refusal\" as const, error };\n    }\n    return ATOMIC_NODE_CLAIM_CLEAR;\n  });\n}\n\nasync function diagnoseAtomicNodeUniqueness<G extends GraphDef>(\n  ctx: NodeOperationContext<G>,\n  backend: GraphBackend | TransactionBackend,\n  preparedCreates: readonly NodeCreatePrepared[],\n): Promise<readonly AtomicNodeClaimDiagnosticVerdict[]> {\n  const boundCheckUniqueBatch = bindExtraIfReachable(\n    backend,\n    ctx.uniqueSidecarBatch.extras.checkUniqueBatch,\n    UNIQUE_SIDECAR_BATCH.id,\n  );\n  const uniquenessContext = createUniquenessContext(\n    ctx.graphId,\n    ctx.registry,\n    backend,\n    ctx.uniqueSidecarBatch,\n  );\n  if (boundCheckUniqueBatch === undefined) {\n    return captureAtomicNodeClaimDiagnosticVerdicts(\n      preparedCreates,\n      async (prepared) =>\n        checkUniquenessConstraints(\n          uniquenessContext,\n          prepared.kind,\n          prepared.id,\n          prepared.validatedProps,\n          prepared.uniqueConstraints,\n        ),\n    );\n  }\n\n  const probeItems = preparedCreates.map((prepared) => ({\n    kind: prepared.kind,\n    entries: nodeClaimEntries(\n      ctx.registry,\n      prepared.kind,\n      prepared.id,\n      prepared.validatedProps,\n      prepared.uniqueConstraints,\n      \"create\",\n    ),\n  }));\n  const groups = groupNodeUniquenessProbes(ctx.registry, probeItems);\n\n  const rowsByTarget = new Map<string, UniqueRow>();\n  await runAtomicNodeClaimDiagnosticGroups(groups, async (group) => {\n    const rows = await boundCheckUniqueBatch.checkUniqueBatch({\n      graphId: ctx.graphId,\n      nodeKind: group.nodeKind,\n      constraintName: group.constraintName,\n      keys: group.keys,\n    });\n    for (const row of rows) {\n      rowsByTarget.set(\n        encodeTupleKey([group.nodeKind, group.constraintName, row.key]),\n        row,\n      );\n    }\n  });\n\n  return Promise.all(\n    preparedCreates.map(async (prepared, index) => {\n      for (const entry of requireDefined(probeItems[index]).entries) {\n        if (!isUniquenessClaimEntry(entry)) continue;\n        try {\n          await probeUniqueKey(\n            uniquenessContext,\n            prepared.kind,\n            prepared.id,\n            entry,\n            (nodeKind, claimEntry) =>\n              rowsByTarget.get(\n                encodeTupleKey([\n                  nodeKind,\n                  claimEntry.constraintName,\n                  claimEntry.key,\n                ]),\n              ),\n          );\n        } catch (error) {\n          return { kind: \"refusal\" as const, error };\n        }\n      }\n      return ATOMIC_NODE_CLAIM_CLEAR;\n    }),\n  );\n}\n\n/**\n * Diagnoses a database-enforced all-or-nothing claim refusal after rollback.\n *\n * The atomic program deliberately reports only the rollback sentinel: claim\n * ownership is read again from committed state so a successful sibling chunk\n * can never be mistaken for permission to commit. These are the same portable\n * verdict owners used outside the native program, preserving their typed errors\n * and input order on the failure-only path.\n */\nasync function diagnoseAtomicNodeBatchNoRow<G extends GraphDef>(\n  ctx: NodeOperationContext<G>,\n  backend: GraphBackend | TransactionBackend,\n  preparedCreates: readonly NodeCreatePrepared[],\n): Promise<never> {\n  await diagnoseFusedSchemaFenceNoRow(ctx, backend);\n  const hasSetOrientedDiagnosis =\n    bindExtraIfReachable(\n      backend,\n      ctx.batchPointRead.extras.getNodes,\n      BATCH_POINT_READ.id,\n    ) !== undefined &&\n    bindExtraIfReachable(\n      backend,\n      ctx.uniqueSidecarBatch.extras.checkUniqueBatch,\n      UNIQUE_SIDECAR_BATCH.id,\n    ) !== undefined;\n  const diagnosticWindows =\n    hasSetOrientedDiagnosis ?\n      [preparedCreates]\n    : chunk(preparedCreates, ATOMIC_NODE_CLAIM_DIAGNOSTIC_WINDOW_SIZE);\n  for (const window of diagnosticWindows) {\n    const [disjointnessVerdicts, uniquenessVerdicts] =\n      hasSetOrientedDiagnosis ?\n        await Promise.all([\n          diagnoseAtomicNodeDisjointness(ctx, backend, window),\n          diagnoseAtomicNodeUniqueness(ctx, backend, window),\n        ])\n      : [\n          await diagnoseAtomicNodeDisjointness(ctx, backend, window),\n          await diagnoseAtomicNodeUniqueness(ctx, backend, window),\n        ];\n    for (const [index] of window.entries()) {\n      const disjointness = requireDefined(disjointnessVerdicts[index]);\n      if (disjointness.kind === \"refusal\") throw disjointness.error;\n      const uniqueness = requireDefined(uniquenessVerdicts[index]);\n      if (uniqueness.kind === \"refusal\") throw uniqueness.error;\n    }\n  }\n  throw new DatabaseOperationError(\n    \"Atomic node batch returned no postimages, but current schema-fence and \" +\n      \"claim state do not explain the refusal. Database state may have \" +\n      \"changed after the atomic program rolled back.\",\n    {\n      operation: \"insert\",\n      entity: \"node\",\n      attempted: preparedCreates.map((prepared) => ({\n        kind: prepared.kind,\n        id: prepared.id,\n      })),\n    },\n  );\n}\n\n/**\n * The backend may return rows in any order. Validate the complete result set\n * before restoring caller order so a malformed native result cannot silently\n * attach one returned payload to another input.\n */\nfunction restoreAtomicNodeBatchRows(\n  graphId: string,\n  preparedCreates: readonly NodeCreatePrepared[],\n  returnedRows: readonly BackendNodeRow[],\n): readonly BackendNodeRow[] {\n  const rowsByReference = new Map<string, BackendNodeRow>();\n  for (const row of returnedRows) {\n    if (row.graph_id !== graphId) {\n      throw new CompilerInvariantError(\n        \"Atomic node batch returned a row for the wrong graph.\",\n        { expectedGraphId: graphId, actualGraphId: row.graph_id },\n      );\n    }\n    const key = refKey({ kind: row.kind, id: row.id });\n    if (rowsByReference.has(key)) {\n      throw new CompilerInvariantError(\n        \"Atomic node batch returned duplicate node references.\",\n        { kind: row.kind, id: row.id },\n      );\n    }\n    rowsByReference.set(key, row);\n  }\n\n  return preparedCreates.map((prepared) => {\n    const row = rowsByReference.get(\n      refKey({ kind: prepared.kind, id: prepared.id }),\n    );\n    if (row === undefined) {\n      throw new CompilerInvariantError(\n        \"Atomic node batch omitted a written node row.\",\n        { kind: prepared.kind, id: prepared.id },\n      );\n    }\n    return row;\n  });\n}\n\ntype CreatePartition = Readonly<{\n  inserts: readonly NodeCreatePrepared[];\n  resurrections: readonly NodeCreatePrepared[];\n}>;\n\n/**\n * Splits prepared creates into fresh inserts and tombstone resurrections.\n *\n * Purely in-memory: preparation already read each id's row under this write\n * lock (batched through `getNodes` when the backend has it, per-row through\n * the validation cache otherwise) and carried it on the prepared record, so\n * routing costs no additional round trip.\n */\nfunction partitionCreates(\n  preparedCreates: readonly NodeCreatePrepared[],\n): CreatePartition {\n  const inserts: NodeCreatePrepared[] = [];\n  const resurrections: NodeCreatePrepared[] = [];\n\n  for (const prepared of preparedCreates) {\n    if (prepared.tombstone === undefined) {\n      inserts.push(prepared);\n    } else {\n      resurrections.push(prepared);\n    }\n  }\n  return { inserts, resurrections };\n}\n\nfunction isNodeUpdateNoRowError(\n  error: unknown,\n): error is DatabaseOperationError {\n  return (\n    error instanceof DatabaseOperationError &&\n    error.details.operation === \"update\" &&\n    error.details.entity === \"node\" &&\n    error.details.reason === \"no_row_returned\"\n  );\n}\n\nasync function resurrectPreparedNode<G extends GraphDef>(\n  ctx: NodeOperationContext<G>,\n  session: NodeWriteSession,\n  target: WriteTarget,\n  prepared: NodeCreatePrepared,\n): Promise<BackendNodeRow> {\n  const current = await target.getNode(ctx.graphId, prepared.kind, prepared.id);\n  if (current === undefined) {\n    throw new DatabaseOperationError(\n      `Node tombstone disappeared before resurrection: ${prepared.kind} ${prepared.id}`,\n      { operation: \"update\", entity: \"node\" },\n    );\n  }\n  if (current.deleted_at === undefined) {\n    throw createAlreadyExistsError(\"node\", prepared.kind, prepared.id);\n  }\n  // A create landing on a tombstone RESETS the window, so this leg stamps a\n  // bound whenever the caller stated none — and it decides which one through\n  // the same owner `performNodeUpdate`'s resurrection leg and every insert\n  // builder use, against an instant sampled HERE. Two consequences. The stored\n  // bound is the one this layer judged rather than the backend's strictly later\n  // sample, so one write has one instant (issue #413). And a create carrying\n  // only a historical `validTo` reaches the same stored shape on a tombstoned\n  // id as on a fresh one — no lower bound (I12).\n  const resurrectionInstant = nowIso();\n  const resurrectionBound = resolveStampedValidityLowerBound(\n    prepared.insertParams.validFrom,\n    prepared.insertParams.validTo,\n    resurrectionInstant,\n  );\n  try {\n    return await session.reviseNode(\n      {\n        existing: current,\n        clearDeleted: true,\n        schema: prepared.nodeKind.schema,\n        validatedProps: prepared.validatedProps,\n        uniqueConstraints: prepared.uniqueConstraints,\n        // The decision itself, never an absence — see the same spelling on\n        // `performNodeUpdate`'s resurrection leg.\n        // eslint-disable-next-line unicorn/no-null -- `validFrom: null` means \"store NULL\"; omitting the key means \"decide for me\", and this path has already decided. See UpdateNodeParams.validFrom.\n        validFrom: resurrectionBound ?? null,\n        ...(prepared.insertParams.validTo === undefined ?\n          {}\n        : { validTo: prepared.insertParams.validTo }),\n      },\n      // This resurrection reads no stored bound: it rewrites the whole window\n      // and is fenced by the UPDATE's own `deleted_at IS NOT NULL` predicate,\n      // so it asserts nothing about `valid_from`. `{}` is how a write states\n      // that, and it is the only way to state it.\n      { validityLowerBound: {} },\n    );\n  } catch (error) {\n    if (!isNodeUpdateNoRowError(error)) throw error;\n    // The UPDATE itself has a tombstone predicate, closing the remaining gap\n    // between the re-read and write. Translate a peer resurrection into the\n    // create API's stable duplicate error instead of leaking a 0-row update.\n    const afterFailure = await target.getNode(\n      ctx.graphId,\n      prepared.kind,\n      prepared.id,\n    );\n    if (afterFailure !== undefined && afterFailure.deleted_at === undefined) {\n      throw createAlreadyExistsError(\"node\", prepared.kind, prepared.id);\n    }\n    throw error;\n  }\n}\n\n// ============================================================\n// Shared Constraint Lookup\n//\n// Both single and bulk find/getOrCreate operations need to look up\n// unique constraint entries across all applicable kinds.\n// ============================================================\n\n/**\n * THE preference rule when a key has claim rows at more than one kind — which a\n * database carrying pre-axis rows legitimately can, at the axis AND at a\n * concrete kind, with different owners:\n *\n * 1. Visit the AXIS first, then the remaining kinds in scope in code-point\n *    order — the order {@link uniquenessProbeKinds} defines, so this reads what\n *    the write path claims before it reads what an older version claimed.\n * 2. Prefer a LIVE row over a tombstoned one, wherever each was found: a\n *    tombstone is a released reservation, and reviving it while a live holder\n *    exists would hand the caller the wrong node.\n * 3. Among rows of the same liveness prefer the axis row, which rule 1 already\n *    delivers.\n *\n * Stated rather than left to iteration order because `getOrCreateByConstraint`\n * decides which node to revive from it.\n */\nfunction prefersClaimRow(\n  incumbent: UniqueMatchRow | undefined,\n  candidate: UniqueMatchRow,\n): boolean {\n  if (incumbent === undefined) return true;\n  return (\n    incumbent.deleted_at !== undefined && candidate.deleted_at === undefined\n  );\n}\n\nasync function findUniqueRowAcrossKinds(\n  backend: WriteTarget,\n  graphId: string,\n  constraintName: string,\n  key: string,\n  kindsToCheck: readonly string[],\n  includeDeleted: boolean,\n): Promise<UniqueMatchRow | undefined> {\n  // `let` earns its place: a tombstoned hit does not end the search, because a\n  // live row later in the order outranks it (rule 2).\n  let preferred: UniqueMatchRow | undefined;\n  for (const kindToCheck of kindsToCheck) {\n    const row = await backend.checkUnique({\n      graphId,\n      nodeKind: kindToCheck,\n      constraintName,\n      key,\n      includeDeleted,\n    });\n    if (row === undefined) continue;\n    if (!prefersClaimRow(preferred, row)) continue;\n    preferred = row;\n    if (row.deleted_at === undefined) return row;\n  }\n  return preferred;\n}\n\ninterface UniqueMatchRow {\n  node_id: string;\n  concrete_kind: string;\n  deleted_at: string | undefined;\n}\n\nasync function batchCheckUniqueAcrossKinds(\n  backend: WriteTarget,\n  uniqueSidecarBatch: BundleVerdictOf<typeof UNIQUE_SIDECAR_BATCH>,\n  graphId: string,\n  constraintName: string,\n  uniqueKeys: readonly string[],\n  kindsToCheck: readonly string[],\n  includeDeleted: boolean,\n): Promise<Map<string, UniqueMatchRow>> {\n  const existingByKey = new Map<string, UniqueMatchRow>();\n  const boundCheckUniqueBatch = bindExtraIfReachable(\n    backend,\n    uniqueSidecarBatch.extras.checkUniqueBatch,\n    UNIQUE_SIDECAR_BATCH.id,\n  );\n\n  for (const kindToCheck of kindsToCheck) {\n    if (boundCheckUniqueBatch === undefined) {\n      for (const key of uniqueKeys) {\n        const incumbent = existingByKey.get(key);\n        if (incumbent !== undefined && incumbent.deleted_at === undefined) {\n          continue;\n        }\n        const row = await backend.checkUnique({\n          graphId,\n          nodeKind: kindToCheck,\n          constraintName,\n          key,\n          includeDeleted,\n        });\n        if (row !== undefined && prefersClaimRow(incumbent, row)) {\n          existingByKey.set(row.key, row);\n        }\n      }\n    } else {\n      const rows = await boundCheckUniqueBatch.checkUniqueBatch({\n        graphId,\n        nodeKind: kindToCheck,\n        constraintName,\n        keys: uniqueKeys,\n        includeDeleted,\n      });\n      for (const row of rows) {\n        if (prefersClaimRow(existingByKey.get(row.key), row)) {\n          existingByKey.set(row.key, row);\n        }\n      }\n    }\n  }\n\n  return existingByKey;\n}\n\n// ============================================================\n// Node Create Operations\n// ============================================================\n\nasync function executeNodeCreateInternal<G extends GraphDef>(\n  ctx: NodeOperationContext<G>,\n  input: CreateNodeInput,\n  backend: GraphBackend | TransactionBackend,\n  options?: Readonly<{ returnRow?: boolean }> & NodeCreateInternalOptions,\n): Promise<Node | undefined> {\n  const kind = input.kind;\n  const id = input.id ?? generateId();\n  const opContext = ctx.createOperationContext(\"create\", \"node\", kind, id);\n  const shouldReturnRow = options?.returnRow ?? true;\n  const autocommitBackend =\n    isBundledRootAutocommitEligible(backend) ? backend : undefined;\n  const registeredKind =\n    hasOwnKey(ctx.graph.nodes, kind) ?\n      getNodeRegistration(ctx.graph, kind)\n    : undefined;\n  const candidate =\n    registeredKind === undefined ? undefined : (\n      ({\n        backend,\n        schemaVersion: ctx.schemaVersion,\n        historyEnabled: ctx.historyEnabled,\n        revisionTrackingEnabled: ctx.revisionTrackingEnabled,\n        identityEnabled: ctx.identity !== undefined,\n        idGenerated: input.id === undefined,\n        kindRegistered: true,\n        uniqueConstraintCount: registeredKind.unique?.length ?? 0,\n        disjointKindCount: ctx.registry.getDisjointKinds(kind).length,\n        schema: registeredKind.type.schema,\n      } as const)\n    );\n  const schemaFenceInFirstWrite =\n    candidate !== undefined &&\n    canFuseSchemaFenceInFirstWrite({ kind: \"node\", candidate });\n  const autocommitSingleStatement =\n    autocommitBackend !== undefined &&\n    candidate !== undefined &&\n    isAutocommitSingleStatementWrite({ kind: \"node\", candidate });\n  const plan = nodeWritePlan(\n    nodeFencesConstraintProbe(ctx, kind, \"create\"),\n    nodeCreateRequiresIdentityLock(ctx, input),\n  );\n\n  const rowWork = async (\n    session: NodeWriteSession,\n    target: WriteTarget,\n    _overlaidSession: OverlaidSessionMint<\"node\">,\n    _lock: GraphWriteLock,\n    transactionMode: WriteTransactionMode,\n  ): Promise<Node | undefined> => {\n    // The outer backend's mark chooses the optimistic plan, but a custom\n    // transaction wrapper can replace its callback target. Re-check the\n    // factory-owned origin at the actual write receiver before letting that\n    // receiver carry the schema fence; otherwise a wrapper that dropped the\n    // ordinary diagnostic fence could silently write a verified store.\n    const targetBackend = unfencedTarget(target);\n    const fuseSchemaFenceInFirstWrite =\n      schemaFenceInFirstWrite &&\n      isSchemaFencedInsertEligible(targetBackend) &&\n      !hasLeasedSchemaFence(ctx, targetBackend);\n    if (schemaFenceInFirstWrite && !fuseSchemaFenceInFirstWrite) {\n      await lockSchemaVersionForStoreWrite(ctx, targetBackend);\n    }\n    const identity = ctx.identity;\n    const draft = draftNodeCreate(ctx, input, id, options);\n    const claimPlan = planNodeCreateClaims(\n      { graphId: ctx.graphId, registry: ctx.registry },\n      {\n        kind: draft.kind,\n        id: draft.id,\n        props: draft.validatedProps,\n        constraints: draft.uniqueConstraints,\n      },\n    );\n    const projections = resolveNodeInsertProjections(\n      draft.nodeKind.schema,\n      draft.validatedProps,\n    );\n    const preparationMode: NodeCreatePreparationMode =\n      (\n        shouldReturnRow &&\n        !fuseSchemaFenceInFirstWrite &&\n        supportsNodeCreatePlan(target, {\n          params: buildInsertNodeParams(\n            ctx.graphId,\n            draft.kind,\n            draft.id,\n            draft.validatedProps,\n            draft.validFrom,\n            draft.validTo,\n          ),\n          idGenerated: !draft.idProvided,\n          mode: { kind: \"ordinary\" },\n          claims: claimPlan.claims,\n          projections,\n          allowNonTransactionalClaims:\n            ctx.identity === undefined &&\n            !ctx.historyEnabled &&\n            !ctx.revisionTrackingEnabled,\n        })\n      ) ?\n        \"authoritative-plan\"\n      : \"probe\";\n    const prepared = await finishNodeCreatePreparation(\n      ctx,\n      draft,\n      target,\n      true,\n      preparationMode,\n      claimPlan,\n    );\n    const projectionFusionEligible =\n      shouldReturnRow && !prepared.idProvided && projections.length > 0;\n    const fuseProjections =\n      projectionFusionEligible &&\n      supportsNodeInsertProjections(target, projections);\n    const fuseSchemaFenceProjections =\n      fuseSchemaFenceInFirstWrite &&\n      projectionFusionEligible &&\n      supportsNodeInsertProjections(target, projections);\n\n    const existing = prepared.tombstone;\n    if (existing !== undefined) {\n      const resurrected = await resurrectPreparedNode(\n        ctx,\n        session,\n        target,\n        prepared,\n      );\n      if (identity !== undefined) {\n        await identity.foldCreated(target, foldReferences([prepared]));\n      }\n      return shouldReturnRow ? rowToNode(resurrected) : undefined;\n    }\n\n    if (fuseSchemaFenceInFirstWrite) {\n      const schemaFence = {\n        graphId: ctx.graphId,\n        expectedVersion: requireDefined(ctx.schemaVersion),\n      };\n      const work =\n        fuseSchemaFenceProjections ?\n          nodeCreateWork(prepared, projections, false)\n        : nodeCreateWork(prepared, [], false);\n      const inserted =\n        prepared.insertIfAbsent ?\n          await session.createNodeIfAbsentWithSchemaFence(work, schemaFence)\n        : await session.createNodeWithSchemaFence(work, schemaFence);\n      if (inserted !== undefined) {\n        memoizeLeasedSchemaFence(ctx, targetBackend);\n        return shouldReturnRow ? rowToNode(inserted) : undefined;\n      }\n\n      // The fused statement's empty result is intentionally ambiguous. Its\n      // ordinary active-schema diagnostic preserves the settled version in\n      // StaleVersionError.details.actual without a second PostgreSQL lock.\n      await diagnoseFusedSchemaFenceNoRow(ctx, targetBackend);\n      // An empty INSERT result does not prove PostgreSQL evaluated the nested\n      // locking subquery: an ON CONFLICT or other zero-row branch can make the\n      // executor skip it. Acquire the portable fence before any fallback read\n      // or later write relies on this transaction's lease.\n      const directInteractiveAutocommit =\n        autocommitSingleStatement &&\n        transactionMode === \"none\" &&\n        targetBackend.capabilities.execution.interactiveTransactions;\n      if (directInteractiveAutocommit) {\n        throw new AutocommitWriteRequiresTransaction();\n      }\n      if (!prepared.insertIfAbsent) {\n        if (transactionMode !== \"none\") {\n          await lockSchemaVersionForStoreWrite(ctx, targetBackend);\n        }\n        throw new DatabaseOperationError(\n          `Fresh node insert returned no row: ${prepared.kind} ${prepared.id}`,\n          { operation: \"insert\", entity: \"node\" },\n        );\n      }\n      // A supplied id's fused statement returned no row because the id is\n      // already occupied (the stale-version case already threw above) — the\n      // occupancy check below re-reads to report the duplicate. On a\n      // transaction this re-fences before that read, matching the\n      // fresh-id branch above; a `\"none\"`-mode target (a batch engine's\n      // fused statement already carried its own fence) has no ordinary\n      // lock to take here.\n      if (transactionMode !== \"none\") {\n        await lockSchemaVersionForStoreWrite(ctx, targetBackend);\n      }\n    }\n\n    if (fuseProjections && !fuseSchemaFenceProjections) {\n      const row = await withAlreadyExistsTranslation(\"node\", () =>\n        session.createNode(\n          nodeCreateWork(\n            prepared,\n            projections,\n            ctx.identity === undefined &&\n              !ctx.historyEnabled &&\n              !ctx.revisionTrackingEnabled,\n          ),\n        ),\n      );\n      return rowToNode(row);\n    }\n\n    if (prepared.insertIfAbsent) {\n      const inserted =\n        fuseSchemaFenceInFirstWrite ? undefined : (\n          await session.createNodeIfAbsent(nodeCreateWork(prepared))\n        );\n      if (inserted !== undefined) {\n        if (identity !== undefined) {\n          await identity.foldCreated(target, foldReferences([prepared]));\n        }\n        return shouldReturnRow ? rowToNode(inserted) : undefined;\n      }\n\n      // `ON CONFLICT DO NOTHING` leaves PostgreSQL's transaction usable. A\n      // single read now classifies the occupied slot, rather than paying it\n      // on every successful caller-supplied-id create.\n      const occupied = await target.getNode(\n        ctx.graphId,\n        prepared.kind,\n        prepared.id,\n      );\n      if (occupied === undefined) {\n        throw new DatabaseOperationError(\n          `Node disappeared after insert-if-absent conflict: ${prepared.kind} ${prepared.id}`,\n          { operation: \"insert\", entity: \"node\" },\n        );\n      }\n      if (occupied.deleted_at === undefined) {\n        throw createAlreadyExistsError(\"node\", prepared.kind, prepared.id);\n      }\n      // The tombstone-slot classification above is a read; resurrecting it is\n      // a genuine write (`session.reviseNode`) outside the fused INSERT's\n      // atomicity. When that INSERT's own no-row diagnosis left the schema\n      // fence untaken for a `\"none\"`-mode target (see above), fail closed\n      // here before the write, matching edge create's identical point.\n      // `lockSchemaVersionForStoreWrite` throws the plain\n      // `SCHEMA_WRITE_FENCE_UNSUPPORTED` limitation here, not\n      // `BATCH_WRITE_UNSUPPORTED`: a tombstone resurrection needs a second\n      // write outside the fused INSERT regardless of `unitOfWork`, which is\n      // not one of `BatchWriteRefusalReason`'s five proven needs (an\n      // interactive callback, a constraint probe, identity, history, or a\n      // schema commit) — it is simply a write shape that cannot fuse, the\n      // same plain limitation an ineligible write kind or a derived backend\n      // reaches through this same call.\n      if (fuseSchemaFenceInFirstWrite && transactionMode === \"none\") {\n        await lockSchemaVersionForStoreWrite(ctx, targetBackend);\n      }\n      const resurrected = await resurrectPreparedNode(\n        ctx,\n        session,\n        target,\n        prepared,\n      );\n      if (identity !== undefined) {\n        await identity.foldCreated(target, foldReferences([prepared]));\n      }\n      return shouldReturnRow ? rowToNode(resurrected) : undefined;\n    }\n\n    // The existence probe above is not the last word: on an engine that does\n    // not serialize the two writers, a concurrent create of the same new id\n    // can commit between the probe and this INSERT, and only the engine's\n    // refusal reports it. Both routes to that conclusion raise the same error.\n    //\n    // The claims are the session's, at their declared placements: the\n    // pre-insert group gates the row and is compensated away if it does not\n    // land, the post-insert group follows it. The translation spans the fused\n    // unit — claims, row AND sidecars — because the session applies them\n    // together. That widening is inert: `isDuplicateKeyInsertError` fires only\n    // on a classified node-INSERT duplicate, which no claim, fulltext or\n    // embedding write raises. The alternative — the session owning the\n    // translation — would change import's create-leg error type on a lost\n    // race, which it must not.\n    const row = await withAlreadyExistsTranslation(\"node\", async () => {\n      const work = nodeCreateWork(\n        prepared,\n        [],\n        ctx.identity === undefined &&\n          !ctx.historyEnabled &&\n          !ctx.revisionTrackingEnabled,\n      );\n      if (shouldReturnRow) return session.createNode(work);\n      await session.createNodeNoReturn(work);\n      return;\n    });\n\n    if (identity !== undefined) {\n      await identity.foldCreated(target, foldReferences([prepared]));\n    }\n\n    if (row === undefined) return;\n    return rowToNode(row);\n  };\n\n  if (autocommitSingleStatement) {\n    return runAutocommitSingleStatementWritePlan(\n      nodeWritePlanContext(ctx),\n      opContext,\n      plan,\n      autocommitBackend,\n      rowWork,\n      { didWrite: writeResultAlwaysChanges },\n    );\n  }\n  return runHookedWritePlan(\n    nodeWritePlanContext(ctx),\n    opContext,\n    plan,\n    backend,\n    rowWork,\n    {\n      schemaFenceInFirstWrite,\n      didWrite: writeResultAlwaysChanges,\n    },\n  );\n}\n\nexport async function executeNodeCreate<G extends GraphDef>(\n  ctx: NodeOperationContext<G>,\n  input: CreateNodeInput,\n  backend: GraphBackend | TransactionBackend,\n  options?: NodeCreateInternalOptions,\n): Promise<Node> {\n  const result = await executeNodeCreateInternal(ctx, input, backend, {\n    returnRow: true,\n    ...options,\n  });\n  if (!result) {\n    throw new DatabaseOperationError(\n      \"Node create failed: expected created node row\",\n      { operation: \"insert\", entity: \"node\" },\n    );\n  }\n  return result;\n}\n\nexport async function executeNodeCreateNoReturn<G extends GraphDef>(\n  ctx: NodeOperationContext<G>,\n  input: CreateNodeInput,\n  backend: GraphBackend | TransactionBackend,\n): Promise<void> {\n  await executeNodeCreateInternal(ctx, input, backend, { returnRow: false });\n}\n\n/**\n * Executes batched node creates without returning inserted node payloads.\n *\n * Note: `withOperationHooks` is intentionally skipped for batch throughput.\n * Per-item hooks would negate the performance benefit of batching.\n */\nexport async function executeNodeCreateNoReturnBatch<G extends GraphDef>(\n  ctx: NodeOperationContext<G>,\n  inputs: readonly CreateNodeInput[],\n  backend: GraphBackend | TransactionBackend,\n): Promise<void> {\n  if (inputs.length === 0) return;\n\n  const atomicExecutor = resolveAtomicNodeBatchExecutor({\n    backend,\n    graph: ctx.graph,\n    registry: ctx.registry,\n    inputs,\n    schemaVersion: ctx.schemaVersion,\n    identityEnabled: ctx.identity !== undefined,\n    historyEnabled: ctx.historyEnabled,\n    revisionTrackingEnabled: ctx.revisionTrackingEnabled,\n  });\n\n  if (atomicExecutor !== undefined) {\n    const preparedCreates = await prepareAtomicBatchCreates(\n      ctx,\n      inputs,\n      backend,\n    );\n    const entries = atomicNodeBatchEntries(\n      preparedCreates,\n      atomicExecutor.claimSupport,\n    );\n    if (entries !== undefined) {\n      const schemaFence = {\n        graphId: ctx.graphId,\n        expectedVersion: requireDefined(ctx.schemaVersion),\n      };\n      const insertedCount = await withAtomicNodeClaimTranslation(\n        preparedCreates,\n        () =>\n          withAlreadyExistsTranslation(\"node\", () =>\n            atomicExecutor({ entries, resultMode: \"count\", schemaFence }),\n          ),\n      );\n      if (insertedCount === 0) {\n        await diagnoseAtomicNodeBatchNoRow(ctx, backend, preparedCreates);\n      }\n      if (insertedCount !== inputs.length) {\n        throw new DatabaseOperationError(\n          `Atomic node batch returned ${insertedCount} rows, expected ${inputs.length}`,\n          {\n            operation: \"insert\",\n            entity: \"node\",\n            attempted: preparedCreates.map((prepared) => ({\n              kind: prepared.kind,\n              id: prepared.id,\n            })),\n          },\n        );\n      }\n      memoizeLeasedSchemaFence(ctx, backend);\n      return;\n    }\n  }\n\n  await runWritePlan(\n    nodeWritePlanContext(ctx),\n    nodeBatchWritePlan(\n      nodeBatchConstraintProbes(ctx, inputs, \"create\"),\n      nodeBatchCreateRequiresIdentityLock(ctx, inputs),\n    ),\n    backend,\n    async (session, target) => {\n      const identity = ctx.identity;\n      const preparedCreates = await prepareBatchCreates(ctx, inputs, target);\n\n      const partition = partitionCreates(preparedCreates);\n      // ## Resurrections follow the whole insert unit\n      //\n      // The batch INSERT, its claim groups and its sidecar batch are ONE session\n      // call, so the resurrection updates that used to run BETWEEN the insert and\n      // the fans now run after all of them. That is the one statement-order\n      // difference this migration makes, and it is safe because the two groups\n      // touch disjoint rows: a prepared create is either an insert or a\n      // resurrection, never both, and the embedding/fulltext rows are\n      // node-id-keyed. Their only shared resource is the claim relation — and two\n      // batch members claiming one key are already refused during preparation,\n      // which registers each row's pending claims so a later row sees an earlier\n      // one ({@link prepareBatchCreates}). So no error this batch can raise\n      // depends on which of the two groups writes first.\n      await withAlreadyExistsTranslation(\"node\", () =>\n        session.createNodesNoReturn(\n          partition.inserts.map((prepared) => nodeCreateWork(prepared)),\n        ),\n      );\n      for (const prepared of partition.resurrections) {\n        await resurrectPreparedNode(ctx, session, target, prepared);\n      }\n      if (identity !== undefined) {\n        await identity.foldCreated(target, foldReferences(preparedCreates));\n      }\n    },\n    { didWrite: writeResultAlwaysChanges },\n  );\n}\n\n/**\n * Executes batched node creates and returns the inserted node payloads.\n *\n * Uses batch validation caching and a single multi-row INSERT with RETURNING\n * when the backend supports it. Falls back to sequential inserts otherwise.\n *\n * Note: `withOperationHooks` is intentionally skipped for batch throughput.\n * Per-item hooks would negate the performance benefit of batching.\n */\nexport async function executeNodeCreateBatch<G extends GraphDef>(\n  ctx: NodeOperationContext<G>,\n  inputs: readonly CreateNodeInput[],\n  backend: GraphBackend | TransactionBackend,\n  options?: NodeCreateInternalOptions,\n): Promise<readonly Node[]> {\n  if (inputs.length === 0) return [];\n\n  const atomicExecutor = resolveAtomicNodeBatchExecutor({\n    backend,\n    graph: ctx.graph,\n    registry: ctx.registry,\n    inputs,\n    schemaVersion: ctx.schemaVersion,\n    identityEnabled: ctx.identity !== undefined,\n    historyEnabled: ctx.historyEnabled,\n    revisionTrackingEnabled: ctx.revisionTrackingEnabled,\n  });\n\n  if (atomicExecutor !== undefined) {\n    const preparedCreates = await prepareAtomicBatchCreates(\n      ctx,\n      inputs,\n      backend,\n      options,\n    );\n    const entries = atomicNodeBatchEntries(\n      preparedCreates,\n      atomicExecutor.claimSupport,\n    );\n    if (entries !== undefined) {\n      const schemaFence = {\n        graphId: ctx.graphId,\n        expectedVersion: requireDefined(ctx.schemaVersion),\n      };\n      const returnedRows = await withAtomicNodeClaimTranslation(\n        preparedCreates,\n        () =>\n          withAlreadyExistsTranslation(\"node\", () =>\n            atomicExecutor({ entries, resultMode: \"rows\", schemaFence }),\n          ),\n      );\n      if (returnedRows.length === 0) {\n        await diagnoseAtomicNodeBatchNoRow(ctx, backend, preparedCreates);\n      }\n      if (returnedRows.length !== preparedCreates.length) {\n        throw new DatabaseOperationError(\n          `Atomic node batch returned ${returnedRows.length} rows, expected ${preparedCreates.length}`,\n          {\n            operation: \"insert\",\n            entity: \"node\",\n            attempted: preparedCreates.map((prepared) => ({\n              kind: prepared.kind,\n              id: prepared.id,\n            })),\n          },\n        );\n      }\n      memoizeLeasedSchemaFence(ctx, backend);\n      return restoreAtomicNodeBatchRows(\n        ctx.graphId,\n        preparedCreates,\n        returnedRows,\n      ).map((row) => rowToNode(row));\n    }\n  }\n\n  return runWritePlan(\n    nodeWritePlanContext(ctx),\n    nodeBatchWritePlan(\n      nodeBatchConstraintProbes(ctx, inputs, \"create\"),\n      nodeRequiresIdentityLock(ctx),\n    ),\n    backend,\n    async (session, target) => {\n      const identity = ctx.identity;\n      const preparedCreates = await prepareBatchCreates(\n        ctx,\n        inputs,\n        target,\n        options,\n      );\n\n      const partition = partitionCreates(preparedCreates);\n      // One call for claims + row + sidecars, so the resurrections follow the\n      // whole unit — same reasoning as {@link executeNodeCreateNoReturnBatch}.\n      const inserted = await withAlreadyExistsTranslation(\"node\", () =>\n        session.createNodes(\n          partition.inserts.map((prepared) => nodeCreateWork(prepared)),\n        ),\n      );\n      const resurrected: BackendNodeRow[] = [];\n      for (const prepared of partition.resurrections) {\n        resurrected.push(\n          await resurrectPreparedNode(ctx, session, target, prepared),\n        );\n      }\n      const byReference = new Map(\n        [...inserted, ...resurrected].map((row) => [\n          refKey({ kind: row.kind, id: row.id }),\n          row,\n        ]),\n      );\n      const rows = preparedCreates.map((prepared) =>\n        requireDefined(\n          byReference.get(refKey({ kind: prepared.kind, id: prepared.id })),\n          `Missing written row for ${prepared.kind} ${prepared.id}`,\n        ),\n      );\n      if (identity !== undefined) {\n        await identity.foldCreated(target, foldReferences(preparedCreates));\n      }\n\n      return rows.map((row) => rowToNode(row));\n    },\n    { didWrite: writeResultAlwaysChanges },\n  );\n}\n\n// ============================================================\n// Node Update Operations\n// ============================================================\n\nfunction resolveAtomicNodeUpdateExecutor<G extends GraphDef>(\n  ctx: NodeOperationContext<G>,\n  entries: readonly NodeUpsertUpdateBatchEntry[],\n  backend: GraphBackend | TransactionBackend,\n): AtomicNodeResolvedUpdateBatchExecutor | undefined {\n  const first = entries[0];\n  if (first === undefined) return;\n  const distinctIds = new Set(entries.map((entry) => entry.input.id));\n  if (\n    distinctIds.size !== entries.length ||\n    entries.some(\n      (entry) =>\n        entry.clearDeleted ||\n        entry.input.validFrom !== undefined ||\n        entry.input.validTo !== undefined ||\n        entry.input.clearValidTo === true,\n    )\n  ) {\n    return;\n  }\n  return resolveAtomicNodeResolvedUpdateBatchExecutor({\n    backend,\n    graph: ctx.graph,\n    schemaVersion: ctx.schemaVersion,\n    historyEnabled: ctx.historyEnabled,\n    revisionTrackingEnabled: ctx.revisionTrackingEnabled,\n    kind: first.input.kind,\n    entryCount: entries.length,\n    identityEnabled: ctx.identity !== undefined,\n    registry: ctx.registry,\n  });\n}\n\nexport async function executeNodeUpdate<G extends GraphDef>(\n  ctx: NodeOperationContext<G>,\n  input: UpsertUpdateNodeInput,\n  backend: GraphBackend | TransactionBackend,\n  options?: Readonly<{ clearDeleted?: boolean }>,\n): Promise<Node> {\n  // The capability refusal is taken on the backend the CALLER handed in, before\n  // the frame opens: a stated `clearValidTo` a backend does not promise to apply\n  // must be refused, never accepted and dropped, and no transaction is needed to\n  // read a capability. Same placement as `executeNodeUpsertUpdate`'s.\n  if (input.clearValidTo === true) {\n    assertClearValidToSupported(backend, \"node\");\n  }\n  const atomicEntry = {\n    input,\n    clearDeleted: options?.clearDeleted === true,\n  } satisfies NodeUpsertUpdateBatchEntry;\n  const atomicExecutor = resolveAtomicNodeUpdateExecutor(\n    ctx,\n    [atomicEntry],\n    backend,\n  );\n  const opContext = ctx.createOperationContext(\n    \"update\",\n    \"node\",\n    input.kind,\n    input.id,\n  );\n  if (atomicExecutor !== undefined) {\n    return runAtomicProgramWithHooks(\n      ctx,\n      opContext,\n      async () => {\n        const nodes = await executeAtomicNodeResolvedUpdates(\n          ctx,\n          [atomicEntry],\n          backend,\n          atomicExecutor,\n        );\n        return requireDefined(nodes[0]);\n      },\n      writeResultAlwaysChanges,\n    );\n  }\n  return runHookedWritePlan(\n    nodeWritePlanContext(ctx),\n    opContext,\n    nodeWritePlan(\n      nodeFencesConstraintProbe(ctx, input.kind, \"update\"),\n      // Identity participates in an update when it RESURRECTS, and when it\n      // states a validity end: a live-row update cannot change a node's kind, so\n      // nothing folds, but an end reads the identity assertions that touch it.\n      options?.clearDeleted === true || input.validTo !== undefined ?\n        nodeRequiresIdentityLock(ctx)\n      : false,\n    ),\n    backend,\n    async (session, target) => {\n      const validTo = validateOptionalCanonicalIsoDate(\n        input.validTo,\n        \"validTo\",\n      );\n      const identity = ctx.identity;\n      if (identity !== undefined && validTo !== undefined) {\n        await identity.requireValidityEndCompatible(\n          target,\n          { kind: input.kind, id: input.id },\n          validTo,\n        );\n      }\n      const node = await performNodeUpdateWithResurrectionRecovery(\n        ctx,\n        input,\n        session,\n        target,\n        options,\n      );\n      if (options?.clearDeleted && identity !== undefined) {\n        await identity.foldCreated(target, [\n          { kind: input.kind, id: input.id },\n        ]);\n      }\n      return node;\n    },\n    { didWrite: writeResultAlwaysChanges },\n  );\n}\n\nfunction validateNodePropertySubset(\n  schema: z.ZodObject<z.ZodRawShape>,\n  properties: Record<string, unknown>,\n  context: Readonly<{ kind: string; operation: \"update\" }>,\n) {\n  // Reconstruct from `.shape` so object-level refinements stay on the complete\n  // after-image. Zod 4 throws if `schema.partial()` is called on a refined object.\n  return validateNodeProps(\n    z.object(schema.shape).partial(),\n    properties,\n    context,\n  );\n}\n\nfunction normalizeCompareAndSetExpectations(\n  schema: z.ZodObject<z.ZodRawShape>,\n  kind: string,\n  inputExpected: Record<string, unknown>,\n): Readonly<Record<string, NodePropertyExpectation>> {\n  if (Object.keys(inputExpected).length === 0) {\n    throw new ValidationError(\"compareAndSet() expected must not be empty\", {\n      entityType: \"node\",\n      kind,\n      operation: \"update\",\n      issues: [{ path: \"expected\", message: \"Provide at least one property\" }],\n    });\n  }\n  const unknownExpectedProperty = Object.keys(inputExpected).find(\n    (property) => !Object.hasOwn(schema.shape, property),\n  );\n  if (unknownExpectedProperty !== undefined) {\n    throw new ValidationError(\n      `Unknown ${kind} property in compareAndSet() expected state: ${unknownExpectedProperty}`,\n      {\n        entityType: \"node\",\n        kind,\n        operation: \"update\",\n        issues: [\n          {\n            path: unknownExpectedProperty,\n            message: \"Property is not declared by the node schema\",\n          },\n        ],\n      },\n    );\n  }\n\n  const expected = createDataKeyedBag<NodePropertyExpectation>();\n  const scalarExpectedInput = createDataKeyedBag<unknown>();\n  for (const [property, value] of Object.entries(inputExpected)) {\n    if (value === compareAndSetAbsent) {\n      expected[property] = { kind: \"absent\" };\n      continue;\n    }\n    if (value === undefined || (typeof value === \"object\" && value !== null)) {\n      throw new ValidationError(\n        `compareAndSet() expected property \"${property}\" must be a JSON scalar or compareAndSetAbsent`,\n        {\n          entityType: \"node\",\n          kind,\n          operation: \"update\",\n          issues: [\n            {\n              path: property,\n              message:\n                \"Expected a string, number, boolean, null, or compareAndSetAbsent\",\n            },\n          ],\n        },\n      );\n    }\n    scalarExpectedInput[property] = value;\n  }\n\n  const parsedExpected = validateNodePropertySubset(\n    schema,\n    scalarExpectedInput,\n    { kind, operation: \"update\" },\n  );\n  for (const property of Object.keys(scalarExpectedInput)) {\n    const value = parsedExpected[property];\n    if (value === undefined || (typeof value === \"object\" && value !== null)) {\n      throw new ValidationError(\n        `compareAndSet() expected property \"${property}\" did not resolve to a JSON scalar`,\n        {\n          entityType: \"node\",\n          kind,\n          operation: \"update\",\n          issues: [{ path: property, message: \"Expected a JSON scalar\" }],\n        },\n      );\n    }\n    assertJsonValue(\n      value,\n      property,\n      `Node \"${kind}\" compareAndSet expected state`,\n    );\n    expected[property] = { kind: \"value\", value: value as JsonScalar };\n  }\n  return expected;\n}\n\n/**\n * Executes an atomic, set-based update of current nodes. The backend returns\n * every after-image so the Store can validate the complete rows before\n * rebuilding all derived sidecars inside the same transaction.\n */\nexport async function executeNodeSetUpdate<G extends GraphDef>(\n  ctx: NodeOperationContext<G>,\n  kind: string,\n  inputPatch: Record<string, unknown>,\n  candidateIds: CompiledSelectSql,\n  candidateIdColumn: string,\n  backend: GraphBackend | TransactionBackend,\n  request: NodeSetUpdateRequest,\n): Promise<Readonly<{ affectedCount: number }>> {\n  const operation = request.operation;\n  const registration = getNodeRegistration(ctx.graph, kind);\n  const schema = registration.type.schema;\n  const uniqueConstraints = registration.unique ?? [];\n\n  if (!backend.capabilities.execution.interactiveTransactions) {\n    throw new ConfigurationError(\n      `${operation}() requires a transactional backend so validation and sidecars are atomic`,\n      { code: \"SET_UPDATE_TRANSACTIONS_REQUIRED\", kind },\n    );\n  }\n  if (operation === \"updateWhere\" && backend.updateNodeSet === undefined) {\n    throw new ConfigurationError(\n      \"This backend does not support set-based node updates\",\n      { code: \"SET_UPDATE_UNSUPPORTED\", kind },\n    );\n  }\n  if (\n    operation === \"compareAndSet\" &&\n    backend.compareAndSetNode === undefined\n  ) {\n    throw new ConfigurationError(\n      \"This backend does not support node compare-and-set\",\n      { code: \"COMPARE_AND_SET_UNSUPPORTED\", kind },\n    );\n  }\n  if (Object.keys(inputPatch).length === 0) {\n    throw new ValidationError(`${operation}() patch must not be empty`, {\n      entityType: \"node\",\n      kind,\n      operation: \"update\",\n      issues: [{ path: \"patch\", message: \"Provide at least one property\" }],\n    });\n  }\n  const unknownProperty = Object.keys(inputPatch).find(\n    (property) => !Object.hasOwn(schema.shape, property),\n  );\n  if (unknownProperty !== undefined) {\n    throw new ValidationError(\n      `Unknown ${kind} property in ${operation}() patch: ${unknownProperty}`,\n      {\n        entityType: \"node\",\n        kind,\n        operation: \"update\",\n        issues: [\n          {\n            path: unknownProperty,\n            message: \"Property is not declared by the node schema\",\n          },\n        ],\n      },\n    );\n  }\n\n  const parsedPatch = validateNodePropertySubset(schema, inputPatch, {\n    kind,\n    operation: \"update\",\n  });\n  // Data-keyed: `property` comes from the caller's patch object.\n  const patch = createDataKeyedBag<JsonValue>();\n  const unsetProperties: string[] = [];\n  for (const [property, value] of Object.entries(parsedPatch)) {\n    if (value === undefined) {\n      unsetProperties.push(property);\n      continue;\n    }\n    assertJsonValue(value, property, `Node \"${kind}\" ${operation} patch`);\n    patch[property] = value as JsonValue;\n  }\n  if (Object.keys(patch).length === 0 && unsetProperties.length === 0) {\n    throw new ValidationError(\n      `${operation}() patch has no recognized properties`,\n      {\n        entityType: \"node\",\n        kind,\n        operation: \"update\",\n        issues: [\n          { path: \"patch\", message: \"Provide a declared node property\" },\n        ],\n      },\n    );\n  }\n\n  const expected =\n    request.operation === \"compareAndSet\" ?\n      normalizeCompareAndSetExpectations(schema, kind, request.expected)\n    : createDataKeyedBag<NodePropertyExpectation>();\n\n  if (\n    uniqueConstraints.length > 0 &&\n    missingRequiredExtras(\n      UNIQUE_SIDECAR_BATCH,\n      ctx.uniqueSidecarBatch,\n      \"set-based node update\",\n    ).length > 0\n  ) {\n    throw new ConfigurationError(\n      \"updateWhere() requires batched uniqueness sidecar operations for constrained nodes\",\n      { code: \"SET_UPDATE_UNIQUENESS_UNSUPPORTED\", kind },\n    );\n  }\n  if (getSearchableFields(schema).length > 0) {\n    // A fulltext-off backend (`resolveBackendFulltext` returns `false`) gets\n    // the same typed capability refusal every other fulltext entry point\n    // raises, rather than the member-presence assertions below — those are\n    // for a backend that DOES have fulltext but lacks one of the four\n    // members the write plan calls, mirroring the batched-uniqueness and\n    // batched-vector checks around it.\n    if (resolveBackendFulltext(backend) === false) {\n      refuseFulltextUnavailable(backend, kind);\n    }\n    // Fulltext is available, so a missing batch member here is not an\n    // availability decision but a backend contract violation — the same\n    // invariant `syncFulltextBatchForKind` asserts on its own members.\n    assertFulltextMember(backend.upsertFulltext, \"upsertFulltext\", backend);\n    assertFulltextMember(backend.deleteFulltext, \"deleteFulltext\", backend);\n    assertFulltextMember(\n      backend.upsertFulltextBatch,\n      \"upsertFulltextBatch\",\n      backend,\n    );\n    assertFulltextMember(\n      backend.deleteFulltextBatch,\n      \"deleteFulltextBatch\",\n      backend,\n    );\n  }\n  if (\n    getEmbeddingFields(schema).length > 0 &&\n    (backend.upsertEmbedding === undefined ||\n      backend.deleteEmbedding === undefined ||\n      backend.upsertEmbeddingBatch === undefined ||\n      backend.deleteEmbeddingBatch === undefined)\n  ) {\n    throw new ConfigurationError(\n      \"updateWhere() requires batched vector sidecar operations for embedded nodes\",\n      { code: \"SET_UPDATE_VECTOR_UNSUPPORTED\", kind },\n    );\n  }\n\n  const hookContext = ctx.createBulkOperationContext(operation, kind);\n  return ctx.withBulkOperationHooks(hookContext, () =>\n    runWritePlan(\n      nodeWritePlanContext(ctx),\n      // The set update re-checks every changed unique key across the\n      // constraint's scope before rebuilding the sidecars, so a shared-scope\n      // constraint makes it a constrained write like any other update.\n      // Identity does not participate: a set update rewrites props, and no\n      // patch can change a node's kind.\n      nodeWritePlan(nodeFencesConstraintProbe(ctx, kind, \"update\"), false),\n      backend,\n      (session) =>\n        session.reviseNodeSet(\n          operation === \"compareAndSet\" ?\n            {\n              operation: \"compareAndSet\",\n              kind,\n              schema,\n              uniqueConstraints,\n              patch,\n              unsetProperties,\n              candidateIds,\n              candidateIdColumn,\n              expected,\n            }\n          : {\n              operation: \"updateWhere\",\n              kind,\n              schema,\n              uniqueConstraints,\n              patch,\n              unsetProperties,\n              candidateIds,\n              candidateIdColumn,\n            },\n          // This path states no window — it patches properties — so the write\n          // asserts no stored lower bound. The set UPDATE has no field to\n          // carry one, so a future windowed set update is refused here rather\n          // than run unfenced.\n          { validityLowerBound: {} },\n        ),\n      { didWrite: (result) => result.affectedCount > 0 },\n    ),\n  );\n}\n\n/**\n * Executes a node update for upsert — bypasses operation hooks\n * and allows updating soft-deleted nodes when clearDeleted is set.\n */\nexport async function executeNodeUpsertUpdate<G extends GraphDef>(\n  ctx: NodeOperationContext<G>,\n  input: UpsertUpdateNodeInput,\n  backend: GraphBackend | TransactionBackend,\n  options?: Readonly<{ clearDeleted?: boolean }>,\n): Promise<Node> {\n  if (input.clearValidTo === true) {\n    assertClearValidToSupported(backend, \"node\");\n  }\n  return runWritePlan(\n    nodeWritePlanContext(ctx),\n    nodeWritePlan(\n      nodeFencesConstraintProbe(ctx, input.kind, \"update\"),\n      // Conditional for the same reason as {@link executeNodeUpdate}: a\n      // resurrecting upsert folds, and stating a validity end reads the\n      // identity's other members, so both take the lock.\n      options?.clearDeleted === true || input.validTo !== undefined ?\n        nodeRequiresIdentityLock(ctx)\n      : false,\n    ),\n    backend,\n    async (session, target) => {\n      const validTo = validateOptionalCanonicalIsoDate(\n        input.validTo,\n        \"validTo\",\n      );\n      const identity = ctx.identity;\n      if (identity !== undefined && validTo !== undefined) {\n        await identity.requireValidityEndCompatible(\n          target,\n          { kind: input.kind, id: input.id },\n          validTo,\n        );\n      }\n      const node = await performNodeUpdateWithResurrectionRecovery(\n        ctx,\n        input,\n        session,\n        target,\n        options,\n      );\n      if (options?.clearDeleted && identity !== undefined) {\n        await identity.foldCreated(target, [\n          { kind: input.kind, id: input.id },\n        ]);\n      }\n      return node;\n    },\n    { didWrite: writeResultAlwaysChanges },\n  );\n}\n\n/**\n * Executes an already-resolved set of node upsert updates under one write plan.\n *\n * Collection-level resolution still owns input order, repeated-id running\n * state, and create/update partitioning. This boundary owns the database work:\n * one graph fence and one write session cover the complete update set instead\n * of opening a managed frame for every member.\n */\nexport async function executeNodeResolvedMutationSet<G extends GraphDef>(\n  ctx: NodeOperationContext<G>,\n  creates: readonly CreateNodeInput[],\n  updates: readonly NodeUpsertUpdateBatchEntry[],\n  backend: GraphBackend | TransactionBackend,\n): Promise<\n  ResolvedMutationSetAttempt<\n    Readonly<{ created: readonly Node[]; updated: readonly Node[] }>\n  >\n> {\n  if (creates.length === 0 || updates.length === 0) {\n    return unsupportedResolvedMutationSet();\n  }\n  const firstUpdate = requireDefined(updates[0]);\n  const executor = resolveAtomicNodeResolvedMutationSetExecutor({\n    backend,\n    graph: ctx.graph,\n    schemaVersion: ctx.schemaVersion,\n    historyEnabled: ctx.historyEnabled,\n    revisionTrackingEnabled: ctx.revisionTrackingEnabled,\n    kind: firstUpdate.input.kind,\n    creates,\n    updateCount: updates.length,\n    identityEnabled: ctx.identity !== undefined,\n    registry: ctx.registry,\n  });\n  if (executor === undefined) return unsupportedResolvedMutationSet();\n  const ids = new Set([\n    ...creates.map((input) => requireDefined(input.id)),\n    ...updates.map((entry) => entry.input.id),\n  ]);\n  if (ids.size !== creates.length + updates.length) {\n    return unsupportedResolvedMutationSet();\n  }\n  if (\n    updates.some(\n      (entry) =>\n        entry.clearDeleted ||\n        entry.existing === undefined ||\n        entry.input.validFrom !== undefined ||\n        entry.input.validTo !== undefined ||\n        entry.input.clearValidTo === true,\n    )\n  ) {\n    return unsupportedResolvedMutationSet();\n  }\n\n  // The eligibility owner above excludes every node kind whose create planner\n  // can emit claims. Preparation is allowed to normalize that proven shape,\n  // not to reopen eligibility after the operation has committed to this\n  // executor. A claim here therefore means those two owners drifted.\n  const preparedCreates = await prepareAtomicBatchCreates(\n    ctx,\n    creates,\n    backend,\n  );\n  const createEntries = atomicNodeBatchEntries(preparedCreates, undefined);\n  if (createEntries === undefined) {\n    throw new CompilerInvariantError(\n      \"An eligible resolved node mutation set produced unsupported create claims.\",\n    );\n  }\n  const resolvedUpdates = updates.map((entry) => {\n    const existing = requireDefined(entry.existing);\n    const validatedProps =\n      entry.replacementProps ??\n      resolveNodeUpdateProps(ctx, existing, entry.input.props).validatedProps;\n    return {\n      graphId: ctx.graphId,\n      kind: entry.input.kind,\n      id: entry.input.id,\n      props: validatedProps,\n      expectedVersion: existing.version,\n      projections: resolveAtomicNodeProjections(\n        getNodeRegistration(ctx.graph, entry.input.kind).type.schema,\n        validatedProps,\n      ),\n    };\n  });\n  const result = await withAlreadyExistsTranslation(\"node\", () =>\n    executor({\n      creates: createEntries,\n      updates: resolvedUpdates,\n      schemaFence: {\n        graphId: ctx.graphId,\n        expectedVersion: requireDefined(ctx.schemaVersion),\n      },\n    }),\n  );\n  if (result.created.length === 0 && result.updated.length === 0) {\n    await diagnoseFusedSchemaFenceNoRow(ctx, backend);\n    throw new ResolvedMutationSetMoved(\"node\", executor);\n  }\n  if (\n    result.created.length !== creates.length ||\n    result.updated.length !== updates.length\n  ) {\n    throw new CompilerInvariantError(\n      \"Atomic resolved node mutation set returned a partial result.\",\n    );\n  }\n  memoizeLeasedSchemaFence(ctx, backend);\n  const created = restoreAtomicNodeBatchRows(\n    ctx.graphId,\n    preparedCreates,\n    result.created,\n  ).map((row) => rowToNode(row));\n  const updatedById = new Map(result.updated.map((row) => [row.id, row]));\n  return appliedResolvedMutationSet({\n    created,\n    updated: updates.map((entry) =>\n      rowToNode(requireDefined(updatedById.get(entry.input.id))),\n    ),\n  });\n}\n\nexport async function executeNodeUpsertUpdateBatch<G extends GraphDef>(\n  ctx: NodeOperationContext<G>,\n  entries: readonly NodeUpsertUpdateBatchEntry[],\n  backend: GraphBackend | TransactionBackend,\n): Promise<readonly Node[]> {\n  if (entries.length === 0) return [];\n  for (const entry of entries) {\n    if (entry.input.clearValidTo === true) {\n      assertClearValidToSupported(backend, \"node\");\n    }\n  }\n\n  const first = requireDefined(entries[0]);\n  const distinctIds = new Set(entries.map((entry) => entry.input.id));\n  const atomicExecutor = resolveAtomicNodeUpdateExecutor(ctx, entries, backend);\n  if (atomicExecutor !== undefined) {\n    return executeAtomicNodeResolvedUpdates(\n      ctx,\n      entries,\n      backend,\n      atomicExecutor,\n    );\n  }\n\n  return runWritePlan(\n    nodeWritePlanContext(ctx),\n    nodeWritePlan(\n      nodeFencesConstraintProbe(ctx, first.input.kind, \"update\"),\n      entries.some(\n        (entry) => entry.clearDeleted || entry.input.validTo !== undefined,\n      ) && nodeRequiresIdentityLock(ctx),\n    ),\n    backend,\n    async (session, target) => {\n      const resolvedRows =\n        (\n          target.capabilities.execution.interactiveTransactions &&\n          distinctIds.size === entries.length\n        ) ?\n          await getNodeRowsByIds(\n            target,\n            ctx.batchPointRead,\n            ctx.graphId,\n            first.input.kind,\n            [...distinctIds],\n          )\n        : undefined;\n      const canBatchResolvedUpdates =\n        resolvedRows !== undefined &&\n        resolvedNodeUpdateBatchFitsBindBudget(\n          entries.length,\n          target.capabilities.maxBindParameters,\n        ) &&\n        entries.every(\n          (entry) =>\n            !entry.clearDeleted &&\n            entry.input.validFrom === undefined &&\n            entry.input.validTo === undefined &&\n            entry.input.clearValidTo !== true,\n        );\n      let batchMissed = false;\n      if (canBatchResolvedUpdates) {\n        const resolvedEntries = entries.map((entry) => {\n          const existing = resolvedRows.get(entry.input.id);\n          if (existing === undefined || !isLiveNodeRow(existing)) {\n            throw new NodeNotFoundError(entry.input.kind, entry.input.id);\n          }\n          const props =\n            entry.replacementProps ??\n            resolveNodeUpdateProps(ctx, existing, entry.input.props)\n              .validatedProps;\n          return {\n            graphId: ctx.graphId,\n            kind: entry.input.kind,\n            id: entry.input.id,\n            props,\n            expectedVersion: existing.version,\n          };\n        });\n        const registration = getNodeRegistration(ctx.graph, first.input.kind);\n        const uniqueSidecarsReachable =\n          registration.unique === undefined ||\n          registration.unique.length === 0 ||\n          resolvedNodeUniqueSidecarBatchIsReachable(\n            createUniquenessContext(\n              ctx.graphId,\n              ctx.registry,\n              target,\n              ctx.uniqueSidecarBatch,\n            ),\n          );\n        const preservesClaimKeys = resolvedEntries.every((entry) => {\n          const existing = requireDefined(resolvedRows.get(entry.id));\n          return resolvedNodeUpdatePreservesClaimKeys(\n            ctx.registry,\n            entry.kind,\n            entry.id,\n            rowPropsToObject(existing.props),\n            entry.props,\n            registration.unique ?? [],\n          );\n        });\n        if (uniqueSidecarsReachable && preservesClaimKeys) {\n          const rows = await session.reviseResolvedNodes({\n            schema: registration.type.schema,\n            uniqueConstraints: registration.unique ?? [],\n            entries: resolvedEntries,\n          });\n          if (rows !== undefined) {\n            const byId = new Map(rows.map((row) => [row.id, row]));\n            return entries.map((entry) =>\n              rowToNode(requireDefined(byId.get(entry.input.id))),\n            );\n          }\n          batchMissed = true;\n        }\n      }\n      // A zero-row version-gated batch means a peer changed at least one row\n      // after the shared preimage read. The portable recovery below must start\n      // from the rows that are CURRENT now: carrying the old preimage would\n      // turn a partial upsert into a stale full replacement.\n      const fallbackRows = batchMissed ? undefined : resolvedRows;\n      const nodes: Node[] = [];\n      for (const entry of entries) {\n        nodes.push(\n          await performNodeUpdateWithResurrectionRecovery(\n            ctx,\n            entry.input,\n            session,\n            target,\n            entry.clearDeleted || entry.replacementProps !== undefined ?\n              {\n                ...(entry.clearDeleted ? { clearDeleted: true } : {}),\n                ...(entry.replacementProps === undefined ?\n                  {}\n                : { replacementProps: entry.replacementProps }),\n              }\n            : undefined,\n            fallbackRows?.get(entry.input.id),\n          ),\n        );\n        if (entry.clearDeleted && ctx.identity !== undefined) {\n          await ctx.identity.foldCreated(target, [\n            { kind: entry.input.kind, id: entry.input.id },\n          ]);\n        }\n      }\n      return nodes;\n    },\n    { didWrite: writeResultAlwaysChanges },\n  );\n}\n\nasync function executeAtomicNodeResolvedUpdates<G extends GraphDef>(\n  ctx: NodeOperationContext<G>,\n  entries: readonly NodeUpsertUpdateBatchEntry[],\n  backend: GraphBackend | TransactionBackend,\n  atomicExecutor: AtomicNodeResolvedUpdateBatchExecutor,\n): Promise<readonly Node[]> {\n  const maxAttempts = atomicResolvedUpdateAttemptBudget(\n    entries.length,\n    NODE_UPDATE_ATTEMPTS,\n  );\n  const first = requireDefined(entries[0]);\n  const distinctIds = new Set(entries.map((entry) => entry.input.id));\n  const supplied = entries.flatMap((entry) =>\n    entry.existing === undefined ? [] : [entry.existing],\n  );\n  const fetched =\n    supplied.length === entries.length ?\n      undefined\n    : await getNodeRowsByIds(\n        backend,\n        ctx.batchPointRead,\n        ctx.graphId,\n        first.input.kind,\n        [...distinctIds],\n      );\n  let existing = fetched === undefined ? supplied : [...fetched.values()];\n  for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {\n    const byId = new Map(existing.map((row) => [row.id, row]));\n    const missing = entries.find((entry) => {\n      const row = byId.get(entry.input.id);\n      return row === undefined || row.deleted_at !== undefined;\n    });\n    if (missing !== undefined) {\n      // This update-only partition was resolved from live rows. Once a\n      // refreshed preimage is absent or tombstoned, the requested update\n      // target no longer exists; do not reinterpret it as a create or fall\n      // through to a transactionless portable write.\n      throw new NodeNotFoundError(first.input.kind, missing.input.id);\n    }\n    const resolved = entries.map((entry) => {\n      const row = requireDefined(byId.get(entry.input.id));\n      const validatedProps =\n        entry.replacementProps ??\n        resolveNodeUpdateProps(ctx, row, entry.input.props).validatedProps;\n      return {\n        graphId: ctx.graphId,\n        kind: entry.input.kind,\n        id: entry.input.id,\n        props: validatedProps,\n        expectedVersion: row.version,\n        projections: resolveAtomicNodeProjections(\n          getNodeRegistration(ctx.graph, entry.input.kind).type.schema,\n          validatedProps,\n        ),\n      };\n    });\n    const rows = await atomicExecutor({\n      entries: resolved,\n      schemaFence: {\n        graphId: ctx.graphId,\n        expectedVersion: requireDefined(ctx.schemaVersion),\n      },\n    });\n    if (rows.length === entries.length) {\n      memoizeLeasedSchemaFence(ctx, backend);\n      const returned = new Map(rows.map((row) => [row.id, row]));\n      return entries.map((entry) =>\n        rowToNode(requireDefined(returned.get(entry.input.id))),\n      );\n    }\n    if (rows.length > 0) {\n      throw new CompilerInvariantError(\n        \"Atomic resolved node update returned a partial result.\",\n        { expected: entries.length, actual: rows.length },\n      );\n    }\n    await diagnoseFusedSchemaFenceNoRow(ctx, backend);\n    if (attempt === maxAttempts) {\n      throw new DatabaseOperationError(\n        `Atomic node update could not be applied to stable rows after ${maxAttempts} attempts.`,\n        {\n          operation: \"update\",\n          entity: \"node\",\n          attempted: entries.map((entry) => ({\n            kind: entry.input.kind,\n            id: entry.input.id,\n          })),\n        },\n      );\n    }\n    const refreshed = await getNodeRowsByIds(\n      backend,\n      ctx.batchPointRead,\n      ctx.graphId,\n      first.input.kind,\n      [...distinctIds],\n    );\n    existing = [...refreshed.values()];\n  }\n  throw new CompilerInvariantError(\n    \"Atomic resolved node update exhausted its retry loop.\",\n  );\n}\n\n// ============================================================\n// Node Delete Operations\n// ============================================================\n\nexport async function executeNodeDelete<G extends GraphDef>(\n  ctx: NodeOperationContext<G>,\n  kind: string,\n  id: string,\n  backend: GraphBackend | TransactionBackend,\n): Promise<void> {\n  // Gate outside hooks and execution (matching edge deletes): an absent or\n  // already-tombstoned node is a no-op, so it neither fires hooks nor submits\n  // a write. Eligible plain deletes carry the live/restrict/schema verdicts in\n  // one closed program. The portable cascade re-reads inside its transaction,\n  // so a node concurrently deleted between this gate and the write lock is\n  // still handled correctly.\n  const gate = await backend.getNode(ctx.graphId, kind, id);\n  if (!gate || gate.deleted_at) return;\n\n  const opContext = ctx.createOperationContext(\"delete\", \"node\", kind, id);\n\n  const atomicExecutor = resolveAtomicNodeDeleteBatchExecutor({\n    backend,\n    graph: ctx.graph,\n    kind,\n    ids: [id],\n    schemaVersion: ctx.schemaVersion,\n    identityEnabled: ctx.identity !== undefined,\n    registry: ctx.registry,\n    historyEnabled: ctx.historyEnabled,\n    revisionTrackingEnabled: ctx.revisionTrackingEnabled,\n  });\n  if (atomicExecutor !== undefined) {\n    await runAtomicProgramWithHooks(\n      ctx,\n      opContext,\n      () => executeAtomicNodeDeletes(ctx, kind, [id], backend, atomicExecutor),\n      (affectedCount) => affectedCount > 0,\n    );\n    return;\n  }\n\n  await runHookedWritePlan(\n    nodeWritePlanContext(ctx),\n    opContext,\n    nodeWritePlan(undefined, nodeRequiresIdentityLock(ctx)),\n    backend,\n    async (session, target) => {\n      const identity = ctx.identity;\n      const registration = getNodeRegistration(ctx.graph, kind);\n      // This preflight is NOT removable round-trip fat: the soft-delete\n      // pipeline consumes the pre-image (uniqueness entries are keyed by\n      // props-derived constraint keys), and this in-transaction read is\n      // the concurrency-correct source for it.\n      const preflight = await target.getNode(ctx.graphId, kind, id);\n      if (!preflight || !isLiveNodeRow(preflight)) return false;\n\n      // The cascade (connected edges, uniques, embeddings, fulltext, node) is\n      // not individually atomic, so it runs in one write transaction. Under\n      // recorded-time capture this also collapses the cascade into a single\n      // recorded commit instant instead of one instant per sub-write.\n      await session.retireNode({\n        existing: preflight,\n        schema: registration.type.schema,\n        uniqueConstraints: registration.unique ?? [],\n        onDelete: registration.onDelete,\n      });\n      if (identity !== undefined) {\n        await identity.detachDeleted(target, { kind, id }, \"soft\");\n      }\n      return true;\n    },\n    { didWrite: booleanWriteResultChanges },\n  );\n}\n\nasync function findConnectedEdgesForNodeBatch<G extends GraphDef>(\n  ctx: NodeOperationContext<G>,\n  kind: string,\n  ids: readonly string[],\n  backend: GraphBackend | TransactionBackend,\n): Promise<ReadonlyMap<string, readonly BackendEdgeRow[]> | undefined> {\n  const setRead = backend.findEdgesByHeterogeneousEndpointSet;\n  if (setRead === undefined) return;\n\n  const uniqueIds = [...new Set(ids)];\n  const edgeKinds = Object.keys(ctx.graph.edges);\n  const connectedByNode = new Map<string, Map<string, BackendEdgeRow>>();\n  for (const id of uniqueIds) connectedByNode.set(id, new Map());\n  if (edgeKinds.length === 0) return;\n\n  const endpoints = uniqueIds.map((id) => ({ kind, id }));\n  const [fromRows, toRows] = await Promise.all([\n    setRead({\n      graphId: ctx.graphId,\n      side: \"from\",\n      endpoints,\n      edgeKinds,\n      excludeDeleted: true,\n    }),\n    setRead({\n      graphId: ctx.graphId,\n      side: \"to\",\n      endpoints,\n      edgeKinds,\n      excludeDeleted: true,\n    }),\n  ]);\n  // The closed program deliberately checks every stored edge kind, while the\n  // heterogeneous set port is licensed by the reconciled graph's kind set.\n  // No licensed rows after a refusal is therefore insufficient evidence: let\n  // the caller recover through the kind-blind scalar authority.\n  if (fromRows.length === 0 && toRows.length === 0) return;\n  for (const row of fromRows) {\n    connectedByNode.get(row.from_id)?.set(row.id, row);\n  }\n  for (const row of toRows) {\n    connectedByNode.get(row.to_id)?.set(row.id, row);\n  }\n  return new Map(\n    [...connectedByNode].map(([id, rows]) => [id, [...rows.values()]]),\n  );\n}\n\n/**\n * Soft-deletes a batch without per-item operation hooks.\n *\n * Batch collection methods deliberately omit per-item hooks for throughput.\n * Owning the write transaction here also prevents a per-item success from\n * being reported before the batch's outer COMMIT.\n */\nexport async function executeNodeDeleteBatch<G extends GraphDef>(\n  ctx: NodeOperationContext<G>,\n  kind: string,\n  ids: readonly string[],\n  backend: GraphBackend | TransactionBackend,\n): Promise<void> {\n  const atomicExecutor = resolveAtomicNodeDeleteBatchExecutor({\n    backend,\n    graph: ctx.graph,\n    kind,\n    ids,\n    schemaVersion: ctx.schemaVersion,\n    identityEnabled: ctx.identity !== undefined,\n    registry: ctx.registry,\n    historyEnabled: ctx.historyEnabled,\n    revisionTrackingEnabled: ctx.revisionTrackingEnabled,\n  });\n  if (atomicExecutor !== undefined) {\n    await executeAtomicNodeDeletes(ctx, kind, ids, backend, atomicExecutor);\n    return;\n  }\n\n  await runWritePlan(\n    nodeWritePlanContext(ctx),\n    nodeWritePlan(undefined, nodeRequiresIdentityLock(ctx)),\n    backend,\n    async (session, target) => {\n      const identity = ctx.identity;\n      const registration = getNodeRegistration(ctx.graph, kind);\n      let affectedCount = 0;\n\n      for (const id of ids) {\n        // This is both the existence gate and the concurrency-correct\n        // pre-image consumed by uniqueness cleanup. It must stay inside the\n        // batch transaction after the graph write lock is held.\n        const preflight = await target.getNode(ctx.graphId, kind, id);\n        if (!preflight || !isLiveNodeRow(preflight)) continue;\n\n        await session.retireNode({\n          existing: preflight,\n          schema: registration.type.schema,\n          uniqueConstraints: registration.unique ?? [],\n          onDelete: registration.onDelete,\n        });\n        if (identity !== undefined) {\n          await identity.detachDeleted(target, { kind, id }, \"soft\");\n        }\n        affectedCount += 1;\n      }\n\n      return affectedCount;\n    },\n    { didWrite: (affectedCount) => affectedCount > 0 },\n  );\n}\n\nasync function executeAtomicNodeDeletes<G extends GraphDef>(\n  ctx: NodeOperationContext<G>,\n  kind: string,\n  ids: readonly string[],\n  backend: GraphBackend | TransactionBackend,\n  atomicExecutor: AtomicNodeDeleteBatchExecutor,\n): Promise<number> {\n  try {\n    const result = await atomicExecutor({\n      graphId: ctx.graphId,\n      kind,\n      ids,\n      schemaFence: {\n        graphId: ctx.graphId,\n        expectedVersion: requireDefined(ctx.schemaVersion),\n      },\n    });\n    await assertAtomicDeleteSchemaFenceMatched(\n      result.schemaFenceMatched,\n      ctx,\n      backend,\n      \"node\",\n    );\n    return result.affectedCount;\n  } catch (error) {\n    if (!(error instanceof AtomicNodeDeleteRestrictedRefusalError)) throw error;\n    const connectedById = await findConnectedEdgesForNodeBatch(\n      ctx,\n      kind,\n      ids,\n      backend,\n    );\n    for (const id of ids) {\n      const connectedEdges =\n        connectedById?.get(id) ??\n        (await backend.findEdgesConnectedTo({\n          graphId: ctx.graphId,\n          nodeKind: kind,\n          nodeId: id,\n        }));\n      if (connectedEdges.length === 0) continue;\n      throw new RestrictedDeleteError({\n        nodeKind: kind,\n        nodeId: id,\n        edgeCount: connectedEdges.length,\n        edgeKinds: [...new Set(connectedEdges.map((edge) => edge.kind))],\n      });\n    }\n    throw new DatabaseOperationError(\n      \"Atomic node delete refused a connected edge, but no current \" +\n        \"restriction could be diagnosed. The connected edge may have \" +\n        \"changed concurrently after the atomic program aborted.\",\n      { operation: \"delete\", entity: \"node\" },\n      { cause: error.cause },\n    );\n  }\n}\n\n/**\n * Executes a node hard delete operation (permanent removal).\n *\n * Unlike soft delete, this permanently removes the node and all\n * associated data (uniqueness entries, embeddings) from the database.\n */\nexport async function executeNodeHardDelete<G extends GraphDef>(\n  ctx: NodeOperationContext<G>,\n  kind: string,\n  id: string,\n  backend: GraphBackend | TransactionBackend,\n): Promise<void> {\n  // Gate outside hooks and transaction so an absent node neither fires hooks\n  // nor opens an empty transaction (see executeNodeDelete). The cascade\n  // re-reads inside the transaction.\n  const gate = await backend.getNode(ctx.graphId, kind, id);\n  if (!gate) return;\n\n  const opContext = ctx.createOperationContext(\"delete\", \"node\", kind, id);\n\n  return runHookedWritePlan(\n    nodeWritePlanContext(ctx),\n    opContext,\n    nodeWritePlan(undefined, nodeRequiresIdentityLock(ctx)),\n    backend,\n    async (session, target) => {\n      const identity = ctx.identity;\n      const registration = getNodeRegistration(ctx.graph, kind);\n      // No in-transaction preflight (unlike soft delete, whose pipeline\n      // consumes the pre-image for uniqueness-key cleanup): every hard\n      // cascade member is id-keyed and idempotent — the delete-behavior\n      // check re-reads edges itself, `hardDeleteNode` deletes by primary\n      // key, and embeddings clean up by id — so a node concurrently\n      // removed between the gate and the write lock makes each statement\n      // a 0-row no-op.\n\n      // The cascade (edges, node, embeddings) is not individually atomic, so\n      // it runs in one write transaction. Embeddings live in strategy-owned\n      // per-`(kind, field)` tables, so they are cleaned up here rather than\n      // in the backend's graph-agnostic `hardDeleteNode` cascade.\n      await session.purgeNode({\n        kind,\n        id,\n        schema: registration.type.schema,\n        onDelete: registration.onDelete,\n      });\n      if (identity !== undefined) {\n        await identity.detachDeleted(target, { kind, id }, \"hard\");\n      }\n    },\n  );\n}\n\n// ============================================================\n// Get-Or-Create Operations\n// ============================================================\n\nexport async function executeNodeGetOrCreateByConstraint<G extends GraphDef>(\n  ctx: NodeOperationContext<G>,\n  kind: string,\n  constraintName: string,\n  props: Record<string, unknown>,\n  backend: GraphBackend | TransactionBackend,\n  options?: NodeGetOrCreateByConstraintOptions,\n): Promise<Readonly<{ node: Node; action: GetOrCreateAction }>> {\n  const ifExists = options?.ifExists ?? \"return\";\n\n  const registration = getNodeRegistration(ctx.graph, kind);\n  const nodeKind = registration.type;\n  const validatedProps = validateNodeProps(nodeKind.schema, props, {\n    kind,\n    operation: \"create\",\n  });\n\n  const constraint = resolveConstraint(ctx.graph, kind, constraintName);\n\n  if (!checkWherePredicate(constraint, validatedProps)) {\n    const node = await executeNodeCreate(\n      ctx,\n      { kind, props: validatedProps },\n      backend,\n      { propsPreValidated: true },\n    );\n    return { node, action: \"created\" };\n  }\n\n  const key = computeUniqueKey(\n    validatedProps,\n    constraint.fields,\n    constraint.collation,\n  );\n\n  const kindsToCheck = uniquenessProbeKinds(\n    kind,\n    constraint.scope,\n    ctx.registry,\n  );\n\n  // The probe runs outside any transaction (the found path is a pure read),\n  // and each write leg opens its own hooked transaction. A concurrent create\n  // can therefore reserve the key between the probe and the create — that\n  // surfaces as UniquenessError, and the caller retries the probe once to\n  // converge on the row the winner created.\n  async function attempt(): Promise<\n    Readonly<{ node: Node; action: GetOrCreateAction }>\n  > {\n    const existingUniqueRow = await findUniqueRowAcrossKinds(\n      backend,\n      ctx.graphId,\n      constraint.name,\n      key,\n      kindsToCheck,\n      true,\n    );\n\n    if (existingUniqueRow === undefined) {\n      const node = await executeNodeCreate(\n        ctx,\n        { kind, props: validatedProps },\n        backend,\n        { propsPreValidated: true },\n      );\n      return { node, action: \"created\" };\n    }\n\n    // Fetch using concrete_kind (may differ from requested kind\n    // when scope is \"kindWithSubClasses\" and the match is on a sibling/parent kind)\n    const existingRow = await backend.getNode(\n      ctx.graphId,\n      existingUniqueRow.concrete_kind,\n      existingUniqueRow.node_id,\n    );\n\n    if (existingRow === undefined) {\n      const node = await executeNodeCreate(\n        ctx,\n        { kind, props: validatedProps },\n        backend,\n        { propsPreValidated: true },\n      );\n      return { node, action: \"created\" };\n    }\n\n    const isSoftDeleted = existingRow.deleted_at !== undefined;\n\n    if (isSoftDeleted || ifExists === \"update\") {\n      const concreteKind = existingUniqueRow.concrete_kind;\n      const node = await executeNodeUpsertUpdate(\n        ctx,\n        {\n          kind: concreteKind,\n          id: existingRow.id as UpdateNodeInput[\"id\"],\n          props: validatedProps,\n        },\n        backend,\n        { clearDeleted: isSoftDeleted },\n      );\n      return { node, action: isSoftDeleted ? \"resurrected\" : \"updated\" };\n    }\n\n    return { node: rowToNode(existingRow), action: \"found\" };\n  }\n\n  try {\n    return await attempt();\n  } catch (error) {\n    if (!(error instanceof UniquenessError)) throw error;\n    return attempt();\n  }\n}\n\n// ============================================================\n// Find-By-Constraint Operations\n// ============================================================\n\nexport async function executeNodeFindByConstraint<G extends GraphDef>(\n  ctx: NodeOperationContext<G>,\n  kind: string,\n  constraintName: string,\n  props: Record<string, unknown>,\n  backend: GraphBackend | TransactionBackend,\n): Promise<Node | undefined> {\n  const registration = getNodeRegistration(ctx.graph, kind);\n  const nodeKind = registration.type;\n  const validatedProps = validateNodeProps(nodeKind.schema, props, {\n    kind,\n    operation: \"create\",\n  });\n\n  const constraint = resolveConstraint(ctx.graph, kind, constraintName);\n  if (!checkWherePredicate(constraint, validatedProps)) return undefined;\n\n  const key = computeUniqueKey(\n    validatedProps,\n    constraint.fields,\n    constraint.collation,\n  );\n\n  const kindsToCheck = uniquenessProbeKinds(\n    kind,\n    constraint.scope,\n    ctx.registry,\n  );\n\n  const existingUniqueRow = await findUniqueRowAcrossKinds(\n    backend,\n    ctx.graphId,\n    constraint.name,\n    key,\n    kindsToCheck,\n    false,\n  );\n\n  if (existingUniqueRow === undefined) return undefined;\n\n  const existingRow = await backend.getNode(\n    ctx.graphId,\n    existingUniqueRow.concrete_kind,\n    existingUniqueRow.node_id,\n  );\n\n  if (existingRow === undefined || existingRow.deleted_at !== undefined)\n    return undefined;\n\n  return rowToNode(existingRow);\n}\n\n// ============================================================\n// Bulk Find-By-Constraint\n// ============================================================\n\n/**\n * Validates all items and computes unique constraint keys.\n * Shared by both bulk find and bulk getOrCreate.\n */\nfunction validateAndComputeKeys(\n  nodeKind: NodeType,\n  kind: string,\n  constraint: UniqueConstraint,\n  items: readonly Readonly<{ props: Record<string, unknown> }>[],\n): { validatedProps: Record<string, unknown>; key: string | undefined }[] {\n  const validated: {\n    validatedProps: Record<string, unknown>;\n    key: string | undefined;\n  }[] = [];\n\n  for (const item of items) {\n    const validatedProps = validateNodeProps(nodeKind.schema, item.props, {\n      kind,\n      operation: \"create\",\n    });\n    const applies = checkWherePredicate(constraint, validatedProps);\n    const key =\n      applies ?\n        computeUniqueKey(\n          validatedProps,\n          constraint.fields,\n          constraint.collation,\n        )\n      : undefined;\n    validated.push({ validatedProps, key });\n  }\n\n  return validated;\n}\n\nfunction collectUniqueKeys(\n  validated: readonly { key: string | undefined }[],\n): string[] {\n  return [\n    ...new Set(\n      validated\n        .map((entry) => entry.key)\n        .filter((key): key is string => key !== undefined),\n    ),\n  ];\n}\n\nexport async function executeNodeBulkFindByConstraint<G extends GraphDef>(\n  ctx: NodeOperationContext<G>,\n  kind: string,\n  constraintName: string,\n  items: readonly Readonly<{ props: Record<string, unknown> }>[],\n  backend: GraphBackend | TransactionBackend,\n): Promise<(Node | undefined)[]> {\n  if (items.length === 0) return [];\n\n  const registration = getNodeRegistration(ctx.graph, kind);\n  const nodeKind = registration.type;\n  const constraint = resolveConstraint(ctx.graph, kind, constraintName);\n\n  const validated = validateAndComputeKeys(nodeKind, kind, constraint, items);\n  const uniqueKeys = collectUniqueKeys(validated);\n\n  const kindsToCheck = uniquenessProbeKinds(\n    kind,\n    constraint.scope,\n    ctx.registry,\n  );\n\n  const existingByKey =\n    uniqueKeys.length > 0 ?\n      await batchCheckUniqueAcrossKinds(\n        backend,\n        ctx.uniqueSidecarBatch,\n        ctx.graphId,\n        constraint.name,\n        uniqueKeys,\n        kindsToCheck,\n        false,\n      )\n    : new Map<string, { node_id: string; concrete_kind: string }>();\n\n  // Assemble results, deduplicating keys seen within the batch\n  const results: (Node | undefined)[] = Array.from({ length: items.length });\n  const seenKeys = new Map<string, number>();\n\n  for (const [index, { key }] of validated.entries()) {\n    if (key === undefined) {\n      results[index] = undefined;\n      continue;\n    }\n\n    const previousIndex = seenKeys.get(key);\n    if (previousIndex !== undefined) {\n      results[index] = results[previousIndex];\n      continue;\n    }\n    seenKeys.set(key, index);\n\n    const existing = existingByKey.get(key);\n    if (existing === undefined) {\n      results[index] = undefined;\n      continue;\n    }\n\n    const existingRow = await backend.getNode(\n      ctx.graphId,\n      existing.concrete_kind,\n      existing.node_id,\n    );\n\n    if (existingRow === undefined || existingRow.deleted_at !== undefined) {\n      results[index] = undefined;\n      continue;\n    }\n\n    results[index] = rowToNode(existingRow);\n  }\n\n  return results;\n}\n\n// ============================================================\n// Bulk Find-By-Index\n// ============================================================\n\n/**\n * Resolves a declared node index by name, validating the kind first.\n *\n * @throws {KindNotFoundError} when the node kind is not registered\n * @throws {NodeIndexNotFoundError} when no node index of that name exists\n */\nfunction resolveNodeIndex<G extends GraphDef>(\n  graph: G,\n  kind: string,\n  indexName: string,\n): NodeIndexDeclaration {\n  getNodeRegistration(graph, kind);\n\n  const declaration = graph.indexes?.find(\n    (candidate) =>\n      candidate.entity === \"node\" &&\n      candidate.kind === kind &&\n      candidate.name === indexName,\n  );\n\n  if (declaration?.entity !== \"node\") {\n    throw new NodeIndexNotFoundError(indexName, kind);\n  }\n\n  // GIN-family indexes serve containment / substring predicates, not the\n  // equality probes bulkFindByIndex compiles — targeting one here would\n  // silently probe with the wrong extraction semantics.\n  if (declaration.method !== undefined) {\n    throw new ConfigurationError(\n      `bulkFindByIndex cannot probe index \"${indexName}\" (method ` +\n        `\"${declaration.method}\"): only btree indexes serve equality probes.`,\n      { indexName, kind, method: declaration.method },\n    );\n  }\n\n  return declaration;\n}\n\nconst INDEX_PROBE_EXPECTED_TYPEOF: Partial<Record<ValueType, string>> = {\n  string: \"string\",\n  number: \"number\",\n  boolean: \"boolean\",\n};\n\n/**\n * Validates a single probe value against its declared index-field type.\n * Missing/null values are valid (null probes); only a present, scalar\n * value of the wrong type is rejected.\n */\nfunction validateIndexProbeValue(\n  value: unknown,\n  valueType: ValueType | undefined,\n  pointer: JsonPointer,\n  kind: string,\n): void {\n  if (value === undefined || value === null) return;\n\n  // Index keys are scalar; a non-scalar probe can't be bound and must fail\n  // with a typed error rather than a cryptic driver bind error downstream.\n  if (\n    typeof value !== \"string\" &&\n    typeof value !== \"number\" &&\n    typeof value !== \"boolean\" &&\n    !(value instanceof Date)\n  ) {\n    throw indexProbeTypeError(\n      pointer,\n      kind,\n      \"a scalar (string, number, boolean, or Date)\",\n      value,\n    );\n  }\n\n  if (valueType === \"date\") {\n    if (value instanceof Date || typeof value === \"string\") return;\n    throw indexProbeTypeError(\n      pointer,\n      kind,\n      \"date (Date or ISO string)\",\n      value,\n    );\n  }\n\n  const expected = INDEX_PROBE_EXPECTED_TYPEOF[valueType ?? \"unknown\"];\n  if (expected === undefined) return;\n  if (typeof value !== expected) {\n    throw indexProbeTypeError(pointer, kind, expected, value);\n  }\n}\n\nfunction indexProbeTypeError(\n  pointer: JsonPointer,\n  kind: string,\n  expected: string,\n  value: unknown,\n): ValidationError {\n  return new ValidationError(\n    `Index probe value for \"${pointer}\" on node kind \"${kind}\" has an incompatible type`,\n    {\n      entityType: \"node\",\n      kind,\n      issues: [\n        {\n          path: pointer,\n          message: `Expected ${expected}, received ${typeof value}`,\n          code: \"invalid_type\",\n        },\n      ],\n    },\n  );\n}\n\n/** Coerces a non-null probe value into a driver-bindable scalar. */\nfunction coerceIndexProbeBind(\n  value: unknown,\n  adapter: DialectAdapter,\n): unknown {\n  return adapter.bindValue(normalizeProbeScalar(value as ProbeScalar));\n}\n\ntype ProbeScalar = string | number | boolean | Date;\n\n/**\n * Canonical scalar form of a validated probe value, shared by the dedup key\n * and the bound SQL value so the two can never drift (a Date and its ISO\n * string normalize identically — and produce identical predicates).\n */\nfunction normalizeProbeScalar(value: ProbeScalar): string | number | boolean {\n  return value instanceof Date ? value.toISOString() : value;\n}\n\nconst PROBE_NULL_TAG = 0;\nconst PROBE_VALUE_TAG = 1;\n\n/**\n * Stable dedup key for a probe tuple. Each slot is tagged so a null/undefined\n * value can never collide with a string that happens to equal a sentinel -\n * null maps to [0], a present scalar to [1, normalized].\n */\nfunction canonicalIndexProbeKey(probe: readonly unknown[]): string {\n  return JSON.stringify(\n    probe.map((value) =>\n      value === undefined || value === null ?\n        [PROBE_NULL_TAG]\n      : [PROBE_VALUE_TAG, normalizeProbeScalar(value as ProbeScalar)],\n    ),\n  );\n}\n\n/**\n * Batched candidate retrieval against a declared node index.\n *\n * Emits a single query against the nodes table: each input's indexed-field\n * values become a probe predicate (null-safe equality, reusing the index's\n * own extraction expressions so the planner can use the physical index), and\n * a `CASE` selector tags each matched row with the deduped probe group it\n * satisfies. Rows are grouped back to input positions in order; each input's\n * candidate set is ordered by node id.\n */\nexport async function executeNodeBulkFindByIndex<G extends GraphDef>(\n  ctx: NodeOperationContext<G>,\n  kind: string,\n  indexName: string,\n  items: readonly Readonly<{ props: Record<string, unknown> }>[],\n  backend: GraphBackend | TransactionBackend,\n  options?: NodeBulkFindByIndexOptions,\n): Promise<Node[][]> {\n  if (items.length === 0) return [];\n\n  const index = resolveNodeIndex(ctx.graph, kind, indexName);\n\n  if (index.fields.length === 0) {\n    throw new ConfigurationError(\n      `bulkFindByIndex requires an index with at least one prop-based field on index \"${indexName}\" (node kind \"${kind}\")`,\n      { indexName, kind },\n      {\n        suggestion:\n          \"bulkFindByIndex probes by legacy prop fields from each item; an index declared with ordered keys, keySystemColumns, or coveringFields but no fields has nothing to probe by.\",\n      },\n    );\n  }\n\n  // Date-typed lookup keys can't satisfy the cross-backend parity guarantee:\n  // SQLite compares stored ISO text byte-wise while Postgres compares\n  // timestamptz instants, so equal instants in different ISO forms diverge.\n  // Declare the gap rather than return backend-dependent results.\n  if (index.fieldValueTypes.includes(\"date\")) {\n    throw new ConfigurationError(\n      `bulkFindByIndex does not support date-typed key fields on index \"${indexName}\" (node kind \"${kind}\")`,\n      { indexName, kind },\n      {\n        suggestion:\n          \"Date index keys compare differently across SQLite and PostgreSQL. Use a string-encoded key field, or query date predicates via store.query(...).where(...).\",\n      },\n    );\n  }\n\n  const limitPerInput = options?.limitPerInput;\n  if (\n    limitPerInput !== undefined &&\n    (!Number.isInteger(limitPerInput) || limitPerInput <= 0)\n  ) {\n    throw new ValidationError(\n      \"bulkFindByIndex limitPerInput must be a positive integer\",\n      {\n        entityType: \"node\",\n        kind,\n        issues: [\n          {\n            path: \"limitPerInput\",\n            message: `Expected a positive integer, received ${String(limitPerInput)}`,\n            code: \"invalid_value\",\n          },\n        ],\n      },\n    );\n  }\n\n  const adapter = getDialect(backend.dialect);\n\n  // 1. Extract + validate each input's indexed-field probe tuple.\n  const probes: unknown[][] = items.map((item) =>\n    index.fields.map((pointer, position) => {\n      const value = resolveJsonPointer(item.props, pointer);\n      validateIndexProbeValue(\n        value,\n        index.fieldValueTypes[position],\n        pointer,\n        kind,\n      );\n      return value;\n    }),\n  );\n\n  // 2. Dedupe probe tuples; map each distinct tuple to its input positions.\n  const groupByKey = new Map<string, number>();\n  const groupProbes: unknown[][] = [];\n  const groupToInputs: number[][] = [];\n  for (const [inputIndex, probe] of probes.entries()) {\n    const key = canonicalIndexProbeKey(probe);\n    const existing = groupByKey.get(key);\n    if (existing === undefined) {\n      groupByKey.set(key, groupProbes.length);\n      groupProbes.push(probe);\n      groupToInputs.push([inputIndex]);\n      continue;\n    }\n    groupToInputs[existing]?.push(inputIndex);\n  }\n\n  // 3. Build probe predicates shared by the CASE selector and WHERE filter.\n  const schema =\n    backend.tableNames ?\n      createSqlSchema(backend.tableNames)\n    : DEFAULT_SQL_SCHEMA;\n  const compileContext: IndexCompilationContext = {\n    dialect: backend.dialect,\n    propsColumn: sql.raw(`\"props\"`),\n    systemColumn: (column) => sql.raw(`\"${column}\"`),\n  };\n  const fieldKeys = compileNodeIndexFieldKeys(index, compileContext);\n\n  const groupPredicates = groupProbes.map(\n    (probe) =>\n      sql`(${sql.join(\n        fieldKeys.map((fieldKey, position) => {\n          const value = probe[position];\n          if (value === undefined || value === null) {\n            return sql`${fieldKey} IS NULL`;\n          }\n          return adapter.nullSafeEquals(\n            fieldKey,\n            sql`${coerceIndexProbeBind(value, adapter)}`,\n          );\n        }),\n        sql` AND `,\n      )})`,\n  );\n\n  const caseBranches = groupPredicates.map(\n    (predicate, group) => sql`WHEN ${predicate} THEN ${sql.raw(String(group))}`,\n  );\n  const probeIndexExpr = sql`CASE ${sql.join(caseBranches, sql` `)} ELSE NULL END`;\n\n  const conditions: SqlFragment[] = [\n    sql`\"graph_id\" = ${ctx.graphId}`,\n    sql`\"kind\" = ${kind}`,\n    sql`\"deleted_at\" IS NULL`,\n  ];\n  if (index.where !== undefined) {\n    conditions.push(compileIndexWhere(compileContext, index.where));\n  }\n  conditions.push(sql`(${sql.join(groupPredicates, sql` OR `)})`);\n  const whereClause = sql.join(conditions, sql` AND `);\n\n  // The probe matching runs against the nodes table; rows are hydrated\n  // separately via the backend's normalized node reads so the returned\n  // shape is identical to every other node API (props/timestamp\n  // normalization is backend-owned, not re-derived from raw driver rows).\n  const probedSelect = sql`SELECT \"id\", ${probeIndexExpr} AS probe_idx FROM ${schema.nodesTable} WHERE ${whereClause}`;\n\n  // limitPerInput caps each input's candidates per probe group. When the\n  // backend supports window functions we cap in SQL (`ROW_NUMBER()`), which\n  // also avoids transferring excess ids on low-selectivity keys. Otherwise we\n  // degrade gracefully: fetch all matching ids and cap per group in JS before\n  // hydration — the cap stays correct, only the id transfer is unbounded.\n  const capInSql =\n    limitPerInput !== undefined && backend.capabilities.windowFunctions;\n\n  const query =\n    capInSql ?\n      sql`SELECT \"id\", probe_idx FROM (SELECT \"id\", probe_idx, ROW_NUMBER() OVER (PARTITION BY probe_idx ORDER BY \"id\") AS probe_rank FROM (${probedSelect}) AS probed) AS ranked WHERE probe_rank <= ${limitPerInput} ORDER BY probe_idx, \"id\"`\n    : sql`${probedSelect} ORDER BY probe_idx, \"id\"`;\n\n  // 4. Execute, hydrate matched nodes, and group back to input positions.\n  const rawMatches = await backend.execute<ProbeMatch>(\n    asCompiledRowsSql(query),\n  );\n  const matches =\n    limitPerInput !== undefined && !capInSql ?\n      capMatchesPerGroup(rawMatches, limitPerInput)\n    : rawMatches;\n\n  const nodesById = await hydrateNodesById(\n    backend,\n    ctx.batchPointRead,\n    ctx.graphId,\n    kind,\n    matches.map((match) => match.id),\n  );\n\n  const results: Node[][] = Array.from({ length: items.length }, () => []);\n  for (const match of matches) {\n    const node = nodesById.get(match.id);\n    if (node === undefined) continue;\n    const inputs = groupToInputs[match.probe_idx];\n    if (inputs === undefined) continue;\n    for (const inputIndex of inputs) {\n      results[inputIndex]?.push(node);\n    }\n  }\n\n  return results;\n}\n\ntype ProbeMatch = Readonly<{ id: string; probe_idx: number }>;\n\n/**\n * Caps matches to the first `limitPerInput` per probe group (the JS-side\n * equivalent of the `ROW_NUMBER()` window). Relies on `matches` already being\n * ordered by `(probe_idx, id)`, so the kept rows are the lowest ids per group.\n */\nfunction capMatchesPerGroup(\n  matches: readonly ProbeMatch[],\n  limitPerInput: number,\n): ProbeMatch[] {\n  const perGroupCount = new Map<number, number>();\n  const capped: ProbeMatch[] = [];\n  for (const match of matches) {\n    const count = perGroupCount.get(match.probe_idx) ?? 0;\n    if (count >= limitPerInput) continue;\n    perGroupCount.set(match.probe_idx, count + 1);\n    capped.push(match);\n  }\n  return capped;\n}\n\n/** Hydrates live nodes by id via the backend's normalized node reads. */\nasync function hydrateNodesById(\n  backend: GraphBackend | TransactionBackend,\n  batchPointRead: BundleVerdictOf<typeof BATCH_POINT_READ>,\n  graphId: string,\n  kind: string,\n  ids: readonly string[],\n): Promise<Map<string, Node>> {\n  const rowsById = await getNodeRowsByIds(\n    backend,\n    batchPointRead,\n    graphId,\n    kind,\n    ids,\n  );\n  const nodesById = new Map<string, Node>();\n  for (const [id, row] of rowsById) {\n    if (row.deleted_at !== undefined) continue;\n    nodesById.set(id, rowToNode(row));\n  }\n  return nodesById;\n}\n\n// ============================================================\n// Bulk Get-Or-Create-By-Constraint\n// ============================================================\n\nexport async function executeNodeBulkGetOrCreateByConstraint<\n  G extends GraphDef,\n>(\n  ctx: NodeOperationContext<G>,\n  kind: string,\n  constraintName: string,\n  items: readonly Readonly<{ props: Record<string, unknown> }>[],\n  backend: GraphBackend | TransactionBackend,\n  options?: NodeGetOrCreateByConstraintOptions,\n): Promise<Readonly<{ node: Node; action: GetOrCreateAction }>[]> {\n  if (items.length === 0) return [];\n\n  const ifExists = options?.ifExists ?? \"return\";\n  const registration = getNodeRegistration(ctx.graph, kind);\n  const nodeKind = registration.type;\n  const constraint = resolveConstraint(ctx.graph, kind, constraintName);\n\n  // Step 1: Validate all props and compute keys\n  const validated = validateAndComputeKeys(nodeKind, kind, constraint, items);\n  const uniqueKeys = collectUniqueKeys(validated);\n\n  const kindsToCheck = uniquenessProbeKinds(\n    kind,\n    constraint.scope,\n    ctx.registry,\n  );\n\n  type Result = Readonly<{ node: Node; action: GetOrCreateAction }>;\n\n  // Steps 2-6 are one convergence attempt: the batch probe runs outside any\n  // transaction and each write leg opens its own, so a concurrent create can\n  // reserve a key between them. The uniques primary key catches that and raises\n  // `UniquenessError`; re-running the whole attempt converges on the winner's\n  // row. Without this the single-item path retried and the batch failed\n  // outright, which is the asymmetry #428 called out.\n  async function attempt(): Promise<Result[]> {\n    // Step 2: Batch-check existing keys\n    const existingByKey =\n      uniqueKeys.length > 0 ?\n        await batchCheckUniqueAcrossKinds(\n          backend,\n          ctx.uniqueSidecarBatch,\n          ctx.graphId,\n          constraint.name,\n          uniqueKeys,\n          kindsToCheck,\n          true,\n        )\n      : new Map<\n          string,\n          {\n            node_id: string;\n            concrete_kind: string;\n            deleted_at: string | undefined;\n          }\n        >();\n\n    // Step 3: Partition into toCreate, toFetch, and duplicates\n    const toCreate: { index: number; input: CreateNodeInput }[] = [];\n    const toFetch: {\n      index: number;\n      nodeId: string;\n      concreteKind: string;\n      validatedProps: Record<string, unknown>;\n    }[] = [];\n    const duplicateOf: { index: number; sourceIndex: number }[] = [];\n    const seenKeys = new Map<string, number>();\n\n    for (const [index, { validatedProps, key }] of validated.entries()) {\n      if (key === undefined) {\n        toCreate.push({ index, input: { kind, props: validatedProps } });\n        continue;\n      }\n\n      const previousIndex = seenKeys.get(key);\n      if (previousIndex !== undefined) {\n        duplicateOf.push({ index, sourceIndex: previousIndex });\n        continue;\n      }\n\n      seenKeys.set(key, index);\n\n      const existing = existingByKey.get(key);\n      if (existing === undefined) {\n        toCreate.push({ index, input: { kind, props: validatedProps } });\n      } else {\n        toFetch.push({\n          index,\n          nodeId: existing.node_id,\n          concreteKind: existing.concrete_kind,\n          validatedProps,\n        });\n      }\n    }\n\n    const results: Result[] = Array.from({ length: items.length });\n\n    // Step 4: Execute creates\n    if (toCreate.length > 0) {\n      const createInputs = toCreate.map((entry) => entry.input);\n      const createdNodes = await executeNodeCreateBatch(\n        ctx,\n        createInputs,\n        backend,\n        { propsPreValidated: true },\n      );\n      for (const [batchIndex, entry] of toCreate.entries()) {\n        results[entry.index] = {\n          node: requireDefined(createdNodes[batchIndex]),\n          action: \"created\",\n        };\n      }\n    }\n\n    // Step 5: Handle existing nodes (fetch/update/resurrect)\n    for (const entry of toFetch) {\n      const { index, concreteKind, validatedProps, nodeId } = entry;\n\n      const existingRow = await backend.getNode(\n        ctx.graphId,\n        concreteKind,\n        nodeId,\n      );\n\n      if (existingRow === undefined) {\n        const node = await executeNodeCreate(\n          ctx,\n          { kind, props: validatedProps },\n          backend,\n          { propsPreValidated: true },\n        );\n        results[index] = { node, action: \"created\" };\n        continue;\n      }\n\n      // Read from the NODE ROW this loop just fetched, not from the uniques row\n      // the batch probe captured back in step 2 — the single-item path has\n      // always derived it here (see `executeNodeGetOrCreateByConstraint`), and\n      // one decision with two owners drifts. The uniques copy is also the\n      // staler of the two: step 4's creates run between the probe and this\n      // read, and a peer can soft-delete or resurrect the node in that window.\n      // Whether this write RESURRECTS has to come from the row it will target.\n      const isSoftDeleted = existingRow.deleted_at !== undefined;\n\n      if (isSoftDeleted || ifExists === \"update\") {\n        const node = await executeNodeUpsertUpdate(\n          ctx,\n          {\n            kind: concreteKind,\n            id: existingRow.id as UpdateNodeInput[\"id\"],\n            props: validatedProps,\n          },\n          backend,\n          { clearDeleted: isSoftDeleted },\n        );\n        results[index] = {\n          node,\n          action: isSoftDeleted ? \"resurrected\" : \"updated\",\n        };\n      } else {\n        results[index] = { node: rowToNode(existingRow), action: \"found\" };\n      }\n    }\n\n    // Step 6: Resolve within-batch duplicates by copying the first occurrence's result\n    for (const { index, sourceIndex } of duplicateOf) {\n      const sourceResult = requireDefined(results[sourceIndex]);\n      results[index] = { node: sourceResult.node, action: \"found\" };\n    }\n\n    return results;\n  }\n\n  try {\n    return await attempt();\n  } catch (error) {\n    if (!(error instanceof UniquenessError)) throw error;\n    return attempt();\n  }\n}\n"]}