@nicia-ai/typegraph 0.47.0 → 0.49.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) hide show
  1. package/dist/backend/drizzle/indexes.d.cts +1 -1
  2. package/dist/backend/drizzle/indexes.d.ts +1 -1
  3. package/dist/backend/index.cjs +27 -19
  4. package/dist/backend/index.d.cts +37 -55
  5. package/dist/backend/index.d.ts +37 -55
  6. package/dist/backend/index.js +4 -4
  7. package/dist/backend/postgres/index.cjs +7 -7
  8. package/dist/backend/postgres/index.d.cts +21 -7
  9. package/dist/backend/postgres/index.d.ts +21 -7
  10. package/dist/backend/postgres/index.js +6 -6
  11. package/dist/backend/postgres/pglite-store.cjs +17 -17
  12. package/dist/backend/postgres/pglite-store.d.cts +8 -8
  13. package/dist/backend/postgres/pglite-store.d.ts +8 -8
  14. package/dist/backend/postgres/pglite-store.js +14 -14
  15. package/dist/backend/postgres/pglite.cjs +8 -8
  16. package/dist/backend/postgres/pglite.d.cts +3 -3
  17. package/dist/backend/postgres/pglite.d.ts +3 -3
  18. package/dist/backend/postgres/pglite.js +7 -7
  19. package/dist/backend/sqlite/index.cjs +7 -7
  20. package/dist/backend/sqlite/index.d.cts +20 -7
  21. package/dist/backend/sqlite/index.d.ts +20 -7
  22. package/dist/backend/sqlite/index.js +6 -6
  23. package/dist/backend/sqlite/libsql.cjs +8 -8
  24. package/dist/backend/sqlite/libsql.d.cts +3 -3
  25. package/dist/backend/sqlite/libsql.d.ts +3 -3
  26. package/dist/backend/sqlite/libsql.js +6 -6
  27. package/dist/backend/sqlite/local-store.cjs +18 -18
  28. package/dist/backend/sqlite/local-store.d.cts +8 -8
  29. package/dist/backend/sqlite/local-store.d.ts +8 -8
  30. package/dist/backend/sqlite/local-store.js +15 -15
  31. package/dist/backend/sqlite/local.cjs +9 -9
  32. package/dist/backend/sqlite/local.d.cts +3 -3
  33. package/dist/backend/sqlite/local.d.ts +3 -3
  34. package/dist/backend/sqlite/local.js +7 -7
  35. package/dist/{chunk-5FBRVORR.cjs → chunk-2O4PCIZ6.cjs} +8 -7
  36. package/dist/chunk-2O4PCIZ6.cjs.map +1 -0
  37. package/dist/{chunk-6KFLYYOC.cjs → chunk-2QGYQBS2.cjs} +5 -5
  38. package/dist/{chunk-6KFLYYOC.cjs.map → chunk-2QGYQBS2.cjs.map} +1 -1
  39. package/dist/{chunk-XYBQI6LE.js → chunk-2TYSSBU5.js} +6 -6
  40. package/dist/{chunk-XYBQI6LE.js.map → chunk-2TYSSBU5.js.map} +1 -1
  41. package/dist/{chunk-6JVZSOHQ.cjs → chunk-3FPR224C.cjs} +26 -26
  42. package/dist/{chunk-6JVZSOHQ.cjs.map → chunk-3FPR224C.cjs.map} +1 -1
  43. package/dist/{chunk-U5EDAVOJ.cjs → chunk-3G5W2U2L.cjs} +82 -51
  44. package/dist/chunk-3G5W2U2L.cjs.map +1 -0
  45. package/dist/{chunk-MFZR4QKM.cjs → chunk-3KOY4FH3.cjs} +181 -4
  46. package/dist/chunk-3KOY4FH3.cjs.map +1 -0
  47. package/dist/{chunk-UPAJHMW3.cjs → chunk-3QNZ5SAJ.cjs} +55 -58
  48. package/dist/chunk-3QNZ5SAJ.cjs.map +1 -0
  49. package/dist/{chunk-NG2RB5WL.js → chunk-5K2BKEBD.js} +18 -3
  50. package/dist/chunk-5K2BKEBD.js.map +1 -0
  51. package/dist/chunk-5PRKMB24.cjs +124 -0
  52. package/dist/chunk-5PRKMB24.cjs.map +1 -0
  53. package/dist/chunk-6LN7FIVU.js +107 -0
  54. package/dist/chunk-6LN7FIVU.js.map +1 -0
  55. package/dist/{chunk-M35DF33T.js → chunk-7LZJNLA5.js} +29 -16
  56. package/dist/chunk-7LZJNLA5.js.map +1 -0
  57. package/dist/{chunk-I4G3SQPF.cjs → chunk-7UOLHNWC.cjs} +7 -7
  58. package/dist/chunk-7UOLHNWC.cjs.map +1 -0
  59. package/dist/{chunk-DJZTXBWY.js → chunk-BRRP76WO.js} +71 -30
  60. package/dist/chunk-BRRP76WO.js.map +1 -0
  61. package/dist/{chunk-5FT3TLPK.js → chunk-D4QLTJSM.js} +16 -13
  62. package/dist/chunk-D4QLTJSM.js.map +1 -0
  63. package/dist/{chunk-XY5OMOJD.js → chunk-DZAICA5J.js} +3 -3
  64. package/dist/{chunk-XY5OMOJD.js.map → chunk-DZAICA5J.js.map} +1 -1
  65. package/dist/{chunk-OIFSOPSR.cjs → chunk-EZEEWCFJ.cjs} +38 -156
  66. package/dist/chunk-EZEEWCFJ.cjs.map +1 -0
  67. package/dist/{chunk-AMMWA76F.cjs → chunk-FA2AFWLP.cjs} +6 -6
  68. package/dist/{chunk-AMMWA76F.cjs.map → chunk-FA2AFWLP.cjs.map} +1 -1
  69. package/dist/{chunk-FNOMT74T.js → chunk-I4GAZH5Z.js} +180 -5
  70. package/dist/chunk-I4GAZH5Z.js.map +1 -0
  71. package/dist/{chunk-WGX7JH7E.cjs → chunk-JB6T4GLL.cjs} +106 -134
  72. package/dist/chunk-JB6T4GLL.cjs.map +1 -0
  73. package/dist/{chunk-MX4DHSQP.cjs → chunk-JFRT7S3B.cjs} +92 -98
  74. package/dist/chunk-JFRT7S3B.cjs.map +1 -0
  75. package/dist/{chunk-5UMTUOM5.js → chunk-JPD2CTC3.js} +5 -4
  76. package/dist/chunk-JPD2CTC3.js.map +1 -0
  77. package/dist/{chunk-SE6EGQSD.js → chunk-KF6K7TGH.js} +38 -66
  78. package/dist/chunk-KF6K7TGH.js.map +1 -0
  79. package/dist/{chunk-QS3NQZVC.js → chunk-LTXQOEIC.js} +44 -14
  80. package/dist/chunk-LTXQOEIC.js.map +1 -0
  81. package/dist/{chunk-ZHNXLS3C.js → chunk-NACVVDWB.js} +208 -8
  82. package/dist/chunk-NACVVDWB.js.map +1 -0
  83. package/dist/{chunk-AVGUJWVX.js → chunk-S5TERQVW.js} +15 -132
  84. package/dist/chunk-S5TERQVW.js.map +1 -0
  85. package/dist/chunk-SIT26LAZ.cjs +614 -0
  86. package/dist/chunk-SIT26LAZ.cjs.map +1 -0
  87. package/dist/{chunk-BR7SHKGM.cjs → chunk-SR725PWF.cjs} +548 -507
  88. package/dist/chunk-SR725PWF.cjs.map +1 -0
  89. package/dist/{chunk-425IZOQ5.cjs → chunk-TQHGE7UC.cjs} +20 -2
  90. package/dist/chunk-TQHGE7UC.cjs.map +1 -0
  91. package/dist/{chunk-GYUJZARH.cjs → chunk-TUNPBZY3.cjs} +4 -4
  92. package/dist/{chunk-GYUJZARH.cjs.map → chunk-TUNPBZY3.cjs.map} +1 -1
  93. package/dist/chunk-UGHG7PGX.js +592 -0
  94. package/dist/chunk-UGHG7PGX.js.map +1 -0
  95. package/dist/{chunk-BCQ76AXA.cjs → chunk-UGHQV7MP.cjs} +107 -94
  96. package/dist/chunk-UGHQV7MP.cjs.map +1 -0
  97. package/dist/{chunk-KABFHAL7.cjs → chunk-UMGZDVOA.cjs} +213 -12
  98. package/dist/chunk-UMGZDVOA.cjs.map +1 -0
  99. package/dist/{chunk-6FWSNSRE.js → chunk-WIC7DRXW.js} +4 -4
  100. package/dist/chunk-WIC7DRXW.js.map +1 -0
  101. package/dist/{chunk-LEWHMOUY.js → chunk-YIURNGXI.js} +4 -4
  102. package/dist/{chunk-LEWHMOUY.js.map → chunk-YIURNGXI.js.map} +1 -1
  103. package/dist/{chunk-EP4RUYD6.js → chunk-YVF2EM7B.js} +3 -3
  104. package/dist/{chunk-EP4RUYD6.js.map → chunk-YVF2EM7B.js.map} +1 -1
  105. package/dist/{chunk-EMIB2RXD.cjs → chunk-YYUHLYM2.cjs} +99 -96
  106. package/dist/chunk-YYUHLYM2.cjs.map +1 -0
  107. package/dist/{chunk-KH7XW7VV.js → chunk-Z2JCLZFJ.js} +25 -28
  108. package/dist/chunk-Z2JCLZFJ.js.map +1 -0
  109. package/dist/{chunk-NNQ6A3RM.js → chunk-ZFMCDJGB.js} +7 -12
  110. package/dist/chunk-ZFMCDJGB.js.map +1 -0
  111. package/dist/core/index.cjs +6 -6
  112. package/dist/core/index.d.cts +4 -4
  113. package/dist/core/index.d.ts +4 -4
  114. package/dist/core/index.js +2 -2
  115. package/dist/ddl-BL1NZLMY.d.cts +78 -0
  116. package/dist/ddl-D_oW-EVO.d.ts +78 -0
  117. package/dist/graph-extension/index.d.cts +4 -4
  118. package/dist/graph-extension/index.d.ts +4 -4
  119. package/dist/graph-merge/index.cjs +357 -191
  120. package/dist/graph-merge/index.cjs.map +1 -1
  121. package/dist/graph-merge/index.d.cts +68 -15
  122. package/dist/graph-merge/index.d.ts +68 -15
  123. package/dist/graph-merge/index.js +197 -32
  124. package/dist/graph-merge/index.js.map +1 -1
  125. package/dist/{index-CHTv4XMZ.d.cts → index-COs_z6nV.d.cts} +2 -2
  126. package/dist/{index-CzoJ3MUw.d.ts → index-D7d1u2gr.d.ts} +2 -2
  127. package/dist/index.cjs +90 -86
  128. package/dist/index.cjs.map +1 -1
  129. package/dist/index.d.cts +12 -12
  130. package/dist/index.d.ts +12 -12
  131. package/dist/index.js +13 -13
  132. package/dist/index.js.map +1 -1
  133. package/dist/indexes/index.d.cts +4 -4
  134. package/dist/indexes/index.d.ts +4 -4
  135. package/dist/ingestion-import-target-XPxZYw89.d.cts +17 -0
  136. package/dist/ingestion-import-target-dNeL7iAv.d.ts +17 -0
  137. package/dist/interchange/index.cjs +38 -38
  138. package/dist/interchange/index.d.cts +15 -12
  139. package/dist/interchange/index.d.ts +15 -12
  140. package/dist/interchange/index.js +10 -10
  141. package/dist/{manager-DlY1vlla.d.cts → manager-CYaff3n3.d.cts} +2 -2
  142. package/dist/{manager-B6sOQzcQ.d.ts → manager-D9eRT_ns.d.ts} +2 -2
  143. package/dist/{materialize-indexes-DQL4xcpf.d.ts → materialize-indexes-DJ3ykH59.d.ts} +1 -1
  144. package/dist/{materialize-indexes-sskhp-c_.d.cts → materialize-indexes-DTtAnvfY.d.cts} +1 -1
  145. package/dist/{postgres-BXy_nyMs.d.cts → postgres-CcL4bAHS.d.ts} +1 -1
  146. package/dist/{postgres-B6YOUcaK.d.ts → postgres-DMj39MEu.d.cts} +1 -1
  147. package/dist/profiler/index.d.cts +9 -9
  148. package/dist/profiler/index.d.ts +9 -9
  149. package/dist/provenance/index.cjs +25 -26
  150. package/dist/provenance/index.cjs.map +1 -1
  151. package/dist/provenance/index.d.cts +7 -7
  152. package/dist/provenance/index.d.ts +7 -7
  153. package/dist/provenance/index.js +9 -10
  154. package/dist/provenance/index.js.map +1 -1
  155. package/dist/repair-validity-windows-BFNZvd_H.d.cts +166 -0
  156. package/dist/repair-validity-windows-DlUSqwCg.d.ts +166 -0
  157. package/dist/schema/index.cjs +35 -35
  158. package/dist/schema/index.d.cts +6 -6
  159. package/dist/schema/index.d.ts +6 -6
  160. package/dist/schema/index.js +8 -8
  161. package/dist/{searchable-D9gMiwcS.d.ts → searchable-DHJMh_nj.d.cts} +1 -1
  162. package/dist/{searchable-0Cn_lY8U.d.cts → searchable-bpE1bBfc.d.ts} +1 -1
  163. package/dist/{sqlite-DioSxaPe.d.cts → sqlite-D7Oz0SQh.d.ts} +1 -1
  164. package/dist/{sqlite-ClXuBYAj.d.ts → sqlite-YppHrNFb.d.cts} +1 -1
  165. package/dist/{store-5j-w5onJ.d.ts → store-DRrFCx5x.d.ts} +122 -27
  166. package/dist/{store-CFedKGU5.d.cts → store-bphCSo7z.d.cts} +122 -27
  167. package/dist/{temporal-CjO9FH1l.d.ts → temporal-5GqpYCk2.d.cts} +1 -1
  168. package/dist/{temporal-Ce1pG0S1.d.cts → temporal-CbnLzTmM.d.ts} +1 -1
  169. package/dist/{types-DKkMJZjR.d.cts → types-BqFZTQmV.d.cts} +29 -4
  170. package/dist/{types-DKkMJZjR.d.ts → types-BqFZTQmV.d.ts} +29 -4
  171. package/dist/{types-BrdOFu48.d.ts → types-Bx74kaTt.d.ts} +1 -1
  172. package/dist/{types-oj_OGAaZ.d.cts → types-CXAhpW-c.d.cts} +1 -1
  173. package/dist/{where-D1wKCJ4Q.d.cts → where-DI_Fqz-X.d.cts} +1 -1
  174. package/dist/{where-C8w2627G.d.ts → where-O-k2wgYm.d.ts} +1 -1
  175. package/package.json +2 -3
  176. package/dist/chunk-3HGRTCDU.cjs +0 -269
  177. package/dist/chunk-3HGRTCDU.cjs.map +0 -1
  178. package/dist/chunk-425IZOQ5.cjs.map +0 -1
  179. package/dist/chunk-5FBRVORR.cjs.map +0 -1
  180. package/dist/chunk-5FT3TLPK.js.map +0 -1
  181. package/dist/chunk-5UMTUOM5.js.map +0 -1
  182. package/dist/chunk-6FWSNSRE.js.map +0 -1
  183. package/dist/chunk-AVGUJWVX.js.map +0 -1
  184. package/dist/chunk-BCQ76AXA.cjs.map +0 -1
  185. package/dist/chunk-BR7SHKGM.cjs.map +0 -1
  186. package/dist/chunk-DJZTXBWY.js.map +0 -1
  187. package/dist/chunk-EMIB2RXD.cjs.map +0 -1
  188. package/dist/chunk-FNOMT74T.js.map +0 -1
  189. package/dist/chunk-I4G3SQPF.cjs.map +0 -1
  190. package/dist/chunk-JR6SX5RH.cjs +0 -268
  191. package/dist/chunk-JR6SX5RH.cjs.map +0 -1
  192. package/dist/chunk-KABFHAL7.cjs.map +0 -1
  193. package/dist/chunk-KH7XW7VV.js.map +0 -1
  194. package/dist/chunk-M35DF33T.js.map +0 -1
  195. package/dist/chunk-MFZR4QKM.cjs.map +0 -1
  196. package/dist/chunk-MX4DHSQP.cjs.map +0 -1
  197. package/dist/chunk-NAZ2RA4L.js +0 -254
  198. package/dist/chunk-NAZ2RA4L.js.map +0 -1
  199. package/dist/chunk-NG2RB5WL.js.map +0 -1
  200. package/dist/chunk-NNQ6A3RM.js.map +0 -1
  201. package/dist/chunk-OIFSOPSR.cjs.map +0 -1
  202. package/dist/chunk-QS3NQZVC.js.map +0 -1
  203. package/dist/chunk-SE6EGQSD.js.map +0 -1
  204. package/dist/chunk-SHSSRCFR.js +0 -246
  205. package/dist/chunk-SHSSRCFR.js.map +0 -1
  206. package/dist/chunk-U5EDAVOJ.cjs.map +0 -1
  207. package/dist/chunk-UPAJHMW3.cjs.map +0 -1
  208. package/dist/chunk-WGX7JH7E.cjs.map +0 -1
  209. package/dist/chunk-ZHNXLS3C.js.map +0 -1
  210. package/dist/ddl-CprnMXJ-.d.ts +0 -38
  211. package/dist/ddl-DJA7Lci5.d.cts +0 -38
@@ -1,14 +1,15 @@
1
- import { bf as NodeId, u as NodeType, b6 as JsonValue, aA as EdgeId, d as GraphDef, bg as NodeKinds, aR as GetNodeType, y as GraphBackend, b7 as KindAnnotations, bb as MetaEdge, a5 as EdgeType, aw as DeleteBehavior, T as TemporalMode, I as IndexDeclaration, aX as GraphExtensionVersion, cs as ExtensionNodeDef, ct as ExtensionEdgeDef, cu as ExtensionOntologyRelation, cv as ExtensionIndex } from '../types-DKkMJZjR.cjs';
2
- export { C as ContributionDiagnostic, a as ContributionDiagnosticState, b as ContributionRepairEntry, c as ContributionRepairResult } from '../types-DKkMJZjR.cjs';
3
- import { a as Store, aP as Node, ce as UniqueIntrospection } from '../store-CFedKGU5.cjs';
4
- import { aj as TypeGraphError, ak as TypeGraphErrorOptions } from '../index-CHTv4XMZ.cjs';
1
+ import { dP as NodeId, dg as NodeType, bh as JsonValue, dw as EdgeId, d8 as GraphDef, dQ as NodeKinds, dD as GetNodeType, aM as GraphBackend, bi as KindAnnotations, dN as MetaEdge, dr as EdgeType, S as DeleteBehavior, ce as TemporalMode, I as IndexDeclaration, aQ as GraphExtensionVersion, ak as ExtensionNodeDef, ae as ExtensionEdgeDef, ap as ExtensionOntologyRelation, ai as ExtensionIndex } from '../types-BqFZTQmV.cjs';
2
+ export { u as ContributionDiagnostic, v as ContributionDiagnosticState, J as ContributionRepairEntry, K as ContributionRepairResult } from '../types-BqFZTQmV.cjs';
3
+ import { I as IngestionImportTarget } from '../ingestion-import-target-XPxZYw89.cjs';
4
+ import { a as Store, az as IdentityAssertionWriteFacade, aQ as Node, cf as UniqueIntrospection } from '../store-bphCSo7z.cjs';
5
+ import { aj as TypeGraphError, ak as TypeGraphErrorOptions } from '../index-COs_z6nV.cjs';
5
6
  import { R as Result } from '../result-DWo6mUVz.cjs';
6
7
  export { i as isErr, a as isOk, u as unwrap } from '../result-DWo6mUVz.cjs';
7
8
  import { z } from 'zod';
8
- import '../temporal-Ce1pG0S1.cjs';
9
- import '../searchable-0Cn_lY8U.cjs';
10
- import '../manager-DlY1vlla.cjs';
11
- import '../materialize-indexes-sskhp-c_.cjs';
9
+ import '../temporal-5GqpYCk2.cjs';
10
+ import '../searchable-DHJMh_nj.cjs';
11
+ import '../manager-CYaff3n3.cjs';
12
+ import '../materialize-indexes-DTtAnvfY.cjs';
12
13
 
13
14
  /**
14
15
  * The composite MERGE IDENTITY key for a node: the pair `(kind, id)`.
@@ -200,6 +201,35 @@ type GraphBranch<G extends GraphDef> = Readonly<{
200
201
  hash: string;
201
202
  }> | undefined;
202
203
  }>;
204
+ declare const INGESTION_BRANCH_BRAND: unique symbol;
205
+ /**
206
+ * Node collections exposed by an {@link IngestionBranch}. They retain normal
207
+ * validation, reads, and staging writes, but omit APIs that claim a declared
208
+ * uniqueness constraint exists on the relaxed physical working copy.
209
+ */
210
+ type IngestionNodeCollections<G extends GraphDef> = Readonly<{
211
+ [K in keyof Store<G>["nodes"]]-?: Pick<Store<G>["nodes"][K], "create" | "getById" | "getByIds" | "update" | "updateWhere" | "delete" | "hardDelete" | "find" | "count" | "createFromRecord" | "upsertById" | "upsertByIdFromRecord" | "bulkCreate" | "bulkUpsertById" | "bulkInsert" | "bulkDelete" | "bulkFindByIndex">;
212
+ }>;
213
+ /**
214
+ * Opaque handle for an untrusted ingestion working copy.
215
+ *
216
+ * The ordinary {@link Store} is intentionally absent: callers may stage and
217
+ * inspect graph data through the typed collections, then pass this handle to
218
+ * merge planning, but cannot access schema evolution, transactions, or runtime
219
+ * internals. `close()` releases the private working-copy backend.
220
+ */
221
+ type IngestionBranch<G extends GraphDef> = IngestionImportTarget<G> & Readonly<{
222
+ [INGESTION_BRANCH_BRAND]: true;
223
+ id: BranchId;
224
+ base: BaseVersion;
225
+ nodes: IngestionNodeCollections<G>;
226
+ edges: Store<G>["edges"];
227
+ close: () => Promise<void>;
228
+ }> & ("identity" extends keyof Store<G> ? Readonly<{
229
+ identity: IdentityAssertionWriteFacade<G>;
230
+ }> : Readonly<Record<never, never>>);
231
+ /** A normal branch or an opaque ingestion branch accepted by merge entrypoints. */
232
+ type MergeBranch<G extends GraphDef> = GraphBranch<G> | IngestionBranch<G>;
203
233
  /**
204
234
  * Options for {@link GraphBranch} creation. `id` is optional — when omitted a
205
235
  * fresh id is generated.
@@ -470,7 +500,7 @@ type MergeOptions<G extends GraphDef = GraphDef> = Readonly<{
470
500
  type MergeIncrementalArgs<G extends GraphDef = GraphDef> = Readonly<{
471
501
  forkPoint: Store<G>;
472
502
  target: Store<G>;
473
- branches: readonly GraphBranch<G>[];
503
+ branches: readonly MergeBranch<G>[];
474
504
  options?: Omit<MergeOptions<G>, "target">;
475
505
  }>;
476
506
  /**
@@ -967,9 +997,11 @@ declare class MatchEvidenceError extends MergeError {
967
997
  * `includeTemporal: true` carries `validFrom`/`validTo` through unchanged,
968
998
  * preserving the base's exact valid-time window on the clone: create-time
969
999
  * paths default an omitted `validFrom` to the row's own creation instant
970
- * (see #240), and export/import round-trip a still-open-left `valid_from`
971
- * (e.g. a row that predates the #240 fix) as an explicit `null` rather than
972
- * silently dropping it — see `InterchangeNodeSchema.validFrom`'s doc.
1000
+ * (see #240) — except for a BORN-ENDED row, whose stated `validTo` at or before
1001
+ * the write instant leaves it with no lower bound at all (see #407) — and
1002
+ * export/import round-trip a still-open-left `valid_from` (a born-ended row, or
1003
+ * one that predates the #240 fix) as an explicit `null` rather than silently
1004
+ * dropping it — see `InterchangeNodeSchema.validFrom`'s doc.
973
1005
  * Without either half of this, the clone's re-import would re-stamp the
974
1006
  * affected base rows to the CLONE's creation instant instead — narrowing
975
1007
  * their validity window and making `asOf` reads on the fork diverge from
@@ -1085,6 +1117,27 @@ declare function cloneWorkingCopyStrategy<G extends GraphDef>(makeBackend: MakeB
1085
1117
  */
1086
1118
  declare function branch<G extends GraphDef>(baseStore: GraphBranch<G>["store"], makeBackend: MakeBackend, options?: BranchOptions, strategy?: WorkingCopyStrategy<G>): Promise<Result<GraphBranch<G>, BranchError>>;
1087
1119
 
1120
+ /**
1121
+ * Constraint-aware working copies for untrusted ingestion.
1122
+ *
1123
+ * An ingestion branch persists a mechanically-derived schema with node
1124
+ * uniqueness declarations removed. That lets aliases reach merge planning,
1125
+ * where canonical candidate generation and final resolved-write validation use
1126
+ * the canonical graph's constraints. Every other working-copy constraint stays
1127
+ * active during staging.
1128
+ */
1129
+
1130
+ /**
1131
+ * Creates an isolated ingestion branch whose node uniqueness constraints are
1132
+ * deferred until the resolved merge write set is applied.
1133
+ *
1134
+ * The returned handle deliberately exposes no ordinary Store. Its typed node
1135
+ * and edge collections are sufficient to stage and inspect incoming data, and
1136
+ * merge entrypoints accept the handle directly. Call `close()` when the working
1137
+ * copy is no longer needed.
1138
+ */
1139
+ declare function ingestionBranch<G extends GraphDef>(baseStore: GraphBranch<G>["store"], makeBackend: MakeBackend, options?: BranchOptions): Promise<Result<IngestionBranch<G>, BranchError>>;
1140
+
1088
1141
  /**
1089
1142
  * The shared SCORING stage (design §4, the single match-decision point).
1090
1143
  *
@@ -1379,7 +1432,7 @@ type MergePlanArtifact = MergePlanArtifactV1;
1379
1432
  type MergePlanArtifactV1Input = Omit<MergePlanArtifactV1, "digest">;
1380
1433
 
1381
1434
  /** Builds a durable, reviewable snapshot merge plan without mutating the target. */
1382
- declare function planMerge<G extends GraphDef>(store: Store<G>, branches: readonly GraphBranch<G>[], optionsInput?: MergeOptions<G>): Promise<Result<MergePlanArtifact, MergeError>>;
1435
+ declare function planMerge<G extends GraphDef>(store: Store<G>, branchInputs: readonly MergeBranch<G>[], optionsInput?: MergeOptions<G>): Promise<Result<MergePlanArtifact, MergeError>>;
1383
1436
  /** Builds a durable, reviewable incremental merge plan without mutating the target. */
1384
1437
  declare function planMergeIncremental<G extends GraphDef>(args: MergeIncrementalArgs<G>): Promise<Result<MergePlanArtifact, MergeError>>;
1385
1438
  /** Validates and atomically applies an approved serialized merge plan. */
@@ -1408,7 +1461,7 @@ declare function applyMergePlan<G extends GraphDef>(target: Store<G>, input: Mer
1408
1461
  * report and committed graph are identical across any permutation.
1409
1462
  * @param optionsInput Caller-facing {@link MergeOptions}; normalized internally.
1410
1463
  */
1411
- declare function merge<G extends GraphDef>(store: Store<G>, branches: readonly GraphBranch<G>[], optionsInput?: MergeOptions<G>): Promise<Result<MergeReport<G>, MergeError>>;
1464
+ declare function merge<G extends GraphDef>(store: Store<G>, branchInputs: readonly MergeBranch<G>[], optionsInput?: MergeOptions<G>): Promise<Result<MergeReport<G>, MergeError>>;
1412
1465
  /**
1413
1466
  * Incremental merge — the public fork-point-vs-live-target entry point (design
1414
1467
  * §6.4-B / §6.6). It treats `forkPoint` as the immutable ancestor, folds the live
@@ -1722,4 +1775,4 @@ type KeylessConfig = Readonly<{
1722
1775
  sortFields: readonly string[];
1723
1776
  }>;
1724
1777
 
1725
- export { type BaseAmbiguity, type BaseNodeLookup, type BaseVersion, BaseVersionMismatchError, BranchError, type BranchId, type BranchOptions, type BranchProvenance, type CandidateDiagnostic, type CandidateDiagnostics, type CandidateDiagnosticsOptions, type CandidateSource, CandidateSourceError, type ComparisonCeilingPolicy, type ConflictingValue, type DeleteModifyConflict, type DeleteModifyPolicy, type DroppedItem, type Embedder, type EntityRef, type EntityResolution, type GraphBranch, IdentityMergeConflictError, InvalidMergeOptionsError, InvalidMergePlanError, type KeylessConfig, MERGE_ERROR_CODES, MERGE_OPTION_DEFAULTS, MERGE_PLAN_DIGEST_ALGORITHM, MERGE_PLAN_FORMAT_VERSION, type MakeBackend, type MatchEvidence, MatchEvidenceError, type MatchSource, type MatchStrategy, MergeConflictError, MergeConstraintConflictError, type MergeConstraintConflictErrorDetails, MergeError, type MergeIncrementalArgs, type MergeOptions, type MergePlanAnchors, type MergePlanArtifact, type MergePlanArtifactV1, type MergePlanArtifactV1Input, type MergePlanBranchAnchor, type MergePlanCandidateDiagnostic, type MergePlanCanonicalMapping, MergePlanCapabilityError, type MergePlanDiagnostics, type MergePlanDigest, MergePlanDigestMismatchError, type MergePlanEdgeDelete, type MergePlanEdgeUpsert, type MergePlanEntityRef, type MergePlanEntityResolution, type MergePlanGuards, type MergePlanIdentityAssertion, type MergePlanMatchEvidence, type MergePlanMatchSource, type MergePlanNodeDelete, type MergePlanNodeUpsert, MergePlanOriginMismatchError, type MergePlanProposedSummary, type MergePlanProvenanceOptions, type MergePlanRetype, type MergePlanReview, type MergePlanRevisionFence, type MergePlanSchemaFence, MergePlanSchemaMismatchError, type MergePlanSimilarityStrategy, type MergePlanTargetFence, MergePlanTargetMismatchError, type MergePlanTypeReconciliation, type MergePlanWrites, MergePlanningStaleError, type MergeReport, type MergedCounts, type NormalizedMergeOptions, type PropertyConflict, type PropertyConflictPolicy, type ProvenanceGraph, type ProvenanceIndex, type ProvenanceNode, type ProvenanceQuery, type ProvenanceRecord, type ReconcileTypesMode, type ResolveConfig, type ResolveMap, type ResolvedCluster, Result, type SimilarityStrategy, SimilarityUnavailableError, type SourceScope, StaleMergePlanError, type TypeReconciliation, UnsupportedMergePlanVersionError, VALIDITY_END_TARGET_PRECEDENCE, type ValidityEndResolution, type WorkingCopyStrategy, applyMergePlan, asBaseVersion, asBranchId, branch, cloneWorkingCopyStrategy, computeBaseVersion, merge, mergeIncremental, normalizeMergeOptions, openProvenanceStore, persistProvenanceRecords, planMerge, planMergeIncremental, provenanceGraphId, readProvenance };
1778
+ export { type BaseAmbiguity, type BaseNodeLookup, type BaseVersion, BaseVersionMismatchError, BranchError, type BranchId, type BranchOptions, type BranchProvenance, type CandidateDiagnostic, type CandidateDiagnostics, type CandidateDiagnosticsOptions, type CandidateSource, CandidateSourceError, type ComparisonCeilingPolicy, type ConflictingValue, type DeleteModifyConflict, type DeleteModifyPolicy, type DroppedItem, type Embedder, type EntityRef, type EntityResolution, type GraphBranch, IdentityAssertionWriteFacade, IdentityMergeConflictError, type IngestionBranch, IngestionImportTarget, type IngestionNodeCollections, InvalidMergeOptionsError, InvalidMergePlanError, type KeylessConfig, MERGE_ERROR_CODES, MERGE_OPTION_DEFAULTS, MERGE_PLAN_DIGEST_ALGORITHM, MERGE_PLAN_FORMAT_VERSION, type MakeBackend, type MatchEvidence, MatchEvidenceError, type MatchSource, type MatchStrategy, type MergeBranch, MergeConflictError, MergeConstraintConflictError, type MergeConstraintConflictErrorDetails, MergeError, type MergeIncrementalArgs, type MergeOptions, type MergePlanAnchors, type MergePlanArtifact, type MergePlanArtifactV1, type MergePlanArtifactV1Input, type MergePlanBranchAnchor, type MergePlanCandidateDiagnostic, type MergePlanCanonicalMapping, MergePlanCapabilityError, type MergePlanDiagnostics, type MergePlanDigest, MergePlanDigestMismatchError, type MergePlanEdgeDelete, type MergePlanEdgeUpsert, type MergePlanEntityRef, type MergePlanEntityResolution, type MergePlanGuards, type MergePlanIdentityAssertion, type MergePlanMatchEvidence, type MergePlanMatchSource, type MergePlanNodeDelete, type MergePlanNodeUpsert, MergePlanOriginMismatchError, type MergePlanProposedSummary, type MergePlanProvenanceOptions, type MergePlanRetype, type MergePlanReview, type MergePlanRevisionFence, type MergePlanSchemaFence, MergePlanSchemaMismatchError, type MergePlanSimilarityStrategy, type MergePlanTargetFence, MergePlanTargetMismatchError, type MergePlanTypeReconciliation, type MergePlanWrites, MergePlanningStaleError, type MergeReport, type MergedCounts, type NormalizedMergeOptions, type PropertyConflict, type PropertyConflictPolicy, type ProvenanceGraph, type ProvenanceIndex, type ProvenanceNode, type ProvenanceQuery, type ProvenanceRecord, type ReconcileTypesMode, type ResolveConfig, type ResolveMap, type ResolvedCluster, Result, type SimilarityStrategy, SimilarityUnavailableError, type SourceScope, StaleMergePlanError, type TypeReconciliation, UnsupportedMergePlanVersionError, VALIDITY_END_TARGET_PRECEDENCE, type ValidityEndResolution, type WorkingCopyStrategy, applyMergePlan, asBaseVersion, asBranchId, branch, cloneWorkingCopyStrategy, computeBaseVersion, ingestionBranch, merge, mergeIncremental, normalizeMergeOptions, openProvenanceStore, persistProvenanceRecords, planMerge, planMergeIncremental, provenanceGraphId, readProvenance };
@@ -1,14 +1,15 @@
1
- import { bf as NodeId, u as NodeType, b6 as JsonValue, aA as EdgeId, d as GraphDef, bg as NodeKinds, aR as GetNodeType, y as GraphBackend, b7 as KindAnnotations, bb as MetaEdge, a5 as EdgeType, aw as DeleteBehavior, T as TemporalMode, I as IndexDeclaration, aX as GraphExtensionVersion, cs as ExtensionNodeDef, ct as ExtensionEdgeDef, cu as ExtensionOntologyRelation, cv as ExtensionIndex } from '../types-DKkMJZjR.js';
2
- export { C as ContributionDiagnostic, a as ContributionDiagnosticState, b as ContributionRepairEntry, c as ContributionRepairResult } from '../types-DKkMJZjR.js';
3
- import { a as Store, aP as Node, ce as UniqueIntrospection } from '../store-5j-w5onJ.js';
4
- import { aj as TypeGraphError, ak as TypeGraphErrorOptions } from '../index-CzoJ3MUw.js';
1
+ import { dP as NodeId, dg as NodeType, bh as JsonValue, dw as EdgeId, d8 as GraphDef, dQ as NodeKinds, dD as GetNodeType, aM as GraphBackend, bi as KindAnnotations, dN as MetaEdge, dr as EdgeType, S as DeleteBehavior, ce as TemporalMode, I as IndexDeclaration, aQ as GraphExtensionVersion, ak as ExtensionNodeDef, ae as ExtensionEdgeDef, ap as ExtensionOntologyRelation, ai as ExtensionIndex } from '../types-BqFZTQmV.js';
2
+ export { u as ContributionDiagnostic, v as ContributionDiagnosticState, J as ContributionRepairEntry, K as ContributionRepairResult } from '../types-BqFZTQmV.js';
3
+ import { I as IngestionImportTarget } from '../ingestion-import-target-dNeL7iAv.js';
4
+ import { a as Store, az as IdentityAssertionWriteFacade, aQ as Node, cf as UniqueIntrospection } from '../store-DRrFCx5x.js';
5
+ import { aj as TypeGraphError, ak as TypeGraphErrorOptions } from '../index-D7d1u2gr.js';
5
6
  import { R as Result } from '../result-DWo6mUVz.js';
6
7
  export { i as isErr, a as isOk, u as unwrap } from '../result-DWo6mUVz.js';
7
8
  import { z } from 'zod';
8
- import '../temporal-CjO9FH1l.js';
9
- import '../searchable-D9gMiwcS.js';
10
- import '../manager-B6sOQzcQ.js';
11
- import '../materialize-indexes-DQL4xcpf.js';
9
+ import '../temporal-CbnLzTmM.js';
10
+ import '../searchable-bpE1bBfc.js';
11
+ import '../manager-D9eRT_ns.js';
12
+ import '../materialize-indexes-DJ3ykH59.js';
12
13
 
13
14
  /**
14
15
  * The composite MERGE IDENTITY key for a node: the pair `(kind, id)`.
@@ -200,6 +201,35 @@ type GraphBranch<G extends GraphDef> = Readonly<{
200
201
  hash: string;
201
202
  }> | undefined;
202
203
  }>;
204
+ declare const INGESTION_BRANCH_BRAND: unique symbol;
205
+ /**
206
+ * Node collections exposed by an {@link IngestionBranch}. They retain normal
207
+ * validation, reads, and staging writes, but omit APIs that claim a declared
208
+ * uniqueness constraint exists on the relaxed physical working copy.
209
+ */
210
+ type IngestionNodeCollections<G extends GraphDef> = Readonly<{
211
+ [K in keyof Store<G>["nodes"]]-?: Pick<Store<G>["nodes"][K], "create" | "getById" | "getByIds" | "update" | "updateWhere" | "delete" | "hardDelete" | "find" | "count" | "createFromRecord" | "upsertById" | "upsertByIdFromRecord" | "bulkCreate" | "bulkUpsertById" | "bulkInsert" | "bulkDelete" | "bulkFindByIndex">;
212
+ }>;
213
+ /**
214
+ * Opaque handle for an untrusted ingestion working copy.
215
+ *
216
+ * The ordinary {@link Store} is intentionally absent: callers may stage and
217
+ * inspect graph data through the typed collections, then pass this handle to
218
+ * merge planning, but cannot access schema evolution, transactions, or runtime
219
+ * internals. `close()` releases the private working-copy backend.
220
+ */
221
+ type IngestionBranch<G extends GraphDef> = IngestionImportTarget<G> & Readonly<{
222
+ [INGESTION_BRANCH_BRAND]: true;
223
+ id: BranchId;
224
+ base: BaseVersion;
225
+ nodes: IngestionNodeCollections<G>;
226
+ edges: Store<G>["edges"];
227
+ close: () => Promise<void>;
228
+ }> & ("identity" extends keyof Store<G> ? Readonly<{
229
+ identity: IdentityAssertionWriteFacade<G>;
230
+ }> : Readonly<Record<never, never>>);
231
+ /** A normal branch or an opaque ingestion branch accepted by merge entrypoints. */
232
+ type MergeBranch<G extends GraphDef> = GraphBranch<G> | IngestionBranch<G>;
203
233
  /**
204
234
  * Options for {@link GraphBranch} creation. `id` is optional — when omitted a
205
235
  * fresh id is generated.
@@ -470,7 +500,7 @@ type MergeOptions<G extends GraphDef = GraphDef> = Readonly<{
470
500
  type MergeIncrementalArgs<G extends GraphDef = GraphDef> = Readonly<{
471
501
  forkPoint: Store<G>;
472
502
  target: Store<G>;
473
- branches: readonly GraphBranch<G>[];
503
+ branches: readonly MergeBranch<G>[];
474
504
  options?: Omit<MergeOptions<G>, "target">;
475
505
  }>;
476
506
  /**
@@ -967,9 +997,11 @@ declare class MatchEvidenceError extends MergeError {
967
997
  * `includeTemporal: true` carries `validFrom`/`validTo` through unchanged,
968
998
  * preserving the base's exact valid-time window on the clone: create-time
969
999
  * paths default an omitted `validFrom` to the row's own creation instant
970
- * (see #240), and export/import round-trip a still-open-left `valid_from`
971
- * (e.g. a row that predates the #240 fix) as an explicit `null` rather than
972
- * silently dropping it — see `InterchangeNodeSchema.validFrom`'s doc.
1000
+ * (see #240) — except for a BORN-ENDED row, whose stated `validTo` at or before
1001
+ * the write instant leaves it with no lower bound at all (see #407) — and
1002
+ * export/import round-trip a still-open-left `valid_from` (a born-ended row, or
1003
+ * one that predates the #240 fix) as an explicit `null` rather than silently
1004
+ * dropping it — see `InterchangeNodeSchema.validFrom`'s doc.
973
1005
  * Without either half of this, the clone's re-import would re-stamp the
974
1006
  * affected base rows to the CLONE's creation instant instead — narrowing
975
1007
  * their validity window and making `asOf` reads on the fork diverge from
@@ -1085,6 +1117,27 @@ declare function cloneWorkingCopyStrategy<G extends GraphDef>(makeBackend: MakeB
1085
1117
  */
1086
1118
  declare function branch<G extends GraphDef>(baseStore: GraphBranch<G>["store"], makeBackend: MakeBackend, options?: BranchOptions, strategy?: WorkingCopyStrategy<G>): Promise<Result<GraphBranch<G>, BranchError>>;
1087
1119
 
1120
+ /**
1121
+ * Constraint-aware working copies for untrusted ingestion.
1122
+ *
1123
+ * An ingestion branch persists a mechanically-derived schema with node
1124
+ * uniqueness declarations removed. That lets aliases reach merge planning,
1125
+ * where canonical candidate generation and final resolved-write validation use
1126
+ * the canonical graph's constraints. Every other working-copy constraint stays
1127
+ * active during staging.
1128
+ */
1129
+
1130
+ /**
1131
+ * Creates an isolated ingestion branch whose node uniqueness constraints are
1132
+ * deferred until the resolved merge write set is applied.
1133
+ *
1134
+ * The returned handle deliberately exposes no ordinary Store. Its typed node
1135
+ * and edge collections are sufficient to stage and inspect incoming data, and
1136
+ * merge entrypoints accept the handle directly. Call `close()` when the working
1137
+ * copy is no longer needed.
1138
+ */
1139
+ declare function ingestionBranch<G extends GraphDef>(baseStore: GraphBranch<G>["store"], makeBackend: MakeBackend, options?: BranchOptions): Promise<Result<IngestionBranch<G>, BranchError>>;
1140
+
1088
1141
  /**
1089
1142
  * The shared SCORING stage (design §4, the single match-decision point).
1090
1143
  *
@@ -1379,7 +1432,7 @@ type MergePlanArtifact = MergePlanArtifactV1;
1379
1432
  type MergePlanArtifactV1Input = Omit<MergePlanArtifactV1, "digest">;
1380
1433
 
1381
1434
  /** Builds a durable, reviewable snapshot merge plan without mutating the target. */
1382
- declare function planMerge<G extends GraphDef>(store: Store<G>, branches: readonly GraphBranch<G>[], optionsInput?: MergeOptions<G>): Promise<Result<MergePlanArtifact, MergeError>>;
1435
+ declare function planMerge<G extends GraphDef>(store: Store<G>, branchInputs: readonly MergeBranch<G>[], optionsInput?: MergeOptions<G>): Promise<Result<MergePlanArtifact, MergeError>>;
1383
1436
  /** Builds a durable, reviewable incremental merge plan without mutating the target. */
1384
1437
  declare function planMergeIncremental<G extends GraphDef>(args: MergeIncrementalArgs<G>): Promise<Result<MergePlanArtifact, MergeError>>;
1385
1438
  /** Validates and atomically applies an approved serialized merge plan. */
@@ -1408,7 +1461,7 @@ declare function applyMergePlan<G extends GraphDef>(target: Store<G>, input: Mer
1408
1461
  * report and committed graph are identical across any permutation.
1409
1462
  * @param optionsInput Caller-facing {@link MergeOptions}; normalized internally.
1410
1463
  */
1411
- declare function merge<G extends GraphDef>(store: Store<G>, branches: readonly GraphBranch<G>[], optionsInput?: MergeOptions<G>): Promise<Result<MergeReport<G>, MergeError>>;
1464
+ declare function merge<G extends GraphDef>(store: Store<G>, branchInputs: readonly MergeBranch<G>[], optionsInput?: MergeOptions<G>): Promise<Result<MergeReport<G>, MergeError>>;
1412
1465
  /**
1413
1466
  * Incremental merge — the public fork-point-vs-live-target entry point (design
1414
1467
  * §6.4-B / §6.6). It treats `forkPoint` as the immutable ancestor, folds the live
@@ -1722,4 +1775,4 @@ type KeylessConfig = Readonly<{
1722
1775
  sortFields: readonly string[];
1723
1776
  }>;
1724
1777
 
1725
- export { type BaseAmbiguity, type BaseNodeLookup, type BaseVersion, BaseVersionMismatchError, BranchError, type BranchId, type BranchOptions, type BranchProvenance, type CandidateDiagnostic, type CandidateDiagnostics, type CandidateDiagnosticsOptions, type CandidateSource, CandidateSourceError, type ComparisonCeilingPolicy, type ConflictingValue, type DeleteModifyConflict, type DeleteModifyPolicy, type DroppedItem, type Embedder, type EntityRef, type EntityResolution, type GraphBranch, IdentityMergeConflictError, InvalidMergeOptionsError, InvalidMergePlanError, type KeylessConfig, MERGE_ERROR_CODES, MERGE_OPTION_DEFAULTS, MERGE_PLAN_DIGEST_ALGORITHM, MERGE_PLAN_FORMAT_VERSION, type MakeBackend, type MatchEvidence, MatchEvidenceError, type MatchSource, type MatchStrategy, MergeConflictError, MergeConstraintConflictError, type MergeConstraintConflictErrorDetails, MergeError, type MergeIncrementalArgs, type MergeOptions, type MergePlanAnchors, type MergePlanArtifact, type MergePlanArtifactV1, type MergePlanArtifactV1Input, type MergePlanBranchAnchor, type MergePlanCandidateDiagnostic, type MergePlanCanonicalMapping, MergePlanCapabilityError, type MergePlanDiagnostics, type MergePlanDigest, MergePlanDigestMismatchError, type MergePlanEdgeDelete, type MergePlanEdgeUpsert, type MergePlanEntityRef, type MergePlanEntityResolution, type MergePlanGuards, type MergePlanIdentityAssertion, type MergePlanMatchEvidence, type MergePlanMatchSource, type MergePlanNodeDelete, type MergePlanNodeUpsert, MergePlanOriginMismatchError, type MergePlanProposedSummary, type MergePlanProvenanceOptions, type MergePlanRetype, type MergePlanReview, type MergePlanRevisionFence, type MergePlanSchemaFence, MergePlanSchemaMismatchError, type MergePlanSimilarityStrategy, type MergePlanTargetFence, MergePlanTargetMismatchError, type MergePlanTypeReconciliation, type MergePlanWrites, MergePlanningStaleError, type MergeReport, type MergedCounts, type NormalizedMergeOptions, type PropertyConflict, type PropertyConflictPolicy, type ProvenanceGraph, type ProvenanceIndex, type ProvenanceNode, type ProvenanceQuery, type ProvenanceRecord, type ReconcileTypesMode, type ResolveConfig, type ResolveMap, type ResolvedCluster, Result, type SimilarityStrategy, SimilarityUnavailableError, type SourceScope, StaleMergePlanError, type TypeReconciliation, UnsupportedMergePlanVersionError, VALIDITY_END_TARGET_PRECEDENCE, type ValidityEndResolution, type WorkingCopyStrategy, applyMergePlan, asBaseVersion, asBranchId, branch, cloneWorkingCopyStrategy, computeBaseVersion, merge, mergeIncremental, normalizeMergeOptions, openProvenanceStore, persistProvenanceRecords, planMerge, planMergeIncremental, provenanceGraphId, readProvenance };
1778
+ export { type BaseAmbiguity, type BaseNodeLookup, type BaseVersion, BaseVersionMismatchError, BranchError, type BranchId, type BranchOptions, type BranchProvenance, type CandidateDiagnostic, type CandidateDiagnostics, type CandidateDiagnosticsOptions, type CandidateSource, CandidateSourceError, type ComparisonCeilingPolicy, type ConflictingValue, type DeleteModifyConflict, type DeleteModifyPolicy, type DroppedItem, type Embedder, type EntityRef, type EntityResolution, type GraphBranch, IdentityAssertionWriteFacade, IdentityMergeConflictError, type IngestionBranch, IngestionImportTarget, type IngestionNodeCollections, InvalidMergeOptionsError, InvalidMergePlanError, type KeylessConfig, MERGE_ERROR_CODES, MERGE_OPTION_DEFAULTS, MERGE_PLAN_DIGEST_ALGORITHM, MERGE_PLAN_FORMAT_VERSION, type MakeBackend, type MatchEvidence, MatchEvidenceError, type MatchSource, type MatchStrategy, type MergeBranch, MergeConflictError, MergeConstraintConflictError, type MergeConstraintConflictErrorDetails, MergeError, type MergeIncrementalArgs, type MergeOptions, type MergePlanAnchors, type MergePlanArtifact, type MergePlanArtifactV1, type MergePlanArtifactV1Input, type MergePlanBranchAnchor, type MergePlanCandidateDiagnostic, type MergePlanCanonicalMapping, MergePlanCapabilityError, type MergePlanDiagnostics, type MergePlanDigest, MergePlanDigestMismatchError, type MergePlanEdgeDelete, type MergePlanEdgeUpsert, type MergePlanEntityRef, type MergePlanEntityResolution, type MergePlanGuards, type MergePlanIdentityAssertion, type MergePlanMatchEvidence, type MergePlanMatchSource, type MergePlanNodeDelete, type MergePlanNodeUpsert, MergePlanOriginMismatchError, type MergePlanProposedSummary, type MergePlanProvenanceOptions, type MergePlanRetype, type MergePlanReview, type MergePlanRevisionFence, type MergePlanSchemaFence, MergePlanSchemaMismatchError, type MergePlanSimilarityStrategy, type MergePlanTargetFence, MergePlanTargetMismatchError, type MergePlanTypeReconciliation, type MergePlanWrites, MergePlanningStaleError, type MergeReport, type MergedCounts, type NormalizedMergeOptions, type PropertyConflict, type PropertyConflictPolicy, type ProvenanceGraph, type ProvenanceIndex, type ProvenanceNode, type ProvenanceQuery, type ProvenanceRecord, type ReconcileTypesMode, type ResolveConfig, type ResolveMap, type ResolvedCluster, Result, type SimilarityStrategy, SimilarityUnavailableError, type SourceScope, StaleMergePlanError, type TypeReconciliation, UnsupportedMergePlanVersionError, VALIDITY_END_TARGET_PRECEDENCE, type ValidityEndResolution, type WorkingCopyStrategy, applyMergePlan, asBaseVersion, asBranchId, branch, cloneWorkingCopyStrategy, computeBaseVersion, ingestionBranch, merge, mergeIncremental, normalizeMergeOptions, openProvenanceStore, persistProvenanceRecords, planMerge, planMergeIncremental, provenanceGraphId, readProvenance };
@@ -1,20 +1,20 @@
1
- import { createStoreWithSchema } from '../chunk-DJZTXBWY.js';
2
- import '../chunk-LEWHMOUY.js';
3
- import { importGraphStream, exportGraphStream, importGraph, exportGraph } from '../chunk-QS3NQZVC.js';
4
- import '../chunk-SE6EGQSD.js';
5
- import { storeBackend, storeRuntime, transactionBackend } from '../chunk-FNOMT74T.js';
6
- import { computeSchemaHash, serializeSchema } from '../chunk-XYBQI6LE.js';
1
+ import { createStoreWithSchema } from '../chunk-BRRP76WO.js';
2
+ import '../chunk-YIURNGXI.js';
3
+ import { importGraphStream, exportGraphStream, importGraph, exportGraph, registerIngestionImportTarget } from '../chunk-LTXQOEIC.js';
4
+ import '../chunk-KF6K7TGH.js';
5
+ import { storeBackend, storeRuntime, transactionBackend } from '../chunk-I4GAZH5Z.js';
6
+ import { computeSchemaHash, serializeSchema } from '../chunk-2TYSSBU5.js';
7
7
  import { defineNode } from '../chunk-SHFBB23Q.js';
8
- import { encodeTupleKey, forceWriteTransactionRevision, normalizeIdentityPair, identityReferenceKey, identityValidityWindowsOverlap, identityAssertionSemanticKey } from '../chunk-NNQ6A3RM.js';
9
- import { compareStrings, generateId, lockRecordedGraphWrite, readRevisionOrigin, readRecordedClock, forceRecordedGraphRevision, advanceRevisionClock, compareCodePoints } from '../chunk-AVGUJWVX.js';
8
+ import { forceWriteTransactionRevision, normalizeIdentityPair, identityReferenceKey, identityValidityWindowsOverlap, identityAssertionSemanticKey } from '../chunk-ZFMCDJGB.js';
9
+ import { compareStrings, generateId, encodeTupleKey, lockRecordedGraphWrite, readRevisionOrigin, readRecordedClock, forceRecordedGraphRevision, advanceRevisionClock, compareCodePoints } from '../chunk-S5TERQVW.js';
10
10
  import { sortedReplacer } from '../chunk-JBQQ7THH.js';
11
- import '../chunk-NAZ2RA4L.js';
11
+ import { snapshotExportContention } from '../chunk-UGHG7PGX.js';
12
12
  import { createSqlSchema } from '../chunk-NVY5CJFP.js';
13
- import { snapshotExportContention } from '../chunk-SHSSRCFR.js';
13
+ import '../chunk-6LN7FIVU.js';
14
14
  import { getNodeKinds, getEdgeKinds, defineInternalGraph } from '../chunk-HEV35TGT.js';
15
15
  import { validateEdgeEndpoints, computeUniqueKey } from '../chunk-GLHXM7C4.js';
16
- import '../chunk-XY5OMOJD.js';
17
- import { canonicalizeDatabaseTimestamp } from '../chunk-NG2RB5WL.js';
16
+ import '../chunk-DZAICA5J.js';
17
+ import { canonicalizeDatabaseTimestamp } from '../chunk-5K2BKEBD.js';
18
18
  import '../chunk-KKBDXCLQ.js';
19
19
  import '../chunk-SDBBMD4N.js';
20
20
  import '../chunk-P6YLZTRE.js';
@@ -1885,12 +1885,24 @@ function contentComponentOf(version) {
1885
1885
  // src/graph-merge/working-copy.ts
1886
1886
  var CLONE_IMPORT_BATCH_SIZE = 1e3;
1887
1887
  function cloneWorkingCopyStrategy(makeBackend) {
1888
+ return cloneWorkingCopyWithGraphStrategy(
1889
+ makeBackend,
1890
+ (baseStore) => baseStore.graph
1891
+ );
1892
+ }
1893
+ function cloneIngestionWorkingCopyStrategy(makeBackend) {
1894
+ return cloneWorkingCopyWithGraphStrategy(
1895
+ makeBackend,
1896
+ (baseStore) => graphWithoutNodeUniqueness(baseStore.graph)
1897
+ );
1898
+ }
1899
+ function cloneWorkingCopyWithGraphStrategy(makeBackend, graphForClone) {
1888
1900
  return {
1889
1901
  create: async (baseStore) => {
1890
1902
  const backend = await makeBackend();
1891
1903
  try {
1892
1904
  const [freshStore] = await createStoreWithSchema(
1893
- baseStore.graph,
1905
+ graphForClone(baseStore),
1894
1906
  backend,
1895
1907
  {
1896
1908
  // Keep descendants branchable with the same O(1) anchor contract,
@@ -1939,6 +1951,30 @@ function cloneWorkingCopyStrategy(makeBackend) {
1939
1951
  }
1940
1952
  };
1941
1953
  }
1954
+ function graphWithoutNodeUniqueness(graph) {
1955
+ const nodes = Object.fromEntries(
1956
+ Object.entries(graph.nodes).map(([name, registration]) => {
1957
+ const { unique: _omitted, ...withoutUnique } = registration;
1958
+ return [name, Object.freeze(withoutUnique)];
1959
+ })
1960
+ );
1961
+ const extension = graph.extension?.nodes === void 0 ? graph.extension : Object.freeze({
1962
+ ...graph.extension,
1963
+ nodes: Object.freeze(
1964
+ Object.fromEntries(
1965
+ Object.entries(graph.extension.nodes).map(([name, node]) => {
1966
+ const { unique: _omitted, ...withoutUnique } = node;
1967
+ return [name, Object.freeze(withoutUnique)];
1968
+ })
1969
+ )
1970
+ )
1971
+ });
1972
+ return Object.freeze({
1973
+ ...graph,
1974
+ nodes: Object.freeze(nodes),
1975
+ extension
1976
+ });
1977
+ }
1942
1978
 
1943
1979
  // src/graph-merge/branch.ts
1944
1980
  async function branch(baseStore, makeBackend, options, strategy) {
@@ -1947,7 +1983,7 @@ async function branch(baseStore, makeBackend, options, strategy) {
1947
1983
  const id = options?.id ?? asBranchId(generateId());
1948
1984
  const workingCopyStrategy = strategy ?? cloneWorkingCopyStrategy(makeBackend);
1949
1985
  const store = await workingCopyStrategy.create(baseStore);
1950
- const schemaAnchor = await readSchemaAnchor(store);
1986
+ const schemaAnchor = await captureBranchSchemaAnchor(store);
1951
1987
  return ok({
1952
1988
  id,
1953
1989
  base,
@@ -1962,7 +1998,7 @@ async function branch(baseStore, makeBackend, options, strategy) {
1962
1998
  );
1963
1999
  }
1964
2000
  }
1965
- async function readSchemaAnchor(store) {
2001
+ async function captureBranchSchemaAnchor(store) {
1966
2002
  try {
1967
2003
  const schemaRow = await storeBackend(store).getActiveSchema(store.graphId);
1968
2004
  return schemaRow === void 0 ? void 0 : { version: schemaRow.version, hash: schemaRow.schema_hash };
@@ -1975,6 +2011,76 @@ async function readSchemaAnchor(store) {
1975
2011
  }
1976
2012
  }
1977
2013
 
2014
+ // src/graph-merge/ingestion-branch.ts
2015
+ var PRIVATE_BRANCHES = /* @__PURE__ */ new WeakMap();
2016
+ function createIngestionIdentityFacade(identity) {
2017
+ return Object.freeze({
2018
+ assertSame(a, b, window) {
2019
+ return identity.assertSame(a, b, window);
2020
+ },
2021
+ assertDifferent(a, b, window) {
2022
+ return identity.assertDifferent(a, b, window);
2023
+ },
2024
+ bulkAssertSame(pairs) {
2025
+ return identity.bulkAssertSame(pairs);
2026
+ },
2027
+ bulkAssertDifferent(pairs) {
2028
+ return identity.bulkAssertDifferent(pairs);
2029
+ }
2030
+ });
2031
+ }
2032
+ async function ingestionBranch(baseStore, makeBackend, options) {
2033
+ try {
2034
+ const created = await branch(
2035
+ baseStore,
2036
+ makeBackend,
2037
+ options,
2038
+ cloneIngestionWorkingCopyStrategy(makeBackend)
2039
+ );
2040
+ if (isErr(created)) {
2041
+ return err(
2042
+ new BranchError("Failed to create constraint-aware ingestion branch", {
2043
+ cause: created.error
2044
+ })
2045
+ );
2046
+ }
2047
+ const privateBranch = created.data;
2048
+ const { base, id, store } = privateBranch;
2049
+ const identityAccess = store.graph.identity === void 0 ? {} : {
2050
+ identity: createIngestionIdentityFacade(
2051
+ store.identity
2052
+ )
2053
+ };
2054
+ const handle = Object.freeze({
2055
+ id,
2056
+ base,
2057
+ nodes: store.nodes,
2058
+ edges: store.edges,
2059
+ ...identityAccess,
2060
+ close: async () => storeBackend(store).close()
2061
+ });
2062
+ PRIVATE_BRANCHES.set(handle, privateBranch);
2063
+ registerIngestionImportTarget(handle, store);
2064
+ return ok(handle);
2065
+ } catch (error) {
2066
+ return err(
2067
+ new BranchError("Failed to create constraint-aware ingestion branch", {
2068
+ cause: error
2069
+ })
2070
+ );
2071
+ }
2072
+ }
2073
+ function unwrapMergeBranch(input) {
2074
+ const privateBranch = PRIVATE_BRANCHES.get(input);
2075
+ if (privateBranch !== void 0) {
2076
+ return privateBranch;
2077
+ }
2078
+ return input;
2079
+ }
2080
+ function unwrapMergeBranches(inputs) {
2081
+ return inputs.map((input) => unwrapMergeBranch(input));
2082
+ }
2083
+
1978
2084
  // src/graph-merge/blocking.ts
1979
2085
  var UNBLOCKED_BUCKET_KEY = "unblocked";
1980
2086
  var KEY_PART_SEPARATOR = "\0";
@@ -6658,20 +6764,67 @@ function nodeWriteWindowOptions(write) {
6658
6764
  ...write.validTo === void 0 ? {} : { validTo: write.validTo }
6659
6765
  };
6660
6766
  }
6661
- async function applyNodeRows(nodesApi, deletions, upserts) {
6662
- for (const deletion of deletions) {
6663
- await nodeCollection(nodesApi, deletion.kind).delete(deletion.id);
6664
- }
6665
- const committed = /* @__PURE__ */ new Set();
6767
+ async function applyNodeRows(target, txBackend, nodesApi, deletions, upserts) {
6768
+ const afterImages = /* @__PURE__ */ new Map();
6769
+ const upsertsByKind = /* @__PURE__ */ new Map();
6666
6770
  for (const upsert of upserts) {
6667
- await nodeCollection(nodesApi, upsert.kind).upsertByIdFromRecord(
6668
- upsert.id,
6669
- upsert.props,
6670
- nodeWriteWindowOptions(upsert)
6771
+ const items = upsertsByKind.get(upsert.kind);
6772
+ if (items === void 0) upsertsByKind.set(upsert.kind, [upsert]);
6773
+ else items.push(upsert);
6774
+ }
6775
+ for (const [kind, items] of upsertsByKind) {
6776
+ const currentRows = await nodeCollection(nodesApi, kind).getByIds(
6777
+ items.map((item) => item.id),
6778
+ INCLUDE_TOMBSTONES
6671
6779
  );
6672
- committed.add(mergeKey(upsert.kind, upsert.id));
6780
+ const currentById = /* @__PURE__ */ new Map();
6781
+ for (const node of currentRows) {
6782
+ if (node !== void 0) currentById.set(node.id, nodeProps2(node));
6783
+ }
6784
+ for (const item of items) {
6785
+ const props = createDataKeyedBag();
6786
+ const unset = new Set(
6787
+ Object.entries(item.props).filter(([, value]) => value === void 0).map(([key]) => key)
6788
+ );
6789
+ for (const [key, value] of Object.entries(
6790
+ currentById.get(item.id) ?? {}
6791
+ )) {
6792
+ if (!unset.has(key)) props[key] = value;
6793
+ }
6794
+ for (const [key, value] of Object.entries(item.props)) {
6795
+ if (value !== void 0) props[key] = value;
6796
+ }
6797
+ afterImages.set(mergeKey(kind, item.id), props);
6798
+ }
6673
6799
  }
6674
- return committed.size;
6800
+ return storeRuntime(target).applyResolvedNodeUniqueness(
6801
+ txBackend,
6802
+ {
6803
+ upserts: upserts.map((upsert) => ({
6804
+ kind: upsert.kind,
6805
+ id: upsert.id,
6806
+ props: requireDefined(
6807
+ afterImages.get(mergeKey(upsert.kind, upsert.id))
6808
+ )
6809
+ })),
6810
+ releases: deletions
6811
+ },
6812
+ async () => {
6813
+ for (const deletion of deletions) {
6814
+ await nodeCollection(nodesApi, deletion.kind).delete(deletion.id);
6815
+ }
6816
+ const committed = /* @__PURE__ */ new Set();
6817
+ for (const upsert of upserts) {
6818
+ await nodeCollection(nodesApi, upsert.kind).upsertByIdFromRecord(
6819
+ upsert.id,
6820
+ upsert.props,
6821
+ nodeWriteWindowOptions(upsert)
6822
+ );
6823
+ committed.add(mergeKey(upsert.kind, upsert.id));
6824
+ }
6825
+ return committed.size;
6826
+ }
6827
+ );
6675
6828
  }
6676
6829
  async function applyEdgeRows(edgesApi, deletions, upserts) {
6677
6830
  for (const deletion of deletions) {
@@ -6732,7 +6885,13 @@ async function applyInternalMergePlan(plan, nodesApi, edgesApi, target, txBacken
6732
6885
  );
6733
6886
  let committedNodes;
6734
6887
  try {
6735
- committedNodes = await applyNodeRows(nodesApi, nodeDeletions, nodeUpserts);
6888
+ committedNodes = await applyNodeRows(
6889
+ target,
6890
+ txBackend,
6891
+ nodesApi,
6892
+ nodeDeletions,
6893
+ nodeUpserts
6894
+ );
6736
6895
  } catch (error) {
6737
6896
  throw error instanceof IdentityEndpointValidityError ? translateIdentityCommitError(error) : error;
6738
6897
  }
@@ -7396,7 +7555,8 @@ function incrementalSchemaError() {
7396
7555
  { details: {} }
7397
7556
  );
7398
7557
  }
7399
- async function planMerge(store, branches, optionsInput = {}) {
7558
+ async function planMerge(store, branchInputs, optionsInput = {}) {
7559
+ const branches = unwrapMergeBranches(branchInputs);
7400
7560
  const normalized = tryNormalize(optionsInput);
7401
7561
  if (isErr(normalized)) return err(normalized.error);
7402
7562
  const options = normalized.data;
@@ -7437,7 +7597,8 @@ async function planMerge(store, branches, optionsInput = {}) {
7437
7597
  );
7438
7598
  }
7439
7599
  async function planMergeIncremental(args) {
7440
- const { forkPoint, target, branches } = args;
7600
+ const { forkPoint, target } = args;
7601
+ const branches = unwrapMergeBranches(args.branches);
7441
7602
  const normalized = tryNormalize(args.options ?? {}, ["target"]);
7442
7603
  if (isErr(normalized)) return err(normalized.error);
7443
7604
  const options = normalized.data;
@@ -7878,6 +8039,8 @@ function identityConsistencySeeds(artifact, profile) {
7878
8039
  }
7879
8040
  async function applyWireMergeWrites(target, nodesApi, edgesApi, txBackend, artifact) {
7880
8041
  const committedNodes = await applyNodeRows(
8042
+ target,
8043
+ txBackend,
7881
8044
  nodesApi,
7882
8045
  artifact.writes.nodeDeletes,
7883
8046
  artifact.writes.nodeUpserts.map((upsert) => ({
@@ -8050,7 +8213,8 @@ async function applyMergePlan(target, input) {
8050
8213
  );
8051
8214
  }
8052
8215
  }
8053
- async function merge(store, branches, optionsInput = {}) {
8216
+ async function merge(store, branchInputs, optionsInput = {}) {
8217
+ const branches = unwrapMergeBranches(branchInputs);
8054
8218
  const normalized = tryNormalize(optionsInput);
8055
8219
  if (isErr(normalized)) {
8056
8220
  return err(normalized.error);
@@ -8527,7 +8691,8 @@ async function commitIncrementalPlan(target, plan, guard) {
8527
8691
  );
8528
8692
  }
8529
8693
  async function mergeIncremental(args) {
8530
- const { forkPoint, target, branches } = args;
8694
+ const { forkPoint, target } = args;
8695
+ const branches = unwrapMergeBranches(args.branches);
8531
8696
  const normalized = tryNormalize(args.options ?? {}, ["target"]);
8532
8697
  if (isErr(normalized)) {
8533
8698
  return err(normalized.error);
@@ -8571,6 +8736,6 @@ async function mergeIncremental(args) {
8571
8736
  );
8572
8737
  }
8573
8738
 
8574
- export { BaseVersionMismatchError, BranchError, CandidateSourceError, IdentityMergeConflictError, InvalidMergeOptionsError, InvalidMergePlanError, MERGE_ERROR_CODES, MERGE_OPTION_DEFAULTS, MERGE_PLAN_DIGEST_ALGORITHM, MERGE_PLAN_FORMAT_VERSION, MatchEvidenceError, MergeConflictError, MergeConstraintConflictError, MergeError, MergePlanCapabilityError, MergePlanDigestMismatchError, MergePlanOriginMismatchError, MergePlanSchemaMismatchError, MergePlanTargetMismatchError, MergePlanningStaleError, SimilarityUnavailableError, StaleMergePlanError, UnsupportedMergePlanVersionError, VALIDITY_END_TARGET_PRECEDENCE, applyMergePlan, asBaseVersion, asBranchId, branch, cloneWorkingCopyStrategy, computeBaseVersion, merge, mergeIncremental, normalizeMergeOptions, openProvenanceStore, persistProvenanceRecords, planMerge, planMergeIncremental, provenanceGraphId, readProvenance };
8739
+ export { BaseVersionMismatchError, BranchError, CandidateSourceError, IdentityMergeConflictError, InvalidMergeOptionsError, InvalidMergePlanError, MERGE_ERROR_CODES, MERGE_OPTION_DEFAULTS, MERGE_PLAN_DIGEST_ALGORITHM, MERGE_PLAN_FORMAT_VERSION, MatchEvidenceError, MergeConflictError, MergeConstraintConflictError, MergeError, MergePlanCapabilityError, MergePlanDigestMismatchError, MergePlanOriginMismatchError, MergePlanSchemaMismatchError, MergePlanTargetMismatchError, MergePlanningStaleError, SimilarityUnavailableError, StaleMergePlanError, UnsupportedMergePlanVersionError, VALIDITY_END_TARGET_PRECEDENCE, applyMergePlan, asBaseVersion, asBranchId, branch, cloneWorkingCopyStrategy, computeBaseVersion, ingestionBranch, merge, mergeIncremental, normalizeMergeOptions, openProvenanceStore, persistProvenanceRecords, planMerge, planMergeIncremental, provenanceGraphId, readProvenance };
8575
8740
  //# sourceMappingURL=index.js.map
8576
8741
  //# sourceMappingURL=index.js.map