@nicia-ai/typegraph 0.47.0 → 0.48.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 (207) 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-EMIB2RXD.cjs → chunk-2HIYYMWY.cjs} +99 -96
  36. package/dist/chunk-2HIYYMWY.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-5FT3TLPK.js → chunk-2SYZXD54.js} +16 -13
  40. package/dist/chunk-2SYZXD54.js.map +1 -0
  41. package/dist/{chunk-XYBQI6LE.js → chunk-2TYSSBU5.js} +6 -6
  42. package/dist/{chunk-XYBQI6LE.js.map → chunk-2TYSSBU5.js.map} +1 -1
  43. package/dist/{chunk-6JVZSOHQ.cjs → chunk-3FPR224C.cjs} +26 -26
  44. package/dist/{chunk-6JVZSOHQ.cjs.map → chunk-3FPR224C.cjs.map} +1 -1
  45. package/dist/{chunk-MFZR4QKM.cjs → chunk-3KOY4FH3.cjs} +181 -4
  46. package/dist/chunk-3KOY4FH3.cjs.map +1 -0
  47. package/dist/{chunk-6FWSNSRE.js → chunk-4WMMBDS5.js} +4 -4
  48. package/dist/chunk-4WMMBDS5.js.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-I4G3SQPF.cjs → chunk-7XUYFFR4.cjs} +7 -7
  56. package/dist/chunk-7XUYFFR4.cjs.map +1 -0
  57. package/dist/{chunk-KH7XW7VV.js → chunk-ACGSAMD3.js} +24 -27
  58. package/dist/chunk-ACGSAMD3.js.map +1 -0
  59. package/dist/{chunk-QS3NQZVC.js → chunk-AX6JGVTZ.js} +16 -11
  60. package/dist/chunk-AX6JGVTZ.js.map +1 -0
  61. package/dist/{chunk-DJZTXBWY.js → chunk-BRRP76WO.js} +71 -30
  62. package/dist/chunk-BRRP76WO.js.map +1 -0
  63. package/dist/{chunk-5UMTUOM5.js → chunk-CT3ZKTOF.js} +5 -4
  64. package/dist/chunk-CT3ZKTOF.js.map +1 -0
  65. package/dist/{chunk-XY5OMOJD.js → chunk-DZAICA5J.js} +3 -3
  66. package/dist/{chunk-XY5OMOJD.js.map → chunk-DZAICA5J.js.map} +1 -1
  67. package/dist/{chunk-OIFSOPSR.cjs → chunk-EZEEWCFJ.cjs} +38 -156
  68. package/dist/chunk-EZEEWCFJ.cjs.map +1 -0
  69. package/dist/{chunk-AMMWA76F.cjs → chunk-FA2AFWLP.cjs} +6 -6
  70. package/dist/{chunk-AMMWA76F.cjs.map → chunk-FA2AFWLP.cjs.map} +1 -1
  71. package/dist/{chunk-FNOMT74T.js → chunk-I4GAZH5Z.js} +180 -5
  72. package/dist/chunk-I4GAZH5Z.js.map +1 -0
  73. package/dist/{chunk-WGX7JH7E.cjs → chunk-JB6T4GLL.cjs} +106 -134
  74. package/dist/chunk-JB6T4GLL.cjs.map +1 -0
  75. package/dist/{chunk-MX4DHSQP.cjs → chunk-JFRT7S3B.cjs} +92 -98
  76. package/dist/chunk-JFRT7S3B.cjs.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-ZHNXLS3C.js → chunk-NACVVDWB.js} +208 -8
  80. package/dist/chunk-NACVVDWB.js.map +1 -0
  81. package/dist/{chunk-M35DF33T.js → chunk-OD4SSY2U.js} +29 -16
  82. package/dist/chunk-OD4SSY2U.js.map +1 -0
  83. package/dist/{chunk-U5EDAVOJ.cjs → chunk-OTUPEF2W.cjs} +54 -49
  84. package/dist/chunk-OTUPEF2W.cjs.map +1 -0
  85. package/dist/{chunk-BCQ76AXA.cjs → chunk-PFBRJBUL.cjs} +107 -94
  86. package/dist/chunk-PFBRJBUL.cjs.map +1 -0
  87. package/dist/{chunk-AVGUJWVX.js → chunk-S5TERQVW.js} +15 -132
  88. package/dist/chunk-S5TERQVW.js.map +1 -0
  89. package/dist/chunk-SIT26LAZ.cjs +614 -0
  90. package/dist/chunk-SIT26LAZ.cjs.map +1 -0
  91. package/dist/{chunk-BR7SHKGM.cjs → chunk-SR725PWF.cjs} +548 -507
  92. package/dist/chunk-SR725PWF.cjs.map +1 -0
  93. package/dist/{chunk-5FBRVORR.cjs → chunk-TKZXMWQF.cjs} +8 -7
  94. package/dist/chunk-TKZXMWQF.cjs.map +1 -0
  95. package/dist/{chunk-425IZOQ5.cjs → chunk-TQHGE7UC.cjs} +20 -2
  96. package/dist/chunk-TQHGE7UC.cjs.map +1 -0
  97. package/dist/{chunk-GYUJZARH.cjs → chunk-TUNPBZY3.cjs} +4 -4
  98. package/dist/{chunk-GYUJZARH.cjs.map → chunk-TUNPBZY3.cjs.map} +1 -1
  99. package/dist/chunk-UGHG7PGX.js +592 -0
  100. package/dist/chunk-UGHG7PGX.js.map +1 -0
  101. package/dist/{chunk-KABFHAL7.cjs → chunk-UMGZDVOA.cjs} +213 -12
  102. package/dist/chunk-UMGZDVOA.cjs.map +1 -0
  103. package/dist/{chunk-UPAJHMW3.cjs → chunk-WCCATHMB.cjs} +54 -57
  104. package/dist/chunk-WCCATHMB.cjs.map +1 -0
  105. package/dist/{chunk-LEWHMOUY.js → chunk-YIURNGXI.js} +4 -4
  106. package/dist/{chunk-LEWHMOUY.js.map → chunk-YIURNGXI.js.map} +1 -1
  107. package/dist/{chunk-EP4RUYD6.js → chunk-YVF2EM7B.js} +3 -3
  108. package/dist/{chunk-EP4RUYD6.js.map → chunk-YVF2EM7B.js.map} +1 -1
  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 +334 -191
  120. package/dist/graph-merge/index.cjs.map +1 -1
  121. package/dist/graph-merge/index.d.cts +65 -15
  122. package/dist/graph-merge/index.d.ts +65 -15
  123. package/dist/graph-merge/index.js +174 -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.d.cts +12 -12
  129. package/dist/index.d.ts +12 -12
  130. package/dist/index.js +13 -13
  131. package/dist/indexes/index.d.cts +4 -4
  132. package/dist/indexes/index.d.ts +4 -4
  133. package/dist/interchange/index.cjs +38 -38
  134. package/dist/interchange/index.d.cts +7 -7
  135. package/dist/interchange/index.d.ts +7 -7
  136. package/dist/interchange/index.js +10 -10
  137. package/dist/{manager-DlY1vlla.d.cts → manager-CYaff3n3.d.cts} +2 -2
  138. package/dist/{manager-B6sOQzcQ.d.ts → manager-D9eRT_ns.d.ts} +2 -2
  139. package/dist/{materialize-indexes-DQL4xcpf.d.ts → materialize-indexes-DJ3ykH59.d.ts} +1 -1
  140. package/dist/{materialize-indexes-sskhp-c_.d.cts → materialize-indexes-DTtAnvfY.d.cts} +1 -1
  141. package/dist/{postgres-BXy_nyMs.d.cts → postgres-CcL4bAHS.d.ts} +1 -1
  142. package/dist/{postgres-B6YOUcaK.d.ts → postgres-DMj39MEu.d.cts} +1 -1
  143. package/dist/profiler/index.d.cts +9 -9
  144. package/dist/profiler/index.d.ts +9 -9
  145. package/dist/provenance/index.cjs +25 -26
  146. package/dist/provenance/index.cjs.map +1 -1
  147. package/dist/provenance/index.d.cts +7 -7
  148. package/dist/provenance/index.d.ts +7 -7
  149. package/dist/provenance/index.js +9 -10
  150. package/dist/provenance/index.js.map +1 -1
  151. package/dist/repair-validity-windows-BFNZvd_H.d.cts +166 -0
  152. package/dist/repair-validity-windows-DlUSqwCg.d.ts +166 -0
  153. package/dist/schema/index.cjs +35 -35
  154. package/dist/schema/index.d.cts +6 -6
  155. package/dist/schema/index.d.ts +6 -6
  156. package/dist/schema/index.js +8 -8
  157. package/dist/{searchable-D9gMiwcS.d.ts → searchable-DHJMh_nj.d.cts} +1 -1
  158. package/dist/{searchable-0Cn_lY8U.d.cts → searchable-bpE1bBfc.d.ts} +1 -1
  159. package/dist/{sqlite-DioSxaPe.d.cts → sqlite-D7Oz0SQh.d.ts} +1 -1
  160. package/dist/{sqlite-ClXuBYAj.d.ts → sqlite-YppHrNFb.d.cts} +1 -1
  161. package/dist/{store-5j-w5onJ.d.ts → store-JUVvtmR4.d.cts} +113 -26
  162. package/dist/{store-CFedKGU5.d.cts → store-UzrGvZOo.d.ts} +113 -26
  163. package/dist/{temporal-CjO9FH1l.d.ts → temporal-5GqpYCk2.d.cts} +1 -1
  164. package/dist/{temporal-Ce1pG0S1.d.cts → temporal-CbnLzTmM.d.ts} +1 -1
  165. package/dist/{types-DKkMJZjR.d.cts → types-BqFZTQmV.d.cts} +29 -4
  166. package/dist/{types-DKkMJZjR.d.ts → types-BqFZTQmV.d.ts} +29 -4
  167. package/dist/{types-BrdOFu48.d.ts → types-Bx74kaTt.d.ts} +1 -1
  168. package/dist/{types-oj_OGAaZ.d.cts → types-CXAhpW-c.d.cts} +1 -1
  169. package/dist/{where-D1wKCJ4Q.d.cts → where-DI_Fqz-X.d.cts} +1 -1
  170. package/dist/{where-C8w2627G.d.ts → where-O-k2wgYm.d.ts} +1 -1
  171. package/package.json +1 -1
  172. package/dist/chunk-3HGRTCDU.cjs +0 -269
  173. package/dist/chunk-3HGRTCDU.cjs.map +0 -1
  174. package/dist/chunk-425IZOQ5.cjs.map +0 -1
  175. package/dist/chunk-5FBRVORR.cjs.map +0 -1
  176. package/dist/chunk-5FT3TLPK.js.map +0 -1
  177. package/dist/chunk-5UMTUOM5.js.map +0 -1
  178. package/dist/chunk-6FWSNSRE.js.map +0 -1
  179. package/dist/chunk-AVGUJWVX.js.map +0 -1
  180. package/dist/chunk-BCQ76AXA.cjs.map +0 -1
  181. package/dist/chunk-BR7SHKGM.cjs.map +0 -1
  182. package/dist/chunk-DJZTXBWY.js.map +0 -1
  183. package/dist/chunk-EMIB2RXD.cjs.map +0 -1
  184. package/dist/chunk-FNOMT74T.js.map +0 -1
  185. package/dist/chunk-I4G3SQPF.cjs.map +0 -1
  186. package/dist/chunk-JR6SX5RH.cjs +0 -268
  187. package/dist/chunk-JR6SX5RH.cjs.map +0 -1
  188. package/dist/chunk-KABFHAL7.cjs.map +0 -1
  189. package/dist/chunk-KH7XW7VV.js.map +0 -1
  190. package/dist/chunk-M35DF33T.js.map +0 -1
  191. package/dist/chunk-MFZR4QKM.cjs.map +0 -1
  192. package/dist/chunk-MX4DHSQP.cjs.map +0 -1
  193. package/dist/chunk-NAZ2RA4L.js +0 -254
  194. package/dist/chunk-NAZ2RA4L.js.map +0 -1
  195. package/dist/chunk-NG2RB5WL.js.map +0 -1
  196. package/dist/chunk-NNQ6A3RM.js.map +0 -1
  197. package/dist/chunk-OIFSOPSR.cjs.map +0 -1
  198. package/dist/chunk-QS3NQZVC.js.map +0 -1
  199. package/dist/chunk-SE6EGQSD.js.map +0 -1
  200. package/dist/chunk-SHSSRCFR.js +0 -246
  201. package/dist/chunk-SHSSRCFR.js.map +0 -1
  202. package/dist/chunk-U5EDAVOJ.cjs.map +0 -1
  203. package/dist/chunk-UPAJHMW3.cjs.map +0 -1
  204. package/dist/chunk-WGX7JH7E.cjs.map +0 -1
  205. package/dist/chunk-ZHNXLS3C.js.map +0 -1
  206. package/dist/ddl-CprnMXJ-.d.ts +0 -38
  207. package/dist/ddl-DJA7Lci5.d.cts +0 -38
@@ -1,14 +1,14 @@
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 { a as Store, aP as Node, ce as UniqueIntrospection } from '../store-JUVvtmR4.cjs';
4
+ import { aj as TypeGraphError, ak as TypeGraphErrorOptions } from '../index-COs_z6nV.cjs';
5
5
  import { R as Result } from '../result-DWo6mUVz.cjs';
6
6
  export { i as isErr, a as isOk, u as unwrap } from '../result-DWo6mUVz.cjs';
7
7
  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';
8
+ import '../temporal-5GqpYCk2.cjs';
9
+ import '../searchable-DHJMh_nj.cjs';
10
+ import '../manager-CYaff3n3.cjs';
11
+ import '../materialize-indexes-DTtAnvfY.cjs';
12
12
 
13
13
  /**
14
14
  * The composite MERGE IDENTITY key for a node: the pair `(kind, id)`.
@@ -200,6 +200,33 @@ type GraphBranch<G extends GraphDef> = Readonly<{
200
200
  hash: string;
201
201
  }> | undefined;
202
202
  }>;
203
+ declare const INGESTION_BRANCH_BRAND: unique symbol;
204
+ /**
205
+ * Node collections exposed by an {@link IngestionBranch}. They retain normal
206
+ * validation, reads, and staging writes, but omit APIs that claim a declared
207
+ * uniqueness constraint exists on the relaxed physical working copy.
208
+ */
209
+ type IngestionNodeCollections<G extends GraphDef> = Readonly<{
210
+ [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">;
211
+ }>;
212
+ /**
213
+ * Opaque handle for an untrusted ingestion working copy.
214
+ *
215
+ * The ordinary {@link Store} is intentionally absent: callers may stage and
216
+ * inspect graph data through the typed collections, then pass this handle to
217
+ * merge planning, but cannot access schema evolution, transactions, or runtime
218
+ * internals. `close()` releases the private working-copy backend.
219
+ */
220
+ type IngestionBranch<G extends GraphDef> = Readonly<{
221
+ [INGESTION_BRANCH_BRAND]: true;
222
+ id: BranchId;
223
+ base: BaseVersion;
224
+ nodes: IngestionNodeCollections<G>;
225
+ edges: Store<G>["edges"];
226
+ close: () => Promise<void>;
227
+ }>;
228
+ /** A normal branch or an opaque ingestion branch accepted by merge entrypoints. */
229
+ type MergeBranch<G extends GraphDef> = GraphBranch<G> | IngestionBranch<G>;
203
230
  /**
204
231
  * Options for {@link GraphBranch} creation. `id` is optional — when omitted a
205
232
  * fresh id is generated.
@@ -470,7 +497,7 @@ type MergeOptions<G extends GraphDef = GraphDef> = Readonly<{
470
497
  type MergeIncrementalArgs<G extends GraphDef = GraphDef> = Readonly<{
471
498
  forkPoint: Store<G>;
472
499
  target: Store<G>;
473
- branches: readonly GraphBranch<G>[];
500
+ branches: readonly MergeBranch<G>[];
474
501
  options?: Omit<MergeOptions<G>, "target">;
475
502
  }>;
476
503
  /**
@@ -967,9 +994,11 @@ declare class MatchEvidenceError extends MergeError {
967
994
  * `includeTemporal: true` carries `validFrom`/`validTo` through unchanged,
968
995
  * preserving the base's exact valid-time window on the clone: create-time
969
996
  * 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.
997
+ * (see #240) — except for a BORN-ENDED row, whose stated `validTo` at or before
998
+ * the write instant leaves it with no lower bound at all (see #407) — and
999
+ * export/import round-trip a still-open-left `valid_from` (a born-ended row, or
1000
+ * one that predates the #240 fix) as an explicit `null` rather than silently
1001
+ * dropping it — see `InterchangeNodeSchema.validFrom`'s doc.
973
1002
  * Without either half of this, the clone's re-import would re-stamp the
974
1003
  * affected base rows to the CLONE's creation instant instead — narrowing
975
1004
  * their validity window and making `asOf` reads on the fork diverge from
@@ -1085,6 +1114,27 @@ declare function cloneWorkingCopyStrategy<G extends GraphDef>(makeBackend: MakeB
1085
1114
  */
1086
1115
  declare function branch<G extends GraphDef>(baseStore: GraphBranch<G>["store"], makeBackend: MakeBackend, options?: BranchOptions, strategy?: WorkingCopyStrategy<G>): Promise<Result<GraphBranch<G>, BranchError>>;
1087
1116
 
1117
+ /**
1118
+ * Constraint-aware working copies for untrusted ingestion.
1119
+ *
1120
+ * An ingestion branch persists a mechanically-derived schema with node
1121
+ * uniqueness declarations removed. That lets aliases reach merge planning,
1122
+ * where canonical candidate generation and final resolved-write validation use
1123
+ * the canonical graph's constraints. Every other working-copy constraint stays
1124
+ * active during staging.
1125
+ */
1126
+
1127
+ /**
1128
+ * Creates an isolated ingestion branch whose node uniqueness constraints are
1129
+ * deferred until the resolved merge write set is applied.
1130
+ *
1131
+ * The returned handle deliberately exposes no ordinary Store. Its typed node
1132
+ * and edge collections are sufficient to stage and inspect incoming data, and
1133
+ * merge entrypoints accept the handle directly. Call `close()` when the working
1134
+ * copy is no longer needed.
1135
+ */
1136
+ declare function ingestionBranch<G extends GraphDef>(baseStore: GraphBranch<G>["store"], makeBackend: MakeBackend, options?: BranchOptions): Promise<Result<IngestionBranch<G>, BranchError>>;
1137
+
1088
1138
  /**
1089
1139
  * The shared SCORING stage (design §4, the single match-decision point).
1090
1140
  *
@@ -1379,7 +1429,7 @@ type MergePlanArtifact = MergePlanArtifactV1;
1379
1429
  type MergePlanArtifactV1Input = Omit<MergePlanArtifactV1, "digest">;
1380
1430
 
1381
1431
  /** 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>>;
1432
+ declare function planMerge<G extends GraphDef>(store: Store<G>, branchInputs: readonly MergeBranch<G>[], optionsInput?: MergeOptions<G>): Promise<Result<MergePlanArtifact, MergeError>>;
1383
1433
  /** Builds a durable, reviewable incremental merge plan without mutating the target. */
1384
1434
  declare function planMergeIncremental<G extends GraphDef>(args: MergeIncrementalArgs<G>): Promise<Result<MergePlanArtifact, MergeError>>;
1385
1435
  /** Validates and atomically applies an approved serialized merge plan. */
@@ -1408,7 +1458,7 @@ declare function applyMergePlan<G extends GraphDef>(target: Store<G>, input: Mer
1408
1458
  * report and committed graph are identical across any permutation.
1409
1459
  * @param optionsInput Caller-facing {@link MergeOptions}; normalized internally.
1410
1460
  */
1411
- declare function merge<G extends GraphDef>(store: Store<G>, branches: readonly GraphBranch<G>[], optionsInput?: MergeOptions<G>): Promise<Result<MergeReport<G>, MergeError>>;
1461
+ declare function merge<G extends GraphDef>(store: Store<G>, branchInputs: readonly MergeBranch<G>[], optionsInput?: MergeOptions<G>): Promise<Result<MergeReport<G>, MergeError>>;
1412
1462
  /**
1413
1463
  * Incremental merge — the public fork-point-vs-live-target entry point (design
1414
1464
  * §6.4-B / §6.6). It treats `forkPoint` as the immutable ancestor, folds the live
@@ -1722,4 +1772,4 @@ type KeylessConfig = Readonly<{
1722
1772
  sortFields: readonly string[];
1723
1773
  }>;
1724
1774
 
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 };
1775
+ 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, type IngestionBranch, 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,14 @@
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 { a as Store, aP as Node, ce as UniqueIntrospection } from '../store-UzrGvZOo.js';
4
+ import { aj as TypeGraphError, ak as TypeGraphErrorOptions } from '../index-D7d1u2gr.js';
5
5
  import { R as Result } from '../result-DWo6mUVz.js';
6
6
  export { i as isErr, a as isOk, u as unwrap } from '../result-DWo6mUVz.js';
7
7
  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';
8
+ import '../temporal-CbnLzTmM.js';
9
+ import '../searchable-bpE1bBfc.js';
10
+ import '../manager-D9eRT_ns.js';
11
+ import '../materialize-indexes-DJ3ykH59.js';
12
12
 
13
13
  /**
14
14
  * The composite MERGE IDENTITY key for a node: the pair `(kind, id)`.
@@ -200,6 +200,33 @@ type GraphBranch<G extends GraphDef> = Readonly<{
200
200
  hash: string;
201
201
  }> | undefined;
202
202
  }>;
203
+ declare const INGESTION_BRANCH_BRAND: unique symbol;
204
+ /**
205
+ * Node collections exposed by an {@link IngestionBranch}. They retain normal
206
+ * validation, reads, and staging writes, but omit APIs that claim a declared
207
+ * uniqueness constraint exists on the relaxed physical working copy.
208
+ */
209
+ type IngestionNodeCollections<G extends GraphDef> = Readonly<{
210
+ [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">;
211
+ }>;
212
+ /**
213
+ * Opaque handle for an untrusted ingestion working copy.
214
+ *
215
+ * The ordinary {@link Store} is intentionally absent: callers may stage and
216
+ * inspect graph data through the typed collections, then pass this handle to
217
+ * merge planning, but cannot access schema evolution, transactions, or runtime
218
+ * internals. `close()` releases the private working-copy backend.
219
+ */
220
+ type IngestionBranch<G extends GraphDef> = Readonly<{
221
+ [INGESTION_BRANCH_BRAND]: true;
222
+ id: BranchId;
223
+ base: BaseVersion;
224
+ nodes: IngestionNodeCollections<G>;
225
+ edges: Store<G>["edges"];
226
+ close: () => Promise<void>;
227
+ }>;
228
+ /** A normal branch or an opaque ingestion branch accepted by merge entrypoints. */
229
+ type MergeBranch<G extends GraphDef> = GraphBranch<G> | IngestionBranch<G>;
203
230
  /**
204
231
  * Options for {@link GraphBranch} creation. `id` is optional — when omitted a
205
232
  * fresh id is generated.
@@ -470,7 +497,7 @@ type MergeOptions<G extends GraphDef = GraphDef> = Readonly<{
470
497
  type MergeIncrementalArgs<G extends GraphDef = GraphDef> = Readonly<{
471
498
  forkPoint: Store<G>;
472
499
  target: Store<G>;
473
- branches: readonly GraphBranch<G>[];
500
+ branches: readonly MergeBranch<G>[];
474
501
  options?: Omit<MergeOptions<G>, "target">;
475
502
  }>;
476
503
  /**
@@ -967,9 +994,11 @@ declare class MatchEvidenceError extends MergeError {
967
994
  * `includeTemporal: true` carries `validFrom`/`validTo` through unchanged,
968
995
  * preserving the base's exact valid-time window on the clone: create-time
969
996
  * 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.
997
+ * (see #240) — except for a BORN-ENDED row, whose stated `validTo` at or before
998
+ * the write instant leaves it with no lower bound at all (see #407) — and
999
+ * export/import round-trip a still-open-left `valid_from` (a born-ended row, or
1000
+ * one that predates the #240 fix) as an explicit `null` rather than silently
1001
+ * dropping it — see `InterchangeNodeSchema.validFrom`'s doc.
973
1002
  * Without either half of this, the clone's re-import would re-stamp the
974
1003
  * affected base rows to the CLONE's creation instant instead — narrowing
975
1004
  * their validity window and making `asOf` reads on the fork diverge from
@@ -1085,6 +1114,27 @@ declare function cloneWorkingCopyStrategy<G extends GraphDef>(makeBackend: MakeB
1085
1114
  */
1086
1115
  declare function branch<G extends GraphDef>(baseStore: GraphBranch<G>["store"], makeBackend: MakeBackend, options?: BranchOptions, strategy?: WorkingCopyStrategy<G>): Promise<Result<GraphBranch<G>, BranchError>>;
1087
1116
 
1117
+ /**
1118
+ * Constraint-aware working copies for untrusted ingestion.
1119
+ *
1120
+ * An ingestion branch persists a mechanically-derived schema with node
1121
+ * uniqueness declarations removed. That lets aliases reach merge planning,
1122
+ * where canonical candidate generation and final resolved-write validation use
1123
+ * the canonical graph's constraints. Every other working-copy constraint stays
1124
+ * active during staging.
1125
+ */
1126
+
1127
+ /**
1128
+ * Creates an isolated ingestion branch whose node uniqueness constraints are
1129
+ * deferred until the resolved merge write set is applied.
1130
+ *
1131
+ * The returned handle deliberately exposes no ordinary Store. Its typed node
1132
+ * and edge collections are sufficient to stage and inspect incoming data, and
1133
+ * merge entrypoints accept the handle directly. Call `close()` when the working
1134
+ * copy is no longer needed.
1135
+ */
1136
+ declare function ingestionBranch<G extends GraphDef>(baseStore: GraphBranch<G>["store"], makeBackend: MakeBackend, options?: BranchOptions): Promise<Result<IngestionBranch<G>, BranchError>>;
1137
+
1088
1138
  /**
1089
1139
  * The shared SCORING stage (design §4, the single match-decision point).
1090
1140
  *
@@ -1379,7 +1429,7 @@ type MergePlanArtifact = MergePlanArtifactV1;
1379
1429
  type MergePlanArtifactV1Input = Omit<MergePlanArtifactV1, "digest">;
1380
1430
 
1381
1431
  /** 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>>;
1432
+ declare function planMerge<G extends GraphDef>(store: Store<G>, branchInputs: readonly MergeBranch<G>[], optionsInput?: MergeOptions<G>): Promise<Result<MergePlanArtifact, MergeError>>;
1383
1433
  /** Builds a durable, reviewable incremental merge plan without mutating the target. */
1384
1434
  declare function planMergeIncremental<G extends GraphDef>(args: MergeIncrementalArgs<G>): Promise<Result<MergePlanArtifact, MergeError>>;
1385
1435
  /** Validates and atomically applies an approved serialized merge plan. */
@@ -1408,7 +1458,7 @@ declare function applyMergePlan<G extends GraphDef>(target: Store<G>, input: Mer
1408
1458
  * report and committed graph are identical across any permutation.
1409
1459
  * @param optionsInput Caller-facing {@link MergeOptions}; normalized internally.
1410
1460
  */
1411
- declare function merge<G extends GraphDef>(store: Store<G>, branches: readonly GraphBranch<G>[], optionsInput?: MergeOptions<G>): Promise<Result<MergeReport<G>, MergeError>>;
1461
+ declare function merge<G extends GraphDef>(store: Store<G>, branchInputs: readonly MergeBranch<G>[], optionsInput?: MergeOptions<G>): Promise<Result<MergeReport<G>, MergeError>>;
1412
1462
  /**
1413
1463
  * Incremental merge — the public fork-point-vs-live-target entry point (design
1414
1464
  * §6.4-B / §6.6). It treats `forkPoint` as the immutable ancestor, folds the live
@@ -1722,4 +1772,4 @@ type KeylessConfig = Readonly<{
1722
1772
  sortFields: readonly string[];
1723
1773
  }>;
1724
1774
 
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 };
1775
+ 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, type IngestionBranch, 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 } from '../chunk-AX6JGVTZ.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,53 @@ 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
+ async function ingestionBranch(baseStore, makeBackend, options) {
2017
+ try {
2018
+ const created = await branch(
2019
+ baseStore,
2020
+ makeBackend,
2021
+ options,
2022
+ cloneIngestionWorkingCopyStrategy(makeBackend)
2023
+ );
2024
+ if (isErr(created)) {
2025
+ return err(
2026
+ new BranchError("Failed to create constraint-aware ingestion branch", {
2027
+ cause: created.error
2028
+ })
2029
+ );
2030
+ }
2031
+ const privateBranch = created.data;
2032
+ const { base, id, store } = privateBranch;
2033
+ const handle = Object.freeze({
2034
+ id,
2035
+ base,
2036
+ nodes: store.nodes,
2037
+ edges: store.edges,
2038
+ close: async () => storeBackend(store).close()
2039
+ });
2040
+ PRIVATE_BRANCHES.set(handle, privateBranch);
2041
+ return ok(handle);
2042
+ } catch (error) {
2043
+ return err(
2044
+ new BranchError("Failed to create constraint-aware ingestion branch", {
2045
+ cause: error
2046
+ })
2047
+ );
2048
+ }
2049
+ }
2050
+ function unwrapMergeBranch(input) {
2051
+ const privateBranch = PRIVATE_BRANCHES.get(input);
2052
+ if (privateBranch !== void 0) {
2053
+ return privateBranch;
2054
+ }
2055
+ return input;
2056
+ }
2057
+ function unwrapMergeBranches(inputs) {
2058
+ return inputs.map((input) => unwrapMergeBranch(input));
2059
+ }
2060
+
1978
2061
  // src/graph-merge/blocking.ts
1979
2062
  var UNBLOCKED_BUCKET_KEY = "unblocked";
1980
2063
  var KEY_PART_SEPARATOR = "\0";
@@ -6658,20 +6741,67 @@ function nodeWriteWindowOptions(write) {
6658
6741
  ...write.validTo === void 0 ? {} : { validTo: write.validTo }
6659
6742
  };
6660
6743
  }
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();
6744
+ async function applyNodeRows(target, txBackend, nodesApi, deletions, upserts) {
6745
+ const afterImages = /* @__PURE__ */ new Map();
6746
+ const upsertsByKind = /* @__PURE__ */ new Map();
6666
6747
  for (const upsert of upserts) {
6667
- await nodeCollection(nodesApi, upsert.kind).upsertByIdFromRecord(
6668
- upsert.id,
6669
- upsert.props,
6670
- nodeWriteWindowOptions(upsert)
6748
+ const items = upsertsByKind.get(upsert.kind);
6749
+ if (items === void 0) upsertsByKind.set(upsert.kind, [upsert]);
6750
+ else items.push(upsert);
6751
+ }
6752
+ for (const [kind, items] of upsertsByKind) {
6753
+ const currentRows = await nodeCollection(nodesApi, kind).getByIds(
6754
+ items.map((item) => item.id),
6755
+ INCLUDE_TOMBSTONES
6671
6756
  );
6672
- committed.add(mergeKey(upsert.kind, upsert.id));
6757
+ const currentById = /* @__PURE__ */ new Map();
6758
+ for (const node of currentRows) {
6759
+ if (node !== void 0) currentById.set(node.id, nodeProps2(node));
6760
+ }
6761
+ for (const item of items) {
6762
+ const props = createDataKeyedBag();
6763
+ const unset = new Set(
6764
+ Object.entries(item.props).filter(([, value]) => value === void 0).map(([key]) => key)
6765
+ );
6766
+ for (const [key, value] of Object.entries(
6767
+ currentById.get(item.id) ?? {}
6768
+ )) {
6769
+ if (!unset.has(key)) props[key] = value;
6770
+ }
6771
+ for (const [key, value] of Object.entries(item.props)) {
6772
+ if (value !== void 0) props[key] = value;
6773
+ }
6774
+ afterImages.set(mergeKey(kind, item.id), props);
6775
+ }
6673
6776
  }
6674
- return committed.size;
6777
+ return storeRuntime(target).applyResolvedNodeUniqueness(
6778
+ txBackend,
6779
+ {
6780
+ upserts: upserts.map((upsert) => ({
6781
+ kind: upsert.kind,
6782
+ id: upsert.id,
6783
+ props: requireDefined(
6784
+ afterImages.get(mergeKey(upsert.kind, upsert.id))
6785
+ )
6786
+ })),
6787
+ releases: deletions
6788
+ },
6789
+ async () => {
6790
+ for (const deletion of deletions) {
6791
+ await nodeCollection(nodesApi, deletion.kind).delete(deletion.id);
6792
+ }
6793
+ const committed = /* @__PURE__ */ new Set();
6794
+ for (const upsert of upserts) {
6795
+ await nodeCollection(nodesApi, upsert.kind).upsertByIdFromRecord(
6796
+ upsert.id,
6797
+ upsert.props,
6798
+ nodeWriteWindowOptions(upsert)
6799
+ );
6800
+ committed.add(mergeKey(upsert.kind, upsert.id));
6801
+ }
6802
+ return committed.size;
6803
+ }
6804
+ );
6675
6805
  }
6676
6806
  async function applyEdgeRows(edgesApi, deletions, upserts) {
6677
6807
  for (const deletion of deletions) {
@@ -6732,7 +6862,13 @@ async function applyInternalMergePlan(plan, nodesApi, edgesApi, target, txBacken
6732
6862
  );
6733
6863
  let committedNodes;
6734
6864
  try {
6735
- committedNodes = await applyNodeRows(nodesApi, nodeDeletions, nodeUpserts);
6865
+ committedNodes = await applyNodeRows(
6866
+ target,
6867
+ txBackend,
6868
+ nodesApi,
6869
+ nodeDeletions,
6870
+ nodeUpserts
6871
+ );
6736
6872
  } catch (error) {
6737
6873
  throw error instanceof IdentityEndpointValidityError ? translateIdentityCommitError(error) : error;
6738
6874
  }
@@ -7396,7 +7532,8 @@ function incrementalSchemaError() {
7396
7532
  { details: {} }
7397
7533
  );
7398
7534
  }
7399
- async function planMerge(store, branches, optionsInput = {}) {
7535
+ async function planMerge(store, branchInputs, optionsInput = {}) {
7536
+ const branches = unwrapMergeBranches(branchInputs);
7400
7537
  const normalized = tryNormalize(optionsInput);
7401
7538
  if (isErr(normalized)) return err(normalized.error);
7402
7539
  const options = normalized.data;
@@ -7437,7 +7574,8 @@ async function planMerge(store, branches, optionsInput = {}) {
7437
7574
  );
7438
7575
  }
7439
7576
  async function planMergeIncremental(args) {
7440
- const { forkPoint, target, branches } = args;
7577
+ const { forkPoint, target } = args;
7578
+ const branches = unwrapMergeBranches(args.branches);
7441
7579
  const normalized = tryNormalize(args.options ?? {}, ["target"]);
7442
7580
  if (isErr(normalized)) return err(normalized.error);
7443
7581
  const options = normalized.data;
@@ -7878,6 +8016,8 @@ function identityConsistencySeeds(artifact, profile) {
7878
8016
  }
7879
8017
  async function applyWireMergeWrites(target, nodesApi, edgesApi, txBackend, artifact) {
7880
8018
  const committedNodes = await applyNodeRows(
8019
+ target,
8020
+ txBackend,
7881
8021
  nodesApi,
7882
8022
  artifact.writes.nodeDeletes,
7883
8023
  artifact.writes.nodeUpserts.map((upsert) => ({
@@ -8050,7 +8190,8 @@ async function applyMergePlan(target, input) {
8050
8190
  );
8051
8191
  }
8052
8192
  }
8053
- async function merge(store, branches, optionsInput = {}) {
8193
+ async function merge(store, branchInputs, optionsInput = {}) {
8194
+ const branches = unwrapMergeBranches(branchInputs);
8054
8195
  const normalized = tryNormalize(optionsInput);
8055
8196
  if (isErr(normalized)) {
8056
8197
  return err(normalized.error);
@@ -8527,7 +8668,8 @@ async function commitIncrementalPlan(target, plan, guard) {
8527
8668
  );
8528
8669
  }
8529
8670
  async function mergeIncremental(args) {
8530
- const { forkPoint, target, branches } = args;
8671
+ const { forkPoint, target } = args;
8672
+ const branches = unwrapMergeBranches(args.branches);
8531
8673
  const normalized = tryNormalize(args.options ?? {}, ["target"]);
8532
8674
  if (isErr(normalized)) {
8533
8675
  return err(normalized.error);
@@ -8571,6 +8713,6 @@ async function mergeIncremental(args) {
8571
8713
  );
8572
8714
  }
8573
8715
 
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 };
8716
+ 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
8717
  //# sourceMappingURL=index.js.map
8576
8718
  //# sourceMappingURL=index.js.map