@nicia-ai/typegraph 0.57.0 → 0.57.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/backend/drizzle/engine/index.cjs +8 -8
  3. package/dist/backend/drizzle/engine/index.d.cts +4 -4
  4. package/dist/backend/drizzle/engine/index.d.ts +4 -4
  5. package/dist/backend/drizzle/engine/index.js +3 -3
  6. package/dist/backend/drizzle/indexes.cjs +6 -6
  7. package/dist/backend/drizzle/indexes.js +2 -2
  8. package/dist/backend/postgres/index.cjs +17 -17
  9. package/dist/backend/postgres/index.d.cts +2 -2
  10. package/dist/backend/postgres/index.d.ts +2 -2
  11. package/dist/backend/postgres/index.js +3 -3
  12. package/dist/backend/postgres/pglite-store.cjs +1 -1
  13. package/dist/backend/postgres/pglite-store.js +1 -1
  14. package/dist/backend/postgres/pglite.cjs +5 -5
  15. package/dist/backend/postgres/pglite.js +4 -4
  16. package/dist/backend/sqlite/index.cjs +16 -16
  17. package/dist/backend/sqlite/index.d.cts +2 -2
  18. package/dist/backend/sqlite/index.d.ts +2 -2
  19. package/dist/backend/sqlite/index.js +3 -3
  20. package/dist/backend/sqlite/libsql.cjs +7 -7
  21. package/dist/backend/sqlite/libsql.js +3 -3
  22. package/dist/backend/sqlite/local-store.cjs +1 -1
  23. package/dist/backend/sqlite/local-store.js +1 -1
  24. package/dist/backend/sqlite/local.cjs +5 -5
  25. package/dist/backend/sqlite/local.js +4 -4
  26. package/dist/{chunk-B2FYH5VR.cjs → chunk-2GXLAV4H.cjs} +2 -2
  27. package/dist/{chunk-B2FYH5VR.cjs.map → chunk-2GXLAV4H.cjs.map} +1 -1
  28. package/dist/{chunk-S2U4AZEO.js → chunk-3B6AEIK4.js} +3 -3
  29. package/dist/{chunk-S2U4AZEO.js.map → chunk-3B6AEIK4.js.map} +1 -1
  30. package/dist/{chunk-PZJYWJQB.cjs → chunk-C2LSQ3SJ.cjs} +6 -6
  31. package/dist/{chunk-PZJYWJQB.cjs.map → chunk-C2LSQ3SJ.cjs.map} +1 -1
  32. package/dist/{chunk-CZNYXNOY.cjs → chunk-DIVOGAPS.cjs} +90 -82
  33. package/dist/chunk-DIVOGAPS.cjs.map +1 -0
  34. package/dist/{chunk-GSRUQXYE.cjs → chunk-G72YXUND.cjs} +5 -5
  35. package/dist/{chunk-GSRUQXYE.cjs.map → chunk-G72YXUND.cjs.map} +1 -1
  36. package/dist/{chunk-DLDGDFDF.js → chunk-MPX2F64V.js} +3 -3
  37. package/dist/{chunk-DLDGDFDF.js.map → chunk-MPX2F64V.js.map} +1 -1
  38. package/dist/{chunk-AKCXD3VV.js → chunk-N7XZENEJ.js} +26 -18
  39. package/dist/chunk-N7XZENEJ.js.map +1 -0
  40. package/dist/{chunk-2EMCMUTX.js → chunk-NDLVGHQA.js} +3 -3
  41. package/dist/{chunk-2EMCMUTX.js.map → chunk-NDLVGHQA.js.map} +1 -1
  42. package/dist/{chunk-BP3ANNRA.cjs → chunk-NLLZSEHL.cjs} +8 -8
  43. package/dist/{chunk-BP3ANNRA.cjs.map → chunk-NLLZSEHL.cjs.map} +1 -1
  44. package/dist/{chunk-RWE33LCI.js → chunk-NXK2ZBVV.js} +2 -2
  45. package/dist/{chunk-RWE33LCI.js.map → chunk-NXK2ZBVV.js.map} +1 -1
  46. package/dist/{chunk-53GIRRN2.cjs → chunk-TDRZ46SF.cjs} +12 -12
  47. package/dist/{chunk-53GIRRN2.cjs.map → chunk-TDRZ46SF.cjs.map} +1 -1
  48. package/dist/{chunk-OX2NMPRS.js → chunk-UJW55GPE.js} +3 -3
  49. package/dist/{chunk-OX2NMPRS.js.map → chunk-UJW55GPE.js.map} +1 -1
  50. package/dist/graph-merge/index.cjs +9 -9
  51. package/dist/graph-merge/index.js +2 -2
  52. package/dist/index.cjs +42 -42
  53. package/dist/index.js +2 -2
  54. package/dist/indexes/index.cjs +3 -3
  55. package/dist/indexes/index.js +1 -1
  56. package/dist/{local-store-impl-HRFYR5WM.cjs → local-store-impl-EDCPRE6P.cjs} +10 -10
  57. package/dist/{local-store-impl-HRFYR5WM.cjs.map → local-store-impl-EDCPRE6P.cjs.map} +1 -1
  58. package/dist/{local-store-impl-JSXB77IJ.js → local-store-impl-GAWJELMM.js} +7 -7
  59. package/dist/{local-store-impl-JSXB77IJ.js.map → local-store-impl-GAWJELMM.js.map} +1 -1
  60. package/dist/{pglite-store-impl-Z47DA4XJ.js → pglite-store-impl-7GHPD535.js} +7 -7
  61. package/dist/{pglite-store-impl-Z47DA4XJ.js.map → pglite-store-impl-7GHPD535.js.map} +1 -1
  62. package/dist/{pglite-store-impl-OVR7CZ34.cjs → pglite-store-impl-AJ5E6PGZ.cjs} +10 -10
  63. package/dist/{pglite-store-impl-OVR7CZ34.cjs.map → pglite-store-impl-AJ5E6PGZ.cjs.map} +1 -1
  64. package/dist/{postgres-pzUsZov1.d.ts → postgres-BI8Msmji.d.ts} +1 -1
  65. package/dist/{postgres-BpGAssib.d.cts → postgres-Bj_zNOpG.d.cts} +1 -1
  66. package/dist/{profile-DBDoRSzj.d.ts → profile-DEx6nWHO.d.ts} +10 -10
  67. package/dist/{profile-D1_16oM5.d.cts → profile-DLncvbZ_.d.cts} +10 -10
  68. package/dist/{sqlite-Bg5h3Jk0.d.ts → sqlite-C7AHJCO4.d.ts} +1 -1
  69. package/dist/{sqlite-BzHm5Mc2.d.cts → sqlite-CL86_33e.d.cts} +1 -1
  70. package/package.json +1 -1
  71. package/dist/chunk-AKCXD3VV.js.map +0 -1
  72. package/dist/chunk-CZNYXNOY.cjs.map +0 -1
@@ -257,5 +257,5 @@ function sinceIndexAdoptionDdl(recordedTableNames) {
257
257
  }
258
258
 
259
259
  export { SYSTEM_INDEX_DECLARATIONS, assertNoSystemIndexNameCollision, generateSystemIndexDDL, resolveSystemIndexNames, resolveSystemIndexTableName, sinceIndexAdoptionDdl, systemIndexName };
260
- //# sourceMappingURL=chunk-RWE33LCI.js.map
261
- //# sourceMappingURL=chunk-RWE33LCI.js.map
260
+ //# sourceMappingURL=chunk-NXK2ZBVV.js.map
261
+ //# sourceMappingURL=chunk-NXK2ZBVV.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/indexes/system.ts"],"names":[],"mappings":";;;;AA8EO,IAAM,yBAAA,GAA+D;AAAA;AAAA,EAE1E,EAAE,OAAO,OAAA,EAAS,MAAA,EAAQ,YAAY,OAAA,EAAS,CAAC,UAAA,EAAY,MAAM,CAAA,EAAE;AAAA;AAAA;AAAA;AAAA,EAIpE;AAAA,IACE,KAAA,EAAO,OAAA;AAAA,IACP,MAAA,EAAQ,kBAAA;AAAA,IACR,OAAA,EAAS,CAAC,UAAA,EAAY,MAAA,EAAQ,cAAc,YAAY;AAAA,GAC1D;AAAA,EACA;AAAA,IACE,KAAA,EAAO,OAAA;AAAA,IACP,MAAA,EAAQ,aAAA;AAAA,IACR,OAAA,EAAS,CAAC,UAAA,EAAY,YAAY;AAAA,GACpC;AAAA,EACA;AAAA,IACE,KAAA,EAAO,OAAA;AAAA,IACP,MAAA,EAAQ,WAAA;AAAA,IACR,OAAA,EAAS,CAAC,UAAA,EAAY,YAAA,EAAc,UAAU;AAAA,GAChD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,EAAE,OAAO,OAAA,EAAS,MAAA,EAAQ,UAAU,OAAA,EAAS,CAAC,UAAA,EAAY,IAAI,CAAA,EAAE;AAAA;AAAA,EAGhE,EAAE,OAAO,OAAA,EAAS,MAAA,EAAQ,YAAY,OAAA,EAAS,CAAC,UAAA,EAAY,MAAM,CAAA,EAAE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASpE;AAAA,IACE,KAAA,EAAO,OAAA;AAAA,IACP,MAAA,EAAQ,UAAA;AAAA,IACR,OAAA,EAAS;AAAA,MACP,UAAA;AAAA,MACA,WAAA;AAAA,MACA,SAAA;AAAA,MACA,MAAA;AAAA,M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,IAAA,OAAO,sBAAA,CAAuB,WAAA,EAAa,kBAAA,CAAmB,KAAK,CAAA,EAAG;AAAA,MACpE,UAAA,EAAY;AAAA,KACb,CAAA;AAAA,EACH;AACA,EAAA,SAAS,+BAAA,GAA0C;AACjD,IAAA,MAAM,IAAA,GAAO,eAAA;AAAA,MACX,eAAA;AAAA,QACE,kBAAA,CAAmB,0BAAA;AAAA,QACnB;AAAA;AACF,KACF;AACA,IAAA,MAAM,KAAA,GAAQ,eAAA;AAAA,MACZ,kBAAA,CAAmB;AAAA,KACrB;AACA,IAAA,OAAO,CAAA,2BAAA,EAA8B,IAAI,CAAA,IAAA,EAAO,KAAK,CAAA,EAAA,EAAK,eAAA,CAAgB,UAAU,CAAC,CAAA,EAAA,EAAK,eAAA,CAAgB,eAAe,CAAC,CAAA,EAAA,CAAA;AAAA,EAC5H;AACA,EAAA,OAAO;AAAA,IACL,iBAAiB,eAAe,CAAA;AAAA,IAChC,iBAAiB,eAAe,CAAA;AAAA,IAChC,+BAAA;AAAgC,GAClC;AACF","file":"chunk-RWE33LCI.js","sourcesContent":["/**\n * System-index declarations — the single source of truth for the plain\n * btree indexes TypeGraph ships on its own relations.\n *\n * Both dialect schema factories (`createSqliteTables` /\n * `createPostgresTables`) derive their Drizzle index builders from this\n * list, so the two dialects cannot drift, and\n * `materializeSystemIndexes()` derives the same indexes as runtime DDL so\n * an index added in a new library version reaches already-initialized\n * databases (bootstrap DDL only runs on first boot — see\n * `loadActiveSchemaWithBootstrap`).\n *\n * Scope: non-unique btree column indexes on the four graph relations,\n * where performance iteration actually happens. Primary keys, unique /\n * partial-unique constraints, and status-table indexes are structural —\n * they are created with their table and never retrofitted — and stay in\n * the schema files.\n *\n * Changing a declaration's shape under the same suffix is a signature\n * drift: `materializeSystemIndexes` reports `failed` for it until the\n * operator drops the old physical index. Rename (new suffix) instead,\n * exactly like graph-declared indexes. Two acknowledged limits of that\n * contract: on databases whose indexes were bootstrap-created (no status\n * rows) an in-place reshape is undetectable at runtime — the rename rule\n * is enforced by review and the parity tests; and a renamed suffix\n * strands the old physical index (the runner only adds). When the first\n * rename actually happens, add a retired-suffixes list + drop path here.\n */\nimport { quoteIdentifier, shortHash } from \"../query/dialect/vector-strategy\";\nimport { requireDefined } from \"../utils/presence\";\n\n/** The TypeGraph relations that carry system indexes. */\nexport type SystemIndexTable =\n \"nodes\" | \"edges\" | \"recordedNodes\" | \"recordedEdges\";\n\ntype LiveColumn =\n | \"graph_id\"\n | \"kind\"\n | \"id\"\n | \"deleted_at\"\n | \"valid_from\"\n | \"valid_to\"\n | \"created_at\";\n\ntype LiveEdgeColumn =\n LiveColumn | \"from_kind\" | \"from_id\" | \"to_kind\" | \"to_id\";\n\ntype RecordedColumn =\n | \"graph_id\"\n | \"kind\"\n | \"id\"\n | \"valid_from\"\n | \"valid_to\"\n | \"recorded_from\"\n | \"recorded_to\";\n\ntype RecordedEdgeColumn =\n RecordedColumn | \"from_kind\" | \"from_id\" | \"to_kind\" | \"to_id\";\n\ntype SystemIndexColumnsFor<T extends SystemIndexTable> =\n T extends \"nodes\" ? LiveColumn\n : T extends \"edges\" ? LiveEdgeColumn\n : T extends \"recordedNodes\" ? RecordedColumn\n : RecordedEdgeColumn;\n\ntype SystemIndexDeclarationFor<T extends SystemIndexTable> = Readonly<{\n table: T;\n /** Physical index name is `${physicalTableName}_${suffix}`. */\n suffix: string;\n columns: readonly [SystemIndexColumnsFor<T>, ...SystemIndexColumnsFor<T>[]];\n}>;\n\nexport type SystemIndexDeclaration =\n | SystemIndexDeclarationFor<\"nodes\">\n | SystemIndexDeclarationFor<\"edges\">\n | SystemIndexDeclarationFor<\"recordedNodes\">\n | SystemIndexDeclarationFor<\"recordedEdges\">;\n\nexport const SYSTEM_INDEX_DECLARATIONS: readonly SystemIndexDeclaration[] = [\n // ---------------------------------------------------------- nodes\n { table: \"nodes\", suffix: \"kind_idx\", columns: [\"graph_id\", \"kind\"] },\n // Listing shape: kind partition ordered by creation with the\n // soft-delete column ahead of it so `deleted_at IS NULL` list queries\n // stay index-served.\n {\n table: \"nodes\",\n suffix: \"kind_created_idx\",\n columns: [\"graph_id\", \"kind\", \"deleted_at\", \"created_at\"],\n },\n {\n table: \"nodes\",\n suffix: \"deleted_idx\",\n columns: [\"graph_id\", \"deleted_at\"],\n },\n {\n table: \"nodes\",\n suffix: \"valid_idx\",\n columns: [\"graph_id\", \"valid_from\", \"valid_to\"],\n },\n // Bare-id lookup: the primary key leads with `kind` (graph_id, kind,\n // id), so a `WHERE graph_id = ? AND id = ?` probe that doesn't know the\n // kind can't seek it — SQLite falls back to a graph_id-only scan of\n // every node in the graph (~3M at LDBC SF1).\n // `store.algorithms.degree`'s node-kind subquery does exactly that\n // lookup (it resolves the seed's kind by id), so without this index\n // degree is a full nodes scan (~95ms at SF1). See typegraph#280.\n { table: \"nodes\", suffix: \"id_idx\", columns: [\"graph_id\", \"id\"] },\n\n // ---------------------------------------------------------- edges\n { table: \"edges\", suffix: \"kind_idx\", columns: [\"graph_id\", \"kind\"] },\n // Directional traversal index (outgoing): supports endpoint lookups\n // and extra filtering by edge kind / target kind. Includes every\n // system column the compiled query's soft-delete/temporal-validity\n // predicate touches (deleted_at, valid_from, valid_to), trailed by\n // to_id — the compiled traversal join reads `n.id = e.to_id` for an\n // outgoing traversal (standard-builders.ts), so without to_id here\n // the join still fetches the edge's heap row for that one column\n // even with the seek/predicate columns covered.\n {\n table: \"edges\",\n suffix: \"from_idx\",\n columns: [\n \"graph_id\",\n \"from_kind\",\n \"from_id\",\n \"kind\",\n \"to_kind\",\n \"deleted_at\",\n \"valid_from\",\n \"valid_to\",\n \"to_id\",\n ],\n },\n // Directional traversal index (incoming): mirrors from_idx for\n // reverse traversals, trailed by from_id for the same reason\n // (`n.id = e.from_id` for an incoming traversal).\n {\n table: \"edges\",\n suffix: \"to_idx\",\n columns: [\n \"graph_id\",\n \"to_kind\",\n \"to_id\",\n \"kind\",\n \"from_kind\",\n \"deleted_at\",\n \"valid_from\",\n \"valid_to\",\n \"from_id\",\n ],\n },\n {\n table: \"edges\",\n suffix: \"kind_created_idx\",\n columns: [\"graph_id\", \"kind\", \"deleted_at\", \"created_at\"],\n },\n {\n table: \"edges\",\n suffix: \"deleted_idx\",\n columns: [\"graph_id\", \"deleted_at\"],\n },\n {\n table: \"edges\",\n suffix: \"valid_idx\",\n columns: [\"graph_id\", \"valid_from\", \"valid_to\"],\n },\n // Cardinality enforcement: the one-per-endpoint check probes for a\n // currently-valid edge of a kind from a specific endpoint.\n {\n table: \"edges\",\n suffix: \"cardinality_idx\",\n columns: [\"graph_id\", \"kind\", \"from_kind\", \"from_id\", \"valid_to\"],\n },\n\n // ---------------------------------------------------------- recordedNodes\n {\n table: \"recordedNodes\",\n suffix: \"entity_idx\",\n columns: [\"graph_id\", \"kind\", \"id\", \"recorded_from\", \"recorded_to\"],\n },\n {\n table: \"recordedNodes\",\n suffix: \"open_idx\",\n columns: [\"graph_id\", \"recorded_to\"],\n },\n {\n table: \"recordedNodes\",\n suffix: \"valid_idx\",\n columns: [\"graph_id\", \"valid_from\", \"valid_to\"],\n },\n // Bare-id lookup parity with the live nodes table: recorded-pinned\n // reads swap this relation in as the node source, and `entity_idx`\n // leads with `kind`, so the same kind-by-bare-id probe (e.g.\n // `degree()` at a recorded coordinate) would otherwise scan every\n // historical version in the graph. See typegraph#280.\n { table: \"recordedNodes\", suffix: \"id_idx\", columns: [\"graph_id\", \"id\"] },\n // `recorded_from`-led lookup: `entity_idx` leads with `kind, id`, so it\n // cannot serve the lineage capability's changed-since scan\n // (`store/recorded-capture/lineage.ts`), which filters by `graph_id` and\n // `recorded_from` alone across every kind. Without this the scan is a\n // full per-graph table scan of every historical row.\n {\n table: \"recordedNodes\",\n suffix: \"since_idx\",\n columns: [\"graph_id\", \"recorded_from\"],\n },\n\n // ---------------------------------------------------------- recordedEdges\n {\n table: \"recordedEdges\",\n suffix: \"entity_idx\",\n columns: [\"graph_id\", \"kind\", \"id\", \"recorded_from\", \"recorded_to\"],\n },\n {\n table: \"recordedEdges\",\n suffix: \"open_idx\",\n columns: [\"graph_id\", \"recorded_to\"],\n },\n {\n table: \"recordedEdges\",\n suffix: \"from_idx\",\n columns: [\n \"graph_id\",\n \"from_kind\",\n \"from_id\",\n \"kind\",\n \"to_kind\",\n \"recorded_from\",\n \"recorded_to\",\n ],\n },\n {\n table: \"recordedEdges\",\n suffix: \"to_idx\",\n columns: [\n \"graph_id\",\n \"to_kind\",\n \"to_id\",\n \"kind\",\n \"from_kind\",\n \"recorded_from\",\n \"recorded_to\",\n ],\n },\n {\n table: \"recordedEdges\",\n suffix: \"valid_idx\",\n columns: [\"graph_id\", \"valid_from\", \"valid_to\"],\n },\n // `recorded_from`-led lookup, same rationale as recordedNodes' since_idx:\n // the directional indexes above lead with an endpoint, not `recorded_from`\n // alone, so they cannot serve the lineage capability's changed-since scan.\n {\n table: \"recordedEdges\",\n suffix: \"since_idx\",\n columns: [\"graph_id\", \"recorded_from\"],\n },\n];\n\n/** Default physical table names for the system-index relations. */\nconst DEFAULT_SYSTEM_INDEX_TABLE_NAMES: Readonly<\n Record<SystemIndexTable, string>\n> = {\n nodes: \"typegraph_nodes\",\n edges: \"typegraph_edges\",\n recordedNodes: \"typegraph_recorded_nodes\",\n recordedEdges: \"typegraph_recorded_edges\",\n};\n\n/**\n * Resolves the physical table name for a system-index relation, honoring\n * a backend's table-name overrides.\n */\nexport function resolveSystemIndexTableName(\n table: SystemIndexTable,\n overrides:\n Readonly<Partial<Record<SystemIndexTable, string | undefined>>> | undefined,\n): string {\n return overrides?.[table] ?? DEFAULT_SYSTEM_INDEX_TABLE_NAMES[table];\n}\n\n/**\n * PostgreSQL truncates identifiers to NAMEDATALEN-1 = 63 bytes SILENTLY —\n * two suffixes of one long custom table name would collide after\n * truncation, and the catalog probes (which compare by exact name) would\n * never match the stored name, re-attempting the build on every boot.\n * SQLite has no such limit but uses the same bound so the two dialects'\n * index sets stay in byte-for-byte parity. (Char-based like the vector\n * identifier bound — multibyte table names are out of scope.)\n */\nconst MAX_SQL_IDENTIFIER_LENGTH = 63;\n\n/**\n * Physical index name: `${physicalTableName}_${suffix}`, deterministically\n * truncated + hash-suffixed past the 63-char identifier bound so distinct\n * indexes stay distinct. Single choke point — the Drizzle builders, the\n * runtime DDL, the catalog probes, and the status keys all derive the\n * name here, so they can never disagree.\n */\nexport function systemIndexName(\n physicalTableName: string,\n suffix: string,\n): string {\n const full = `${physicalTableName}_${suffix}`;\n if (full.length <= MAX_SQL_IDENTIFIER_LENGTH) return full;\n const hash = shortHash(JSON.stringify([physicalTableName, suffix]));\n return `${full.slice(0, MAX_SQL_IDENTIFIER_LENGTH - 1 - hash.length)}_${hash}`;\n}\n\n/**\n * Every system index name for a deployment's (possibly overridden) table\n * names. Graph-declared index names must not collide with these: a\n * colliding `CREATE INDEX IF NOT EXISTS` would silently no-op against the\n * system index (wrong shape) while recording a false success — see the\n * guards in the schema factories and `materializeIndexes`.\n */\nexport function resolveSystemIndexNames(\n overrides:\n Readonly<Partial<Record<SystemIndexTable, string | undefined>>> | undefined,\n): ReadonlySet<string> {\n return new Set(\n SYSTEM_INDEX_DECLARATIONS.map((declaration) =>\n systemIndexName(\n resolveSystemIndexTableName(declaration.table, overrides),\n declaration.suffix,\n ),\n ),\n );\n}\n\n/**\n * Rejects graph-declared indexes whose names collide with this\n * deployment's system index names. Called by both dialect schema\n * factories so a colliding declaration fails at table-definition time\n * instead of silently no-opping against the (differently shaped) system\n * index at CREATE INDEX IF NOT EXISTS time. `materializeIndexes` applies\n * the same check per-declaration on its runtime path.\n */\nexport function assertNoSystemIndexNameCollision(\n indexes: readonly Readonly<{ name: string }>[],\n overrides:\n Readonly<Partial<Record<SystemIndexTable, string | undefined>>> | undefined,\n): void {\n if (indexes.length === 0) return;\n const reserved = resolveSystemIndexNames(overrides);\n for (const index of indexes) {\n if (reserved.has(index.name)) {\n throw new Error(\n `Index name \"${index.name}\" collides with a TypeGraph system ` +\n `index. Choose a different name — system index names are ` +\n `reserved, and a same-named CREATE INDEX IF NOT EXISTS would ` +\n `silently no-op against the system index instead of creating ` +\n `the declared one.`,\n );\n }\n }\n}\n\n/**\n * Runtime DDL for one system index — byte-compatible with the index the\n * bootstrap path creates from the Drizzle schema (same name, same\n * columns), plus `CONCURRENTLY` where the dialect supports building\n * without blocking writes.\n */\nexport function generateSystemIndexDDL(\n declaration: SystemIndexDeclaration,\n physicalTableName: string,\n options: Readonly<{ concurrent: boolean }>,\n): string {\n const name = quoteIdentifier(\n systemIndexName(physicalTableName, declaration.suffix),\n );\n const table = quoteIdentifier(physicalTableName);\n const columns = declaration.columns\n .map((column) => quoteIdentifier(column))\n .join(\", \");\n const concurrently = options.concurrent ? \"CONCURRENTLY \" : \"\";\n return `CREATE INDEX ${concurrently}IF NOT EXISTS ${name} ON ${table} (${columns});`;\n}\n\n/**\n * Runtime DDL for the base-schema release's three `since_idx (graph_id,\n * recorded_from)` indexes — the lineage capability's changed-since scan\n * (`store/recorded-capture/lineage.ts`): the two recorded relations\n * (`recordedNodes`, `recordedEdges`, declared in\n * {@link SYSTEM_INDEX_DECLARATIONS} and managed by `materializeIndexes`),\n * plus the recorded identity-assertions relation's own `since_idx`, which\n * `changesSince`'s per-revision completeness scan folds into the same\n * three-relation scan but which is NOT a {@link SystemIndexTable} — like that\n * relation's other three indexes (`entity_idx`/`a_idx`/`b_idx`), it is\n * structural, hand-declared with the table rather than run through\n * `materializeIndexes`' lazy backfill, and this function follows the same\n * pattern for it. Both dialect factories thread this into the base-schema\n * version-3 adoption step (`engine/members/base-schema-members.ts`) the\n * same way `fencesTableDdl` feeds version 2: a fresh bootstrap already\n * carries all three indexes through the schema factories' own index\n * builders, but a database that reaches adoption without re-running\n * bootstrap DDL (a reopen of an already-provisioned installation) needs\n * this explicit `CREATE INDEX IF NOT EXISTS` triple. One owner for the\n * declaration lookup and the identity-assertions index's own name (both\n * routed through {@link systemIndexName}, the single naming choke point)\n * keeps the two dialect factories from re-spelling either and risking\n * drift between them; the identity-assertions name this renders MUST match\n * the schema factories' own hand-written `index(...)` call byte-for-byte —\n * the shape-ratchet test (`tests/base-schema-shape-ratchet.test.ts`) is\n * what would catch a drift.\n */\nexport function sinceIndexAdoptionDdl(\n recordedTableNames: Readonly<{\n recordedNodes: string;\n recordedEdges: string;\n recordedIdentityAssertions: string;\n }>,\n): readonly [string, string, string] {\n function sinceIndexDdlFor(table: \"recordedNodes\" | \"recordedEdges\"): string {\n const declaration = requireDefined(\n SYSTEM_INDEX_DECLARATIONS.find(\n (candidate) =>\n candidate.table === table && candidate.suffix === \"since_idx\",\n ),\n `No \"since_idx\" system index is declared for \"${table}\".`,\n );\n return generateSystemIndexDDL(declaration, recordedTableNames[table], {\n concurrent: false,\n });\n }\n function identityAssertionsSinceIndexDdl(): string {\n const name = quoteIdentifier(\n systemIndexName(\n recordedTableNames.recordedIdentityAssertions,\n \"since_idx\",\n ),\n );\n const table = quoteIdentifier(\n recordedTableNames.recordedIdentityAssertions,\n );\n return `CREATE INDEX IF NOT EXISTS ${name} ON ${table} (${quoteIdentifier(\"graph_id\")}, ${quoteIdentifier(\"recorded_from\")});`;\n }\n return [\n sinceIndexDdlFor(\"recordedNodes\"),\n sinceIndexDdlFor(\"recordedEdges\"),\n identityAssertionsSinceIndexDdl(),\n ];\n}\n"]}
1
+ {"version":3,"sources":["../src/indexes/system.ts"],"names":[],"mappings":";;;;AA8EO,IAAM,yBAAA,GAA+D;AAAA;AAAA,EAE1E,EAAE,OAAO,OAAA,EAAS,MAAA,EAAQ,YAAY,OAAA,EAAS,CAAC,UAAA,EAAY,MAAM,CAAA,EAAE;AAAA;AAAA;AAAA;AAAA,EAIpE;AAAA,IACE,KAAA,EAAO,OAAA;AAAA,IACP,MAAA,EAAQ,kBAAA;AAAA,IACR,OAAA,EAAS,CAAC,UAAA,EAAY,MAAA,EAAQ,cAAc,YAAY;AAAA,GAC1D;AAAA,EACA;AAAA,IACE,KAAA,EAAO,OAAA;AAAA,IACP,MAAA,EAAQ,aAAA;AAAA,IACR,OAAA,E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AAA,IAChC,iBAAiB,eAAe,CAAA;AAAA,IAChC,+BAAA;AAAgC,GAClC;AACF","file":"chunk-NXK2ZBVV.js","sourcesContent":["/**\n * System-index declarations — the single source of truth for the plain\n * btree indexes TypeGraph ships on its own relations.\n *\n * Both dialect schema factories (`createSqliteTables` /\n * `createPostgresTables`) derive their Drizzle index builders from this\n * list, so the two dialects cannot drift, and\n * `materializeSystemIndexes()` derives the same indexes as runtime DDL so\n * an index added in a new library version reaches already-initialized\n * databases (bootstrap DDL only runs on first boot — see\n * `loadActiveSchemaWithBootstrap`).\n *\n * Scope: non-unique btree column indexes on the four graph relations,\n * where performance iteration actually happens. Primary keys, unique /\n * partial-unique constraints, and status-table indexes are structural —\n * they are created with their table and never retrofitted — and stay in\n * the schema files.\n *\n * Changing a declaration's shape under the same suffix is a signature\n * drift: `materializeSystemIndexes` reports `failed` for it until the\n * operator drops the old physical index. Rename (new suffix) instead,\n * exactly like graph-declared indexes. Two acknowledged limits of that\n * contract: on databases whose indexes were bootstrap-created (no status\n * rows) an in-place reshape is undetectable at runtime — the rename rule\n * is enforced by review and the parity tests; and a renamed suffix\n * strands the old physical index (the runner only adds). When the first\n * rename actually happens, add a retired-suffixes list + drop path here.\n */\nimport { quoteIdentifier, shortHash } from \"../query/dialect/vector-strategy\";\nimport { requireDefined } from \"../utils/presence\";\n\n/** The TypeGraph relations that carry system indexes. */\nexport type SystemIndexTable =\n \"nodes\" | \"edges\" | \"recordedNodes\" | \"recordedEdges\";\n\ntype LiveColumn =\n | \"graph_id\"\n | \"kind\"\n | \"id\"\n | \"deleted_at\"\n | \"valid_from\"\n | \"valid_to\"\n | \"created_at\";\n\ntype LiveEdgeColumn =\n LiveColumn | \"from_kind\" | \"from_id\" | \"to_kind\" | \"to_id\";\n\ntype RecordedColumn =\n | \"graph_id\"\n | \"kind\"\n | \"id\"\n | \"valid_from\"\n | \"valid_to\"\n | \"recorded_from\"\n | \"recorded_to\";\n\ntype RecordedEdgeColumn =\n RecordedColumn | \"from_kind\" | \"from_id\" | \"to_kind\" | \"to_id\";\n\ntype SystemIndexColumnsFor<T extends SystemIndexTable> =\n T extends \"nodes\" ? LiveColumn\n : T extends \"edges\" ? LiveEdgeColumn\n : T extends \"recordedNodes\" ? RecordedColumn\n : RecordedEdgeColumn;\n\ntype SystemIndexDeclarationFor<T extends SystemIndexTable> = Readonly<{\n table: T;\n /** Physical index name is `${physicalTableName}_${suffix}`. */\n suffix: string;\n columns: readonly [SystemIndexColumnsFor<T>, ...SystemIndexColumnsFor<T>[]];\n}>;\n\nexport type SystemIndexDeclaration =\n | SystemIndexDeclarationFor<\"nodes\">\n | SystemIndexDeclarationFor<\"edges\">\n | SystemIndexDeclarationFor<\"recordedNodes\">\n | SystemIndexDeclarationFor<\"recordedEdges\">;\n\nexport const SYSTEM_INDEX_DECLARATIONS: readonly SystemIndexDeclaration[] = [\n // ---------------------------------------------------------- nodes\n { table: \"nodes\", suffix: \"kind_idx\", columns: [\"graph_id\", \"kind\"] },\n // Listing shape: kind partition ordered by creation with the\n // soft-delete column ahead of it so `deleted_at IS NULL` list queries\n // stay index-served.\n {\n table: \"nodes\",\n suffix: \"kind_created_idx\",\n columns: [\"graph_id\", \"kind\", \"deleted_at\", \"created_at\"],\n },\n {\n table: \"nodes\",\n suffix: \"deleted_idx\",\n columns: [\"graph_id\", \"deleted_at\"],\n },\n {\n table: \"nodes\",\n suffix: \"valid_idx\",\n columns: [\"graph_id\", \"valid_from\", \"valid_to\"],\n },\n // Bare-id lookup: the primary key leads with `kind` (graph_id, kind,\n // id), so a `WHERE graph_id = ? AND id = ?` probe that doesn't know the\n // kind can't seek it — SQLite falls back to a graph_id-only scan of\n // every node in the graph (~3M at LDBC SF1).\n // `store.algorithms.degree`'s node-kind subquery does exactly that\n // lookup (it resolves the seed's kind by id), so without this index\n // degree is a full nodes scan (~95ms at SF1). See typegraph#280.\n { table: \"nodes\", suffix: \"id_idx\", columns: [\"graph_id\", \"id\"] },\n\n // ---------------------------------------------------------- edges\n { table: \"edges\", suffix: \"kind_idx\", columns: [\"graph_id\", \"kind\"] },\n // Directional traversal index (outgoing): supports endpoint lookups\n // and extra filtering by edge kind / target kind. Includes every\n // system column the compiled query's soft-delete/temporal-validity\n // predicate touches (deleted_at, valid_from, valid_to), trailed by\n // to_id — the compiled traversal join reads `n.id = e.to_id` for an\n // outgoing traversal (standard-builders.ts), so without to_id here\n // the join still fetches the edge's heap row for that one column\n // even with the seek/predicate columns covered.\n {\n table: \"edges\",\n suffix: \"from_idx\",\n columns: [\n \"graph_id\",\n \"from_kind\",\n \"from_id\",\n \"kind\",\n \"to_kind\",\n \"deleted_at\",\n \"valid_from\",\n \"valid_to\",\n \"to_id\",\n ],\n },\n // Directional traversal index (incoming): mirrors from_idx for\n // reverse traversals, trailed by from_id for the same reason\n // (`n.id = e.from_id` for an incoming traversal).\n {\n table: \"edges\",\n suffix: \"to_idx\",\n columns: [\n \"graph_id\",\n \"to_kind\",\n \"to_id\",\n \"kind\",\n \"from_kind\",\n \"deleted_at\",\n \"valid_from\",\n \"valid_to\",\n \"from_id\",\n ],\n },\n {\n table: \"edges\",\n suffix: \"kind_created_idx\",\n columns: [\"graph_id\", \"kind\", \"deleted_at\", \"created_at\"],\n },\n {\n table: \"edges\",\n suffix: \"deleted_idx\",\n columns: [\"graph_id\", \"deleted_at\"],\n },\n {\n table: \"edges\",\n suffix: \"valid_idx\",\n columns: [\"graph_id\", \"valid_from\", \"valid_to\"],\n },\n // Cardinality enforcement: the one-per-endpoint check probes for a\n // currently-valid edge of a kind from a specific endpoint.\n {\n table: \"edges\",\n suffix: \"cardinality_idx\",\n columns: [\"graph_id\", \"kind\", \"from_kind\", \"from_id\", \"valid_to\"],\n },\n\n // ---------------------------------------------------------- recordedNodes\n {\n table: \"recordedNodes\",\n suffix: \"entity_idx\",\n columns: [\"graph_id\", \"kind\", \"id\", \"recorded_from\", \"recorded_to\"],\n },\n {\n table: \"recordedNodes\",\n suffix: \"open_idx\",\n columns: [\"graph_id\", \"recorded_to\"],\n },\n {\n table: \"recordedNodes\",\n suffix: \"valid_idx\",\n columns: [\"graph_id\", \"valid_from\", \"valid_to\"],\n },\n // Bare-id lookup parity with the live nodes table: recorded-pinned\n // reads swap this relation in as the node source, and `entity_idx`\n // leads with `kind`, so the same kind-by-bare-id probe (e.g.\n // `degree()` at a recorded coordinate) would otherwise scan every\n // historical version in the graph. See typegraph#280.\n { table: \"recordedNodes\", suffix: \"id_idx\", columns: [\"graph_id\", \"id\"] },\n // `recorded_from`-led lookup: `entity_idx` leads with `kind, id`, so it\n // cannot serve the lineage capability's changed-since scan\n // (`store/recorded-capture/lineage.ts`), which filters by `graph_id` and\n // `recorded_from` alone across every kind. Without this the scan is a\n // full per-graph table scan of every historical row.\n {\n table: \"recordedNodes\",\n suffix: \"since_idx\",\n columns: [\"graph_id\", \"recorded_from\"],\n },\n\n // ---------------------------------------------------------- recordedEdges\n {\n table: \"recordedEdges\",\n suffix: \"entity_idx\",\n columns: [\"graph_id\", \"kind\", \"id\", \"recorded_from\", \"recorded_to\"],\n },\n {\n table: \"recordedEdges\",\n suffix: \"open_idx\",\n columns: [\"graph_id\", \"recorded_to\"],\n },\n {\n table: \"recordedEdges\",\n suffix: \"from_idx\",\n columns: [\n \"graph_id\",\n \"from_kind\",\n \"from_id\",\n \"kind\",\n \"to_kind\",\n \"recorded_from\",\n \"recorded_to\",\n ],\n },\n {\n table: \"recordedEdges\",\n suffix: \"to_idx\",\n columns: [\n \"graph_id\",\n \"to_kind\",\n \"to_id\",\n \"kind\",\n \"from_kind\",\n \"recorded_from\",\n \"recorded_to\",\n ],\n },\n {\n table: \"recordedEdges\",\n suffix: \"valid_idx\",\n columns: [\"graph_id\", \"valid_from\", \"valid_to\"],\n },\n // `recorded_from`-led lookup, same rationale as recordedNodes' since_idx:\n // the directional indexes above lead with an endpoint, not `recorded_from`\n // alone, so they cannot serve the lineage capability's changed-since scan.\n {\n table: \"recordedEdges\",\n suffix: \"since_idx\",\n columns: [\"graph_id\", \"recorded_from\"],\n },\n];\n\n/** Default physical table names for the system-index relations. */\nconst DEFAULT_SYSTEM_INDEX_TABLE_NAMES: Readonly<\n Record<SystemIndexTable, string>\n> = {\n nodes: \"typegraph_nodes\",\n edges: \"typegraph_edges\",\n recordedNodes: \"typegraph_recorded_nodes\",\n recordedEdges: \"typegraph_recorded_edges\",\n};\n\n/**\n * Resolves the physical table name for a system-index relation, honoring\n * a backend's table-name overrides.\n */\nexport function resolveSystemIndexTableName(\n table: SystemIndexTable,\n overrides:\n Readonly<Partial<Record<SystemIndexTable, string | undefined>>> | undefined,\n): string {\n return overrides?.[table] ?? DEFAULT_SYSTEM_INDEX_TABLE_NAMES[table];\n}\n\n/**\n * PostgreSQL truncates identifiers to NAMEDATALEN-1 = 63 bytes SILENTLY —\n * two suffixes of one long custom table name would collide after\n * truncation, and the catalog probes (which compare by exact name) would\n * never match the stored name, re-attempting the build on every boot.\n * SQLite has no such limit but uses the same bound so the two dialects'\n * index sets stay in byte-for-byte parity. (Char-based like the vector\n * identifier bound — multibyte table names are out of scope.)\n */\nconst MAX_SQL_IDENTIFIER_LENGTH = 63;\n\n/**\n * Physical index name: `${physicalTableName}_${suffix}`, deterministically\n * truncated + hash-suffixed past the 63-char identifier bound so distinct\n * indexes stay distinct. Single choke point — the Drizzle builders, the\n * runtime DDL, the catalog probes, and the status keys all derive the\n * name here, so they can never disagree.\n */\nexport function systemIndexName(\n physicalTableName: string,\n suffix: string,\n): string {\n const full = `${physicalTableName}_${suffix}`;\n if (full.length <= MAX_SQL_IDENTIFIER_LENGTH) return full;\n const hash = shortHash(JSON.stringify([physicalTableName, suffix]));\n return `${full.slice(0, MAX_SQL_IDENTIFIER_LENGTH - 1 - hash.length)}_${hash}`;\n}\n\n/**\n * Every system index name for a deployment's (possibly overridden) table\n * names. Graph-declared index names must not collide with these: a\n * colliding `CREATE INDEX IF NOT EXISTS` would silently no-op against the\n * system index (wrong shape) while recording a false success — see the\n * guards in the schema factories and `materializeIndexes`.\n */\nexport function resolveSystemIndexNames(\n overrides:\n Readonly<Partial<Record<SystemIndexTable, string | undefined>>> | undefined,\n): ReadonlySet<string> {\n return new Set(\n SYSTEM_INDEX_DECLARATIONS.map((declaration) =>\n systemIndexName(\n resolveSystemIndexTableName(declaration.table, overrides),\n declaration.suffix,\n ),\n ),\n );\n}\n\n/**\n * Rejects graph-declared indexes whose names collide with this\n * deployment's system index names. Called by both dialect schema\n * factories so a colliding declaration fails at table-definition time\n * instead of silently no-opping against the (differently shaped) system\n * index at CREATE INDEX IF NOT EXISTS time. `materializeIndexes` applies\n * the same check per-declaration on its runtime path.\n */\nexport function assertNoSystemIndexNameCollision(\n indexes: readonly Readonly<{ name: string }>[],\n overrides:\n Readonly<Partial<Record<SystemIndexTable, string | undefined>>> | undefined,\n): void {\n if (indexes.length === 0) return;\n const reserved = resolveSystemIndexNames(overrides);\n for (const index of indexes) {\n if (reserved.has(index.name)) {\n throw new Error(\n `Index name \"${index.name}\" collides with a TypeGraph system ` +\n `index. Choose a different name — system index names are ` +\n `reserved, and a same-named CREATE INDEX IF NOT EXISTS would ` +\n `silently no-op against the system index instead of creating ` +\n `the declared one.`,\n );\n }\n }\n}\n\n/**\n * Runtime DDL for one system index — byte-compatible with the index the\n * bootstrap path creates from the Drizzle schema (same name, same\n * columns), plus `CONCURRENTLY` where the dialect supports building\n * without blocking writes.\n */\nexport function generateSystemIndexDDL(\n declaration: SystemIndexDeclaration,\n physicalTableName: string,\n options: Readonly<{ concurrent: boolean }>,\n): string {\n const name = quoteIdentifier(\n systemIndexName(physicalTableName, declaration.suffix),\n );\n const table = quoteIdentifier(physicalTableName);\n const columns = declaration.columns\n .map((column) => quoteIdentifier(column))\n .join(\", \");\n const concurrently = options.concurrent ? \"CONCURRENTLY \" : \"\";\n return `CREATE INDEX ${concurrently}IF NOT EXISTS ${name} ON ${table} (${columns});`;\n}\n\n/**\n * Runtime DDL for the base-schema release's three `since_idx (graph_id,\n * recorded_from)` indexes — the lineage capability's changed-since scan\n * (`store/recorded-capture/lineage.ts`): the two recorded relations\n * (`recordedNodes`, `recordedEdges`, declared in\n * {@link SYSTEM_INDEX_DECLARATIONS} and managed by `materializeIndexes`),\n * plus the recorded identity-assertions relation's own `since_idx`, which\n * `changesSince`'s per-revision completeness scan folds into the same\n * three-relation scan but which is NOT a {@link SystemIndexTable} — like that\n * relation's other three indexes (`entity_idx`/`a_idx`/`b_idx`), it is\n * structural, hand-declared with the table rather than run through\n * `materializeIndexes`' lazy backfill, and this function follows the same\n * pattern for it. Both dialect factories thread this into the base-schema\n * version-3 adoption step (`engine/members/base-schema-members.ts`) the\n * same way `fencesTableDdl` feeds version 2: a fresh bootstrap already\n * carries all three indexes through the schema factories' own index\n * builders, but a database that reaches adoption without re-running\n * bootstrap DDL (a reopen of an already-provisioned installation) needs\n * this explicit `CREATE INDEX IF NOT EXISTS` triple. The adoption step must\n * first ensure recorded identity-assertions storage: older provisioned\n * installations can predate that table, which originally shipped only in\n * bootstrap DDL. One owner for the\n * declaration lookup and the identity-assertions index's own name (both\n * routed through {@link systemIndexName}, the single naming choke point)\n * keeps the two dialect factories from re-spelling either and risking\n * drift between them; the identity-assertions name this renders MUST match\n * the schema factories' own hand-written `index(...)` call byte-for-byte —\n * the shape-ratchet test (`tests/base-schema-shape-ratchet.test.ts`) is\n * what would catch a drift.\n */\nexport function sinceIndexAdoptionDdl(\n recordedTableNames: Readonly<{\n recordedNodes: string;\n recordedEdges: string;\n recordedIdentityAssertions: string;\n }>,\n): readonly [string, string, string] {\n function sinceIndexDdlFor(table: \"recordedNodes\" | \"recordedEdges\"): string {\n const declaration = requireDefined(\n SYSTEM_INDEX_DECLARATIONS.find(\n (candidate) =>\n candidate.table === table && candidate.suffix === \"since_idx\",\n ),\n `No \"since_idx\" system index is declared for \"${table}\".`,\n );\n return generateSystemIndexDDL(declaration, recordedTableNames[table], {\n concurrent: false,\n });\n }\n function identityAssertionsSinceIndexDdl(): string {\n const name = quoteIdentifier(\n systemIndexName(\n recordedTableNames.recordedIdentityAssertions,\n \"since_idx\",\n ),\n );\n const table = quoteIdentifier(\n recordedTableNames.recordedIdentityAssertions,\n );\n return `CREATE INDEX IF NOT EXISTS ${name} ON ${table} (${quoteIdentifier(\"graph_id\")}, ${quoteIdentifier(\"recorded_from\")});`;\n }\n return [\n sinceIndexDdlFor(\"recordedNodes\"),\n sinceIndexDdlFor(\"recordedEdges\"),\n identityAssertionsSinceIndexDdl(),\n ];\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var chunkQCD5JKU4_cjs = require('./chunk-QCD5JKU4.cjs');
4
- var chunkCZNYXNOY_cjs = require('./chunk-CZNYXNOY.cjs');
4
+ var chunkDIVOGAPS_cjs = require('./chunk-DIVOGAPS.cjs');
5
5
  var chunkTMEOXADA_cjs = require('./chunk-TMEOXADA.cjs');
6
6
  var chunk3DERXVTU_cjs = require('./chunk-3DERXVTU.cjs');
7
7
  var chunk4ACC3PJC_cjs = require('./chunk-4ACC3PJC.cjs');
@@ -16,26 +16,26 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
16
16
 
17
17
  var Database__default = /*#__PURE__*/_interopDefault(Database);
18
18
 
19
- var nodeRequire = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-53GIRRN2.cjs', document.baseURI).href)));
19
+ var nodeRequire = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-TDRZ46SF.cjs', document.baseURI).href)));
20
20
  function installLocalSqliteBaseSchema(sqlite, tables2, fulltextStrategy) {
21
- if (chunkCZNYXNOY_cjs.CURRENT_BASE_SCHEMA_VERSION !== 3) {
21
+ if (chunkDIVOGAPS_cjs.CURRENT_BASE_SCHEMA_VERSION !== 3) {
22
22
  throw new chunkKD3BDZHS_cjs.CompilerInvariantError(
23
23
  "The synchronous managed SQLite installation path only implements base-schema v1 through v3 adoption.",
24
- { currentVersion: chunkCZNYXNOY_cjs.CURRENT_BASE_SCHEMA_VERSION }
24
+ { currentVersion: chunkDIVOGAPS_cjs.CURRENT_BASE_SCHEMA_VERSION }
25
25
  );
26
26
  }
27
- const installationSql = chunkCZNYXNOY_cjs.generateSqliteMigrationSQL(tables2, fulltextStrategy);
27
+ const installationSql = chunkDIVOGAPS_cjs.generateSqliteMigrationSQL(tables2, fulltextStrategy);
28
28
  try {
29
29
  sqlite.exec(installationSql);
30
30
  } catch (error) {
31
31
  if (!chunk4ACC3PJC_cjs.isSqliteMissingEdgeMatchIdentityColumnError(error)) throw error;
32
32
  const edgeTableName = drizzleOrm.getTableName(tables2.edges);
33
33
  for (let attempt = 0; attempt < 3; attempt += 1) {
34
- const rows = sqlite.prepare(`PRAGMA table_info(${chunkCZNYXNOY_cjs.quoteDdlIdentifier(edgeTableName)})`).all();
34
+ const rows = sqlite.prepare(`PRAGMA table_info(${chunkDIVOGAPS_cjs.quoteDdlIdentifier(edgeTableName)})`).all();
35
35
  const columns = new Set(
36
36
  rows.flatMap((row) => typeof row.name === "string" ? [row.name] : [])
37
37
  );
38
- const adoptionSql = chunkCZNYXNOY_cjs.planSqliteEdgeMatchIdentityAdoption(
38
+ const adoptionSql = chunkDIVOGAPS_cjs.planSqliteEdgeMatchIdentityAdoption(
39
39
  edgeTableName,
40
40
  columns
41
41
  );
@@ -162,16 +162,16 @@ function applyConnectionPragmas(sqlite, pragmas) {
162
162
  }
163
163
  }
164
164
  function createLocalSqliteBackend(options = {}) {
165
- chunkCZNYXNOY_cjs.assertNoLegacyTransactionCapability(options.capabilities);
165
+ chunkDIVOGAPS_cjs.assertNoLegacyTransactionCapability(options.capabilities);
166
166
  const path = options.path ?? ":memory:";
167
- const tables2 = options.tables ?? chunkCZNYXNOY_cjs.tables2;
167
+ const tables2 = options.tables ?? chunkDIVOGAPS_cjs.tables2;
168
168
  const sqlite = createDatabase(path);
169
169
  try {
170
170
  applyConnectionPragmas(sqlite, options.pragmas);
171
171
  const hasSqliteVec = tryLoadSqliteVec(sqlite);
172
172
  const db = betterSqlite3.drizzle(sqlite);
173
173
  installLocalSqliteBaseSchema(sqlite, tables2, options.fulltext);
174
- const backend = chunkCZNYXNOY_cjs.createSqliteBackend(db, {
174
+ const backend = chunkDIVOGAPS_cjs.createSqliteBackend(db, {
175
175
  executionProfile: {
176
176
  isSync: true
177
177
  },
@@ -212,5 +212,5 @@ function tryLoadSqliteVec(sqlite) {
212
212
  }
213
213
 
214
214
  exports.createLocalSqliteBackend = createLocalSqliteBackend;
215
- //# sourceMappingURL=chunk-53GIRRN2.cjs.map
216
- //# sourceMappingURL=chunk-53GIRRN2.cjs.map
215
+ //# sourceMappingURL=chunk-TDRZ46SF.cjs.map
216
+ //# sourceMappingURL=chunk-TDRZ46SF.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/backend/sqlite/local.ts"],"names":["createRequire","tables","CURRENT_BASE_SCHEMA_VERSION","CompilerInvariantError","generateSqliteMigrationSQL","isSqliteMissingEdgeMatchIdentityColumnError","getTableName","quoteDdlIdentifier","planSqliteEdgeMatchIdentityAdoption","isSqliteDuplicateEdgeMatchIdentityColumnError","Database","ConfigurationError","DEFAULT_LOCAL_SQLITE_PRAGMAS","assertNoLegacyTransactionCapability","drizzle","createSqliteBackend","sqliteVecStrategy","wrapWithManagedClose","markBundledRootAutocommitEligible"],"mappings":";;;;;;;;;;;;;;;;;;AAgFA,IAAM,WAAA,GAAcA,sBAAA,CAAc,oQAAe,CAAA;AAEjD,SAAS,4BAAA,CACP,MAAA,EACAC,OAAAA,EACA,gBAAA,EACM;AAUN,EAAA,IAAIC,kDAAgC,CAAA,EAAG;AACrC,IAAA,MAAM,IAAIC,wCAAA;AAAA,MACR,sGAAA;AAAA,MACA,EAAE,gBAAgBD,6CAAA;AAA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AA,KAAY,IAAA,IACZ,UAAU,OAAA,IACV,OAAO,OAAA,CAAQ,IAAA,KAAS,UAAA,EACxB;AACA,MAAC,OAAA,CAAsD,KAAK,MAAM,CAAA;AAClE,MAAA,OAAO,IAAA;AAAA,IACT;AACA,IAAA,OAAO,KAAA;AAAA,EACT,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,KAAA;AAAA,EACT;AACF","file":"chunk-53GIRRN2.cjs","sourcesContent":["/**\n * Local SQLite backend using better-sqlite3.\n *\n * This module depends on the `better-sqlite3` native addon and should only\n * be imported in Node.js environments. For bundler-friendly SQLite DDL\n * generation and Drizzle backend creation, import from `@nicia-ai/typegraph/adapters/drizzle/sqlite`.\n *\n * @example In-memory database (default)\n * ```typescript\n * import { createLocalSqliteBackend } from \"@nicia-ai/typegraph/adapters/drizzle/sqlite/local\";\n *\n * const { backend, db } = createLocalSqliteBackend();\n * const store = createStore(graph, backend);\n * ```\n *\n * @example File-based database for persistent local development\n * ```typescript\n * import { createLocalSqliteBackend } from \"@nicia-ai/typegraph/adapters/drizzle/sqlite/local\";\n *\n * const { backend, db } = createLocalSqliteBackend({ path: \"./dev.db\" });\n * const store = createStore(graph, backend);\n * ```\n */\nimport { createRequire } from \"node:module\";\n\nimport Database from \"better-sqlite3\";\nimport { getTableName } from \"drizzle-orm\";\nimport {\n type BetterSQLite3Database,\n drizzle,\n} from \"drizzle-orm/better-sqlite3\";\n\nimport { CompilerInvariantError, ConfigurationError } from \"../../errors\";\nimport { type FulltextStrategy } from \"../../query/dialect/fulltext-strategy\";\nimport { sqliteVecStrategy } from \"../../query/dialect/vector/sqlite-vec-strategy\";\nimport {\n isSqliteDuplicateEdgeMatchIdentityColumnError,\n isSqliteMissingEdgeMatchIdentityColumnError,\n} from \"../../utils/sql-errors\";\nimport { markBundledRootAutocommitEligible } from \"../capabilities/autocommit-single-statement\";\nimport { wrapWithManagedClose } from \"../derive-backend\";\nimport { CURRENT_BASE_SCHEMA_VERSION } from \"../drizzle/base-schema\";\nimport {\n generateSqliteMigrationSQL,\n planSqliteEdgeMatchIdentityAdoption,\n quoteDdlIdentifier,\n} from \"../drizzle/ddl\";\nimport { type AnySqliteDatabase } from \"../drizzle/execution\";\nexport type { AnySqliteDatabase } from \"../drizzle/execution\";\nimport { assertNoLegacyTransactionCapability } from \"../capabilities/declarations\";\nimport {\n createSqliteBackend,\n type SqliteTables,\n tables as defaultTables,\n} from \"../drizzle/sqlite\";\nimport {\n DEFAULT_LOCAL_SQLITE_PRAGMAS,\n type LocalSqliteJournalMode,\n type LocalSqlitePragmaOptions,\n type LocalSqliteSynchronousMode,\n} from \"./local-options\";\n\nexport {\n DEFAULT_LOCAL_SQLITE_PRAGMAS,\n type LocalSqliteJournalMode,\n type LocalSqlitePragmaOptions,\n type LocalSqliteSynchronousMode,\n} from \"./local-options\";\nimport {\n type AdapterBackend,\n type BundledBackendCapabilityOverrides,\n} from \"../types\";\nexport type { BundledBackendCapabilityOverrides } from \"../types\";\nexport type {\n ContributionDiagnostic,\n ContributionDiagnosticState,\n ContributionRepairEntry,\n ContributionRepairResult,\n} from \"../types\";\n\nconst nodeRequire = createRequire(import.meta.url);\n\nfunction installLocalSqliteBaseSchema(\n sqlite: Database.Database,\n tables: SqliteTables,\n fulltextStrategy: FulltextStrategy | false | undefined,\n): void {\n // v2 (the fences relation) and v3 (the recorded-relations' and recorded\n // identity-assertions relation's `since_idx` indexes) need no adoption\n // logic beyond what `generateSqliteMigrationSQL` already emits: a\n // brand-new relation or index is fully covered by its own `CREATE TABLE\n // IF NOT EXISTS` / `CREATE INDEX IF NOT EXISTS`, on both a fresh database\n // and one that already has every OTHER base table or index. Only v1's\n // edge-match-identity `ADD COLUMN` migration — handled by the catch block\n // below — needed runtime introspection this synchronous path writes by\n // hand instead of running `BaseSchemaLifecycle`'s async state machine.\n if (CURRENT_BASE_SCHEMA_VERSION !== 3) {\n throw new CompilerInvariantError(\n \"The synchronous managed SQLite installation path only implements base-schema v1 through v3 adoption.\",\n { currentVersion: CURRENT_BASE_SCHEMA_VERSION },\n );\n }\n const installationSql = generateSqliteMigrationSQL(tables, fulltextStrategy);\n try {\n sqlite.exec(installationSql);\n } catch (error) {\n if (!isSqliteMissingEdgeMatchIdentityColumnError(error)) throw error;\n const edgeTableName = getTableName(tables.edges);\n for (let attempt = 0; attempt < 3; attempt += 1) {\n const rows = sqlite\n .prepare(`PRAGMA table_info(${quoteDdlIdentifier(edgeTableName)})`)\n .all() as readonly Readonly<{ name?: unknown }>[];\n const columns = new Set(\n rows.flatMap((row) => (typeof row.name === \"string\" ? [row.name] : [])),\n );\n const adoptionSql = planSqliteEdgeMatchIdentityAdoption(\n edgeTableName,\n columns,\n );\n try {\n sqlite.exec([...adoptionSql, installationSql].join(\"\\n\"));\n return;\n } catch (repairError) {\n if (\n attempt === 2 ||\n !isSqliteDuplicateEdgeMatchIdentityColumnError(repairError)\n ) {\n throw repairError;\n }\n }\n }\n throw new CompilerInvariantError(\n \"Local SQLite match-identity adoption exhausted its retry loop without returning or throwing.\",\n );\n }\n}\n\n// ============================================================\n// Native Addon Helpers\n// ============================================================\n\ntype NodeModuleVersionMismatch = Readonly<{\n compiled: number;\n required: number;\n}>;\n\nfunction getUnknownErrorMessage(error: unknown): string {\n if (error instanceof Error) return error.message;\n return String(error);\n}\n\nfunction parseNodeModuleVersionMismatchMessage(\n message: string,\n): NodeModuleVersionMismatch | undefined {\n const regexp =\n /NODE_MODULE_VERSION (?<compiled>\\d+)[\\s\\S]*?NODE_MODULE_VERSION (?<required>\\d+)/;\n const match = regexp.exec(message);\n if (!match?.groups) return undefined;\n\n const compiled = Number(match.groups[\"compiled\"]);\n const required = Number(match.groups[\"required\"]);\n\n if (!Number.isFinite(compiled) || !Number.isFinite(required))\n return undefined;\n\n return { compiled, required };\n}\n\nfunction createDatabase(path: string): Database.Database {\n try {\n return new Database(path);\n } catch (error) {\n const message = getUnknownErrorMessage(error);\n const mismatch = parseNodeModuleVersionMismatchMessage(message);\n if (!mismatch) throw error;\n\n throw new ConfigurationError(\n [\n \"Failed to load better-sqlite3 native addon.\",\n `It was compiled for NODE_MODULE_VERSION ${mismatch.compiled}, but this Node.js runtime requires ${mismatch.required}.`,\n \"This usually happens after switching Node versions without rebuilding native dependencies.\",\n \"Rebuild with: pnpm rebuild better-sqlite3 (or npm rebuild better-sqlite3).\",\n ].join(\" \"),\n {\n nodeVersion: process.version,\n nodeModuleVersion: process.versions.modules,\n compiledNodeModuleVersion: mismatch.compiled,\n requiredNodeModuleVersion: mismatch.required,\n },\n { cause: error },\n );\n }\n}\n\n// ============================================================\n// Types\n// ============================================================\n\nconst LOCAL_SQLITE_JOURNAL_MODES: readonly LocalSqliteJournalMode[] = [\n \"wal\",\n \"delete\",\n \"truncate\",\n \"persist\",\n \"memory\",\n \"off\",\n];\n\nconst LOCAL_SQLITE_SYNCHRONOUS_MODES: readonly LocalSqliteSynchronousMode[] = [\n \"off\",\n \"normal\",\n \"full\",\n \"extra\",\n];\n\nconst SQLITE_MAX_WAL_AUTOCHECKPOINT_PAGES = 2_147_483_647;\n\nfunction applyConnectionPragmas(\n sqlite: Database.Database,\n pragmas: LocalSqlitePragmaOptions | false | undefined,\n): void {\n if (pragmas === false) return;\n const resolved: Required<LocalSqlitePragmaOptions> = {\n ...DEFAULT_LOCAL_SQLITE_PRAGMAS,\n ...pragmas,\n };\n\n // Runtime guards mirror the compile-time unions: pragma values are spliced\n // into pragma statements, so reject anything outside the allowlists rather\n // than forwarding it to SQLite.\n if (!LOCAL_SQLITE_JOURNAL_MODES.includes(resolved.journalMode)) {\n throw new ConfigurationError(\n `Invalid journalMode pragma: ${resolved.journalMode}. ` +\n `Expected one of: ${LOCAL_SQLITE_JOURNAL_MODES.join(\", \")}.`,\n { journalMode: resolved.journalMode },\n );\n }\n if (!LOCAL_SQLITE_SYNCHRONOUS_MODES.includes(resolved.synchronous)) {\n throw new ConfigurationError(\n `Invalid synchronous pragma: ${resolved.synchronous}. ` +\n `Expected one of: ${LOCAL_SQLITE_SYNCHRONOUS_MODES.join(\", \")}.`,\n { synchronous: resolved.synchronous },\n );\n }\n if (\n !Number.isSafeInteger(resolved.busyTimeoutMs) ||\n resolved.busyTimeoutMs < 0\n ) {\n throw new ConfigurationError(\n `Invalid busyTimeoutMs pragma: ${String(resolved.busyTimeoutMs)}. ` +\n \"Expected a non-negative integer number of milliseconds.\",\n { busyTimeoutMs: resolved.busyTimeoutMs },\n );\n }\n if (\n resolved.cacheSizeKib !== undefined &&\n (!Number.isSafeInteger(resolved.cacheSizeKib) || resolved.cacheSizeKib >= 0)\n ) {\n throw new ConfigurationError(\n `Invalid cacheSizeKib pragma: ${String(resolved.cacheSizeKib)}. ` +\n \"Expected a negative safe integer — SQLite's own cache_size pragma \" +\n \"interprets a positive value as a page count, not KiB, so a caller \" +\n 'who passes e.g. 131072 meaning \"131072 KiB\" silently gets ' +\n \"131072 pages (~512MiB at the default 4KiB page size) instead.\",\n { cacheSizeKib: resolved.cacheSizeKib },\n );\n }\n if (\n resolved.mmapSizeBytes !== undefined &&\n (!Number.isSafeInteger(resolved.mmapSizeBytes) ||\n resolved.mmapSizeBytes < 0)\n ) {\n throw new ConfigurationError(\n `Invalid mmapSizeBytes pragma: ${String(resolved.mmapSizeBytes)}. ` +\n \"Expected a non-negative safe integer number of bytes.\",\n { mmapSizeBytes: resolved.mmapSizeBytes },\n );\n }\n if (\n resolved.walAutocheckpointPages !== undefined &&\n (!Number.isSafeInteger(resolved.walAutocheckpointPages) ||\n resolved.walAutocheckpointPages < 0 ||\n resolved.walAutocheckpointPages > SQLITE_MAX_WAL_AUTOCHECKPOINT_PAGES)\n ) {\n throw new ConfigurationError(\n `Invalid walAutocheckpointPages pragma: ${String(resolved.walAutocheckpointPages)}. ` +\n `Expected an integer between 0 and ${SQLITE_MAX_WAL_AUTOCHECKPOINT_PAGES} ` +\n \"WAL pages (0 disables automatic checkpointing entirely).\",\n { walAutocheckpointPages: resolved.walAutocheckpointPages },\n );\n }\n\n // \":memory:\" databases always journal in memory; SQLite answers the WAL\n // request with \"memory\" instead of erroring, so no special-casing needed.\n sqlite.pragma(`journal_mode = ${resolved.journalMode}`);\n sqlite.pragma(`synchronous = ${resolved.synchronous}`);\n sqlite.pragma(`busy_timeout = ${resolved.busyTimeoutMs}`);\n if (resolved.cacheSizeKib !== undefined) {\n sqlite.pragma(`cache_size = ${resolved.cacheSizeKib}`);\n }\n if (resolved.mmapSizeBytes !== undefined) {\n sqlite.pragma(`mmap_size = ${resolved.mmapSizeBytes}`);\n }\n if (resolved.walAutocheckpointPages !== undefined) {\n sqlite.pragma(`wal_autocheckpoint = ${resolved.walAutocheckpointPages}`);\n }\n}\n\n/**\n * Options for creating a local SQLite backend.\n */\nexport type LocalSqliteBackendOptions = Readonly<{\n /**\n * Path to the SQLite database file.\n * Defaults to \":memory:\" for an in-memory database.\n */\n path?: string;\n\n /**\n * Connection pragmas applied at open. Defaults to\n * {@link DEFAULT_LOCAL_SQLITE_PRAGMAS} (WAL, `synchronous=NORMAL`, 5s busy\n * timeout, and SQLite's own tiny built-in page cache / disabled mmap\n * left untouched). Individual values merge over the defaults; pass\n * `false` to skip pragma configuration entirely and keep the driver\n * defaults (rollback journal, `synchronous=FULL`, and better-sqlite3's\n * own 5s busy timeout from its `timeout` constructor option). Set\n * `cacheSizeKib`/`mmapSizeBytes` explicitly once a database's working\n * set is known to exceed SQLite's 2MiB default cache — otherwise every\n * query pays a fresh disk read per page past that tiny working set. Set\n * `walAutocheckpointPages` explicitly for a bulk-insert-heavy workload —\n * SQLite's own default checkpoints every ~4MiB of WAL growth, which gets\n * more expensive as the database file grows over a large load.\n */\n pragmas?: LocalSqlitePragmaOptions | false;\n\n /**\n * Custom table definitions.\n * Defaults to standard TypeGraph table names.\n */\n tables?: SqliteTables;\n\n /**\n * Override the fulltext strategy. Defaults to `fts5Strategy` (SQLite's\n * built-in FTS5 virtual table). Pass `false` to disable fulltext support\n * entirely — the backend then advertises no `capabilities.fulltext` and\n * omits the fulltext CRUD/search methods, and the managed installation\n * never creates the fulltext table. Forwarded to both the installation\n * DDL and `createSqliteBackend`.\n */\n fulltext?: FulltextStrategy | false;\n\n /**\n * Override specific backend capabilities — e.g. to simulate an engine-level\n * gap like missing SQL window functions in tests. Forwarded to\n * createSqliteBackend.\n */\n capabilities?: BundledBackendCapabilityOverrides;\n}>;\n\n/**\n * Result of creating a local SQLite backend.\n */\nexport type LocalSqliteBackendResult = Readonly<{\n /**\n * The GraphBackend instance for use with createStore.\n */\n backend: AdapterBackend<AnySqliteDatabase>;\n\n /**\n * The underlying Drizzle database instance.\n * Useful for direct SQL access or cleanup.\n */\n db: BetterSQLite3Database;\n}>;\n\n// ============================================================\n// Factory Function\n// ============================================================\n\n/**\n * Creates a SQLite backend with minimal configuration.\n *\n * This is a convenience function for local development and testing.\n * It handles database creation, schema migration, and backend setup.\n *\n * For production deployments or custom configurations, use createSqliteBackend\n * directly with your own Drizzle database instance.\n *\n * @param options - Configuration options\n * @returns Backend and database instances\n *\n * @example In-memory database (default)\n * ```typescript\n * const { backend } = createLocalSqliteBackend();\n * const store = createStore(graph, backend);\n * ```\n *\n * @example File-based database\n * ```typescript\n * const { backend, db } = createLocalSqliteBackend({ path: \"./data.db\" });\n * const store = createStore(graph, backend);\n * ```\n */\nexport function createLocalSqliteBackend(\n options: LocalSqliteBackendOptions = {},\n): LocalSqliteBackendResult {\n assertNoLegacyTransactionCapability(options.capabilities);\n const path = options.path ?? \":memory:\";\n const tables = options.tables ?? defaultTables;\n\n const sqlite = createDatabase(path);\n try {\n applyConnectionPragmas(sqlite, options.pragmas);\n\n // Best-effort: load sqlite-vec so embedding fields are persisted to\n // per-`(kind, field)` `vec0` storage. Without it, nodes with\n // `embedding()` fields validate and insert but their vectors are silently\n // dropped. When the user has installed sqlite-vec as a peer dep we load\n // it and wire the strategy; otherwise we proceed without vector support.\n const hasSqliteVec = tryLoadSqliteVec(sqlite);\n\n const db = drizzle(sqlite);\n\n // The managed factory owns a complete fresh installation, including the\n // deployment-wide base-schema marker consumed by verified/runtime-only\n // entrypoints. Raw generateSqliteDDL intentionally omits that marker.\n installLocalSqliteBaseSchema(sqlite, tables, options.fulltext);\n\n const backend = createSqliteBackend(db, {\n executionProfile: {\n isSync: true,\n },\n tables,\n ...(hasSqliteVec ? { vector: sqliteVecStrategy } : {}),\n ...(options.fulltext === undefined ? {} : { fulltext: options.fulltext }),\n capabilities: {\n ...options.capabilities,\n graphAnalytics: {\n supported:\n options.capabilities?.graphAnalytics?.supported ??\n options.capabilities?.execution?.interactiveTransactions !== false,\n mathFunctions:\n options.capabilities?.graphAnalytics?.mathFunctions ?? true,\n },\n },\n });\n const managedBackend = wrapWithManagedClose(backend, () => {\n sqlite.close();\n });\n\n return { backend: markBundledRootAutocommitEligible(managedBackend), db };\n } catch (error) {\n try {\n sqlite.close();\n } catch {\n // Preserve the provisioning error; a cleanup failure is secondary.\n }\n throw error;\n }\n}\n\nfunction tryLoadSqliteVec(sqlite: Database.Database): boolean {\n try {\n // `sqlite-vec` is an optional peer dep; resolved via createRequire so\n // bundlers don't mark it as a hard import. Node resolves the package\n // only when it's actually installed.\n const module_: unknown = nodeRequire(\"sqlite-vec\");\n if (\n typeof module_ === \"object\" &&\n module_ !== null &&\n \"load\" in module_ &&\n typeof module_.load === \"function\"\n ) {\n (module_ as { load: (db: Database.Database) => void }).load(sqlite);\n return true;\n }\n return false;\n } catch {\n return false;\n }\n}\nexport type { GraphIdentityConfig } from \"../../core/define-graph\";\n"]}
1
+ {"version":3,"sources":["../src/backend/sqlite/local.ts"],"names":["createRequire","tables","CURRENT_BASE_SCHEMA_VERSION","CompilerInvariantError","generateSqliteMigrationSQL","isSqliteMissingEdgeMatchIdentityColumnError","getTableName","quoteDdlIdentifier","planSqliteEdgeMatchIdentityAdoption","isSqliteDuplicateEdgeMatchIdentityColumnError","Database","ConfigurationError","DEFAULT_LOCAL_SQLITE_PRAGMAS","assertNoLegacyTransactionCapability","drizzle","createSqliteBackend","sqliteVecStrategy","wrapWithManagedClose","markBundledRootAutoc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IAAA,IAAI;AACF,MAAA,MAAA,CAAO,KAAA,EAAM;AAAA,IACf,CAAA,CAAA,MAAQ;AAAA,IAER;AACA,IAAA,MAAM,KAAA;AAAA,EACR;AACF;AAEA,SAAS,iBAAiB,MAAA,EAAoC;AAC5D,EAAA,IAAI;AAIF,IAAA,MAAM,OAAA,GAAmB,YAAY,YAAY,CAAA;AACjD,IAAA,IACE,OAAO,OAAA,KAAY,QAAA,IACnB,OAAA,KAAY,IAAA,IACZ,UAAU,OAAA,IACV,OAAO,OAAA,CAAQ,IAAA,KAAS,UAAA,EACxB;AACA,MAAC,OAAA,CAAsD,KAAK,MAAM,CAAA;AAClE,MAAA,OAAO,IAAA;AAAA,IACT;AACA,IAAA,OAAO,KAAA;AAAA,EACT,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,KAAA;AAAA,EACT;AACF","file":"chunk-TDRZ46SF.cjs","sourcesContent":["/**\n * Local SQLite backend using better-sqlite3.\n *\n * This module depends on the `better-sqlite3` native addon and should only\n * be imported in Node.js environments. For bundler-friendly SQLite DDL\n * generation and Drizzle backend creation, import from `@nicia-ai/typegraph/adapters/drizzle/sqlite`.\n *\n * @example In-memory database (default)\n * ```typescript\n * import { createLocalSqliteBackend } from \"@nicia-ai/typegraph/adapters/drizzle/sqlite/local\";\n *\n * const { backend, db } = createLocalSqliteBackend();\n * const store = createStore(graph, backend);\n * ```\n *\n * @example File-based database for persistent local development\n * ```typescript\n * import { createLocalSqliteBackend } from \"@nicia-ai/typegraph/adapters/drizzle/sqlite/local\";\n *\n * const { backend, db } = createLocalSqliteBackend({ path: \"./dev.db\" });\n * const store = createStore(graph, backend);\n * ```\n */\nimport { createRequire } from \"node:module\";\n\nimport Database from \"better-sqlite3\";\nimport { getTableName } from \"drizzle-orm\";\nimport {\n type BetterSQLite3Database,\n drizzle,\n} from \"drizzle-orm/better-sqlite3\";\n\nimport { CompilerInvariantError, ConfigurationError } from \"../../errors\";\nimport { type FulltextStrategy } from \"../../query/dialect/fulltext-strategy\";\nimport { sqliteVecStrategy } from \"../../query/dialect/vector/sqlite-vec-strategy\";\nimport {\n isSqliteDuplicateEdgeMatchIdentityColumnError,\n isSqliteMissingEdgeMatchIdentityColumnError,\n} from \"../../utils/sql-errors\";\nimport { markBundledRootAutocommitEligible } from \"../capabilities/autocommit-single-statement\";\nimport { wrapWithManagedClose } from \"../derive-backend\";\nimport { CURRENT_BASE_SCHEMA_VERSION } from \"../drizzle/base-schema\";\nimport {\n generateSqliteMigrationSQL,\n planSqliteEdgeMatchIdentityAdoption,\n quoteDdlIdentifier,\n} from \"../drizzle/ddl\";\nimport { type AnySqliteDatabase } from \"../drizzle/execution\";\nexport type { AnySqliteDatabase } from \"../drizzle/execution\";\nimport { assertNoLegacyTransactionCapability } from \"../capabilities/declarations\";\nimport {\n createSqliteBackend,\n type SqliteTables,\n tables as defaultTables,\n} from \"../drizzle/sqlite\";\nimport {\n DEFAULT_LOCAL_SQLITE_PRAGMAS,\n type LocalSqliteJournalMode,\n type LocalSqlitePragmaOptions,\n type LocalSqliteSynchronousMode,\n} from \"./local-options\";\n\nexport {\n DEFAULT_LOCAL_SQLITE_PRAGMAS,\n type LocalSqliteJournalMode,\n type LocalSqlitePragmaOptions,\n type LocalSqliteSynchronousMode,\n} from \"./local-options\";\nimport {\n type AdapterBackend,\n type BundledBackendCapabilityOverrides,\n} from \"../types\";\nexport type { BundledBackendCapabilityOverrides } from \"../types\";\nexport type {\n ContributionDiagnostic,\n ContributionDiagnosticState,\n ContributionRepairEntry,\n ContributionRepairResult,\n} from \"../types\";\n\nconst nodeRequire = createRequire(import.meta.url);\n\nfunction installLocalSqliteBaseSchema(\n sqlite: Database.Database,\n tables: SqliteTables,\n fulltextStrategy: FulltextStrategy | false | undefined,\n): void {\n // v2 (the fences relation) and v3 (the recorded-relations' and recorded\n // identity-assertions relation's `since_idx` indexes) need no adoption\n // logic beyond what `generateSqliteMigrationSQL` already emits: a\n // brand-new relation or index is fully covered by its own `CREATE TABLE\n // IF NOT EXISTS` / `CREATE INDEX IF NOT EXISTS`, on both a fresh database\n // and one that already has every OTHER base table or index. Only v1's\n // edge-match-identity `ADD COLUMN` migration — handled by the catch block\n // below — needed runtime introspection this synchronous path writes by\n // hand instead of running `BaseSchemaLifecycle`'s async state machine.\n if (CURRENT_BASE_SCHEMA_VERSION !== 3) {\n throw new CompilerInvariantError(\n \"The synchronous managed SQLite installation path only implements base-schema v1 through v3 adoption.\",\n { currentVersion: CURRENT_BASE_SCHEMA_VERSION },\n );\n }\n const installationSql = generateSqliteMigrationSQL(tables, fulltextStrategy);\n try {\n sqlite.exec(installationSql);\n } catch (error) {\n if (!isSqliteMissingEdgeMatchIdentityColumnError(error)) throw error;\n const edgeTableName = getTableName(tables.edges);\n for (let attempt = 0; attempt < 3; attempt += 1) {\n const rows = sqlite\n .prepare(`PRAGMA table_info(${quoteDdlIdentifier(edgeTableName)})`)\n .all() as readonly Readonly<{ name?: unknown }>[];\n const columns = new Set(\n rows.flatMap((row) => (typeof row.name === \"string\" ? [row.name] : [])),\n );\n const adoptionSql = planSqliteEdgeMatchIdentityAdoption(\n edgeTableName,\n columns,\n );\n try {\n sqlite.exec([...adoptionSql, installationSql].join(\"\\n\"));\n return;\n } catch (repairError) {\n if (\n attempt === 2 ||\n !isSqliteDuplicateEdgeMatchIdentityColumnError(repairError)\n ) {\n throw repairError;\n }\n }\n }\n throw new CompilerInvariantError(\n \"Local SQLite match-identity adoption exhausted its retry loop without returning or throwing.\",\n );\n }\n}\n\n// ============================================================\n// Native Addon Helpers\n// ============================================================\n\ntype NodeModuleVersionMismatch = Readonly<{\n compiled: number;\n required: number;\n}>;\n\nfunction getUnknownErrorMessage(error: unknown): string {\n if (error instanceof Error) return error.message;\n return String(error);\n}\n\nfunction parseNodeModuleVersionMismatchMessage(\n message: string,\n): NodeModuleVersionMismatch | undefined {\n const regexp =\n /NODE_MODULE_VERSION (?<compiled>\\d+)[\\s\\S]*?NODE_MODULE_VERSION (?<required>\\d+)/;\n const match = regexp.exec(message);\n if (!match?.groups) return undefined;\n\n const compiled = Number(match.groups[\"compiled\"]);\n const required = Number(match.groups[\"required\"]);\n\n if (!Number.isFinite(compiled) || !Number.isFinite(required))\n return undefined;\n\n return { compiled, required };\n}\n\nfunction createDatabase(path: string): Database.Database {\n try {\n return new Database(path);\n } catch (error) {\n const message = getUnknownErrorMessage(error);\n const mismatch = parseNodeModuleVersionMismatchMessage(message);\n if (!mismatch) throw error;\n\n throw new ConfigurationError(\n [\n \"Failed to load better-sqlite3 native addon.\",\n `It was compiled for NODE_MODULE_VERSION ${mismatch.compiled}, but this Node.js runtime requires ${mismatch.required}.`,\n \"This usually happens after switching Node versions without rebuilding native dependencies.\",\n \"Rebuild with: pnpm rebuild better-sqlite3 (or npm rebuild better-sqlite3).\",\n ].join(\" \"),\n {\n nodeVersion: process.version,\n nodeModuleVersion: process.versions.modules,\n compiledNodeModuleVersion: mismatch.compiled,\n requiredNodeModuleVersion: mismatch.required,\n },\n { cause: error },\n );\n }\n}\n\n// ============================================================\n// Types\n// ============================================================\n\nconst LOCAL_SQLITE_JOURNAL_MODES: readonly LocalSqliteJournalMode[] = [\n \"wal\",\n \"delete\",\n \"truncate\",\n \"persist\",\n \"memory\",\n \"off\",\n];\n\nconst LOCAL_SQLITE_SYNCHRONOUS_MODES: readonly LocalSqliteSynchronousMode[] = [\n \"off\",\n \"normal\",\n \"full\",\n \"extra\",\n];\n\nconst SQLITE_MAX_WAL_AUTOCHECKPOINT_PAGES = 2_147_483_647;\n\nfunction applyConnectionPragmas(\n sqlite: Database.Database,\n pragmas: LocalSqlitePragmaOptions | false | undefined,\n): void {\n if (pragmas === false) return;\n const resolved: Required<LocalSqlitePragmaOptions> = {\n ...DEFAULT_LOCAL_SQLITE_PRAGMAS,\n ...pragmas,\n };\n\n // Runtime guards mirror the compile-time unions: pragma values are spliced\n // into pragma statements, so reject anything outside the allowlists rather\n // than forwarding it to SQLite.\n if (!LOCAL_SQLITE_JOURNAL_MODES.includes(resolved.journalMode)) {\n throw new ConfigurationError(\n `Invalid journalMode pragma: ${resolved.journalMode}. ` +\n `Expected one of: ${LOCAL_SQLITE_JOURNAL_MODES.join(\", \")}.`,\n { journalMode: resolved.journalMode },\n );\n }\n if (!LOCAL_SQLITE_SYNCHRONOUS_MODES.includes(resolved.synchronous)) {\n throw new ConfigurationError(\n `Invalid synchronous pragma: ${resolved.synchronous}. ` +\n `Expected one of: ${LOCAL_SQLITE_SYNCHRONOUS_MODES.join(\", \")}.`,\n { synchronous: resolved.synchronous },\n );\n }\n if (\n !Number.isSafeInteger(resolved.busyTimeoutMs) ||\n resolved.busyTimeoutMs < 0\n ) {\n throw new ConfigurationError(\n `Invalid busyTimeoutMs pragma: ${String(resolved.busyTimeoutMs)}. ` +\n \"Expected a non-negative integer number of milliseconds.\",\n { busyTimeoutMs: resolved.busyTimeoutMs },\n );\n }\n if (\n resolved.cacheSizeKib !== undefined &&\n (!Number.isSafeInteger(resolved.cacheSizeKib) || resolved.cacheSizeKib >= 0)\n ) {\n throw new ConfigurationError(\n `Invalid cacheSizeKib pragma: ${String(resolved.cacheSizeKib)}. ` +\n \"Expected a negative safe integer — SQLite's own cache_size pragma \" +\n \"interprets a positive value as a page count, not KiB, so a caller \" +\n 'who passes e.g. 131072 meaning \"131072 KiB\" silently gets ' +\n \"131072 pages (~512MiB at the default 4KiB page size) instead.\",\n { cacheSizeKib: resolved.cacheSizeKib },\n );\n }\n if (\n resolved.mmapSizeBytes !== undefined &&\n (!Number.isSafeInteger(resolved.mmapSizeBytes) ||\n resolved.mmapSizeBytes < 0)\n ) {\n throw new ConfigurationError(\n `Invalid mmapSizeBytes pragma: ${String(resolved.mmapSizeBytes)}. ` +\n \"Expected a non-negative safe integer number of bytes.\",\n { mmapSizeBytes: resolved.mmapSizeBytes },\n );\n }\n if (\n resolved.walAutocheckpointPages !== undefined &&\n (!Number.isSafeInteger(resolved.walAutocheckpointPages) ||\n resolved.walAutocheckpointPages < 0 ||\n resolved.walAutocheckpointPages > SQLITE_MAX_WAL_AUTOCHECKPOINT_PAGES)\n ) {\n throw new ConfigurationError(\n `Invalid walAutocheckpointPages pragma: ${String(resolved.walAutocheckpointPages)}. ` +\n `Expected an integer between 0 and ${SQLITE_MAX_WAL_AUTOCHECKPOINT_PAGES} ` +\n \"WAL pages (0 disables automatic checkpointing entirely).\",\n { walAutocheckpointPages: resolved.walAutocheckpointPages },\n );\n }\n\n // \":memory:\" databases always journal in memory; SQLite answers the WAL\n // request with \"memory\" instead of erroring, so no special-casing needed.\n sqlite.pragma(`journal_mode = ${resolved.journalMode}`);\n sqlite.pragma(`synchronous = ${resolved.synchronous}`);\n sqlite.pragma(`busy_timeout = ${resolved.busyTimeoutMs}`);\n if (resolved.cacheSizeKib !== undefined) {\n sqlite.pragma(`cache_size = ${resolved.cacheSizeKib}`);\n }\n if (resolved.mmapSizeBytes !== undefined) {\n sqlite.pragma(`mmap_size = ${resolved.mmapSizeBytes}`);\n }\n if (resolved.walAutocheckpointPages !== undefined) {\n sqlite.pragma(`wal_autocheckpoint = ${resolved.walAutocheckpointPages}`);\n }\n}\n\n/**\n * Options for creating a local SQLite backend.\n */\nexport type LocalSqliteBackendOptions = Readonly<{\n /**\n * Path to the SQLite database file.\n * Defaults to \":memory:\" for an in-memory database.\n */\n path?: string;\n\n /**\n * Connection pragmas applied at open. Defaults to\n * {@link DEFAULT_LOCAL_SQLITE_PRAGMAS} (WAL, `synchronous=NORMAL`, 5s busy\n * timeout, and SQLite's own tiny built-in page cache / disabled mmap\n * left untouched). Individual values merge over the defaults; pass\n * `false` to skip pragma configuration entirely and keep the driver\n * defaults (rollback journal, `synchronous=FULL`, and better-sqlite3's\n * own 5s busy timeout from its `timeout` constructor option). Set\n * `cacheSizeKib`/`mmapSizeBytes` explicitly once a database's working\n * set is known to exceed SQLite's 2MiB default cache — otherwise every\n * query pays a fresh disk read per page past that tiny working set. Set\n * `walAutocheckpointPages` explicitly for a bulk-insert-heavy workload —\n * SQLite's own default checkpoints every ~4MiB of WAL growth, which gets\n * more expensive as the database file grows over a large load.\n */\n pragmas?: LocalSqlitePragmaOptions | false;\n\n /**\n * Custom table definitions.\n * Defaults to standard TypeGraph table names.\n */\n tables?: SqliteTables;\n\n /**\n * Override the fulltext strategy. Defaults to `fts5Strategy` (SQLite's\n * built-in FTS5 virtual table). Pass `false` to disable fulltext support\n * entirely — the backend then advertises no `capabilities.fulltext` and\n * omits the fulltext CRUD/search methods, and the managed installation\n * never creates the fulltext table. Forwarded to both the installation\n * DDL and `createSqliteBackend`.\n */\n fulltext?: FulltextStrategy | false;\n\n /**\n * Override specific backend capabilities — e.g. to simulate an engine-level\n * gap like missing SQL window functions in tests. Forwarded to\n * createSqliteBackend.\n */\n capabilities?: BundledBackendCapabilityOverrides;\n}>;\n\n/**\n * Result of creating a local SQLite backend.\n */\nexport type LocalSqliteBackendResult = Readonly<{\n /**\n * The GraphBackend instance for use with createStore.\n */\n backend: AdapterBackend<AnySqliteDatabase>;\n\n /**\n * The underlying Drizzle database instance.\n * Useful for direct SQL access or cleanup.\n */\n db: BetterSQLite3Database;\n}>;\n\n// ============================================================\n// Factory Function\n// ============================================================\n\n/**\n * Creates a SQLite backend with minimal configuration.\n *\n * This is a convenience function for local development and testing.\n * It handles database creation, schema migration, and backend setup.\n *\n * For production deployments or custom configurations, use createSqliteBackend\n * directly with your own Drizzle database instance.\n *\n * @param options - Configuration options\n * @returns Backend and database instances\n *\n * @example In-memory database (default)\n * ```typescript\n * const { backend } = createLocalSqliteBackend();\n * const store = createStore(graph, backend);\n * ```\n *\n * @example File-based database\n * ```typescript\n * const { backend, db } = createLocalSqliteBackend({ path: \"./data.db\" });\n * const store = createStore(graph, backend);\n * ```\n */\nexport function createLocalSqliteBackend(\n options: LocalSqliteBackendOptions = {},\n): LocalSqliteBackendResult {\n assertNoLegacyTransactionCapability(options.capabilities);\n const path = options.path ?? \":memory:\";\n const tables = options.tables ?? defaultTables;\n\n const sqlite = createDatabase(path);\n try {\n applyConnectionPragmas(sqlite, options.pragmas);\n\n // Best-effort: load sqlite-vec so embedding fields are persisted to\n // per-`(kind, field)` `vec0` storage. Without it, nodes with\n // `embedding()` fields validate and insert but their vectors are silently\n // dropped. When the user has installed sqlite-vec as a peer dep we load\n // it and wire the strategy; otherwise we proceed without vector support.\n const hasSqliteVec = tryLoadSqliteVec(sqlite);\n\n const db = drizzle(sqlite);\n\n // The managed factory owns a complete fresh installation, including the\n // deployment-wide base-schema marker consumed by verified/runtime-only\n // entrypoints. Raw generateSqliteDDL intentionally omits that marker.\n installLocalSqliteBaseSchema(sqlite, tables, options.fulltext);\n\n const backend = createSqliteBackend(db, {\n executionProfile: {\n isSync: true,\n },\n tables,\n ...(hasSqliteVec ? { vector: sqliteVecStrategy } : {}),\n ...(options.fulltext === undefined ? {} : { fulltext: options.fulltext }),\n capabilities: {\n ...options.capabilities,\n graphAnalytics: {\n supported:\n options.capabilities?.graphAnalytics?.supported ??\n options.capabilities?.execution?.interactiveTransactions !== false,\n mathFunctions:\n options.capabilities?.graphAnalytics?.mathFunctions ?? true,\n },\n },\n });\n const managedBackend = wrapWithManagedClose(backend, () => {\n sqlite.close();\n });\n\n return { backend: markBundledRootAutocommitEligible(managedBackend), db };\n } catch (error) {\n try {\n sqlite.close();\n } catch {\n // Preserve the provisioning error; a cleanup failure is secondary.\n }\n throw error;\n }\n}\n\nfunction tryLoadSqliteVec(sqlite: Database.Database): boolean {\n try {\n // `sqlite-vec` is an optional peer dep; resolved via createRequire so\n // bundlers don't mark it as a hard import. Node resolves the package\n // only when it's actually installed.\n const module_: unknown = nodeRequire(\"sqlite-vec\");\n if (\n typeof module_ === \"object\" &&\n module_ !== null &&\n \"load\" in module_ &&\n typeof module_.load === \"function\"\n ) {\n (module_ as { load: (db: Database.Database) => void }).load(sqlite);\n return true;\n }\n return false;\n } catch {\n return false;\n }\n}\nexport type { GraphIdentityConfig } from \"../../core/define-graph\";\n"]}
@@ -1,4 +1,4 @@
1
- import { SYSTEM_INDEX_DECLARATIONS, systemIndexName } from './chunk-RWE33LCI.js';
1
+ import { SYSTEM_INDEX_DECLARATIONS, systemIndexName } from './chunk-NXK2ZBVV.js';
2
2
  import { compileNodeIndexKeys, compileIndexWhere, compileEdgeIndexKeys } from './chunk-GZM2HWN2.js';
3
3
  import { isSqlFragment, renderSql, throwUnsupportedSqlChunk, bindSqlValue, sql as sql$1 } from './chunk-QF76TFLV.js';
4
4
  import { uniqueIndex, index } from 'drizzle-orm/pg-core';
@@ -379,5 +379,5 @@ function assertNonEmpty(values, label) {
379
379
  }
380
380
 
381
381
  export { buildPostgresEdgeIndexBuilders, buildPostgresNodeIndexBuilders, buildPostgresSystemIndexBuilders, buildSqliteEdgeIndexBuilders, buildSqliteNodeIndexBuilders, buildSqliteSystemIndexBuilders, compileQueryWithDialect, toDrizzleSql };
382
- //# sourceMappingURL=chunk-OX2NMPRS.js.map
383
- //# sourceMappingURL=chunk-OX2NMPRS.js.map
382
+ //# sourceMappingURL=chunk-UJW55GPE.js.map
383
+ //# sourceMappingURL=chunk-UJW55GPE.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/backend/drizzle/execution/types.ts","../src/indexes/drizzle.ts"],"names":["drizzleSql","index","sql","pgUniqueIndex","pgIndex","sqliteUniqueIndex","sqliteIndex"],"mappings":";;;;;;;AAkFA,IAAM,uBAAA,GAA0B;AAAA,EAC9B,UAAA,EAAY,UAAA;AAAA,EACZ,MAAA,EAAQ;AACV,CAAA;AAEO,SAAS,uBAAA,CACd,EAAA,EACA,KAAA,EACA,WAAA,EACkB;AAClB,EAAA,IAAI,aAAA,CAAc,KAAK,CAAA,EAAG;AACxB,IAAA,OAAO,SAAA,CAAU,KAAA,EAAO,uBAAA,CAAwB,WAAW,CAAC,CAAA;AAAA,EAC9D;AACA,EAAA,MAAM,oBAAA,GAAuB,EAAA;AAC7B,EAAA,MAAM,WAAW,oBAAA,CAAqB,OAAA;AACtC,EAAA,IAAI,aAAa,MAAA,EAAW;AAC1B,IAAA,MAAM,IAAI,K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IAAA,KAASF,KAAA,CAAQ,IAAI;AAAA,GACxB;AACF;AAqCA,SAAS,cAAA,CACP,QACA,KAAA,EACwC;AACxC,EAAA,IAAI,MAAA,CAAO,WAAW,CAAA,EAAG;AACvB,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,kCAAA,EAAqC,KAAK,CAAA,CAAA,CAAG,CAAA;AAAA,EAC/D;AACF","file":"chunk-OX2NMPRS.js","sourcesContent":["import { type SQL as DrizzleSql, sql as drizzleSql } from \"drizzle-orm\";\n\nimport { bindSqlValue } from \"../../../query/dialect/profile\";\nimport { type SqlDialect } from \"../../../query/dialect/types\";\nimport {\n isSqlFragment,\n renderSql,\n type SqlFragment,\n throwUnsupportedSqlChunk,\n} from \"../../../query/sql-fragment\";\nimport type {\n AtomicSqlBatchExecutor,\n CompiledAtomicSqlStatement,\n} from \"../../capabilities/atomic-sql-program\";\n\nexport type ExecutableSql = DrizzleSql | SqlFragment;\n\nexport type CompiledSqlQuery = CompiledAtomicSqlStatement;\n\n/**\n * A driver-native, all-or-nothing group of compiled statements.\n *\n * This is intentionally an optional execution surface. Most SQL drivers only\n * expose one-statement execution through Drizzle; drivers with a native batch\n * primitive can provide it without making callers guess whether a sequence is\n * actually transactional. The static name is deliberate: this hook submits a\n * complete batch to a native primitive and is not an interactive transaction\n * runner.\n */\nexport type PreparedSqlStatement = Readonly<{\n execute: <TRow>(params: readonly unknown[]) => Promise<readonly TRow[]>;\n}>;\n\nexport type SqlExecutionAdapter = Readonly<{\n compile: (query: ExecutableSql) => CompiledSqlQuery;\n execute: <TRow>(query: ExecutableSql) => Promise<readonly TRow[]>;\n executeCompiled?: <TRow>(\n compiledQuery: CompiledSqlQuery,\n ) => Promise<readonly TRow[]>;\n /** Executes all statements atomically when the native driver supports it. */\n executeAtomicBatch?: AtomicSqlBatchExecutor;\n prepare?: (sqlText: string) => PreparedSqlStatement;\n /**\n * Runs `critical` with exclusive use of the connection: no statement from\n * anywhere else can interleave with the ones it issues.\n *\n * Statement-at-a-time serialization is not enough for a *sequence* that must\n * be atomic. `SET LOCAL` around a query is the motivating case — snapshot,\n * set, select, restore. Two searches whose statements merely take turns can\n * still interleave as `A snapshot → B snapshot → A set → B set → A select`,\n * and `A` then runs under `B`'s settings.\n *\n * `critical` is handed the unqueued adapter, so it must not attempt to\n * re-enter the queue. Present only on transaction-scoped (serialized)\n * adapters; a pooled adapter needs no exclusion because every statement gets\n * its own connection.\n */\n runExclusive?: <T>(\n critical: (connection: SqlExecutionAdapter) => Promise<T>,\n ) => Promise<T>;\n /**\n * Recognizes this engine's own commit-conflict shape when it is not\n * PostgreSQL's `40001`/`40P01` SQLSTATE (or the fixed message fallback for\n * a driver that drops the code). `createSqlBackend` registers this\n * classifier against the exact backend object it returns; `isSerializationFailure`\n * (`src/utils/sql-errors.ts`) consults it before falling back to its own\n * SQLSTATE/message rules, so there remains ONE predicate every retry owner\n * calls, never a second inline check for engines this covers.\n */\n serializationFailure?: (error: unknown) => boolean;\n}>;\n\ntype SqlCompiler = Readonly<{\n sqlToQuery: (query: DrizzleSql) => CompiledSqlQuery;\n}>;\n\ntype DatabaseWithCompiler = Readonly<{\n dialect?: SqlCompiler;\n}>;\n\ntype BackendName = \"PostgreSQL\" | \"SQLite\";\n\nconst DIALECT_BY_BACKEND_NAME = {\n PostgreSQL: \"postgres\",\n SQLite: \"sqlite\",\n} as const satisfies Record<BackendName, SqlDialect>;\n\nexport function compileQueryWithDialect(\n db: unknown,\n query: ExecutableSql,\n backendName: BackendName,\n): CompiledSqlQuery {\n if (isSqlFragment(query)) {\n return renderSql(query, DIALECT_BY_BACKEND_NAME[backendName]);\n }\n const databaseWithCompiler = db as DatabaseWithCompiler;\n const compiler = databaseWithCompiler.dialect;\n if (compiler === undefined) {\n throw new Error(`${backendName} backend is missing a SQL compiler`);\n }\n return compiler.sqlToQuery(query);\n}\n\n/**\n * Translates TypeGraph's fragment IR into Drizzle's adapter-native SQL object.\n *\n * Most execution paths render directly to text and parameters. Async SQLite\n * drivers expose only Drizzle's execution method, so that adapter needs this\n * lossless bridge at its final boundary.\n */\nexport function toDrizzleSql(\n fragment: SqlFragment,\n dialect: SqlDialect,\n): DrizzleSql {\n const chunks = fragment.chunks.map((chunk) => {\n switch (chunk.kind) {\n case \"text\": {\n return drizzleSql.raw(chunk.value);\n }\n case \"identifier\": {\n // Drizzle's schema builders treat Name chunks as bare index-column\n // references and omit dialect quoting. Preserve the portable IR's\n // identifier semantics by handing the adapter an already-quoted,\n // trusted SQL token instead.\n return drizzleSql.raw(`\"${chunk.value.replaceAll('\"', '\"\"')}\"`);\n }\n case \"parameter\": {\n return drizzleSql.param(bindSqlValue(chunk.value, dialect));\n }\n case \"placeholder\": {\n return drizzleSql.placeholder(chunk.value.name);\n }\n default: {\n return throwUnsupportedSqlChunk(chunk);\n }\n }\n });\n return drizzleSql.join(chunks);\n}\n","import { type SQLWrapper } from \"drizzle-orm\";\nimport {\n index as pgIndex,\n type IndexBuilder as PgIndexBuilder,\n type PgColumn,\n uniqueIndex as pgUniqueIndex,\n} from \"drizzle-orm/pg-core\";\nimport {\n index as sqliteIndex,\n type IndexBuilder as SqliteIndexBuilder,\n type SQLiteColumn,\n uniqueIndex as sqliteUniqueIndex,\n} from \"drizzle-orm/sqlite-core\";\n\nimport { toDrizzleSql } from \"../backend/drizzle/execution/types\";\nimport { sql as portableSql, type SqlFragment } from \"../query/sql-fragment\";\nimport {\n compileEdgeIndexKeys,\n compileIndexWhere,\n compileNodeIndexKeys,\n type IndexCompilationContext,\n} from \"./compiler\";\nimport {\n SYSTEM_INDEX_DECLARATIONS,\n type SystemIndexDeclaration,\n systemIndexName,\n type SystemIndexTable,\n} from \"./system\";\nimport {\n type EdgeIndexDeclaration,\n type IndexDeclaration,\n type NodeIndexDeclaration,\n type SystemColumnName,\n} from \"./types\";\n\n// ============================================================\n// PostgreSQL (Drizzle Schema)\n// ============================================================\n\nexport function buildPostgresNodeIndexBuilders(\n table: NodeIndexTable,\n indexes: readonly IndexDeclaration[],\n): readonly PgIndexBuilder[] {\n // GIN-family declarations (method: \"gin\" / \"trigram\") are\n // materialize-only — like pgvector ANN indexes, they are a pure\n // materialization concern and never ride the Drizzle table extras.\n const nodeIndexes = indexes.filter(\n (index): index is NodeIndexDeclaration =>\n index.entity === \"node\" && index.method === undefined,\n );\n\n return nodeIndexes.map((index) => {\n const propsColumn = portableSql.identifier(table.props.name);\n const systemColumn = (column: SystemColumnName): SqlFragment =>\n portableSql.identifier(getPostgresNodeSystemColumn(table, column).name);\n\n const { keys } = compileNodeIndexKeys(\n index,\n \"postgres\",\n propsColumn,\n systemColumn,\n );\n assertNonEmpty(keys, `node index \"${index.name}\"`);\n\n const base = index.unique ? pgUniqueIndex(index.name) : pgIndex(index.name);\n\n const drizzleKeys = keys.map((key) => toDrizzleSql(key, \"postgres\"));\n assertNonEmpty(drizzleKeys, `node index \"${index.name}\"`);\n const [firstKey, ...remainingKeys] = drizzleKeys;\n const builder = base.on(firstKey, ...remainingKeys);\n\n if (index.where) {\n const ctx: IndexCompilationContext = {\n dialect: \"postgres\",\n propsColumn,\n systemColumn,\n };\n builder.where(\n toDrizzleSql(compileIndexWhere(ctx, index.where), \"postgres\"),\n );\n }\n\n return builder;\n });\n}\n\nexport function buildPostgresEdgeIndexBuilders(\n table: EdgeIndexTable,\n indexes: readonly IndexDeclaration[],\n): readonly PgIndexBuilder[] {\n const edgeIndexes = indexes.filter(\n (index): index is EdgeIndexDeclaration =>\n index.entity === \"edge\" && index.method === undefined,\n );\n\n return edgeIndexes.map((index) => {\n const propsColumn = portableSql.identifier(table.props.name);\n const systemColumn = (column: SystemColumnName): SqlFragment =>\n portableSql.identifier(getPostgresEdgeSystemColumn(table, column).name);\n\n const { keys } = compileEdgeIndexKeys(\n index,\n \"postgres\",\n propsColumn,\n systemColumn,\n );\n assertNonEmpty(keys, `edge index \"${index.name}\"`);\n\n const base = index.unique ? pgUniqueIndex(index.name) : pgIndex(index.name);\n\n const drizzleKeys = keys.map((key) => toDrizzleSql(key, \"postgres\"));\n assertNonEmpty(drizzleKeys, `edge index \"${index.name}\"`);\n const [firstKey, ...remainingKeys] = drizzleKeys;\n const builder = base.on(firstKey, ...remainingKeys);\n\n if (index.where) {\n const ctx: IndexCompilationContext = {\n dialect: \"postgres\",\n propsColumn,\n systemColumn,\n };\n builder.where(\n toDrizzleSql(compileIndexWhere(ctx, index.where), \"postgres\"),\n );\n }\n\n return builder;\n });\n}\n\nfunction getPostgresNodeSystemColumn(\n table: NodeIndexTable,\n column: SystemColumnName,\n): NamedSqlWrapper {\n switch (column) {\n case \"graph_id\": {\n return table.graphId;\n }\n case \"kind\": {\n return table.kind;\n }\n case \"id\": {\n return table.id;\n }\n case \"from_kind\":\n case \"from_id\":\n case \"to_kind\":\n case \"to_id\": {\n throw new Error(`Unsupported node system column for indexes: ${column}`);\n }\n case \"deleted_at\": {\n return table.deletedAt;\n }\n case \"valid_from\": {\n return table.validFrom;\n }\n case \"valid_to\": {\n return table.validTo;\n }\n case \"created_at\": {\n return table.createdAt;\n }\n case \"updated_at\": {\n return table.updatedAt;\n }\n case \"version\": {\n return table.version;\n }\n }\n}\n\nfunction getPostgresEdgeSystemColumn(\n table: EdgeIndexTable,\n column: SystemColumnName,\n): NamedSqlWrapper {\n switch (column) {\n case \"graph_id\": {\n return table.graphId;\n }\n case \"kind\": {\n return table.kind;\n }\n case \"id\": {\n return table.id;\n }\n case \"from_kind\": {\n return table.fromKind;\n }\n case \"from_id\": {\n return table.fromId;\n }\n case \"to_kind\": {\n return table.toKind;\n }\n case \"to_id\": {\n return table.toId;\n }\n case \"deleted_at\": {\n return table.deletedAt;\n }\n case \"valid_from\": {\n return table.validFrom;\n }\n case \"valid_to\": {\n return table.validTo;\n }\n case \"created_at\": {\n return table.createdAt;\n }\n case \"updated_at\": {\n return table.updatedAt;\n }\n case \"version\": {\n throw new Error(`Unsupported edge system column for indexes: ${column}`);\n }\n }\n}\n\n// ============================================================\n// SQLite (Drizzle Schema)\n// ============================================================\n\nexport function buildSqliteNodeIndexBuilders(\n table: NodeIndexTable,\n indexes: readonly IndexDeclaration[],\n): readonly SqliteIndexBuilder[] {\n // GIN-family declarations (method: \"gin\" / \"trigram\") are\n // materialize-only — like pgvector ANN indexes, they are a pure\n // materialization concern and never ride the Drizzle table extras.\n const nodeIndexes = indexes.filter(\n (index): index is NodeIndexDeclaration =>\n index.entity === \"node\" && index.method === undefined,\n );\n\n return nodeIndexes.map((index) => {\n const propsColumn = portableSql.identifier(table.props.name);\n const systemColumn = (column: SystemColumnName): SqlFragment =>\n portableSql.identifier(getSqliteNodeSystemColumn(table, column).name);\n\n const { keys } = compileNodeIndexKeys(\n index,\n \"sqlite\",\n propsColumn,\n systemColumn,\n );\n assertNonEmpty(keys, `node index \"${index.name}\"`);\n\n const base =\n index.unique ? sqliteUniqueIndex(index.name) : sqliteIndex(index.name);\n\n const drizzleKeys = keys.map((key) => toDrizzleSql(key, \"sqlite\"));\n assertNonEmpty(drizzleKeys, `node index \"${index.name}\"`);\n const [firstKey, ...remainingKeys] = drizzleKeys;\n const builder = base.on(firstKey, ...remainingKeys);\n\n if (index.where) {\n const ctx: IndexCompilationContext = {\n dialect: \"sqlite\",\n propsColumn,\n systemColumn,\n };\n builder.where(\n toDrizzleSql(compileIndexWhere(ctx, index.where), \"sqlite\"),\n );\n }\n\n return builder;\n });\n}\n\nexport function buildSqliteEdgeIndexBuilders(\n table: EdgeIndexTable,\n indexes: readonly IndexDeclaration[],\n): readonly SqliteIndexBuilder[] {\n const edgeIndexes = indexes.filter(\n (index): index is EdgeIndexDeclaration =>\n index.entity === \"edge\" && index.method === undefined,\n );\n\n return edgeIndexes.map((index) => {\n const propsColumn = portableSql.identifier(table.props.name);\n const systemColumn = (column: SystemColumnName): SqlFragment =>\n portableSql.identifier(getSqliteEdgeSystemColumn(table, column).name);\n\n const { keys } = compileEdgeIndexKeys(\n index,\n \"sqlite\",\n propsColumn,\n systemColumn,\n );\n assertNonEmpty(keys, `edge index \"${index.name}\"`);\n\n const base =\n index.unique ? sqliteUniqueIndex(index.name) : sqliteIndex(index.name);\n\n const drizzleKeys = keys.map((key) => toDrizzleSql(key, \"sqlite\"));\n assertNonEmpty(drizzleKeys, `edge index \"${index.name}\"`);\n const [firstKey, ...remainingKeys] = drizzleKeys;\n const builder = base.on(firstKey, ...remainingKeys);\n\n if (index.where) {\n const ctx: IndexCompilationContext = {\n dialect: \"sqlite\",\n propsColumn,\n systemColumn,\n };\n builder.where(\n toDrizzleSql(compileIndexWhere(ctx, index.where), \"sqlite\"),\n );\n }\n\n return builder;\n });\n}\n\nfunction getSqliteNodeSystemColumn(\n table: NodeIndexTable,\n column: SystemColumnName,\n): NamedSqlWrapper {\n switch (column) {\n case \"graph_id\": {\n return table.graphId;\n }\n case \"kind\": {\n return table.kind;\n }\n case \"id\": {\n return table.id;\n }\n case \"from_kind\":\n case \"from_id\":\n case \"to_kind\":\n case \"to_id\": {\n throw new Error(`Unsupported node system column for indexes: ${column}`);\n }\n case \"deleted_at\": {\n return table.deletedAt;\n }\n case \"valid_from\": {\n return table.validFrom;\n }\n case \"valid_to\": {\n return table.validTo;\n }\n case \"created_at\": {\n return table.createdAt;\n }\n case \"updated_at\": {\n return table.updatedAt;\n }\n case \"version\": {\n return table.version;\n }\n }\n}\n\nfunction getSqliteEdgeSystemColumn(\n table: EdgeIndexTable,\n column: SystemColumnName,\n): NamedSqlWrapper {\n switch (column) {\n case \"graph_id\": {\n return table.graphId;\n }\n case \"kind\": {\n return table.kind;\n }\n case \"id\": {\n return table.id;\n }\n case \"from_kind\": {\n return table.fromKind;\n }\n case \"from_id\": {\n return table.fromId;\n }\n case \"to_kind\": {\n return table.toKind;\n }\n case \"to_id\": {\n return table.toId;\n }\n case \"deleted_at\": {\n return table.deletedAt;\n }\n case \"valid_from\": {\n return table.validFrom;\n }\n case \"valid_to\": {\n return table.validTo;\n }\n case \"created_at\": {\n return table.createdAt;\n }\n case \"updated_at\": {\n return table.updatedAt;\n }\n case \"version\": {\n throw new Error(`Unsupported edge system column for indexes: ${column}`);\n }\n }\n}\n\n// ============================================================\n// System indexes (both dialects)\n// ============================================================\n//\n// The schema factories derive their system-index Drizzle builders from\n// `SYSTEM_INDEX_DECLARATIONS` so both dialects emit the same index set by\n// construction. The builders receive the table's real column objects (not\n// SQL wrappers) so the DDL generator renders plain quoted column names —\n// byte-identical to the runtime DDL `materializeSystemIndexes` emits.\n\ntype SystemIndexColumns<C extends { name: string }> = Readonly<\n Record<string, C>\n>;\n\n/**\n * Resolves a declaration's physical column names against the table's own\n * column objects by each column's `.name` — the SQL name Drizzle carries on\n * the column itself — so no naming convention sits between the declaration\n * and the schema. A column the table doesn't define throws at\n * table-construction time (exercised by the system-index parity tests).\n */\nfunction resolveSystemIndexColumns<C extends { name: string }>(\n declaration: SystemIndexDeclaration,\n columns: SystemIndexColumns<C>,\n): readonly [C, ...C[]] {\n const byPhysicalName = new Map(\n Object.values(columns).map((column) => [column.name, column]),\n );\n const resolved = declaration.columns.map((column) => {\n const value = byPhysicalName.get(column);\n if (value === undefined) {\n throw new Error(\n `System index \"${declaration.table}_${declaration.suffix}\" references ` +\n `a column \"${column}\" the ${declaration.table} table does not define`,\n );\n }\n return value;\n });\n // `declaration.columns` is non-empty by type, so `resolved` is too.\n return resolved as [C, ...C[]];\n}\n\n/**\n * The two dialect variants do no dialect-specific work (no unique, no\n * where, no expression compilation — unlike the node/edge builder pairs\n * above), so they share one body parameterized by the dialect's index\n * factory.\n */\nfunction buildSystemIndexBuilders<C extends { name: string }, B>(\n tableKey: SystemIndexTable,\n physicalTableName: string,\n columns: SystemIndexColumns<C>,\n indexFactory: (name: string) => { on: (...cols: [C, ...C[]]) => B },\n): readonly B[] {\n return SYSTEM_INDEX_DECLARATIONS.filter(\n (declaration) => declaration.table === tableKey,\n ).map((declaration) =>\n indexFactory(systemIndexName(physicalTableName, declaration.suffix)).on(\n ...resolveSystemIndexColumns(declaration, columns),\n ),\n );\n}\n\nexport function buildSqliteSystemIndexBuilders(\n tableKey: SystemIndexTable,\n physicalTableName: string,\n columns: SystemIndexColumns<SQLiteColumn>,\n): readonly SqliteIndexBuilder[] {\n return buildSystemIndexBuilders(\n tableKey,\n physicalTableName,\n columns,\n (name) => sqliteIndex(name),\n );\n}\n\nexport function buildPostgresSystemIndexBuilders(\n tableKey: SystemIndexTable,\n physicalTableName: string,\n columns: SystemIndexColumns<PgColumn>,\n): readonly PgIndexBuilder[] {\n return buildSystemIndexBuilders(\n tableKey,\n physicalTableName,\n columns,\n (name) => pgIndex(name),\n );\n}\n\n// ============================================================\n// Minimal table shapes (shared between dialect schemas)\n// ============================================================\n\ntype NamedSqlWrapper = SQLWrapper & Readonly<{ name: string }>;\n\ntype NodeIndexTable = Readonly<{\n graphId: NamedSqlWrapper;\n kind: NamedSqlWrapper;\n id: NamedSqlWrapper;\n props: NamedSqlWrapper;\n version: NamedSqlWrapper;\n validFrom: NamedSqlWrapper;\n validTo: NamedSqlWrapper;\n createdAt: NamedSqlWrapper;\n updatedAt: NamedSqlWrapper;\n deletedAt: NamedSqlWrapper;\n}>;\n\ntype EdgeIndexTable = Readonly<{\n graphId: NamedSqlWrapper;\n id: NamedSqlWrapper;\n kind: NamedSqlWrapper;\n fromKind: NamedSqlWrapper;\n fromId: NamedSqlWrapper;\n toKind: NamedSqlWrapper;\n toId: NamedSqlWrapper;\n props: NamedSqlWrapper;\n validFrom: NamedSqlWrapper;\n validTo: NamedSqlWrapper;\n createdAt: NamedSqlWrapper;\n updatedAt: NamedSqlWrapper;\n deletedAt: NamedSqlWrapper;\n}>;\n\nfunction assertNonEmpty<T>(\n values: readonly T[],\n label: string,\n): asserts values is readonly [T, ...T[]] {\n if (values.length === 0) {\n throw new Error(`Index must have at least one key (${label})`);\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/backend/drizzle/execution/types.ts","../src/indexes/drizzle.ts"],"names":["drizzleSql","index","sql","pgUniqueIndex","pgIndex","sqliteUniqueIndex","sqliteIndex"],"mappings":";;;;;;;AAkFA,IAAM,uBAAA,GA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BAAA,CAA0B,WAAA,EAAa,OAAO;AAAA;AACnD,GACF;AACF;AAEO,SAAS,8BAAA,CACd,QAAA,EACA,iBAAA,EACA,OAAA,EAC+B;AAC/B,EAAA,OAAO,wBAAA;AAAA,IACL,QAAA;AAAA,IACA,iBAAA;AAAA,IACA,OAAA;AAAA,IACA,CAAC,IAAA,KAASA,OAAA,CAAY,IAAI;AAAA,GAC5B;AACF;AAEO,SAAS,gCAAA,CACd,QAAA,EACA,iBAAA,EACA,OAAA,EAC2B;AAC3B,EAAA,OAAO,wBAAA;AAAA,IACL,QAAA;AAAA,IACA,iBAAA;AAAA,IACA,OAAA;AAAA,IACA,CAAC,IAAA,KAASF,KAAA,CAAQ,IAAI;AAAA,GACxB;AACF;AAqCA,SAAS,cAAA,CACP,QACA,KAAA,EACwC;AACxC,EAAA,IAAI,MAAA,CAAO,WAAW,CAAA,EAAG;AACvB,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,kCAAA,EAAqC,KAAK,CAAA,CAAA,CAAG,CAAA;AAAA,EAC/D;AACF","file":"chunk-UJW55GPE.js","sourcesContent":["import { type SQL as DrizzleSql, sql as drizzleSql } from \"drizzle-orm\";\n\nimport { bindSqlValue } from \"../../../query/dialect/profile\";\nimport { type SqlDialect } from \"../../../query/dialect/types\";\nimport {\n isSqlFragment,\n renderSql,\n type SqlFragment,\n throwUnsupportedSqlChunk,\n} from \"../../../query/sql-fragment\";\nimport type {\n AtomicSqlBatchExecutor,\n CompiledAtomicSqlStatement,\n} from \"../../capabilities/atomic-sql-program\";\n\nexport type ExecutableSql = DrizzleSql | SqlFragment;\n\nexport type CompiledSqlQuery = CompiledAtomicSqlStatement;\n\n/**\n * A driver-native, all-or-nothing group of compiled statements.\n *\n * This is intentionally an optional execution surface. Most SQL drivers only\n * expose one-statement execution through Drizzle; drivers with a native batch\n * primitive can provide it without making callers guess whether a sequence is\n * actually transactional. The static name is deliberate: this hook submits a\n * complete batch to a native primitive and is not an interactive transaction\n * runner.\n */\nexport type PreparedSqlStatement = Readonly<{\n execute: <TRow>(params: readonly unknown[]) => Promise<readonly TRow[]>;\n}>;\n\nexport type SqlExecutionAdapter = Readonly<{\n compile: (query: ExecutableSql) => CompiledSqlQuery;\n execute: <TRow>(query: ExecutableSql) => Promise<readonly TRow[]>;\n executeCompiled?: <TRow>(\n compiledQuery: CompiledSqlQuery,\n ) => Promise<readonly TRow[]>;\n /** Executes all statements atomically when the native driver supports it. */\n executeAtomicBatch?: AtomicSqlBatchExecutor;\n prepare?: (sqlText: string) => PreparedSqlStatement;\n /**\n * Runs `critical` with exclusive use of the connection: no statement from\n * anywhere else can interleave with the ones it issues.\n *\n * Statement-at-a-time serialization is not enough for a *sequence* that must\n * be atomic. `SET LOCAL` around a query is the motivating case — snapshot,\n * set, select, restore. Two searches whose statements merely take turns can\n * still interleave as `A snapshot → B snapshot → A set → B set → A select`,\n * and `A` then runs under `B`'s settings.\n *\n * `critical` is handed the unqueued adapter, so it must not attempt to\n * re-enter the queue. Present only on transaction-scoped (serialized)\n * adapters; a pooled adapter needs no exclusion because every statement gets\n * its own connection.\n */\n runExclusive?: <T>(\n critical: (connection: SqlExecutionAdapter) => Promise<T>,\n ) => Promise<T>;\n /**\n * Recognizes this engine's own commit-conflict shape when it is not\n * PostgreSQL's `40001`/`40P01` SQLSTATE (or the fixed message fallback for\n * a driver that drops the code). `createSqlBackend` registers this\n * classifier against the exact backend object it returns; `isSerializationFailure`\n * (`src/utils/sql-errors.ts`) consults it before falling back to its own\n * SQLSTATE/message rules, so there remains ONE predicate every retry owner\n * calls, never a second inline check for engines this covers.\n */\n serializationFailure?: (error: unknown) => boolean;\n}>;\n\ntype SqlCompiler = Readonly<{\n sqlToQuery: (query: DrizzleSql) => CompiledSqlQuery;\n}>;\n\ntype DatabaseWithCompiler = Readonly<{\n dialect?: SqlCompiler;\n}>;\n\ntype BackendName = \"PostgreSQL\" | \"SQLite\";\n\nconst DIALECT_BY_BACKEND_NAME = {\n PostgreSQL: \"postgres\",\n SQLite: \"sqlite\",\n} as const satisfies Record<BackendName, SqlDialect>;\n\nexport function compileQueryWithDialect(\n db: unknown,\n query: ExecutableSql,\n backendName: BackendName,\n): CompiledSqlQuery {\n if (isSqlFragment(query)) {\n return renderSql(query, DIALECT_BY_BACKEND_NAME[backendName]);\n }\n const databaseWithCompiler = db as DatabaseWithCompiler;\n const compiler = databaseWithCompiler.dialect;\n if (compiler === undefined) {\n throw new Error(`${backendName} backend is missing a SQL compiler`);\n }\n return compiler.sqlToQuery(query);\n}\n\n/**\n * Translates TypeGraph's fragment IR into Drizzle's adapter-native SQL object.\n *\n * Most execution paths render directly to text and parameters. Async SQLite\n * drivers expose only Drizzle's execution method, so that adapter needs this\n * lossless bridge at its final boundary.\n */\nexport function toDrizzleSql(\n fragment: SqlFragment,\n dialect: SqlDialect,\n): DrizzleSql {\n const chunks = fragment.chunks.map((chunk) => {\n switch (chunk.kind) {\n case \"text\": {\n return drizzleSql.raw(chunk.value);\n }\n case \"identifier\": {\n // Drizzle's schema builders treat Name chunks as bare index-column\n // references and omit dialect quoting. Preserve the portable IR's\n // identifier semantics by handing the adapter an already-quoted,\n // trusted SQL token instead.\n return drizzleSql.raw(`\"${chunk.value.replaceAll('\"', '\"\"')}\"`);\n }\n case \"parameter\": {\n return drizzleSql.param(bindSqlValue(chunk.value, dialect));\n }\n case \"placeholder\": {\n return drizzleSql.placeholder(chunk.value.name);\n }\n default: {\n return throwUnsupportedSqlChunk(chunk);\n }\n }\n });\n return drizzleSql.join(chunks);\n}\n","import { type SQLWrapper } from \"drizzle-orm\";\nimport {\n index as pgIndex,\n type IndexBuilder as PgIndexBuilder,\n type PgColumn,\n uniqueIndex as pgUniqueIndex,\n} from \"drizzle-orm/pg-core\";\nimport {\n index as sqliteIndex,\n type IndexBuilder as SqliteIndexBuilder,\n type SQLiteColumn,\n uniqueIndex as sqliteUniqueIndex,\n} from \"drizzle-orm/sqlite-core\";\n\nimport { toDrizzleSql } from \"../backend/drizzle/execution/types\";\nimport { sql as portableSql, type SqlFragment } from \"../query/sql-fragment\";\nimport {\n compileEdgeIndexKeys,\n compileIndexWhere,\n compileNodeIndexKeys,\n type IndexCompilationContext,\n} from \"./compiler\";\nimport {\n SYSTEM_INDEX_DECLARATIONS,\n type SystemIndexDeclaration,\n systemIndexName,\n type SystemIndexTable,\n} from \"./system\";\nimport {\n type EdgeIndexDeclaration,\n type IndexDeclaration,\n type NodeIndexDeclaration,\n type SystemColumnName,\n} from \"./types\";\n\n// ============================================================\n// PostgreSQL (Drizzle Schema)\n// ============================================================\n\nexport function buildPostgresNodeIndexBuilders(\n table: NodeIndexTable,\n indexes: readonly IndexDeclaration[],\n): readonly PgIndexBuilder[] {\n // GIN-family declarations (method: \"gin\" / \"trigram\") are\n // materialize-only — like pgvector ANN indexes, they are a pure\n // materialization concern and never ride the Drizzle table extras.\n const nodeIndexes = indexes.filter(\n (index): index is NodeIndexDeclaration =>\n index.entity === \"node\" && index.method === undefined,\n );\n\n return nodeIndexes.map((index) => {\n const propsColumn = portableSql.identifier(table.props.name);\n const systemColumn = (column: SystemColumnName): SqlFragment =>\n portableSql.identifier(getPostgresNodeSystemColumn(table, column).name);\n\n const { keys } = compileNodeIndexKeys(\n index,\n \"postgres\",\n propsColumn,\n systemColumn,\n );\n assertNonEmpty(keys, `node index \"${index.name}\"`);\n\n const base = index.unique ? pgUniqueIndex(index.name) : pgIndex(index.name);\n\n const drizzleKeys = keys.map((key) => toDrizzleSql(key, \"postgres\"));\n assertNonEmpty(drizzleKeys, `node index \"${index.name}\"`);\n const [firstKey, ...remainingKeys] = drizzleKeys;\n const builder = base.on(firstKey, ...remainingKeys);\n\n if (index.where) {\n const ctx: IndexCompilationContext = {\n dialect: \"postgres\",\n propsColumn,\n systemColumn,\n };\n builder.where(\n toDrizzleSql(compileIndexWhere(ctx, index.where), \"postgres\"),\n );\n }\n\n return builder;\n });\n}\n\nexport function buildPostgresEdgeIndexBuilders(\n table: EdgeIndexTable,\n indexes: readonly IndexDeclaration[],\n): readonly PgIndexBuilder[] {\n const edgeIndexes = indexes.filter(\n (index): index is EdgeIndexDeclaration =>\n index.entity === \"edge\" && index.method === undefined,\n );\n\n return edgeIndexes.map((index) => {\n const propsColumn = portableSql.identifier(table.props.name);\n const systemColumn = (column: SystemColumnName): SqlFragment =>\n portableSql.identifier(getPostgresEdgeSystemColumn(table, column).name);\n\n const { keys } = compileEdgeIndexKeys(\n index,\n \"postgres\",\n propsColumn,\n systemColumn,\n );\n assertNonEmpty(keys, `edge index \"${index.name}\"`);\n\n const base = index.unique ? pgUniqueIndex(index.name) : pgIndex(index.name);\n\n const drizzleKeys = keys.map((key) => toDrizzleSql(key, \"postgres\"));\n assertNonEmpty(drizzleKeys, `edge index \"${index.name}\"`);\n const [firstKey, ...remainingKeys] = drizzleKeys;\n const builder = base.on(firstKey, ...remainingKeys);\n\n if (index.where) {\n const ctx: IndexCompilationContext = {\n dialect: \"postgres\",\n propsColumn,\n systemColumn,\n };\n builder.where(\n toDrizzleSql(compileIndexWhere(ctx, index.where), \"postgres\"),\n );\n }\n\n return builder;\n });\n}\n\nfunction getPostgresNodeSystemColumn(\n table: NodeIndexTable,\n column: SystemColumnName,\n): NamedSqlWrapper {\n switch (column) {\n case \"graph_id\": {\n return table.graphId;\n }\n case \"kind\": {\n return table.kind;\n }\n case \"id\": {\n return table.id;\n }\n case \"from_kind\":\n case \"from_id\":\n case \"to_kind\":\n case \"to_id\": {\n throw new Error(`Unsupported node system column for indexes: ${column}`);\n }\n case \"deleted_at\": {\n return table.deletedAt;\n }\n case \"valid_from\": {\n return table.validFrom;\n }\n case \"valid_to\": {\n return table.validTo;\n }\n case \"created_at\": {\n return table.createdAt;\n }\n case \"updated_at\": {\n return table.updatedAt;\n }\n case \"version\": {\n return table.version;\n }\n }\n}\n\nfunction getPostgresEdgeSystemColumn(\n table: EdgeIndexTable,\n column: SystemColumnName,\n): NamedSqlWrapper {\n switch (column) {\n case \"graph_id\": {\n return table.graphId;\n }\n case \"kind\": {\n return table.kind;\n }\n case \"id\": {\n return table.id;\n }\n case \"from_kind\": {\n return table.fromKind;\n }\n case \"from_id\": {\n return table.fromId;\n }\n case \"to_kind\": {\n return table.toKind;\n }\n case \"to_id\": {\n return table.toId;\n }\n case \"deleted_at\": {\n return table.deletedAt;\n }\n case \"valid_from\": {\n return table.validFrom;\n }\n case \"valid_to\": {\n return table.validTo;\n }\n case \"created_at\": {\n return table.createdAt;\n }\n case \"updated_at\": {\n return table.updatedAt;\n }\n case \"version\": {\n throw new Error(`Unsupported edge system column for indexes: ${column}`);\n }\n }\n}\n\n// ============================================================\n// SQLite (Drizzle Schema)\n// ============================================================\n\nexport function buildSqliteNodeIndexBuilders(\n table: NodeIndexTable,\n indexes: readonly IndexDeclaration[],\n): readonly SqliteIndexBuilder[] {\n // GIN-family declarations (method: \"gin\" / \"trigram\") are\n // materialize-only — like pgvector ANN indexes, they are a pure\n // materialization concern and never ride the Drizzle table extras.\n const nodeIndexes = indexes.filter(\n (index): index is NodeIndexDeclaration =>\n index.entity === \"node\" && index.method === undefined,\n );\n\n return nodeIndexes.map((index) => {\n const propsColumn = portableSql.identifier(table.props.name);\n const systemColumn = (column: SystemColumnName): SqlFragment =>\n portableSql.identifier(getSqliteNodeSystemColumn(table, column).name);\n\n const { keys } = compileNodeIndexKeys(\n index,\n \"sqlite\",\n propsColumn,\n systemColumn,\n );\n assertNonEmpty(keys, `node index \"${index.name}\"`);\n\n const base =\n index.unique ? sqliteUniqueIndex(index.name) : sqliteIndex(index.name);\n\n const drizzleKeys = keys.map((key) => toDrizzleSql(key, \"sqlite\"));\n assertNonEmpty(drizzleKeys, `node index \"${index.name}\"`);\n const [firstKey, ...remainingKeys] = drizzleKeys;\n const builder = base.on(firstKey, ...remainingKeys);\n\n if (index.where) {\n const ctx: IndexCompilationContext = {\n dialect: \"sqlite\",\n propsColumn,\n systemColumn,\n };\n builder.where(\n toDrizzleSql(compileIndexWhere(ctx, index.where), \"sqlite\"),\n );\n }\n\n return builder;\n });\n}\n\nexport function buildSqliteEdgeIndexBuilders(\n table: EdgeIndexTable,\n indexes: readonly IndexDeclaration[],\n): readonly SqliteIndexBuilder[] {\n const edgeIndexes = indexes.filter(\n (index): index is EdgeIndexDeclaration =>\n index.entity === \"edge\" && index.method === undefined,\n );\n\n return edgeIndexes.map((index) => {\n const propsColumn = portableSql.identifier(table.props.name);\n const systemColumn = (column: SystemColumnName): SqlFragment =>\n portableSql.identifier(getSqliteEdgeSystemColumn(table, column).name);\n\n const { keys } = compileEdgeIndexKeys(\n index,\n \"sqlite\",\n propsColumn,\n systemColumn,\n );\n assertNonEmpty(keys, `edge index \"${index.name}\"`);\n\n const base =\n index.unique ? sqliteUniqueIndex(index.name) : sqliteIndex(index.name);\n\n const drizzleKeys = keys.map((key) => toDrizzleSql(key, \"sqlite\"));\n assertNonEmpty(drizzleKeys, `edge index \"${index.name}\"`);\n const [firstKey, ...remainingKeys] = drizzleKeys;\n const builder = base.on(firstKey, ...remainingKeys);\n\n if (index.where) {\n const ctx: IndexCompilationContext = {\n dialect: \"sqlite\",\n propsColumn,\n systemColumn,\n };\n builder.where(\n toDrizzleSql(compileIndexWhere(ctx, index.where), \"sqlite\"),\n );\n }\n\n return builder;\n });\n}\n\nfunction getSqliteNodeSystemColumn(\n table: NodeIndexTable,\n column: SystemColumnName,\n): NamedSqlWrapper {\n switch (column) {\n case \"graph_id\": {\n return table.graphId;\n }\n case \"kind\": {\n return table.kind;\n }\n case \"id\": {\n return table.id;\n }\n case \"from_kind\":\n case \"from_id\":\n case \"to_kind\":\n case \"to_id\": {\n throw new Error(`Unsupported node system column for indexes: ${column}`);\n }\n case \"deleted_at\": {\n return table.deletedAt;\n }\n case \"valid_from\": {\n return table.validFrom;\n }\n case \"valid_to\": {\n return table.validTo;\n }\n case \"created_at\": {\n return table.createdAt;\n }\n case \"updated_at\": {\n return table.updatedAt;\n }\n case \"version\": {\n return table.version;\n }\n }\n}\n\nfunction getSqliteEdgeSystemColumn(\n table: EdgeIndexTable,\n column: SystemColumnName,\n): NamedSqlWrapper {\n switch (column) {\n case \"graph_id\": {\n return table.graphId;\n }\n case \"kind\": {\n return table.kind;\n }\n case \"id\": {\n return table.id;\n }\n case \"from_kind\": {\n return table.fromKind;\n }\n case \"from_id\": {\n return table.fromId;\n }\n case \"to_kind\": {\n return table.toKind;\n }\n case \"to_id\": {\n return table.toId;\n }\n case \"deleted_at\": {\n return table.deletedAt;\n }\n case \"valid_from\": {\n return table.validFrom;\n }\n case \"valid_to\": {\n return table.validTo;\n }\n case \"created_at\": {\n return table.createdAt;\n }\n case \"updated_at\": {\n return table.updatedAt;\n }\n case \"version\": {\n throw new Error(`Unsupported edge system column for indexes: ${column}`);\n }\n }\n}\n\n// ============================================================\n// System indexes (both dialects)\n// ============================================================\n//\n// The schema factories derive their system-index Drizzle builders from\n// `SYSTEM_INDEX_DECLARATIONS` so both dialects emit the same index set by\n// construction. The builders receive the table's real column objects (not\n// SQL wrappers) so the DDL generator renders plain quoted column names —\n// byte-identical to the runtime DDL `materializeSystemIndexes` emits.\n\ntype SystemIndexColumns<C extends { name: string }> = Readonly<\n Record<string, C>\n>;\n\n/**\n * Resolves a declaration's physical column names against the table's own\n * column objects by each column's `.name` — the SQL name Drizzle carries on\n * the column itself — so no naming convention sits between the declaration\n * and the schema. A column the table doesn't define throws at\n * table-construction time (exercised by the system-index parity tests).\n */\nfunction resolveSystemIndexColumns<C extends { name: string }>(\n declaration: SystemIndexDeclaration,\n columns: SystemIndexColumns<C>,\n): readonly [C, ...C[]] {\n const byPhysicalName = new Map(\n Object.values(columns).map((column) => [column.name, column]),\n );\n const resolved = declaration.columns.map((column) => {\n const value = byPhysicalName.get(column);\n if (value === undefined) {\n throw new Error(\n `System index \"${declaration.table}_${declaration.suffix}\" references ` +\n `a column \"${column}\" the ${declaration.table} table does not define`,\n );\n }\n return value;\n });\n // `declaration.columns` is non-empty by type, so `resolved` is too.\n return resolved as [C, ...C[]];\n}\n\n/**\n * The two dialect variants do no dialect-specific work (no unique, no\n * where, no expression compilation — unlike the node/edge builder pairs\n * above), so they share one body parameterized by the dialect's index\n * factory.\n */\nfunction buildSystemIndexBuilders<C extends { name: string }, B>(\n tableKey: SystemIndexTable,\n physicalTableName: string,\n columns: SystemIndexColumns<C>,\n indexFactory: (name: string) => { on: (...cols: [C, ...C[]]) => B },\n): readonly B[] {\n return SYSTEM_INDEX_DECLARATIONS.filter(\n (declaration) => declaration.table === tableKey,\n ).map((declaration) =>\n indexFactory(systemIndexName(physicalTableName, declaration.suffix)).on(\n ...resolveSystemIndexColumns(declaration, columns),\n ),\n );\n}\n\nexport function buildSqliteSystemIndexBuilders(\n tableKey: SystemIndexTable,\n physicalTableName: string,\n columns: SystemIndexColumns<SQLiteColumn>,\n): readonly SqliteIndexBuilder[] {\n return buildSystemIndexBuilders(\n tableKey,\n physicalTableName,\n columns,\n (name) => sqliteIndex(name),\n );\n}\n\nexport function buildPostgresSystemIndexBuilders(\n tableKey: SystemIndexTable,\n physicalTableName: string,\n columns: SystemIndexColumns<PgColumn>,\n): readonly PgIndexBuilder[] {\n return buildSystemIndexBuilders(\n tableKey,\n physicalTableName,\n columns,\n (name) => pgIndex(name),\n );\n}\n\n// ============================================================\n// Minimal table shapes (shared between dialect schemas)\n// ============================================================\n\ntype NamedSqlWrapper = SQLWrapper & Readonly<{ name: string }>;\n\ntype NodeIndexTable = Readonly<{\n graphId: NamedSqlWrapper;\n kind: NamedSqlWrapper;\n id: NamedSqlWrapper;\n props: NamedSqlWrapper;\n version: NamedSqlWrapper;\n validFrom: NamedSqlWrapper;\n validTo: NamedSqlWrapper;\n createdAt: NamedSqlWrapper;\n updatedAt: NamedSqlWrapper;\n deletedAt: NamedSqlWrapper;\n}>;\n\ntype EdgeIndexTable = Readonly<{\n graphId: NamedSqlWrapper;\n id: NamedSqlWrapper;\n kind: NamedSqlWrapper;\n fromKind: NamedSqlWrapper;\n fromId: NamedSqlWrapper;\n toKind: NamedSqlWrapper;\n toId: NamedSqlWrapper;\n props: NamedSqlWrapper;\n validFrom: NamedSqlWrapper;\n validTo: NamedSqlWrapper;\n createdAt: NamedSqlWrapper;\n updatedAt: NamedSqlWrapper;\n deletedAt: NamedSqlWrapper;\n}>;\n\nfunction assertNonEmpty<T>(\n values: readonly T[],\n label: string,\n): asserts values is readonly [T, ...T[]] {\n if (values.length === 0) {\n throw new Error(`Index must have at least one key (${label})`);\n }\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkBP3ANNRA_cjs = require('../chunk-BP3ANNRA.cjs');
3
+ var chunkNLLZSEHL_cjs = require('../chunk-NLLZSEHL.cjs');
4
4
  require('../chunk-D2U6E77Y.cjs');
5
5
  var chunkPKQOWADL_cjs = require('../chunk-PKQOWADL.cjs');
6
6
  require('../chunk-HBFGTRJT.cjs');
@@ -23,7 +23,7 @@ var chunk6YREIOSH_cjs = require('../chunk-6YREIOSH.cjs');
23
23
  var chunkA2NZH6JQ_cjs = require('../chunk-A2NZH6JQ.cjs');
24
24
  var chunkRAN6YI6S_cjs = require('../chunk-RAN6YI6S.cjs');
25
25
  require('../chunk-HNMVDH6A.cjs');
26
- require('../chunk-B2FYH5VR.cjs');
26
+ require('../chunk-2GXLAV4H.cjs');
27
27
  require('../chunk-EUDJXMMN.cjs');
28
28
  var chunkZY4GXIVN_cjs = require('../chunk-ZY4GXIVN.cjs');
29
29
  require('../chunk-7LGA7PK2.cjs');
@@ -2097,7 +2097,7 @@ function cloneWorkingCopyWithGraphStrategy(makeBackend, graphForClone) {
2097
2097
  create: async (baseStore) => {
2098
2098
  const backend = await makeBackend();
2099
2099
  try {
2100
- const [freshStore] = await chunkBP3ANNRA_cjs.createStoreWithSchema(
2100
+ const [freshStore] = await chunkNLLZSEHL_cjs.createStoreWithSchema(
2101
2101
  graphForClone(baseStore),
2102
2102
  backend,
2103
2103
  {
@@ -2231,7 +2231,7 @@ function forkedWorkingCopyStrategy(options) {
2231
2231
  { details: { inheritedTables, connectedTables } }
2232
2232
  );
2233
2233
  }
2234
- const forkStore = chunkBP3ANNRA_cjs.createStore(baseStore.graph, backend, forkOptions);
2234
+ const forkStore = chunkNLLZSEHL_cjs.createStore(baseStore.graph, backend, forkOptions);
2235
2235
  const forkVersion = await computeBaseVersion(forkStore);
2236
2236
  if (forkVersion !== base) {
2237
2237
  throw new BranchError(
@@ -2387,8 +2387,8 @@ function unwrapMergeBranches(inputs) {
2387
2387
 
2388
2388
  // src/graph-merge/apply-callbacks.ts
2389
2389
  var NODE_READ_NAMES = [
2390
- ...chunkBP3ANNRA_cjs.NODE_TEMPORAL_READ_NAMES,
2391
- ...chunkBP3ANNRA_cjs.CURRENT_ONLY_READ_NAMES
2390
+ ...chunkNLLZSEHL_cjs.NODE_TEMPORAL_READ_NAMES,
2391
+ ...chunkNLLZSEHL_cjs.CURRENT_ONLY_READ_NAMES
2392
2392
  ];
2393
2393
  function pickReadMethods(source, names) {
2394
2394
  return Object.fromEntries(names.map((name) => [name, source[name]]));
@@ -2406,12 +2406,12 @@ function mergePlanReadContext(tx, graph) {
2406
2406
  kind,
2407
2407
  pickReadMethods(
2408
2408
  chunkBXHAPCQG_cjs.requireDefined(tx.edges[kind]),
2409
- chunkBP3ANNRA_cjs.EDGE_TEMPORAL_READ_NAMES
2409
+ chunkNLLZSEHL_cjs.EDGE_TEMPORAL_READ_NAMES
2410
2410
  )
2411
2411
  ])
2412
2412
  ),
2413
2413
  ..."identity" in tx ? {
2414
- identity: pickReadMethods(tx.identity, chunkBP3ANNRA_cjs.IDENTITY_READ_NAMES)
2414
+ identity: pickReadMethods(tx.identity, chunkNLLZSEHL_cjs.IDENTITY_READ_NAMES)
2415
2415
  } : {}
2416
2416
  };
2417
2417
  }
@@ -5241,7 +5241,7 @@ async function openProvenanceStore(...args) {
5241
5241
  throw provenanceGraphIdCollision(graph.id, targetGraphId, claim.reason);
5242
5242
  }
5243
5243
  }
5244
- const [store] = await chunkBP3ANNRA_cjs.createStoreWithSchema(graph, backend);
5244
+ const [store] = await chunkNLLZSEHL_cjs.createStoreWithSchema(graph, backend);
5245
5245
  return store;
5246
5246
  }
5247
5247
  async function claimSidecarOwnership(backend, graph, targetGraphId) {
@@ -1,4 +1,4 @@
1
- import { NODE_TEMPORAL_READ_NAMES, CURRENT_ONLY_READ_NAMES, createStoreWithSchema, createStore, IDENTITY_READ_NAMES, EDGE_TEMPORAL_READ_NAMES } from '../chunk-S2U4AZEO.js';
1
+ import { NODE_TEMPORAL_READ_NAMES, CURRENT_ONLY_READ_NAMES, createStoreWithSchema, createStore, IDENTITY_READ_NAMES, EDGE_TEMPORAL_READ_NAMES } from '../chunk-3B6AEIK4.js';
2
2
  import '../chunk-YZ3QYASQ.js';
3
3
  import { requireLineage } from '../chunk-JILLFX54.js';
4
4
  import '../chunk-NJAG3AH4.js';
@@ -21,7 +21,7 @@ import { getNodeKinds, getEdgeKinds, defineInternalGraph } from '../chunk-BO5XSN
21
21
  import { encodeTupleKey, validateEdgeEndpoints, computeUniqueKey } from '../chunk-NG62VPFW.js';
22
22
  import { isCanonicalIsoDate, canonicalizeDatabaseTimestamp } from '../chunk-YA77H2XC.js';
23
23
  import '../chunk-BOLOXURT.js';
24
- import '../chunk-RWE33LCI.js';
24
+ import '../chunk-NXK2ZBVV.js';
25
25
  import '../chunk-F6XCLEZF.js';
26
26
  import { sha256Hex } from '../chunk-K34OPSJK.js';
27
27
  import '../chunk-GZM2HWN2.js';