{"version":3,"sources":["../src/backend/capabilities/autocommit-single-statement.ts","../src/backend/capabilities/node-insert-projections.ts","../src/backend/resolved-node-update-batch.ts"],"names":["supportsAtomicNodeClaims"],"mappings":";;;;;AAaA,IAAM,gCAAA,uBAAuC,OAAA,EAAgB;AAGtD,SAAS,kCACd,MAAA,EACG;AACH,EAAA,gCAAA,CAAiC,IAAI,MAAM,CAAA;AAC3C,EAAA,OAAO,MAAA;AACT;AAGO,SAAS,gCACd,MAAA,EACwB;AACxB,EAAA,OAAO,gCAAA,CAAiC,IAAI,MAAM,CAAA;AACpD;;;ACRO,SAAS,wCAAA,CACd,QACA,YAAA,EACS;AACT,EAAA,OAAA,CACG,CAAC,YAAA,CAAa,QAAA,IACb,MAAA,CAAO,gBAAA,EAAkB,yBAAA,KAA8B,MAAA,MACxD,CAAC,YAAA,CAAa,SAAA,IACb,MAAA,CAAO,cAAA,EAAgB,2BAAA,KAAgC,MAAA,CAAA;AAE7D;AAUO,SAAS,6BAAA,CACd,QACA,WAAA,EACS;AACT,EAAA,IAAI,WAAA,CAAY,MAAA,KAAW,CAAA,EAAG,OAAO,KAAA;AACrC,EAAA,OAAO,yCAAyC,MAAA,EAAQ;AAAA,IACtD,UAAU,WAAA,CAAY,IAAA,CAAK,CAAC,UAAA,KAAe,UAAA,CAAW,SAAS,UAAU,CAAA;AAAA,IACzE,WAAW,WAAA,CAAY,IAAA;AAAA,MACrB,CAAC,UAAA,KAAe,UAAA,CAAW,IAAA,KAAS;AAAA;AACtC,GACD,CAAA;AACH;AAaA,SAAS,yBAAyB,MAAA,EAA6C;AAC7E,EAAA,OACE,EAAE,aAAA,IAAiB,MAAA,CAAA,IACnB,MAAA,CAAO,aAAa,sBAAA,KAA2B,IAAA;AAEnD;AASA,SAAS,sCACP,IAAA,EAIS;AACT,EAAA,OACE,IAAA,CAAK,WAAA,IACL,IAAA,CAAK,IAAA,CAAK,SAAS,UAAA,IACnB,IAAA,CAAK,WAAA,CAAY,MAAA,KAAW,KAC5B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M,CAAA,IAC7B,iBAAiB,MAAA,IAAU,eAAA,KAC9B,yCAAyC,MAAA,EAAQ;AAAA,IAC/C,QAAA,EAAU,MAAM,WAAA,CAAY,IAAA;AAAA,MAC1B,CAAC,UAAA,KAAe,UAAA,CAAW,IAAA,KAAS;AAAA,KACtC;AAAA,IACA,SAAA,EAAW,MAAM,WAAA,CAAY,IAAA;AAAA,MAC3B,CAAC,UAAA,KAAe,UAAA,CAAW,IAAA,KAAS;AAAA;AACtC,GACD,CAAA;AAEL;;;AC7MA,IAAM,2CAAA,GAA8C,CAAA;AAGpD,IAAM,2CAAA,GAA8C,CAAA;AAO7C,SAAS,qCAAA,CACd,YACA,iBAAA,EACS;AACT,EAAA,IAAI,CAAC,MAAA,CAAO,aAAA,CAAc,UAAU,CAAA,IAAK,UAAA,GAAa,GAAG,OAAO,KAAA;AAChE,EAAA,IAAI,iBAAA,KAAsB,QAAW,OAAO,IAAA;AAC5C,EAAA,OACE,2CAAA,GACE,aAAa,2CAAA,IACf,iBAAA;AAEJ","file":"chunk-I7SBZJI2.cjs","sourcesContent":["/**\n * Origin evidence for the managed single-statement autocommit fast path.\n *\n * This is intentionally narrower than schema-fenced-insert eligibility. The\n * latter follows bundled transaction targets and derived wrappers because its\n * statement still runs inside an explicit transaction. Here, omitting that\n * transaction is the optimization, so only the literal root objects produced\n * by the bundled factories may opt in. In particular, this evidence is never\n * carried through `deriveBackend`, an owned transaction, or adoption of a\n * caller-owned transaction.\n */\nimport type { GraphBackend, TransactionBackend } from \"../types\";\n\nconst BUNDLED_ROOT_AUTOCOMMIT_BACKENDS = new WeakSet<object>();\n\n/** @internal Called only by bundled factories after their root backend exists. */\nexport function markBundledRootAutocommitEligible<T extends object>(\n  target: T,\n): T {\n  BUNDLED_ROOT_AUTOCOMMIT_BACKENDS.add(target);\n  return target;\n}\n\n/** Whether this is the exact root backend a bundled factory created. */\nexport function isBundledRootAutocommitEligible(\n  target: GraphBackend | TransactionBackend,\n): target is GraphBackend {\n  return BUNDLED_ROOT_AUTOCOMMIT_BACKENDS.has(target);\n}\n","import type {\n  BackendIdentity,\n  GraphBackend,\n  ManagedNodeCreatePlan,\n  NodeInsertClaim,\n  NodeInsertProjection,\n} from \"../types\";\nimport {\n  type AtomicNodeClaimSupport,\n  supportsAtomicNodeClaims,\n} from \"./atomic-mutation-program\";\n\nexport type NodeProjectionInsertTarget = BackendIdentity &\n  Pick<GraphBackend, \"commands\">;\n\nexport type NodeInsertProjectionRequirements = Readonly<{\n  fulltext: boolean;\n  embedding: boolean;\n}>;\n\nexport function supportsNodeInsertProjectionRequirements(\n  target: NodeProjectionInsertTarget,\n  requirements: NodeInsertProjectionRequirements,\n): boolean {\n  return (\n    (!requirements.fulltext ||\n      target.fulltextStrategy?.buildSyncFromInsertedNode !== undefined) &&\n    (!requirements.embedding ||\n      target.vectorStrategy?.buildUpsertFromInsertedNode !== undefined)\n  );\n}\n\n/**\n * The single owner of projection-fusion eligibility.\n *\n * A projection plan is all-or-nothing: every requested projection must have\n * an inserted-node builder on the active strategy, and the receiver must\n * expose the atomic executor. Callers use this same predicate before choosing\n * root autocommit and again on the actual transaction callback target.\n */\nexport function supportsNodeInsertProjections(\n  target: NodeProjectionInsertTarget,\n  projections: readonly NodeInsertProjection[],\n): boolean {\n  if (projections.length === 0) return false;\n  return supportsNodeInsertProjectionRequirements(target, {\n    fulltext: projections.some((projection) => projection.kind === \"fulltext\"),\n    embedding: projections.some(\n      (projection) => projection.kind === \"embedding\",\n    ),\n  });\n}\n\n/**\n * Whether the receiver can make uniqueness/disjointness claims authoritative\n * inside the planned node statement.\n *\n * Claims are reported by the statement as a verdict, so the caller must have a\n * transaction boundary around the statement before it can safely defer the\n * application probes. A root backend is deliberately excluded: its\n * command port is also used for projection-only\n * autocommit writes, but a claim refusal must roll back the node and any\n * claims it touched together.\n */\nfunction supportsNodeInsertClaims(target: NodeProjectionInsertTarget): boolean {\n  return (\n    !(\"transaction\" in target) &&\n    target.capabilities.atomicNodeInsertClaims === true\n  );\n}\n\n/**\n * The only claim shape that is safe to execute on a root backend without a\n * rollback boundary. A generated id cannot collide with a different node, so\n * the claim is the sole conflict source; same-kind uniqueness has no legacy\n * axis or cross-kind/disjoint probe to consult. Rephasing it before the node\n * insert makes a conflict prevent the node row from being written at all.\n */\nfunction supportsNonTransactionalNodeClaimPlan(\n  plan: Pick<\n    ManagedNodeCreatePlan,\n    \"idGenerated\" | \"mode\" | \"params\" | \"claims\" | \"projections\"\n  >,\n): boolean {\n  return (\n    plan.idGenerated &&\n    plan.mode.kind === \"ordinary\" &&\n    plan.projections.length === 0 &&\n    plan.claims.length === 1 &&\n    plan.claims.every(\n      (claim) =>\n        claim.verdict.kind === \"uniqueness\" &&\n        claim.axis === plan.params.kind &&\n        claim.verdict.probeAxes.length === 1 &&\n        claim.verdict.probeAxes[0] === claim.axis,\n    )\n  );\n}\n\n/** Rephases the safe root claim shape so a conflict gates the node insert. */\nexport function rephaseNonTransactionalNodeClaimPlan(\n  plan: ManagedNodeCreatePlan,\n): ManagedNodeCreatePlan | undefined {\n  if (!supportsNonTransactionalNodeClaimPlan(plan)) return;\n  return {\n    ...plan,\n    claims: plan.claims.map((claim) => ({\n      ...claim,\n      placement: \"pre-insert\",\n    })),\n  };\n}\n\n/**\n * Normalizes the complete claim envelope accepted by an atomic node program.\n *\n * Unlike the ordinary root insert seam, a closed program can also prove a\n * disjoint claim because it carries the legacy live-node probe and cleanup in\n * the same atomic transport submission. The executor's advertised support is\n * authoritative; an omitted family remains on the portable path.\n */\nexport function rephaseAtomicNodeClaimPlan(\n  plan: ManagedNodeCreatePlan,\n  support: AtomicNodeClaimSupport | undefined,\n): ManagedNodeCreatePlan | undefined {\n  if (\n    plan.mode.kind !== \"ordinary\" ||\n    plan.claims.length === 0 ||\n    !supportsAtomicNodeClaims(support, plan.claims)\n  ) {\n    return;\n  }\n  const supported = plan.claims.every((claim) => {\n    if (claim.verdict.kind === \"uniqueness\") {\n      return (\n        claim.verdict.probeAxes.length > 0 &&\n        claim.verdict.probeAxes[0] === claim.axis &&\n        new Set(claim.verdict.probeAxes).size === claim.verdict.probeAxes.length\n      );\n    }\n    return (\n      claim.key === plan.params.id &&\n      claim.verdict.conflictingKinds.length > 0 &&\n      new Set(claim.verdict.conflictingKinds).size ===\n        claim.verdict.conflictingKinds.length\n    );\n  });\n  if (!supported) return;\n  return {\n    ...plan,\n    claims: plan.claims.map((claim) => ({\n      ...claim,\n      placement: \"pre-insert\",\n    })),\n  };\n}\n\n/** Whether the receiver can lower this complete insert plan atomically. */\nexport function supportsNodeCreatePlan(\n  target: NodeProjectionInsertTarget,\n  input: Readonly<{\n    params?: ManagedNodeCreatePlan[\"params\"];\n    idGenerated?: ManagedNodeCreatePlan[\"idGenerated\"];\n    mode?: ManagedNodeCreatePlan[\"mode\"];\n    claims: readonly NodeInsertClaim[];\n    projections: readonly NodeInsertProjection[];\n    /** Store-side proof that no identity/history/revision side effect exists. */\n    allowNonTransactionalClaims?: boolean | undefined;\n  }>,\n): boolean {\n  if (input.claims.length === 0) {\n    return supportsNodeInsertProjections(target, input.projections);\n  }\n  // A claim refusal is discovered from the data-modifying statement's result,\n  // so the caller-owned transaction is the rollback boundary. Root graph\n  // backends expose `transaction`; transaction-scoped operation backends do\n  // not. Keep this exported predicate aligned with the execution contract.\n  const ordinaryPlan =\n    (\n      input.params === undefined ||\n      input.mode === undefined ||\n      input.idGenerated === undefined\n    ) ?\n      undefined\n    : {\n        entity: \"node\" as const,\n        params: input.params,\n        idGenerated: input.idGenerated,\n        mode: input.mode,\n        claims: input.claims,\n        projections: input.projections,\n      };\n  const rootClaimFusion =\n    input.allowNonTransactionalClaims === true &&\n    target.capabilities.atomicNodeInsertClaims === true &&\n    ordinaryPlan !== undefined &&\n    supportsNonTransactionalNodeClaimPlan(ordinaryPlan);\n  return (\n    (supportsNodeInsertClaims(target) ||\n      (\"transaction\" in target && rootClaimFusion)) &&\n    supportsNodeInsertProjectionRequirements(target, {\n      fulltext: input.projections.some(\n        (projection) => projection.kind === \"fulltext\",\n      ),\n      embedding: input.projections.some(\n        (projection) => projection.kind === \"embedding\",\n      ),\n    })\n  );\n}\n","/**\n * Bind parameters in one resolved node replacement statement, excluding its\n * entries: two graph/kind predicates, the update timestamp, and the count gate.\n */\nconst RESOLVED_NODE_UPDATE_BATCH_FIXED_BIND_COUNT = 6;\n\n/** Each entry contributes one relational id/props/version row. */\nconst RESOLVED_NODE_UPDATE_BATCH_ENTRY_BIND_COUNT = 3;\n\n/**\n * The one owner of whether the portable resolved-update statement fits the\n * target's advertised bind budget. An absent budget is an explicit admission\n * that this backend has no known ceiling.\n */\nexport function resolvedNodeUpdateBatchFitsBindBudget(\n  entryCount: number,\n  maxBindParameters: number | undefined,\n): boolean {\n  if (!Number.isSafeInteger(entryCount) || entryCount < 1) return false;\n  if (maxBindParameters === undefined) return true;\n  return (\n    RESOLVED_NODE_UPDATE_BATCH_FIXED_BIND_COUNT +\n      entryCount * RESOLVED_NODE_UPDATE_BATCH_ENTRY_BIND_COUNT <=\n    maxBindParameters\n  );\n}\n"]}