@nicia-ai/typegraph 0.36.0 → 0.37.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.
- package/dist/backend/postgres/index.cjs +24 -24
- package/dist/backend/postgres/index.d.cts +6 -6
- package/dist/backend/postgres/index.d.ts +6 -6
- package/dist/backend/postgres/index.js +11 -11
- package/dist/backend/postgres/pglite.cjs +16 -16
- package/dist/backend/postgres/pglite.d.cts +3 -3
- package/dist/backend/postgres/pglite.d.ts +3 -3
- package/dist/backend/postgres/pglite.js +11 -11
- package/dist/backend/sqlite/index.cjs +22 -21
- package/dist/backend/sqlite/index.d.cts +11 -9
- package/dist/backend/sqlite/index.d.ts +11 -9
- package/dist/backend/sqlite/index.js +10 -9
- package/dist/backend/sqlite/libsql.cjs +15 -14
- package/dist/backend/sqlite/libsql.cjs.map +1 -1
- package/dist/backend/sqlite/libsql.d.cts +3 -3
- package/dist/backend/sqlite/libsql.d.ts +3 -3
- package/dist/backend/sqlite/libsql.js +11 -10
- package/dist/backend/sqlite/libsql.js.map +1 -1
- package/dist/backend/sqlite/local.cjs +30 -23
- package/dist/backend/sqlite/local.cjs.map +1 -1
- package/dist/backend/sqlite/local.d.cts +3 -3
- package/dist/backend/sqlite/local.d.ts +3 -3
- package/dist/backend/sqlite/local.js +18 -11
- package/dist/backend/sqlite/local.js.map +1 -1
- package/dist/{chunk-TCOCYN2P.cjs → chunk-27SSDCEP.cjs} +14 -14
- package/dist/{chunk-TCOCYN2P.cjs.map → chunk-27SSDCEP.cjs.map} +1 -1
- package/dist/{chunk-5AQIKK56.cjs → chunk-2N6EOBTH.cjs} +16 -16
- package/dist/{chunk-5AQIKK56.cjs.map → chunk-2N6EOBTH.cjs.map} +1 -1
- package/dist/{chunk-FN35DLCN.cjs → chunk-3C2RYI6L.cjs} +13 -107
- package/dist/chunk-3C2RYI6L.cjs.map +1 -0
- package/dist/{chunk-HW3LW7DH.cjs → chunk-3DS7Z4T4.cjs} +39 -39
- package/dist/{chunk-HW3LW7DH.cjs.map → chunk-3DS7Z4T4.cjs.map} +1 -1
- package/dist/{chunk-RSSQKPSZ.cjs → chunk-3GH67G4Z.cjs} +5 -5
- package/dist/{chunk-RSSQKPSZ.cjs.map → chunk-3GH67G4Z.cjs.map} +1 -1
- package/dist/{chunk-M75SUBFG.js → chunk-3RWZPJKV.js} +24 -9
- package/dist/chunk-3RWZPJKV.js.map +1 -0
- package/dist/{chunk-SKCOUWAX.js → chunk-3SLPDKHQ.js} +4 -4
- package/dist/chunk-3SLPDKHQ.js.map +1 -0
- package/dist/{chunk-5A6FNS6N.cjs → chunk-3XXGYU62.cjs} +11 -11
- package/dist/{chunk-5A6FNS6N.cjs.map → chunk-3XXGYU62.cjs.map} +1 -1
- package/dist/{chunk-IU46OHVW.js → chunk-44TA22QT.js} +58 -11
- package/dist/chunk-44TA22QT.js.map +1 -0
- package/dist/{chunk-5DIPR3L3.js → chunk-552KNYQJ.js} +2392 -279
- package/dist/chunk-552KNYQJ.js.map +1 -0
- package/dist/{chunk-2THZ3TQI.cjs → chunk-5KEQ74YU.cjs} +14 -14
- package/dist/chunk-5KEQ74YU.cjs.map +1 -0
- package/dist/{chunk-Q5TEXCTB.js → chunk-5KPNWT6X.js} +3 -3
- package/dist/{chunk-Q5TEXCTB.js.map → chunk-5KPNWT6X.js.map} +1 -1
- package/dist/{chunk-WI7ISNQF.js → chunk-5PNMDJ7J.js} +94 -5
- package/dist/chunk-5PNMDJ7J.js.map +1 -0
- package/dist/{chunk-AW4A3P5A.cjs → chunk-5VQM6VWP.cjs} +2 -2
- package/dist/{chunk-AW4A3P5A.cjs.map → chunk-5VQM6VWP.cjs.map} +1 -1
- package/dist/{chunk-A3W7QG7K.js → chunk-5WWVZMVX.js} +2 -2
- package/dist/{chunk-A3W7QG7K.js.map → chunk-5WWVZMVX.js.map} +1 -1
- package/dist/{chunk-FACJJWGF.cjs → chunk-6EEO3OVU.cjs} +7 -7
- package/dist/{chunk-FACJJWGF.cjs.map → chunk-6EEO3OVU.cjs.map} +1 -1
- package/dist/{chunk-DIK74MXX.cjs → chunk-BVRDGYXQ.cjs} +97 -4
- package/dist/chunk-BVRDGYXQ.cjs.map +1 -0
- package/dist/{chunk-4BCU6VFZ.cjs → chunk-DEFQM7JU.cjs} +7 -7
- package/dist/{chunk-4BCU6VFZ.cjs.map → chunk-DEFQM7JU.cjs.map} +1 -1
- package/dist/{chunk-456Z2U7Y.cjs → chunk-DIQ3AV5W.cjs} +574 -268
- package/dist/chunk-DIQ3AV5W.cjs.map +1 -0
- package/dist/{chunk-FPIZFYHE.js → chunk-EXU3RASM.js} +74 -15
- package/dist/chunk-EXU3RASM.js.map +1 -0
- package/dist/{chunk-H7YNSMA7.cjs → chunk-HAHNRASW.cjs} +20 -2
- package/dist/chunk-HAHNRASW.cjs.map +1 -0
- package/dist/{chunk-J3LEGNQB.cjs → chunk-IP3CGGPA.cjs} +8 -8
- package/dist/{chunk-J3LEGNQB.cjs.map → chunk-IP3CGGPA.cjs.map} +1 -1
- package/dist/{chunk-X4JBT642.cjs → chunk-IPSVVTWT.cjs} +94 -35
- package/dist/chunk-IPSVVTWT.cjs.map +1 -0
- package/dist/{chunk-VQEXF5D4.js → chunk-IXGYRP2P.js} +184 -92
- package/dist/chunk-IXGYRP2P.js.map +1 -0
- package/dist/{chunk-BJVEU3ZL.js → chunk-J4IUSYFF.js} +251 -121
- package/dist/chunk-J4IUSYFF.js.map +1 -0
- package/dist/{chunk-JFMEONLG.cjs → chunk-JBNOGRKW.cjs} +318 -188
- package/dist/chunk-JBNOGRKW.cjs.map +1 -0
- package/dist/{chunk-4GX2JJXS.js → chunk-K3Q3LJY3.js} +520 -221
- package/dist/chunk-K3Q3LJY3.js.map +1 -0
- package/dist/{chunk-OR5ZA5WP.js → chunk-K5UBVGJN.js} +4 -4
- package/dist/{chunk-OR5ZA5WP.js.map → chunk-K5UBVGJN.js.map} +1 -1
- package/dist/{chunk-UZV3AZKF.js → chunk-KQJ54OG5.js} +3 -3
- package/dist/{chunk-UZV3AZKF.js.map → chunk-KQJ54OG5.js.map} +1 -1
- package/dist/{chunk-SXGE7ITL.js → chunk-L7HQ2OSI.js} +4 -4
- package/dist/{chunk-SXGE7ITL.js.map → chunk-L7HQ2OSI.js.map} +1 -1
- package/dist/{chunk-RAXU3RMB.js → chunk-M6VES7V6.js} +4 -4
- package/dist/{chunk-RAXU3RMB.js.map → chunk-M6VES7V6.js.map} +1 -1
- package/dist/{chunk-7BQLPXK6.cjs → chunk-NBP2WTJW.cjs} +3011 -898
- package/dist/chunk-NBP2WTJW.cjs.map +1 -0
- package/dist/{chunk-PWGX5DF5.cjs → chunk-NUIG3BCV.cjs} +100 -85
- package/dist/chunk-NUIG3BCV.cjs.map +1 -0
- package/dist/{chunk-ZAMFOJ5P.cjs → chunk-NXQFATMF.cjs} +269 -177
- package/dist/chunk-NXQFATMF.cjs.map +1 -0
- package/dist/{chunk-KBGQIPRQ.js → chunk-PC2UBAUB.js} +20 -3
- package/dist/chunk-PC2UBAUB.js.map +1 -0
- package/dist/chunk-QARBLBXT.cjs +219 -0
- package/dist/chunk-QARBLBXT.cjs.map +1 -0
- package/dist/{chunk-6FR2MMS6.js → chunk-QERAIDRJ.js} +45 -4
- package/dist/chunk-QERAIDRJ.js.map +1 -0
- package/dist/chunk-QSXTWU4U.cjs +12 -0
- package/dist/{chunk-4BMPGT35.cjs.map → chunk-QSXTWU4U.cjs.map} +1 -1
- package/dist/{chunk-DN5VP4JC.js → chunk-RCVLFTCT.js} +9 -10
- package/dist/chunk-RCVLFTCT.js.map +1 -0
- package/dist/{chunk-ZIGXMKQQ.js → chunk-RRSNR3TP.js} +3 -3
- package/dist/{chunk-ZIGXMKQQ.js.map → chunk-RRSNR3TP.js.map} +1 -1
- package/dist/{chunk-4CAXEB2F.cjs → chunk-TGOMW4MB.cjs} +91 -92
- package/dist/chunk-TGOMW4MB.cjs.map +1 -0
- package/dist/{chunk-PZKNKG5M.js → chunk-TKT2XHED.js} +8 -8
- package/dist/{chunk-PZKNKG5M.js.map → chunk-TKT2XHED.js.map} +1 -1
- package/dist/{chunk-S5F7ZLP2.js → chunk-TPF25IG6.js} +3 -3
- package/dist/{chunk-S5F7ZLP2.js.map → chunk-TPF25IG6.js.map} +1 -1
- package/dist/{chunk-5SEGFTZX.js → chunk-UGZUAYAR.js} +3 -3
- package/dist/{chunk-5SEGFTZX.js.map → chunk-UGZUAYAR.js.map} +1 -1
- package/dist/{chunk-VHMPG6UL.js → chunk-UXLSNRYL.js} +11 -105
- package/dist/chunk-UXLSNRYL.js.map +1 -0
- package/dist/{chunk-FRV5Q5IO.js → chunk-UYQMBBWJ.js} +3 -3
- package/dist/{chunk-FRV5Q5IO.js.map → chunk-UYQMBBWJ.js.map} +1 -1
- package/dist/{chunk-UUT7UN2N.cjs → chunk-VGDDG3XJ.cjs} +7 -7
- package/dist/{chunk-UUT7UN2N.cjs.map → chunk-VGDDG3XJ.cjs.map} +1 -1
- package/dist/{chunk-5VTR2F2K.js → chunk-VKGKDOKR.js} +12 -10
- package/dist/chunk-VKGKDOKR.js.map +1 -0
- package/dist/{chunk-5W4L6DLF.cjs → chunk-VL2V6PEN.cjs} +11 -11
- package/dist/{chunk-5W4L6DLF.cjs.map → chunk-VL2V6PEN.cjs.map} +1 -1
- package/dist/{chunk-ZUNQ5BEP.cjs → chunk-WOJMKB3N.cjs} +82 -80
- package/dist/chunk-WOJMKB3N.cjs.map +1 -0
- package/dist/{chunk-UMDVATGY.cjs → chunk-WWFHO375.cjs} +6 -6
- package/dist/{chunk-UMDVATGY.cjs.map → chunk-WWFHO375.cjs.map} +1 -1
- package/dist/{chunk-JFUPDJXD.js → chunk-XGPUQ56G.js} +3 -3
- package/dist/{chunk-JFUPDJXD.js.map → chunk-XGPUQ56G.js.map} +1 -1
- package/dist/{chunk-D7ZEOS56.cjs → chunk-XGU7DZDA.cjs} +74 -14
- package/dist/chunk-XGU7DZDA.cjs.map +1 -0
- package/dist/{chunk-S55OV6PW.cjs → chunk-XPCZADMT.cjs} +54 -11
- package/dist/chunk-XPCZADMT.cjs.map +1 -0
- package/dist/{chunk-T2WUSPDA.js → chunk-XWV4JT34.js} +3 -3
- package/dist/{chunk-T2WUSPDA.js.map → chunk-XWV4JT34.js.map} +1 -1
- package/dist/chunk-YTSN73ND.js +212 -0
- package/dist/chunk-YTSN73ND.js.map +1 -0
- package/dist/{ddl-CZz7a0E8.d.cts → ddl-BD-ZfKeX.d.cts} +3 -3
- package/dist/{ddl-C2rZ-Aen.d.ts → ddl-CS0KUVwB.d.ts} +3 -3
- package/dist/{extension-types-ixRpJVUp.d.ts → extension-types-BM2ACfYO.d.cts} +6 -1
- package/dist/{extension-types-ixRpJVUp.d.cts → extension-types-BM2ACfYO.d.ts} +6 -1
- package/dist/{fulltext-strategy-CDkSSYhq.d.cts → fulltext-strategy-C27vXaeB.d.cts} +127 -8
- package/dist/{fulltext-strategy-B57yvC5Q.d.ts → fulltext-strategy-DebsMrqg.d.ts} +127 -8
- package/dist/graph-extension/index.cjs +19 -19
- package/dist/graph-extension/index.d.cts +4 -4
- package/dist/graph-extension/index.d.ts +4 -4
- package/dist/graph-extension/index.js +4 -4
- package/dist/graph-merge/index.cjs +88 -88
- package/dist/graph-merge/index.d.cts +6 -6
- package/dist/graph-merge/index.d.ts +6 -6
- package/dist/graph-merge/index.js +19 -19
- package/dist/{index-BLtQWKRj.d.cts → index-BPM59vsg.d.cts} +52 -7
- package/dist/{index-BFvdmBPV.d.ts → index-BeacbPoe.d.ts} +52 -7
- package/dist/index.cjs +224 -187
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -11
- package/dist/index.d.ts +11 -11
- package/dist/index.js +53 -40
- package/dist/index.js.map +1 -1
- package/dist/indexes/index.cjs +30 -21
- package/dist/indexes/index.d.cts +5 -5
- package/dist/indexes/index.d.ts +5 -5
- package/dist/indexes/index.js +8 -7
- package/dist/interchange/index.cjs +207 -30
- package/dist/interchange/index.cjs.map +1 -1
- package/dist/interchange/index.d.cts +25 -8
- package/dist/interchange/index.d.ts +25 -8
- package/dist/interchange/index.js +190 -11
- package/dist/interchange/index.js.map +1 -1
- package/dist/{manager-DwQi8eV0.d.cts → manager-D00_NXvT.d.ts} +11 -2
- package/dist/{manager-ejUCB52T.d.ts → manager-nU1vTJLy.d.cts} +11 -2
- package/dist/{materialize-indexes-B4e9360H.d.cts → materialize-indexes-CuR3gAZb.d.cts} +8 -2
- package/dist/{materialize-indexes-te9TPMMJ.d.ts → materialize-indexes-zK2J_flP.d.ts} +8 -2
- package/dist/{postgres-CfEqsRMp.d.cts → postgres-IaBA4RgE.d.ts} +1 -1
- package/dist/{postgres-DQ5R6rzV.d.ts → postgres-YrYmPlaU.d.cts} +1 -1
- package/dist/profiler/index.cjs +3 -3
- package/dist/profiler/index.d.cts +7 -7
- package/dist/profiler/index.d.ts +7 -7
- package/dist/profiler/index.js +2 -2
- package/dist/provenance/index.cjs +32 -33
- package/dist/provenance/index.cjs.map +1 -1
- package/dist/provenance/index.d.cts +5 -5
- package/dist/provenance/index.d.ts +5 -5
- package/dist/provenance/index.js +5 -6
- package/dist/provenance/index.js.map +1 -1
- package/dist/schema/index.cjs +35 -35
- package/dist/schema/index.d.cts +7 -7
- package/dist/schema/index.d.ts +7 -7
- package/dist/schema/index.js +11 -11
- package/dist/{sqlite-DvQndLky.d.ts → sqlite-BUOHPx7p.d.ts} +1 -1
- package/dist/{sqlite-D7zBinNR.d.cts → sqlite-Pp8O19WE.d.cts} +1 -1
- package/dist/{store-view-DplHC3Nt.d.ts → store-view-ANL6mTph.d.ts} +213 -27
- package/dist/{store-view-9KDOpZzF.d.cts → store-view-X96Rd00T.d.cts} +213 -27
- package/dist/{types-Bv9DcS_E.d.cts → types-r-Zyq2Hz.d.cts} +2 -2
- package/dist/{types-CoxuV7EJ.d.ts → types-wsvuBgPK.d.ts} +2 -2
- package/dist/where-CJOpJj3a.d.ts +36 -0
- package/dist/where-K3uBP33l.d.cts +36 -0
- package/package.json +1 -1
- package/dist/chunk-2THZ3TQI.cjs.map +0 -1
- package/dist/chunk-456Z2U7Y.cjs.map +0 -1
- package/dist/chunk-4BMPGT35.cjs +0 -12
- package/dist/chunk-4CAXEB2F.cjs.map +0 -1
- package/dist/chunk-4GX2JJXS.js.map +0 -1
- package/dist/chunk-5DIPR3L3.js.map +0 -1
- package/dist/chunk-5VTR2F2K.js.map +0 -1
- package/dist/chunk-6FR2MMS6.js.map +0 -1
- package/dist/chunk-7BQLPXK6.cjs.map +0 -1
- package/dist/chunk-BJVEU3ZL.js.map +0 -1
- package/dist/chunk-D7ZEOS56.cjs.map +0 -1
- package/dist/chunk-DIK74MXX.cjs.map +0 -1
- package/dist/chunk-DN5VP4JC.js.map +0 -1
- package/dist/chunk-EOLERH7Y.cjs +0 -40
- package/dist/chunk-EOLERH7Y.cjs.map +0 -1
- package/dist/chunk-FN35DLCN.cjs.map +0 -1
- package/dist/chunk-FPIZFYHE.js.map +0 -1
- package/dist/chunk-H7YNSMA7.cjs.map +0 -1
- package/dist/chunk-IU46OHVW.js.map +0 -1
- package/dist/chunk-JFMEONLG.cjs.map +0 -1
- package/dist/chunk-KBGQIPRQ.js.map +0 -1
- package/dist/chunk-M75SUBFG.js.map +0 -1
- package/dist/chunk-PWGX5DF5.cjs.map +0 -1
- package/dist/chunk-S55OV6PW.cjs.map +0 -1
- package/dist/chunk-SKCOUWAX.js.map +0 -1
- package/dist/chunk-UT3S4SEN.js +0 -31
- package/dist/chunk-UT3S4SEN.js.map +0 -1
- package/dist/chunk-VHMPG6UL.js.map +0 -1
- package/dist/chunk-VQEXF5D4.js.map +0 -1
- package/dist/chunk-WI7ISNQF.js.map +0 -1
- package/dist/chunk-X4JBT642.cjs.map +0 -1
- package/dist/chunk-ZAMFOJ5P.cjs.map +0 -1
- package/dist/chunk-ZUNQ5BEP.cjs.map +0 -1
- package/dist/where-7RKFOsXt.d.ts +0 -11
- package/dist/where-DdMIXOtH.d.cts +0 -11
|
@@ -1 +1 @@
|
|
|
1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A,MAAM,iBAAkB,KAAA,CACrB,cAAA;AACH,EAAA,IAAI,CAAC,cAAA,EAAgB;AACnB,IAAA,MAAM,IAAI,kBAAA;AAAA,MACR,6EAAA;AAAA,MACA,EAAE,OAAA,EAAS,KAAA,CAAM,OAAA,EAAQ;AAAA,MACzB;AAAA,QACE,UAAA,EACE;AAAA;AACJ,KACF;AAAA,EACF;AACA,EAAA,MAAM,UAAA,GAAa,eAAA,CAAgB,KAAA,CAAM,KAAA,EAAO,MAAM,CAAA;AAItD,EAAA,MAAM,UAAA,GAAa,CACjB,OAAA,EACA,SAAA,KAEA,cAKE,KAAA,EAAO,UAAA,EAAY,SAAS,SAAS,CAAA;AAEzC,EAAA,OAAO;AAAA,IACL,SAAS,CAAC,MAAA,KAAW,WAAW,CAAC,MAAM,GAAG,IAAI,CAAA;AAAA,IAC9C,WAAA,EAAa,CAAC,OAAA,KAAY,UAAA,CAAW,SAAS,IAAI,CAAA;AAAA,IAClD,WAAW,CAAC,MAAA,KAAW,WAAW,CAAC,MAAM,GAAG,KAAK,CAAA;AAAA,IACjD,aAAA,EAAe,CAAC,OAAA,KAAY,UAAA,CAAW,SAAS,KAAK,CAAA;AAAA,IAErD,MAAM,OAAA,GAAU;AACd,MAAA,OAAO,KAAA,CAAM,WAAA,CAAY,OAAO,EAAA,KAAO;AAKrC,QAAA,MAAM,sBAAA,CAAuB,EAAA,CAAG,OAAA,EAAS,KAAA,CAAM,OAAO,CAAA;AACtD,QAAA,MAAM,WAAW,MAAM,cAAA;AAAA,UACrB,EAAA,CAAG,OAAA;AAAA,UACH,KAAA,CAAM,OAAA;AAAA,UACN;AAAA,SACF;AACA,QAAA,OAAO,gBAAA;AAAA,UACL,QAAA,CAAS;AAAA,SACX;AAAA,MACF,CAAC,CAAA;AAAA,IACH;AAAA,GACF;AACF","file":"index.js","sourcesContent":["import {\n type EdgeRow,\n type GraphReadBackend,\n isLiveNodeRow,\n isTombstonedNodeRow,\n type LiveNodeRow,\n type NodeRow,\n rowPropsToObject,\n type TombstonedNodeRow,\n} from \"../backend/types\";\nimport type { GraphDef } from \"../core/define-graph\";\nimport type { NodeRegistration } from \"../core/types\";\nimport { ConfigurationError, NodeNotFoundError } from \"../errors\";\nimport type {\n DynamicNodeCollection,\n HistorySafeTransactionBackend,\n HistoryStore,\n HistoryTransactionContext,\n} from \"../store\";\nimport {\n applyNodeResurrect,\n applyNodeSoftDelete,\n createNodeWriteContext,\n} from \"../store/operations/node-write-pipeline\";\nimport { lockRecordedGraphWrite } from \"../store/recorded-capture\";\nimport { type GraphWriteLock } from \"../store/recorded-capture/clock\";\nimport { compareStrings } from \"../utils/compare\";\nimport { nowIso } from \"../utils/date\";\nimport { isPlainObject } from \"../utils/object\";\n\nconst DEFAULT_RETRACTED_FIELD = \"retracted\";\nconst KEY_SEPARATOR = \"\\u0000\";\n\ntype NodeKind<G extends GraphDef> = Extract<keyof G[\"nodes\"], string>;\ntype EdgeKind<G extends GraphDef> = Extract<keyof G[\"edges\"], string>;\n\nexport type ProvenanceNodeRef<\n G extends GraphDef = GraphDef,\n K extends NodeKind<G> = NodeKind<G>,\n> = Readonly<{\n kind: K;\n id: string;\n}>;\n\nexport type ProvenanceJustificationRef<\n G extends GraphDef = GraphDef,\n K extends NodeKind<G> = NodeKind<G>,\n> = ProvenanceNodeRef<G, K>;\nexport type ProvenanceFactRef<\n G extends GraphDef = GraphDef,\n K extends NodeKind<G> = NodeKind<G>,\n> = ProvenanceNodeRef<G, K>;\n\ntype ProvenanceSourceConfig<G extends GraphDef = GraphDef> =\n | Readonly<{\n kind: NodeKind<G>;\n retractedField?: string;\n }>\n | Readonly<{\n kinds: readonly NodeKind<G>[];\n retractedField?: string;\n }>;\n\nexport type ProvenanceRetractionConfig<G extends GraphDef = GraphDef> =\n Readonly<{\n source: ProvenanceSourceConfig<G>;\n justification: Readonly<{ kind: NodeKind<G> }>;\n fact: Readonly<{ kinds: readonly NodeKind<G>[] }>;\n premiseOf: Readonly<{ kind: EdgeKind<G> }>;\n derives: Readonly<{ kind: EdgeKind<G> }>;\n }>;\n\n/**\n * Extracts the node kind(s) referenced by a provenance role config, whether\n * declared as a single `{ kind }` or a `{ kinds }` array. Falls back to the\n * full `NodeKind<G>` union when neither shape is present (e.g. a role config\n * that also carries unrelated fields, matched structurally).\n */\ntype KindsFromRef<G extends GraphDef, Ref> =\n Ref extends Readonly<{ kind: infer K }> ? Extract<K, NodeKind<G>>\n : Ref extends Readonly<{ kinds: readonly (infer K)[] }> ?\n Extract<K, NodeKind<G>>\n : NodeKind<G>;\n\ntype SourceKindsFromConfig<\n G extends GraphDef,\n C extends ProvenanceRetractionConfig<G>,\n> = KindsFromRef<G, C[\"source\"]>;\n\ntype FactKindsFromConfig<\n G extends GraphDef,\n C extends ProvenanceRetractionConfig<G>,\n> = KindsFromRef<G, C[\"fact\"]>;\n\ntype JustificationKindFromConfig<\n G extends GraphDef,\n C extends ProvenanceRetractionConfig<G>,\n> = KindsFromRef<G, C[\"justification\"]>;\n\nexport type SurvivedVia<\n G extends GraphDef = GraphDef,\n FactKind extends NodeKind<G> = NodeKind<G>,\n JustificationKind extends NodeKind<G> = NodeKind<G>,\n> = Readonly<{\n fact: ProvenanceFactRef<G, FactKind>;\n via: readonly ProvenanceJustificationRef<G, JustificationKind>[];\n}>;\n\nexport type RetractionReport<\n G extends GraphDef = GraphDef,\n FactKind extends NodeKind<G> = NodeKind<G>,\n JustificationKind extends NodeKind<G> = NodeKind<G>,\n> = Readonly<{\n died: readonly ProvenanceFactRef<G, FactKind>[];\n survivedVia: readonly SurvivedVia<G, FactKind, JustificationKind>[];\n unaffected: readonly ProvenanceFactRef<G, FactKind>[];\n}>;\n\nexport type RetractionCapability<\n G extends GraphDef = GraphDef,\n SourceKind extends NodeKind<G> = NodeKind<G>,\n FactKind extends NodeKind<G> = NodeKind<G>,\n JustificationKind extends NodeKind<G> = NodeKind<G>,\n> = Readonly<{\n retract: (\n source: ProvenanceNodeRef<G, SourceKind>,\n ) => Promise<RetractionReport<G, FactKind, JustificationKind>>;\n retractMany: (\n sources: readonly ProvenanceNodeRef<G, SourceKind>[],\n ) => Promise<RetractionReport<G, FactKind, JustificationKind>>;\n unRetract: (\n source: ProvenanceNodeRef<G, SourceKind>,\n ) => Promise<RetractionReport<G, FactKind, JustificationKind>>;\n unRetractMany: (\n sources: readonly ProvenanceNodeRef<G, SourceKind>[],\n ) => Promise<RetractionReport<G, FactKind, JustificationKind>>;\n holding: () => Promise<readonly ProvenanceFactRef<G, FactKind>[]>;\n}>;\n\ntype NormalizedConfig = Readonly<{\n sourceKinds: readonly string[];\n retractedField: string;\n justificationKind: string;\n factKinds: readonly string[];\n premiseOfKind: string;\n derivesKind: string;\n}>;\n\ntype ProvenanceRows = Readonly<{\n justifications: ReadonlyMap<string, NodeRow>;\n facts: ReadonlyMap<string, NodeRow>;\n premiseEdges: readonly EdgeRow[];\n deriveEdges: readonly EdgeRow[];\n}>;\n\ntype SupportEdges = Readonly<{\n premisesByJustification: ReadonlyMap<string, readonly string[]>;\n factsByJustification: ReadonlyMap<string, readonly string[]>;\n justificationsByPremise: ReadonlyMap<string, readonly string[]>;\n}>;\n\ntype SupportSnapshot = Readonly<{\n facts: ReadonlyMap<string, NodeRow>;\n supportedFactKeys: ReadonlySet<string>;\n believedFactKeys: ReadonlySet<string>;\n firingJustificationKeysByFact: ReadonlyMap<string, readonly string[]>;\n affectedFactKeys: (\n sources: readonly ProvenanceNodeRef[],\n ) => ReadonlySet<string>;\n}>;\n\ntype SourceRetractedState = \"retracted\" | \"available\";\n\ntype SourceRow<G extends GraphDef> = Readonly<{\n source: ProvenanceNodeRef<G>;\n row: NodeRow;\n}>;\n\nfunction refKey(ref: ProvenanceNodeRef): string {\n return `${ref.kind}${KEY_SEPARATOR}${ref.id}`;\n}\n\nfunction rowKey(row: Pick<NodeRow, \"kind\" | \"id\">): string {\n return refKey({ kind: row.kind, id: row.id });\n}\n\nfunction edgeFromKey(edge: EdgeRow): string {\n return refKey({ kind: edge.from_kind, id: edge.from_id });\n}\n\nfunction edgeToKey(edge: EdgeRow): string {\n return refKey({ kind: edge.to_kind, id: edge.to_id });\n}\n\nfunction keyToRef<\n G extends GraphDef = GraphDef,\n K extends NodeKind<G> = NodeKind<G>,\n>(key: string): ProvenanceNodeRef<G, K> {\n const separatorIndex = key.indexOf(KEY_SEPARATOR);\n if (separatorIndex === -1) {\n throw new ConfigurationError(\n \"Invalid provenance identity key.\",\n { key },\n {\n suggestion:\n \"Report this TypeGraph provenance bug with the graph roles that produced the key.\",\n },\n );\n }\n const kind = key.slice(0, separatorIndex);\n const id = key.slice(separatorIndex + KEY_SEPARATOR.length);\n return { kind, id } as ProvenanceNodeRef<G, K>;\n}\n\nfunction sortedReferences<\n G extends GraphDef = GraphDef,\n K extends NodeKind<G> = NodeKind<G>,\n>(keys: Iterable<string>): ProvenanceNodeRef<G, K>[] {\n return [...keys]\n .toSorted((left, right) => compareStrings(left, right))\n .map((key) => keyToRef<G, K>(key));\n}\n\nfunction parseNodeProps(row: NodeRow): Record<string, unknown> {\n const parsed = rowPropsToObject(row.props) as unknown;\n if (!isPlainObject(parsed)) {\n throw new ConfigurationError(\n `Node ${row.kind}/${row.id} props are not an object.`,\n { kind: row.kind, id: row.id },\n );\n }\n return parsed;\n}\n\nfunction sourceRetractedState(\n row: NodeRow,\n retractedField: string,\n): SourceRetractedState {\n const props = parseNodeProps(row);\n const value = props[retractedField];\n if (value === undefined) return \"available\";\n if (typeof value !== \"boolean\") {\n throw new ConfigurationError(\n `Provenance source field \"${retractedField}\" must contain a boolean value.`,\n { kind: row.kind, id: row.id, field: retractedField },\n {\n suggestion:\n \"Use a source node schema with a boolean retracted flag, for example z.boolean().default(false).\",\n },\n );\n }\n return value ? \"retracted\" : \"available\";\n}\n\nfunction normalizeConfig<G extends GraphDef>(\n graph: G,\n config: ProvenanceRetractionConfig<G>,\n): NormalizedConfig {\n const sourceKinds = sourceKindsFromConfig(config.source);\n const justificationKind = config.justification.kind;\n const factKinds = [...config.fact.kinds];\n const premiseOfKind = config.premiseOf.kind;\n const derivesKind = config.derives.kind;\n const retractedField =\n config.source.retractedField ?? DEFAULT_RETRACTED_FIELD;\n\n if (sourceKinds.length === 0) {\n throw new ConfigurationError(\n \"Provenance retraction requires at least one source kind.\",\n { role: \"source\" },\n );\n }\n\n if (factKinds.length === 0) {\n throw new ConfigurationError(\n \"Provenance retraction requires at least one fact kind.\",\n { role: \"fact\" },\n );\n }\n\n const duplicateSourceKinds = duplicateValues(sourceKinds);\n if (duplicateSourceKinds.length > 0) {\n throw new ConfigurationError(\"Provenance source kinds must be unique.\", {\n duplicateSourceKinds,\n });\n }\n\n const duplicateFactKinds = duplicateValues(factKinds);\n if (duplicateFactKinds.length > 0) {\n throw new ConfigurationError(\"Provenance fact kinds must be unique.\", {\n duplicateFactKinds,\n });\n }\n\n for (const kind of sourceKinds) {\n assertKind(graph.nodes, kind, \"source\", \"node\", graph.id);\n }\n assertKind(graph.nodes, justificationKind, \"justification\", \"node\", graph.id);\n for (const kind of factKinds) {\n assertKind(graph.nodes, kind, \"fact\", \"node\", graph.id);\n }\n for (const kind of sourceKinds)\n assertSourceField(graph, kind, retractedField);\n assertKind(graph.edges, premiseOfKind, \"premiseOf\", \"edge\", graph.id);\n assertKind(graph.edges, derivesKind, \"derives\", \"edge\", graph.id);\n\n if (\n factKinds.some(\n (kind) => sourceKinds.includes(kind) || kind === justificationKind,\n )\n ) {\n throw new ConfigurationError(\n \"Provenance fact kinds must be distinct from source and justification kinds.\",\n { sourceKinds, justificationKind, factKinds },\n );\n }\n\n assertEdgeEndpoints(graph, premiseOfKind, {\n role: \"premiseOf\",\n fromKinds: sourceKinds,\n toKinds: [justificationKind],\n });\n assertEdgeEndpoints(graph, derivesKind, {\n role: \"derives\",\n fromKinds: [justificationKind],\n toKinds: factKinds,\n });\n\n return {\n sourceKinds,\n retractedField,\n justificationKind,\n factKinds,\n premiseOfKind,\n derivesKind,\n };\n}\n\nfunction sourceKindsFromConfig<G extends GraphDef>(\n source: ProvenanceSourceConfig<G>,\n): string[] {\n if (\"kinds\" in source) return [...source.kinds];\n return [source.kind];\n}\n\nfunction duplicateValues(values: readonly string[]): string[] {\n const seen = new Set<string>();\n const duplicates = new Set<string>();\n for (const value of values) {\n if (seen.has(value)) {\n duplicates.add(value);\n continue;\n }\n seen.add(value);\n }\n return [...duplicates].toSorted((left, right) => compareStrings(left, right));\n}\n\nfunction assertKind(\n records: Readonly<Record<string, unknown>>,\n kind: string,\n role: string,\n noun: \"node\" | \"edge\",\n graphId: string,\n): void {\n if (Object.hasOwn(records, kind)) return;\n throw new ConfigurationError(\n `Provenance ${role} kind \"${kind}\" is not a ${noun} kind in this graph.`,\n { role, kind, graphId },\n );\n}\n\nfunction assertSourceField<G extends GraphDef>(\n graph: G,\n sourceKind: string,\n retractedField: string,\n): void {\n const registration = graph.nodes[sourceKind];\n if (registration === undefined) return;\n if (Object.hasOwn(registration.type.schema.shape, retractedField)) return;\n throw new ConfigurationError(\n `Provenance source kind \"${sourceKind}\" must include field \"${retractedField}\".`,\n { sourceKind, retractedField },\n {\n suggestion:\n \"Add a boolean retracted flag to the source node schema or pass source.retractedField.\",\n },\n );\n}\n\nfunction assertEdgeEndpoints<G extends GraphDef>(\n graph: G,\n edgeKind: string,\n expected: Readonly<{\n role: string;\n fromKinds: readonly string[];\n toKinds: readonly string[];\n }>,\n): void {\n const registration = graph.edges[edgeKind];\n if (registration === undefined) return;\n const fromKinds = new Set(registration.from.map((node) => node.kind));\n const toKinds = new Set(registration.to.map((node) => node.kind));\n for (const kind of expected.fromKinds) {\n if (fromKinds.has(kind)) continue;\n throw new ConfigurationError(\n `Provenance ${expected.role} edge \"${edgeKind}\" cannot start at \"${kind}\".`,\n { edgeKind, role: expected.role, expectedFrom: kind },\n );\n }\n for (const kind of expected.toKinds) {\n if (toKinds.has(kind)) continue;\n throw new ConfigurationError(\n `Provenance ${expected.role} edge \"${edgeKind}\" cannot end at \"${kind}\".`,\n { edgeKind, role: expected.role, expectedTo: kind },\n );\n }\n}\n\n/**\n * Whether a row's validity window contains `asOf`. The JS mirror of the SQL\n * `\"current\"`-mode predicate, for role reads that must include tombstoned\n * rows (which `\"current\"` cannot express) yet still respect validity.\n * Canonical fixed-width UTC ISO strings compare correctly as text.\n */\nfunction isValidAt(\n row: Pick<NodeRow, \"valid_from\" | \"valid_to\">,\n asOf: string,\n): boolean {\n return (\n (row.valid_from === undefined || row.valid_from <= asOf) &&\n (row.valid_to === undefined || row.valid_to > asOf)\n );\n}\n\n/**\n * Provenance reads follow the store's currency semantics: a source,\n * justification, or support edge counts only while currently valid (the\n * default `\"current\"` read mode), so a validity-expired source no longer\n * supports anything and `holding()` agrees with the collection API about\n * which facts are currently believed. Fact rows additionally need their\n * tombstones — a reopen candidate is by definition soft-deleted — so they\n * are loaded with tombstones and filtered to the same validity instant.\n */\nasync function findNodeRows(\n backend: GraphReadBackend,\n graphId: string,\n kind: string,\n options: Readonly<{ includeTombstones: boolean; asOf: string }>,\n): Promise<readonly NodeRow[]> {\n if (options.includeTombstones) {\n const rows = await backend.findNodesByKind({\n graphId,\n kind,\n excludeDeleted: false,\n temporalMode: \"includeTombstones\",\n orderBy: \"id\",\n });\n return rows.filter((row) => isValidAt(row, options.asOf));\n }\n return backend.findNodesByKind({\n graphId,\n kind,\n excludeDeleted: true,\n temporalMode: \"current\",\n asOf: options.asOf,\n orderBy: \"id\",\n });\n}\n\nasync function findEdgeRows(\n backend: GraphReadBackend,\n graphId: string,\n kind: string,\n asOf: string,\n): Promise<readonly EdgeRow[]> {\n return backend.findEdgesByKind({\n graphId,\n kind,\n excludeDeleted: true,\n temporalMode: \"current\",\n asOf,\n orderBy: \"id\",\n });\n}\n\nasync function readRoles(\n backend: GraphReadBackend,\n graphId: string,\n config: NormalizedConfig,\n asOf: string,\n): Promise<ProvenanceRows> {\n const [justificationRows, factRowsByKind, premiseEdges, deriveEdges] =\n await Promise.all([\n findNodeRows(backend, graphId, config.justificationKind, {\n includeTombstones: false,\n asOf,\n }),\n Promise.all(\n config.factKinds.map((kind) =>\n findNodeRows(backend, graphId, kind, {\n includeTombstones: true,\n asOf,\n }),\n ),\n ),\n findEdgeRows(backend, graphId, config.premiseOfKind, asOf),\n findEdgeRows(backend, graphId, config.derivesKind, asOf),\n ]);\n const factRows = factRowsByKind.flat();\n\n return {\n justifications: rowsByKey(justificationRows),\n facts: rowsByKey(factRows),\n premiseEdges,\n deriveEdges,\n };\n}\n\nfunction rowsByKey(rows: readonly NodeRow[]): ReadonlyMap<string, NodeRow> {\n const byKey = new Map<string, NodeRow>();\n for (const row of rows) byKey.set(rowKey(row), row);\n return byKey;\n}\n\nfunction appendGroupedValue(\n groups: Map<string, string[]>,\n key: string,\n value: string,\n): void {\n const group = groups.get(key);\n if (group === undefined) {\n groups.set(key, [value]);\n return;\n }\n if (group.includes(value)) return;\n group.push(value);\n}\n\nfunction buildSupportEdges(\n config: NormalizedConfig,\n rows: ProvenanceRows,\n): SupportEdges {\n const premisesByJustification = new Map<string, string[]>();\n const factsByJustification = new Map<string, string[]>();\n const justificationsByPremise = new Map<string, string[]>();\n\n for (const edge of rows.premiseEdges) {\n if (edge.to_kind !== config.justificationKind) continue;\n if (!isPremiseKind(config, edge.from_kind)) continue;\n\n const premiseKey = edgeFromKey(edge);\n const justificationKey = edgeToKey(edge);\n appendGroupedValue(premisesByJustification, justificationKey, premiseKey);\n appendGroupedValue(justificationsByPremise, premiseKey, justificationKey);\n }\n\n for (const edge of rows.deriveEdges) {\n if (edge.from_kind !== config.justificationKind) continue;\n if (!config.factKinds.includes(edge.to_kind)) continue;\n appendGroupedValue(\n factsByJustification,\n edgeFromKey(edge),\n edgeToKey(edge),\n );\n }\n\n return {\n premisesByJustification,\n factsByJustification,\n justificationsByPremise,\n };\n}\n\n/**\n * The whole-graph read a support computation needs: the role rows, the support\n * edges derived from them, and the (non-retracted-visible) source rows. Loaded\n * once per transition so `before` and `after` snapshots share one read instead\n * of scanning the entire provenance graph twice — the graph structure is\n * identical across a transition, only source availability changes.\n */\ntype SupportGraph = Readonly<{\n roles: ProvenanceRows;\n supportEdges: SupportEdges;\n sourceRows: readonly NodeRow[];\n}>;\n\nasync function loadSupportGraph(\n backend: GraphReadBackend,\n graphId: string,\n config: NormalizedConfig,\n): Promise<SupportGraph> {\n // One read instant for every role read, so the whole snapshot shares a\n // single \"currently valid\" coordinate.\n const asOf = nowIso();\n const roles = await readRoles(backend, graphId, config, asOf);\n const supportEdges = buildSupportEdges(config, roles);\n const sourceRowsByKind = await Promise.all(\n config.sourceKinds.map((kind) =>\n findNodeRows(backend, graphId, kind, { includeTombstones: false, asOf }),\n ),\n );\n return { roles, supportEdges, sourceRows: sourceRowsByKind.flat() };\n}\n\nfunction availableSourceKeys(\n sourceRows: readonly NodeRow[],\n retractedField: string,\n): Set<string> {\n const available = new Set<string>();\n for (const row of sourceRows) {\n if (sourceRetractedState(row, retractedField) === \"available\") {\n available.add(rowKey(row));\n }\n }\n return available;\n}\n\n/**\n * The pure TMS fixpoint: given the loaded graph and the set of available\n * (non-retracted) source keys, derive which facts are supported and believed.\n * No I/O — the same {@link SupportGraph} feeds both the pre- and post-transition\n * snapshots with different availability sets.\n */\nfunction computeSupportSnapshot(\n graph: Pick<SupportGraph, \"roles\" | \"supportEdges\">,\n available: ReadonlySet<string>,\n): SupportSnapshot {\n const { roles, supportEdges } = graph;\n const supported = new Set<string>();\n const inSet = new Set<string>(available);\n const firingJustifications = new Set<string>();\n const firingJustificationKeysByFact = new Map<string, string[]>();\n\n let changed = true;\n while (changed) {\n changed = false;\n for (const [justificationKey] of roles.justifications) {\n if (firingJustifications.has(justificationKey)) continue;\n const premises =\n supportEdges.premisesByJustification.get(justificationKey) ?? [];\n if (!allPremisesSupported(premises, inSet)) continue;\n\n firingJustifications.add(justificationKey);\n const derivedFacts =\n supportEdges.factsByJustification.get(justificationKey) ?? [];\n for (const factKey of derivedFacts) {\n if (!roles.facts.has(factKey)) continue;\n appendGroupedValue(\n firingJustificationKeysByFact,\n factKey,\n justificationKey,\n );\n if (supported.has(factKey)) continue;\n supported.add(factKey);\n inSet.add(factKey);\n changed = true;\n }\n }\n }\n\n const believed = new Set<string>();\n for (const key of supported) {\n const row = roles.facts.get(key);\n if (row !== undefined && row.deleted_at === undefined) believed.add(key);\n }\n\n return {\n facts: roles.facts,\n supportedFactKeys: supported,\n believedFactKeys: believed,\n firingJustificationKeysByFact,\n affectedFactKeys(\n targets: readonly ProvenanceNodeRef[],\n ): ReadonlySet<string> {\n return computeAffectedFactKeys(targets, roles, supportEdges);\n },\n };\n}\n\nasync function computeSupport(\n backend: GraphReadBackend,\n graphId: string,\n config: NormalizedConfig,\n): Promise<SupportSnapshot> {\n const graph = await loadSupportGraph(backend, graphId, config);\n return computeSupportSnapshot(\n graph,\n availableSourceKeys(graph.sourceRows, config.retractedField),\n );\n}\n\nfunction isPremiseKind(config: NormalizedConfig, kind: string): boolean {\n return config.sourceKinds.includes(kind) || config.factKinds.includes(kind);\n}\n\nfunction allPremisesSupported(\n premises: readonly string[],\n supported: ReadonlySet<string>,\n): boolean {\n for (const premise of premises) {\n if (!supported.has(premise)) return false;\n }\n return true;\n}\n\nfunction computeAffectedFactKeys(\n sources: readonly ProvenanceNodeRef[],\n roles: ProvenanceRows,\n supportEdges: SupportEdges,\n): ReadonlySet<string> {\n const affected = new Set<string>();\n // Seed the BFS with every source at once: the union of facts reachable from\n // any source falls out of one traversal, instead of one BFS per source.\n const frontier = sources.map((source) => refKey(source));\n const seen = new Set<string>(frontier);\n\n while (frontier.length > 0) {\n const current = frontier.shift();\n if (current === undefined) continue;\n\n const justifications =\n supportEdges.justificationsByPremise.get(current) ?? [];\n for (const justificationKey of justifications) {\n const derivedFacts =\n supportEdges.factsByJustification.get(justificationKey) ?? [];\n for (const factKey of derivedFacts) {\n if (!roles.facts.has(factKey)) continue;\n affected.add(factKey);\n if (seen.has(factKey)) continue;\n seen.add(factKey);\n frontier.push(factKey);\n }\n }\n }\n\n return affected;\n}\n\nfunction buildReport<\n G extends GraphDef,\n FactKind extends NodeKind<G>,\n JustificationKind extends NodeKind<G>,\n>(\n before: SupportSnapshot,\n after: SupportSnapshot,\n affected: ReadonlySet<string>,\n): RetractionReport<G, FactKind, JustificationKind> {\n const believedBefore = [...before.believedFactKeys];\n const died = sortedReferences<G, FactKind>(\n believedBefore.filter((key) => !after.supportedFactKeys.has(key)),\n );\n const unaffected = sortedReferences<G, FactKind>(\n believedBefore.filter((key) => !affected.has(key)),\n );\n const survivedVia = [...affected]\n .filter((key) => after.supportedFactKeys.has(key))\n .toSorted((left, right) => compareStrings(left, right))\n .map((key) => ({\n fact: keyToRef<G, FactKind>(key),\n via: sortedReferences<G, JustificationKind>(\n after.firingJustificationKeysByFact.get(key) ?? [],\n ),\n }));\n return { died, survivedVia, unaffected };\n}\n\n/**\n * Brings fact currency in line with the post-transition support snapshot —\n * but only for the facts the transition could have affected (those reachable\n * from the flipped sources through justification edges). Facts outside that\n * set are never touched: an unsupported live fact elsewhere in the graph\n * (e.g. one whose justification edges have not been linked yet) is not this\n * transition's business, and silently tombstoning it would be invisible data\n * loss the report cannot even mention.\n *\n * Closes run before reopens: a reopen re-checks uniqueness, and the unique\n * key it needs may still be held by a fact this same transition is about to\n * close — closing first makes a legal transition order-independent.\n */\n/**\n * Runs `action` over every fact row in `snapshot` that is both affected by the\n * transition and matches `isTargetKey`/`isTargetRow`, concurrently — the\n * matched rows are independent facts, so there is no ordering dependency\n * within a single pass (only between the close pass and the reopen pass,\n * which the caller sequences).\n */\nasync function forEachAffectedFact<T extends NodeRow>(\n snapshot: SupportSnapshot,\n affected: ReadonlySet<string>,\n isTargetKey: (key: string) => boolean,\n isTargetRow: (row: NodeRow) => row is T,\n action: (row: T) => Promise<void>,\n): Promise<void> {\n const rows: T[] = [];\n for (const [key, row] of snapshot.facts) {\n if (!affected.has(key)) continue;\n if (!isTargetKey(key)) continue;\n if (!isTargetRow(row)) continue;\n rows.push(row);\n }\n await Promise.all(rows.map((row) => action(row)));\n}\n\n/**\n * The transaction-scoped hook lifecycle fact close/reopen runs through —\n * `HistoryTransactionContext[\"runNodeOperationHooks\"]`. Using the\n * transaction's runner (not the store's) defers each fact's success hook\n * until the transition's COMMIT, so hooks never report a closed or reopened\n * fact that a failed commit then rolls back.\n */\ntype RunNodeOperationHooks = <T>(\n operation: \"create\" | \"update\" | \"delete\",\n kind: string,\n id: string,\n fn: () => Promise<T>,\n) => Promise<T>;\n\nasync function synchronizeFactCurrency<G extends GraphDef>(\n backend: HistorySafeTransactionBackend,\n store: HistoryStore<G>,\n runHooks: RunNodeOperationHooks,\n snapshot: SupportSnapshot,\n affected: ReadonlySet<string>,\n lock: GraphWriteLock,\n): Promise<void> {\n await forEachAffectedFact(\n snapshot,\n affected,\n (key) => !snapshot.supportedFactKeys.has(key),\n isLiveNodeRow,\n (row) => closeFactCurrency(backend, store, runHooks, row, lock),\n );\n await forEachAffectedFact(\n snapshot,\n affected,\n (key) => snapshot.supportedFactKeys.has(key),\n isTombstonedNodeRow,\n (row) => reopenFactCurrency(backend, store, runHooks, row, lock),\n );\n}\n\nfunction getFactRegistration<G extends GraphDef>(\n store: HistoryStore<G>,\n row: NodeRow,\n): NodeRegistration {\n const registration = store.graph.nodes[row.kind];\n if (registration !== undefined) return registration;\n throw new ConfigurationError(\n `Provenance fact kind \"${row.kind}\" is not a node kind in this graph.`,\n { kind: row.kind, graphId: store.graphId },\n );\n}\n\nasync function closeFactCurrency<G extends GraphDef>(\n backend: HistorySafeTransactionBackend,\n store: HistoryStore<G>,\n runHooks: RunNodeOperationHooks,\n row: LiveNodeRow,\n lock: GraphWriteLock,\n): Promise<void> {\n await runHooks(\"delete\", row.kind, row.id, async () => {\n const registration = getFactRegistration(store, row);\n // The canonical soft-delete steps (tombstone, uniqueness/embedding/\n // fulltext cleanup) WITHOUT delete-behavior enforcement: closing a\n // fact's currency is a belief-status change, not a domain delete, so\n // its connected edges neither block the close (`restrict`) nor get\n // removed (`cascade` / `disconnect`). Every edge survives untouched,\n // making a later reopen an exact inverse of this close.\n await applyNodeSoftDelete(\n createNodeWriteContext(store.graphId, store.registry, lock),\n {\n existing: row,\n schema: registration.type.schema,\n uniqueConstraints: registration.unique ?? [],\n onDelete: registration.onDelete,\n },\n backend,\n { enforceDeleteBehavior: false },\n );\n });\n}\n\nasync function reopenFactCurrency<G extends GraphDef>(\n backend: HistorySafeTransactionBackend,\n store: HistoryStore<G>,\n runHooks: RunNodeOperationHooks,\n row: TombstonedNodeRow,\n lock: GraphWriteLock,\n): Promise<void> {\n await runHooks(\"update\", row.kind, row.id, async () => {\n const registration = getFactRegistration(store, row);\n // The delete removed this fact's uniqueness entries, so reopen re-checks and\n // re-inserts them (rather than the diff-based update path) before clearing\n // the tombstone and re-syncing embeddings/fulltext.\n await applyNodeResurrect(\n createNodeWriteContext(store.graphId, store.registry, lock),\n {\n existing: row,\n schema: registration.type.schema,\n uniqueConstraints: registration.unique ?? [],\n },\n backend,\n );\n });\n}\n\nfunction getTransactionNodeCollection<G extends GraphDef>(\n tx: HistoryTransactionContext<G>,\n kind: string,\n): DynamicNodeCollection {\n const collection = tx.getNodeCollection(kind);\n if (collection !== undefined) return collection;\n throw new ConfigurationError(\n `Provenance source kind \"${kind}\" is not available on this transaction.`,\n { kind },\n );\n}\n\nasync function setSourceRetractionState<G extends GraphDef>(\n tx: HistoryTransactionContext<G>,\n config: NormalizedConfig,\n source: ProvenanceNodeRef,\n retracted: boolean,\n): Promise<void> {\n const collection = getTransactionNodeCollection(tx, source.kind);\n await collection.update(source.id, { [config.retractedField]: retracted });\n}\n\nasync function runTransition<\n G extends GraphDef,\n SourceKind extends NodeKind<G>,\n FactKind extends NodeKind<G>,\n JustificationKind extends NodeKind<G>,\n>(\n store: HistoryStore<G>,\n config: NormalizedConfig,\n sources: readonly ProvenanceNodeRef<G, SourceKind>[],\n retracted: boolean,\n): Promise<RetractionReport<G, FactKind, JustificationKind>> {\n const uniqueSources = uniqueNodeReferences(sources);\n for (const source of uniqueSources) {\n if (config.sourceKinds.includes(source.kind)) continue;\n throw new ConfigurationError(\n `Provenance retraction source must be one of: ${config.sourceKinds.join(\", \")}.`,\n { expectedKinds: config.sourceKinds, actualKind: source.kind },\n );\n }\n\n return store.transaction(async (tx) => {\n // Serialize the whole read-compute-write transition per graph BEFORE the\n // first read. `store.transaction` itself takes no lock (write operations\n // acquire it at their own boundaries), but a transition's support\n // snapshot must not race a concurrent transition or history write, so\n // the per-graph write lock is acquired explicitly up front. The token is\n // the evidence the currency-sync pipeline steps require.\n const lock = await lockRecordedGraphWrite(tx.backend, store.graphId);\n const rows = await Promise.all(\n uniqueSources.map((source) =>\n tx.backend.getNode(store.graphId, source.kind, source.id),\n ),\n );\n const sourceRows = uniqueSources.map((source, index): SourceRow<G> => {\n const sourceRow = rows[index];\n if (sourceRow === undefined || sourceRow.deleted_at !== undefined) {\n throw new NodeNotFoundError(source.kind, source.id);\n }\n return { source, row: sourceRow };\n });\n\n // Load the provenance graph once. Its structure (justifications, facts,\n // premise/derive edges) is identical before and after the transition — only\n // source availability changes — so the pre- and post-flip snapshots share\n // this read instead of scanning the whole graph twice per retraction.\n const supportGraph = await loadSupportGraph(\n tx.backend,\n store.graphId,\n config,\n );\n const availableBefore = availableSourceKeys(\n supportGraph.sourceRows,\n config.retractedField,\n );\n const before = computeSupportSnapshot(supportGraph, availableBefore);\n\n const nextState: SourceRetractedState =\n retracted ? \"retracted\" : \"available\";\n const availableAfter = new Set(availableBefore);\n for (const { source, row } of sourceRows) {\n const currentState = sourceRetractedState(row, config.retractedField);\n if (currentState === nextState) continue;\n await setSourceRetractionState(tx, config, source, retracted);\n // Mirror the flip in the in-memory availability so `after` matches the\n // source rows now persisted, without re-reading the whole graph.\n if (nextState === \"available\") {\n availableAfter.add(refKey(source));\n } else {\n availableAfter.delete(refKey(source));\n }\n }\n const after = computeSupportSnapshot(supportGraph, availableAfter);\n const affected = after.affectedFactKeys(uniqueSources);\n await synchronizeFactCurrency(\n tx.backend,\n store,\n tx.runNodeOperationHooks,\n after,\n affected,\n lock,\n );\n return buildReport<G, FactKind, JustificationKind>(before, after, affected);\n });\n}\n\nfunction uniqueNodeReferences<\n G extends GraphDef,\n K extends NodeKind<G> = NodeKind<G>,\n>(references: readonly ProvenanceNodeRef<G, K>[]): ProvenanceNodeRef<G, K>[] {\n const byKey = new Map<string, ProvenanceNodeRef<G, K>>();\n for (const reference of references) {\n byKey.set(refKey(reference), reference);\n }\n return [...byKey.values()];\n}\n\nexport function createRetractionCapability<\n G extends GraphDef,\n const C extends ProvenanceRetractionConfig<G>,\n>(\n store: HistoryStore<G>,\n config: C,\n): RetractionCapability<\n G,\n SourceKindsFromConfig<G, C>,\n FactKindsFromConfig<G, C>,\n JustificationKindFromConfig<G, C>\n> {\n const historyEnabled = (store as Readonly<{ historyEnabled: boolean }>)\n .historyEnabled;\n if (!historyEnabled) {\n throw new ConfigurationError(\n \"createRetractionCapability requires a store created with { history: true }.\",\n { graphId: store.graphId },\n {\n suggestion:\n \"Use createStoreWithSchema(graph, backend, { history: true }) so retraction mutations are captured and queryable with asOfRecorded().\",\n },\n );\n }\n const normalized = normalizeConfig(store.graph, config);\n\n // The four retract verbs differ only in one/many source shape and the target\n // retracted flag; the generics are fixed by the config, so hoist one call.\n const transition = (\n sources: readonly ProvenanceNodeRef<G, SourceKindsFromConfig<G, C>>[],\n retracted: boolean,\n ) =>\n runTransition<\n G,\n SourceKindsFromConfig<G, C>,\n FactKindsFromConfig<G, C>,\n JustificationKindFromConfig<G, C>\n >(store, normalized, sources, retracted);\n\n return {\n retract: (source) => transition([source], true),\n retractMany: (sources) => transition(sources, true),\n unRetract: (source) => transition([source], false),\n unRetractMany: (sources) => transition(sources, false),\n\n async holding() {\n return store.transaction(async (tx) => {\n // Same explicit lock as runTransition: the support computation reads\n // several relations, and PostgreSQL's READ COMMITTED gives each\n // statement its own snapshot — without the lock a concurrent\n // transition could commit between those reads and tear the view.\n await lockRecordedGraphWrite(tx.backend, store.graphId);\n const snapshot = await computeSupport(\n tx.backend,\n store.graphId,\n normalized,\n );\n return sortedReferences<G, FactKindsFromConfig<G, C>>(\n snapshot.believedFactKeys,\n );\n });\n },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/provenance/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AA8BA,IAAM,uBAAA,GAA0B,WAAA;AAChC,IAAM,aAAA,GAAgB,IAAA;AAmJtB,SAAS,OAAO,GAAA,EAAgC;AAC9C,EAAA,OAAO,GAAG,GAAA,CAAI,IAAI,GAAG,aAAa,CAAA,EAAG,IAAI,EAAE,CAAA,CAAA;AAC7C;AAEA,SAAS,OAAO,GAAA,EAA2C;AACzD,EAAA,OAAO,MAAA,CAAO,EAAE,IAAA,EAAM,GAAA,CAAI,MAAM,EAAA,EAAI,GAAA,CAAI,IAAI,CAAA;AAC9C;AAEA,SAAS,YAAY,IAAA,EAAuB;AAC1C,EAAA,OAAO,MAAA,CAAO,EAAE,IAAA,EAAM,IAAA,CAAK,WAAW,EAAA,EAAI,IAAA,CAAK,SAAS,CAAA;AAC1D;AAEA,SAAS,UAAU,IAAA,EAAuB;AACxC,EAAA,OAAO,MAAA,CAAO,EAAE,IAAA,EAAM,IAAA,CAAK,SAAS,EAAA,EAAI,IAAA,CAAK,OAAO,CAAA;AACtD;AAEA,SAAS,SAGP,GAAA,EAAsC;AACtC,EAAA,MAAM,cAAA,GAAiB,GAAA,CAAI,OAAA,CAAQ,aAAa,CAAA;AAChD,EAAA,IAAI,mBAAmB,EAAA,EAAI;AACzB,IAAA,MAAM,IAAI,kBAAA;AAAA,MACR,kCAAA;AAAA,MACA,EAAE,GAAA,EAAI;AAAA,MACN;AAAA,QACE,UAAA,EACE;AAAA;AACJ,KACF;AAAA,EACF;AACA,EAAA,MAAM,IAAA,GAAO,GAAA,CAAI,KAAA,CAAM,CAAA,EAAG,cAAc,CAAA;AACxC,EAAA,MAAM,EAAA,GAAK,GAAA,CAAI,KAAA,CAAM,cAAA,GAAiB,cAAc,MAAM,CAAA;AAC1D,EAAA,OAAO,EAAE,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EdgeRow,\n type GraphReadBackend,\n isLiveNodeRow,\n isTombstonedNodeRow,\n type LiveNodeRow,\n type NodeRow,\n rowPropsToObject,\n type TombstonedNodeRow,\n} from \"../backend/types\";\nimport type { GraphDef } from \"../core/define-graph\";\nimport type { NodeRegistration } from \"../core/types\";\nimport { ConfigurationError, NodeNotFoundError } from \"../errors\";\nimport type {\n DynamicNodeCollection,\n HistorySafeTransactionBackend,\n HistoryStore,\n HistoryTransactionContext,\n} from \"../store\";\nimport {\n applyNodeResurrect,\n applyNodeSoftDelete,\n createNodeWriteContext,\n} from \"../store/operations/node-write-pipeline\";\nimport { lockRecordedGraphWrite } from \"../store/recorded-capture\";\nimport { type GraphWriteLock } from \"../store/recorded-capture/clock\";\nimport { compareStrings } from \"../utils/compare\";\nimport { nowIso } from \"../utils/date\";\nimport { isPlainObject } from \"../utils/object\";\n\nconst DEFAULT_RETRACTED_FIELD = \"retracted\";\nconst KEY_SEPARATOR = \"\\u0000\";\n\ntype NodeKind<G extends GraphDef> = Extract<keyof G[\"nodes\"], string>;\ntype EdgeKind<G extends GraphDef> = Extract<keyof G[\"edges\"], string>;\n\nexport type ProvenanceNodeRef<\n G extends GraphDef = GraphDef,\n K extends NodeKind<G> = NodeKind<G>,\n> = Readonly<{\n kind: K;\n id: string;\n}>;\n\nexport type ProvenanceJustificationRef<\n G extends GraphDef = GraphDef,\n K extends NodeKind<G> = NodeKind<G>,\n> = ProvenanceNodeRef<G, K>;\nexport type ProvenanceFactRef<\n G extends GraphDef = GraphDef,\n K extends NodeKind<G> = NodeKind<G>,\n> = ProvenanceNodeRef<G, K>;\n\ntype ProvenanceSourceConfig<G extends GraphDef = GraphDef> =\n | Readonly<{\n kind: NodeKind<G>;\n retractedField?: string;\n }>\n | Readonly<{\n kinds: readonly NodeKind<G>[];\n retractedField?: string;\n }>;\n\nexport type ProvenanceRetractionConfig<G extends GraphDef = GraphDef> =\n Readonly<{\n source: ProvenanceSourceConfig<G>;\n justification: Readonly<{ kind: NodeKind<G> }>;\n fact: Readonly<{ kinds: readonly NodeKind<G>[] }>;\n premiseOf: Readonly<{ kind: EdgeKind<G> }>;\n derives: Readonly<{ kind: EdgeKind<G> }>;\n }>;\n\n/**\n * Extracts the node kind(s) referenced by a provenance role config, whether\n * declared as a single `{ kind }` or a `{ kinds }` array. Falls back to the\n * full `NodeKind<G>` union when neither shape is present (e.g. a role config\n * that also carries unrelated fields, matched structurally).\n */\ntype KindsFromRef<G extends GraphDef, Ref> =\n Ref extends Readonly<{ kind: infer K }> ? Extract<K, NodeKind<G>>\n : Ref extends Readonly<{ kinds: readonly (infer K)[] }> ?\n Extract<K, NodeKind<G>>\n : NodeKind<G>;\n\ntype SourceKindsFromConfig<\n G extends GraphDef,\n C extends ProvenanceRetractionConfig<G>,\n> = KindsFromRef<G, C[\"source\"]>;\n\ntype FactKindsFromConfig<\n G extends GraphDef,\n C extends ProvenanceRetractionConfig<G>,\n> = KindsFromRef<G, C[\"fact\"]>;\n\ntype JustificationKindFromConfig<\n G extends GraphDef,\n C extends ProvenanceRetractionConfig<G>,\n> = KindsFromRef<G, C[\"justification\"]>;\n\nexport type SurvivedVia<\n G extends GraphDef = GraphDef,\n FactKind extends NodeKind<G> = NodeKind<G>,\n JustificationKind extends NodeKind<G> = NodeKind<G>,\n> = Readonly<{\n fact: ProvenanceFactRef<G, FactKind>;\n via: readonly ProvenanceJustificationRef<G, JustificationKind>[];\n}>;\n\nexport type RetractionReport<\n G extends GraphDef = GraphDef,\n FactKind extends NodeKind<G> = NodeKind<G>,\n JustificationKind extends NodeKind<G> = NodeKind<G>,\n> = Readonly<{\n died: readonly ProvenanceFactRef<G, FactKind>[];\n survivedVia: readonly SurvivedVia<G, FactKind, JustificationKind>[];\n unaffected: readonly ProvenanceFactRef<G, FactKind>[];\n}>;\n\nexport type RetractionCapability<\n G extends GraphDef = GraphDef,\n SourceKind extends NodeKind<G> = NodeKind<G>,\n FactKind extends NodeKind<G> = NodeKind<G>,\n JustificationKind extends NodeKind<G> = NodeKind<G>,\n> = Readonly<{\n retract: (\n source: ProvenanceNodeRef<G, SourceKind>,\n ) => Promise<RetractionReport<G, FactKind, JustificationKind>>;\n retractMany: (\n sources: readonly ProvenanceNodeRef<G, SourceKind>[],\n ) => Promise<RetractionReport<G, FactKind, JustificationKind>>;\n unRetract: (\n source: ProvenanceNodeRef<G, SourceKind>,\n ) => Promise<RetractionReport<G, FactKind, JustificationKind>>;\n unRetractMany: (\n sources: readonly ProvenanceNodeRef<G, SourceKind>[],\n ) => Promise<RetractionReport<G, FactKind, JustificationKind>>;\n holding: () => Promise<readonly ProvenanceFactRef<G, FactKind>[]>;\n}>;\n\ntype NormalizedConfig = Readonly<{\n sourceKinds: readonly string[];\n retractedField: string;\n justificationKind: string;\n factKinds: readonly string[];\n premiseOfKind: string;\n derivesKind: string;\n}>;\n\ntype ProvenanceRows = Readonly<{\n justifications: ReadonlyMap<string, NodeRow>;\n facts: ReadonlyMap<string, NodeRow>;\n premiseEdges: readonly EdgeRow[];\n deriveEdges: readonly EdgeRow[];\n}>;\n\ntype SupportEdges = Readonly<{\n premisesByJustification: ReadonlyMap<string, readonly string[]>;\n factsByJustification: ReadonlyMap<string, readonly string[]>;\n justificationsByPremise: ReadonlyMap<string, readonly string[]>;\n}>;\n\ntype SupportSnapshot = Readonly<{\n facts: ReadonlyMap<string, NodeRow>;\n supportedFactKeys: ReadonlySet<string>;\n believedFactKeys: ReadonlySet<string>;\n firingJustificationKeysByFact: ReadonlyMap<string, readonly string[]>;\n affectedFactKeys: (\n sources: readonly ProvenanceNodeRef[],\n ) => ReadonlySet<string>;\n}>;\n\ntype SourceRetractedState = \"retracted\" | \"available\";\n\ntype SourceRow<G extends GraphDef> = Readonly<{\n source: ProvenanceNodeRef<G>;\n row: NodeRow;\n}>;\n\nfunction refKey(ref: ProvenanceNodeRef): string {\n return `${ref.kind}${KEY_SEPARATOR}${ref.id}`;\n}\n\nfunction rowKey(row: Pick<NodeRow, \"kind\" | \"id\">): string {\n return refKey({ kind: row.kind, id: row.id });\n}\n\nfunction edgeFromKey(edge: EdgeRow): string {\n return refKey({ kind: edge.from_kind, id: edge.from_id });\n}\n\nfunction edgeToKey(edge: EdgeRow): string {\n return refKey({ kind: edge.to_kind, id: edge.to_id });\n}\n\nfunction keyToRef<\n G extends GraphDef = GraphDef,\n K extends NodeKind<G> = NodeKind<G>,\n>(key: string): ProvenanceNodeRef<G, K> {\n const separatorIndex = key.indexOf(KEY_SEPARATOR);\n if (separatorIndex === -1) {\n throw new ConfigurationError(\n \"Invalid provenance identity key.\",\n { key },\n {\n suggestion:\n \"Report this TypeGraph provenance bug with the graph roles that produced the key.\",\n },\n );\n }\n const kind = key.slice(0, separatorIndex);\n const id = key.slice(separatorIndex + KEY_SEPARATOR.length);\n return { kind, id } as ProvenanceNodeRef<G, K>;\n}\n\nfunction sortedReferences<\n G extends GraphDef = GraphDef,\n K extends NodeKind<G> = NodeKind<G>,\n>(keys: Iterable<string>): ProvenanceNodeRef<G, K>[] {\n return [...keys]\n .toSorted((left, right) => compareStrings(left, right))\n .map((key) => keyToRef<G, K>(key));\n}\n\nfunction parseNodeProps(row: NodeRow): Record<string, unknown> {\n const parsed = rowPropsToObject(row.props) as unknown;\n if (!isPlainObject(parsed)) {\n throw new ConfigurationError(\n `Node ${row.kind}/${row.id} props are not an object.`,\n { kind: row.kind, id: row.id },\n );\n }\n return parsed;\n}\n\nfunction sourceRetractedState(\n row: NodeRow,\n retractedField: string,\n): SourceRetractedState {\n const props = parseNodeProps(row);\n const value = props[retractedField];\n if (value === undefined) return \"available\";\n if (typeof value !== \"boolean\") {\n throw new ConfigurationError(\n `Provenance source field \"${retractedField}\" must contain a boolean value.`,\n { kind: row.kind, id: row.id, field: retractedField },\n {\n suggestion:\n \"Use a source node schema with a boolean retracted flag, for example z.boolean().default(false).\",\n },\n );\n }\n return value ? \"retracted\" : \"available\";\n}\n\nfunction normalizeConfig<G extends GraphDef>(\n graph: G,\n config: ProvenanceRetractionConfig<G>,\n): NormalizedConfig {\n const sourceKinds = sourceKindsFromConfig(config.source);\n const justificationKind = config.justification.kind;\n const factKinds = [...config.fact.kinds];\n const premiseOfKind = config.premiseOf.kind;\n const derivesKind = config.derives.kind;\n const retractedField =\n config.source.retractedField ?? DEFAULT_RETRACTED_FIELD;\n\n if (sourceKinds.length === 0) {\n throw new ConfigurationError(\n \"Provenance retraction requires at least one source kind.\",\n { role: \"source\" },\n );\n }\n\n if (factKinds.length === 0) {\n throw new ConfigurationError(\n \"Provenance retraction requires at least one fact kind.\",\n { role: \"fact\" },\n );\n }\n\n const duplicateSourceKinds = duplicateValues(sourceKinds);\n if (duplicateSourceKinds.length > 0) {\n throw new ConfigurationError(\"Provenance source kinds must be unique.\", {\n duplicateSourceKinds,\n });\n }\n\n const duplicateFactKinds = duplicateValues(factKinds);\n if (duplicateFactKinds.length > 0) {\n throw new ConfigurationError(\"Provenance fact kinds must be unique.\", {\n duplicateFactKinds,\n });\n }\n\n for (const kind of sourceKinds) {\n assertKind(graph.nodes, kind, \"source\", \"node\", graph.id);\n }\n assertKind(graph.nodes, justificationKind, \"justification\", \"node\", graph.id);\n for (const kind of factKinds) {\n assertKind(graph.nodes, kind, \"fact\", \"node\", graph.id);\n }\n for (const kind of sourceKinds)\n assertSourceField(graph, kind, retractedField);\n assertKind(graph.edges, premiseOfKind, \"premiseOf\", \"edge\", graph.id);\n assertKind(graph.edges, derivesKind, \"derives\", \"edge\", graph.id);\n\n if (\n factKinds.some(\n (kind) => sourceKinds.includes(kind) || kind === justificationKind,\n )\n ) {\n throw new ConfigurationError(\n \"Provenance fact kinds must be distinct from source and justification kinds.\",\n { sourceKinds, justificationKind, factKinds },\n );\n }\n\n assertEdgeEndpoints(graph, premiseOfKind, {\n role: \"premiseOf\",\n fromKinds: sourceKinds,\n toKinds: [justificationKind],\n });\n assertEdgeEndpoints(graph, derivesKind, {\n role: \"derives\",\n fromKinds: [justificationKind],\n toKinds: factKinds,\n });\n\n return {\n sourceKinds,\n retractedField,\n justificationKind,\n factKinds,\n premiseOfKind,\n derivesKind,\n };\n}\n\nfunction sourceKindsFromConfig<G extends GraphDef>(\n source: ProvenanceSourceConfig<G>,\n): string[] {\n if (\"kinds\" in source) return [...source.kinds];\n return [source.kind];\n}\n\nfunction duplicateValues(values: readonly string[]): string[] {\n const seen = new Set<string>();\n const duplicates = new Set<string>();\n for (const value of values) {\n if (seen.has(value)) {\n duplicates.add(value);\n continue;\n }\n seen.add(value);\n }\n return [...duplicates].toSorted((left, right) => compareStrings(left, right));\n}\n\nfunction assertKind(\n records: Readonly<Record<string, unknown>>,\n kind: string,\n role: string,\n noun: \"node\" | \"edge\",\n graphId: string,\n): void {\n if (Object.hasOwn(records, kind)) return;\n throw new ConfigurationError(\n `Provenance ${role} kind \"${kind}\" is not a ${noun} kind in this graph.`,\n { role, kind, graphId },\n );\n}\n\nfunction assertSourceField<G extends GraphDef>(\n graph: G,\n sourceKind: string,\n retractedField: string,\n): void {\n const registration = graph.nodes[sourceKind];\n if (registration === undefined) return;\n if (Object.hasOwn(registration.type.schema.shape, retractedField)) return;\n throw new ConfigurationError(\n `Provenance source kind \"${sourceKind}\" must include field \"${retractedField}\".`,\n { sourceKind, retractedField },\n {\n suggestion:\n \"Add a boolean retracted flag to the source node schema or pass source.retractedField.\",\n },\n );\n}\n\nfunction assertEdgeEndpoints<G extends GraphDef>(\n graph: G,\n edgeKind: string,\n expected: Readonly<{\n role: string;\n fromKinds: readonly string[];\n toKinds: readonly string[];\n }>,\n): void {\n const registration = graph.edges[edgeKind];\n if (registration === undefined) return;\n const fromKinds = new Set(registration.from.map((node) => node.kind));\n const toKinds = new Set(registration.to.map((node) => node.kind));\n for (const kind of expected.fromKinds) {\n if (fromKinds.has(kind)) continue;\n throw new ConfigurationError(\n `Provenance ${expected.role} edge \"${edgeKind}\" cannot start at \"${kind}\".`,\n { edgeKind, role: expected.role, expectedFrom: kind },\n );\n }\n for (const kind of expected.toKinds) {\n if (toKinds.has(kind)) continue;\n throw new ConfigurationError(\n `Provenance ${expected.role} edge \"${edgeKind}\" cannot end at \"${kind}\".`,\n { edgeKind, role: expected.role, expectedTo: kind },\n );\n }\n}\n\n/**\n * Whether a row's validity window contains `asOf`. The JS mirror of the SQL\n * `\"current\"`-mode predicate, for role reads that must include tombstoned\n * rows (which `\"current\"` cannot express) yet still respect validity.\n * Canonical fixed-width UTC ISO strings compare correctly as text.\n */\nfunction isValidAt(\n row: Pick<NodeRow, \"valid_from\" | \"valid_to\">,\n asOf: string,\n): boolean {\n return (\n (row.valid_from === undefined || row.valid_from <= asOf) &&\n (row.valid_to === undefined || row.valid_to > asOf)\n );\n}\n\n/**\n * Provenance reads follow the store's currency semantics: a source,\n * justification, or support edge counts only while currently valid (the\n * default `\"current\"` read mode), so a validity-expired source no longer\n * supports anything and `holding()` agrees with the collection API about\n * which facts are currently believed. Fact rows additionally need their\n * tombstones — a reopen candidate is by definition soft-deleted — so they\n * are loaded with tombstones and filtered to the same validity instant.\n */\nasync function findNodeRows(\n backend: GraphReadBackend,\n graphId: string,\n kind: string,\n options: Readonly<{ includeTombstones: boolean; asOf: string }>,\n): Promise<readonly NodeRow[]> {\n if (options.includeTombstones) {\n const rows = await backend.findNodesByKind({\n graphId,\n kind,\n excludeDeleted: false,\n temporalMode: \"includeTombstones\",\n orderBy: \"id\",\n });\n return rows.filter((row) => isValidAt(row, options.asOf));\n }\n return backend.findNodesByKind({\n graphId,\n kind,\n excludeDeleted: true,\n temporalMode: \"current\",\n asOf: options.asOf,\n orderBy: \"id\",\n });\n}\n\nasync function findEdgeRows(\n backend: GraphReadBackend,\n graphId: string,\n kind: string,\n asOf: string,\n): Promise<readonly EdgeRow[]> {\n return backend.findEdgesByKind({\n graphId,\n kind,\n excludeDeleted: true,\n temporalMode: \"current\",\n asOf,\n orderBy: \"id\",\n });\n}\n\nasync function readRoles(\n backend: GraphReadBackend,\n graphId: string,\n config: NormalizedConfig,\n asOf: string,\n): Promise<ProvenanceRows> {\n const [justificationRows, factRowsByKind, premiseEdges, deriveEdges] =\n await Promise.all([\n findNodeRows(backend, graphId, config.justificationKind, {\n includeTombstones: false,\n asOf,\n }),\n Promise.all(\n config.factKinds.map((kind) =>\n findNodeRows(backend, graphId, kind, {\n includeTombstones: true,\n asOf,\n }),\n ),\n ),\n findEdgeRows(backend, graphId, config.premiseOfKind, asOf),\n findEdgeRows(backend, graphId, config.derivesKind, asOf),\n ]);\n const factRows = factRowsByKind.flat();\n\n return {\n justifications: rowsByKey(justificationRows),\n facts: rowsByKey(factRows),\n premiseEdges,\n deriveEdges,\n };\n}\n\nfunction rowsByKey(rows: readonly NodeRow[]): ReadonlyMap<string, NodeRow> {\n const byKey = new Map<string, NodeRow>();\n for (const row of rows) byKey.set(rowKey(row), row);\n return byKey;\n}\n\nfunction appendGroupedValue(\n groups: Map<string, string[]>,\n key: string,\n value: string,\n): void {\n const group = groups.get(key);\n if (group === undefined) {\n groups.set(key, [value]);\n return;\n }\n if (group.includes(value)) return;\n group.push(value);\n}\n\nfunction buildSupportEdges(\n config: NormalizedConfig,\n rows: ProvenanceRows,\n): SupportEdges {\n const premisesByJustification = new Map<string, string[]>();\n const factsByJustification = new Map<string, string[]>();\n const justificationsByPremise = new Map<string, string[]>();\n\n for (const edge of rows.premiseEdges) {\n if (edge.to_kind !== config.justificationKind) continue;\n if (!isPremiseKind(config, edge.from_kind)) continue;\n\n const premiseKey = edgeFromKey(edge);\n const justificationKey = edgeToKey(edge);\n appendGroupedValue(premisesByJustification, justificationKey, premiseKey);\n appendGroupedValue(justificationsByPremise, premiseKey, justificationKey);\n }\n\n for (const edge of rows.deriveEdges) {\n if (edge.from_kind !== config.justificationKind) continue;\n if (!config.factKinds.includes(edge.to_kind)) continue;\n appendGroupedValue(\n factsByJustification,\n edgeFromKey(edge),\n edgeToKey(edge),\n );\n }\n\n return {\n premisesByJustification,\n factsByJustification,\n justificationsByPremise,\n };\n}\n\n/**\n * The whole-graph read a support computation needs: the role rows, the support\n * edges derived from them, and the (non-retracted-visible) source rows. Loaded\n * once per transition so `before` and `after` snapshots share one read instead\n * of scanning the entire provenance graph twice — the graph structure is\n * identical across a transition, only source availability changes.\n */\ntype SupportGraph = Readonly<{\n roles: ProvenanceRows;\n supportEdges: SupportEdges;\n sourceRows: readonly NodeRow[];\n}>;\n\nasync function loadSupportGraph(\n backend: GraphReadBackend,\n graphId: string,\n config: NormalizedConfig,\n): Promise<SupportGraph> {\n // One read instant for every role read, so the whole snapshot shares a\n // single \"currently valid\" coordinate.\n const asOf = nowIso();\n const roles = await readRoles(backend, graphId, config, asOf);\n const supportEdges = buildSupportEdges(config, roles);\n const sourceRowsByKind = await Promise.all(\n config.sourceKinds.map((kind) =>\n findNodeRows(backend, graphId, kind, { includeTombstones: false, asOf }),\n ),\n );\n return { roles, supportEdges, sourceRows: sourceRowsByKind.flat() };\n}\n\nfunction availableSourceKeys(\n sourceRows: readonly NodeRow[],\n retractedField: string,\n): Set<string> {\n const available = new Set<string>();\n for (const row of sourceRows) {\n if (sourceRetractedState(row, retractedField) === \"available\") {\n available.add(rowKey(row));\n }\n }\n return available;\n}\n\n/**\n * The pure TMS fixpoint: given the loaded graph and the set of available\n * (non-retracted) source keys, derive which facts are supported and believed.\n * No I/O — the same {@link SupportGraph} feeds both the pre- and post-transition\n * snapshots with different availability sets.\n */\nfunction computeSupportSnapshot(\n graph: Pick<SupportGraph, \"roles\" | \"supportEdges\">,\n available: ReadonlySet<string>,\n): SupportSnapshot {\n const { roles, supportEdges } = graph;\n const supported = new Set<string>();\n const inSet = new Set<string>(available);\n const firingJustifications = new Set<string>();\n const firingJustificationKeysByFact = new Map<string, string[]>();\n\n let changed = true;\n while (changed) {\n changed = false;\n for (const [justificationKey] of roles.justifications) {\n if (firingJustifications.has(justificationKey)) continue;\n const premises =\n supportEdges.premisesByJustification.get(justificationKey) ?? [];\n if (!allPremisesSupported(premises, inSet)) continue;\n\n firingJustifications.add(justificationKey);\n const derivedFacts =\n supportEdges.factsByJustification.get(justificationKey) ?? [];\n for (const factKey of derivedFacts) {\n if (!roles.facts.has(factKey)) continue;\n appendGroupedValue(\n firingJustificationKeysByFact,\n factKey,\n justificationKey,\n );\n if (supported.has(factKey)) continue;\n supported.add(factKey);\n inSet.add(factKey);\n changed = true;\n }\n }\n }\n\n const believed = new Set<string>();\n for (const key of supported) {\n const row = roles.facts.get(key);\n if (row !== undefined && row.deleted_at === undefined) believed.add(key);\n }\n\n return {\n facts: roles.facts,\n supportedFactKeys: supported,\n believedFactKeys: believed,\n firingJustificationKeysByFact,\n affectedFactKeys(\n targets: readonly ProvenanceNodeRef[],\n ): ReadonlySet<string> {\n return computeAffectedFactKeys(targets, roles, supportEdges);\n },\n };\n}\n\nasync function computeSupport(\n backend: GraphReadBackend,\n graphId: string,\n config: NormalizedConfig,\n): Promise<SupportSnapshot> {\n const graph = await loadSupportGraph(backend, graphId, config);\n return computeSupportSnapshot(\n graph,\n availableSourceKeys(graph.sourceRows, config.retractedField),\n );\n}\n\nfunction isPremiseKind(config: NormalizedConfig, kind: string): boolean {\n return config.sourceKinds.includes(kind) || config.factKinds.includes(kind);\n}\n\nfunction allPremisesSupported(\n premises: readonly string[],\n supported: ReadonlySet<string>,\n): boolean {\n for (const premise of premises) {\n if (!supported.has(premise)) return false;\n }\n return true;\n}\n\nfunction computeAffectedFactKeys(\n sources: readonly ProvenanceNodeRef[],\n roles: ProvenanceRows,\n supportEdges: SupportEdges,\n): ReadonlySet<string> {\n const affected = new Set<string>();\n // Seed the BFS with every source at once: the union of facts reachable from\n // any source falls out of one traversal, instead of one BFS per source.\n const frontier = sources.map((source) => refKey(source));\n const seen = new Set<string>(frontier);\n\n while (frontier.length > 0) {\n const current = frontier.shift();\n if (current === undefined) continue;\n\n const justifications =\n supportEdges.justificationsByPremise.get(current) ?? [];\n for (const justificationKey of justifications) {\n const derivedFacts =\n supportEdges.factsByJustification.get(justificationKey) ?? [];\n for (const factKey of derivedFacts) {\n if (!roles.facts.has(factKey)) continue;\n affected.add(factKey);\n if (seen.has(factKey)) continue;\n seen.add(factKey);\n frontier.push(factKey);\n }\n }\n }\n\n return affected;\n}\n\nfunction buildReport<\n G extends GraphDef,\n FactKind extends NodeKind<G>,\n JustificationKind extends NodeKind<G>,\n>(\n before: SupportSnapshot,\n after: SupportSnapshot,\n affected: ReadonlySet<string>,\n): RetractionReport<G, FactKind, JustificationKind> {\n const believedBefore = [...before.believedFactKeys];\n const died = sortedReferences<G, FactKind>(\n believedBefore.filter((key) => !after.supportedFactKeys.has(key)),\n );\n const unaffected = sortedReferences<G, FactKind>(\n believedBefore.filter((key) => !affected.has(key)),\n );\n const survivedVia = [...affected]\n .filter((key) => after.supportedFactKeys.has(key))\n .toSorted((left, right) => compareStrings(left, right))\n .map((key) => ({\n fact: keyToRef<G, FactKind>(key),\n via: sortedReferences<G, JustificationKind>(\n after.firingJustificationKeysByFact.get(key) ?? [],\n ),\n }));\n return { died, survivedVia, unaffected };\n}\n\n/**\n * Brings fact currency in line with the post-transition support snapshot —\n * but only for the facts the transition could have affected (those reachable\n * from the flipped sources through justification edges). Facts outside that\n * set are never touched: an unsupported live fact elsewhere in the graph\n * (e.g. one whose justification edges have not been linked yet) is not this\n * transition's business, and silently tombstoning it would be invisible data\n * loss the report cannot even mention.\n *\n * Closes run before reopens: a reopen re-checks uniqueness, and the unique\n * key it needs may still be held by a fact this same transition is about to\n * close — closing first makes a legal transition order-independent.\n */\n/**\n * Runs `action` over every fact row in `snapshot` that is both affected by the\n * transition and matches `isTargetKey`/`isTargetRow`, concurrently — the\n * matched rows are independent facts, so there is no ordering dependency\n * within a single pass (only between the close pass and the reopen pass,\n * which the caller sequences).\n */\nasync function forEachAffectedFact<T extends NodeRow>(\n snapshot: SupportSnapshot,\n affected: ReadonlySet<string>,\n isTargetKey: (key: string) => boolean,\n isTargetRow: (row: NodeRow) => row is T,\n action: (row: T) => Promise<void>,\n): Promise<void> {\n const rows: T[] = [];\n for (const [key, row] of snapshot.facts) {\n if (!affected.has(key)) continue;\n if (!isTargetKey(key)) continue;\n if (!isTargetRow(row)) continue;\n rows.push(row);\n }\n await Promise.all(rows.map((row) => action(row)));\n}\n\n/**\n * The transaction-scoped hook lifecycle fact close/reopen runs through —\n * `HistoryTransactionContext[\"runNodeOperationHooks\"]`. Using the\n * transaction's runner (not the store's) defers each fact's success hook\n * until the transition's COMMIT, so hooks never report a closed or reopened\n * fact that a failed commit then rolls back.\n */\ntype RunNodeOperationHooks = <T>(\n operation: \"create\" | \"update\" | \"delete\",\n kind: string,\n id: string,\n fn: () => Promise<T>,\n) => Promise<T>;\n\nasync function synchronizeFactCurrency<G extends GraphDef>(\n backend: HistorySafeTransactionBackend,\n store: HistoryStore<G>,\n runHooks: RunNodeOperationHooks,\n snapshot: SupportSnapshot,\n affected: ReadonlySet<string>,\n lock: GraphWriteLock,\n): Promise<void> {\n await forEachAffectedFact(\n snapshot,\n affected,\n (key) => !snapshot.supportedFactKeys.has(key),\n isLiveNodeRow,\n (row) => closeFactCurrency(backend, store, runHooks, row, lock),\n );\n await forEachAffectedFact(\n snapshot,\n affected,\n (key) => snapshot.supportedFactKeys.has(key),\n isTombstonedNodeRow,\n (row) => reopenFactCurrency(backend, store, runHooks, row, lock),\n );\n}\n\nfunction getFactRegistration<G extends GraphDef>(\n store: HistoryStore<G>,\n row: NodeRow,\n): NodeRegistration {\n const registration = store.graph.nodes[row.kind];\n if (registration !== undefined) return registration;\n throw new ConfigurationError(\n `Provenance fact kind \"${row.kind}\" is not a node kind in this graph.`,\n { kind: row.kind, graphId: store.graphId },\n );\n}\n\nasync function closeFactCurrency<G extends GraphDef>(\n backend: HistorySafeTransactionBackend,\n store: HistoryStore<G>,\n runHooks: RunNodeOperationHooks,\n row: LiveNodeRow,\n lock: GraphWriteLock,\n): Promise<void> {\n await runHooks(\"delete\", row.kind, row.id, async () => {\n const registration = getFactRegistration(store, row);\n // The canonical soft-delete steps (tombstone, uniqueness/embedding/\n // fulltext cleanup) WITHOUT delete-behavior enforcement: closing a\n // fact's currency is a belief-status change, not a domain delete, so\n // its connected edges neither block the close (`restrict`) nor get\n // removed (`cascade` / `disconnect`). Every edge survives untouched,\n // making a later reopen an exact inverse of this close.\n await applyNodeSoftDelete(\n createNodeWriteContext(store.graphId, store.registry, lock),\n {\n existing: row,\n schema: registration.type.schema,\n uniqueConstraints: registration.unique ?? [],\n onDelete: registration.onDelete,\n },\n backend,\n { enforceDeleteBehavior: false },\n );\n });\n}\n\nasync function reopenFactCurrency<G extends GraphDef>(\n backend: HistorySafeTransactionBackend,\n store: HistoryStore<G>,\n runHooks: RunNodeOperationHooks,\n row: TombstonedNodeRow,\n lock: GraphWriteLock,\n): Promise<void> {\n await runHooks(\"update\", row.kind, row.id, async () => {\n const registration = getFactRegistration(store, row);\n // The delete removed this fact's uniqueness entries, so reopen re-checks and\n // re-inserts them (rather than the diff-based update path) before clearing\n // the tombstone and re-syncing embeddings/fulltext.\n await applyNodeResurrect(\n createNodeWriteContext(store.graphId, store.registry, lock),\n {\n existing: row,\n schema: registration.type.schema,\n uniqueConstraints: registration.unique ?? [],\n },\n backend,\n );\n });\n}\n\nfunction getTransactionNodeCollection<G extends GraphDef>(\n tx: HistoryTransactionContext<G>,\n kind: string,\n): DynamicNodeCollection {\n const collection = tx.getNodeCollection(kind);\n if (collection !== undefined) return collection;\n throw new ConfigurationError(\n `Provenance source kind \"${kind}\" is not available on this transaction.`,\n { kind },\n );\n}\n\nasync function setSourceRetractionState<G extends GraphDef>(\n tx: HistoryTransactionContext<G>,\n config: NormalizedConfig,\n source: ProvenanceNodeRef,\n retracted: boolean,\n): Promise<void> {\n const collection = getTransactionNodeCollection(tx, source.kind);\n await collection.update(source.id, { [config.retractedField]: retracted });\n}\n\nasync function runTransition<\n G extends GraphDef,\n SourceKind extends NodeKind<G>,\n FactKind extends NodeKind<G>,\n JustificationKind extends NodeKind<G>,\n>(\n store: HistoryStore<G>,\n config: NormalizedConfig,\n sources: readonly ProvenanceNodeRef<G, SourceKind>[],\n retracted: boolean,\n): Promise<RetractionReport<G, FactKind, JustificationKind>> {\n const uniqueSources = uniqueNodeReferences(sources);\n for (const source of uniqueSources) {\n if (config.sourceKinds.includes(source.kind)) continue;\n throw new ConfigurationError(\n `Provenance retraction source must be one of: ${config.sourceKinds.join(\", \")}.`,\n { expectedKinds: config.sourceKinds, actualKind: source.kind },\n );\n }\n\n return store.transaction(async (tx) => {\n // Serialize the whole read-compute-write transition per graph BEFORE the\n // first read. `store.transaction` itself takes no lock (write operations\n // acquire it at their own boundaries), but a transition's support\n // snapshot must not race a concurrent transition or history write, so\n // the per-graph write lock is acquired explicitly up front. The token is\n // the evidence the currency-sync pipeline steps require.\n const lock = await lockRecordedGraphWrite(tx.backend, store.graphId);\n const rows = await Promise.all(\n uniqueSources.map((source) =>\n tx.backend.getNode(store.graphId, source.kind, source.id),\n ),\n );\n const sourceRows = uniqueSources.map((source, index): SourceRow<G> => {\n const sourceRow = rows[index];\n if (sourceRow === undefined || sourceRow.deleted_at !== undefined) {\n throw new NodeNotFoundError(source.kind, source.id);\n }\n return { source, row: sourceRow };\n });\n\n // Load the provenance graph once. Its structure (justifications, facts,\n // premise/derive edges) is identical before and after the transition — only\n // source availability changes — so the pre- and post-flip snapshots share\n // this read instead of scanning the whole graph twice per retraction.\n const supportGraph = await loadSupportGraph(\n tx.backend,\n store.graphId,\n config,\n );\n const availableBefore = availableSourceKeys(\n supportGraph.sourceRows,\n config.retractedField,\n );\n const before = computeSupportSnapshot(supportGraph, availableBefore);\n\n const nextState: SourceRetractedState =\n retracted ? \"retracted\" : \"available\";\n const availableAfter = new Set(availableBefore);\n for (const { source, row } of sourceRows) {\n const currentState = sourceRetractedState(row, config.retractedField);\n if (currentState === nextState) continue;\n await setSourceRetractionState(tx, config, source, retracted);\n // Mirror the flip in the in-memory availability so `after` matches the\n // source rows now persisted, without re-reading the whole graph.\n if (nextState === \"available\") {\n availableAfter.add(refKey(source));\n } else {\n availableAfter.delete(refKey(source));\n }\n }\n const after = computeSupportSnapshot(supportGraph, availableAfter);\n const affected = after.affectedFactKeys(uniqueSources);\n await synchronizeFactCurrency(\n tx.backend,\n store,\n tx.runNodeOperationHooks,\n after,\n affected,\n lock,\n );\n return buildReport<G, FactKind, JustificationKind>(before, after, affected);\n });\n}\n\nfunction uniqueNodeReferences<\n G extends GraphDef,\n K extends NodeKind<G> = NodeKind<G>,\n>(references: readonly ProvenanceNodeRef<G, K>[]): ProvenanceNodeRef<G, K>[] {\n const byKey = new Map<string, ProvenanceNodeRef<G, K>>();\n for (const reference of references) {\n byKey.set(refKey(reference), reference);\n }\n return [...byKey.values()];\n}\n\nexport function createRetractionCapability<\n G extends GraphDef,\n const C extends ProvenanceRetractionConfig<G>,\n>(\n store: HistoryStore<G>,\n config: C,\n): RetractionCapability<\n G,\n SourceKindsFromConfig<G, C>,\n FactKindsFromConfig<G, C>,\n JustificationKindFromConfig<G, C>\n> {\n const historyEnabled = (store as Readonly<{ historyEnabled: boolean }>)\n .historyEnabled;\n if (!historyEnabled) {\n throw new ConfigurationError(\n \"createRetractionCapability requires a store created with { history: true }.\",\n { graphId: store.graphId },\n {\n suggestion:\n \"Use createStoreWithSchema(graph, backend, { history: true }) so retraction mutations are captured and queryable with asOfRecorded().\",\n },\n );\n }\n const normalized = normalizeConfig(store.graph, config);\n\n // The four retract verbs differ only in one/many source shape and the target\n // retracted flag; the generics are fixed by the config, so hoist one call.\n const transition = (\n sources: readonly ProvenanceNodeRef<G, SourceKindsFromConfig<G, C>>[],\n retracted: boolean,\n ) =>\n runTransition<\n G,\n SourceKindsFromConfig<G, C>,\n FactKindsFromConfig<G, C>,\n JustificationKindFromConfig<G, C>\n >(store, normalized, sources, retracted);\n\n return {\n retract: (source) => transition([source], true),\n retractMany: (sources) => transition(sources, true),\n unRetract: (source) => transition([source], false),\n unRetractMany: (sources) => transition(sources, false),\n\n async holding() {\n return store.transaction(async (tx) => {\n // Same explicit lock as runTransition: the support computation reads\n // several relations, and PostgreSQL's READ COMMITTED gives each\n // statement its own snapshot — without the lock a concurrent\n // transition could commit between those reads and tear the view.\n await lockRecordedGraphWrite(tx.backend, store.graphId);\n const snapshot = await computeSupport(\n tx.backend,\n store.graphId,\n normalized,\n );\n return sortedReferences<G, FactKindsFromConfig<G, C>>(\n snapshot.believedFactKeys,\n );\n });\n },\n };\n}\n"]}
|
package/dist/schema/index.cjs
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkNUIG3BCV_cjs = require('../chunk-NUIG3BCV.cjs');
|
|
4
|
+
var chunk5KEQ74YU_cjs = require('../chunk-5KEQ74YU.cjs');
|
|
5
5
|
require('../chunk-ACSVZPK7.cjs');
|
|
6
|
-
require('../chunk-
|
|
6
|
+
require('../chunk-VGDDG3XJ.cjs');
|
|
7
7
|
require('../chunk-TEDRJXOG.cjs');
|
|
8
|
-
require('../chunk-
|
|
9
|
-
require('../chunk-
|
|
10
|
-
require('../chunk-
|
|
11
|
-
require('../chunk-
|
|
12
|
-
require('../chunk-
|
|
8
|
+
require('../chunk-XGU7DZDA.cjs');
|
|
9
|
+
require('../chunk-WWFHO375.cjs');
|
|
10
|
+
require('../chunk-IP3CGGPA.cjs');
|
|
11
|
+
require('../chunk-DEFQM7JU.cjs');
|
|
12
|
+
require('../chunk-3GH67G4Z.cjs');
|
|
13
13
|
require('../chunk-7YSP4V4R.cjs');
|
|
14
|
-
require('../chunk-
|
|
14
|
+
require('../chunk-HAHNRASW.cjs');
|
|
15
15
|
require('../chunk-SJDMVITW.cjs');
|
|
16
16
|
require('../chunk-DI74SMXS.cjs');
|
|
17
|
-
require('../chunk-
|
|
17
|
+
require('../chunk-BVRDGYXQ.cjs');
|
|
18
18
|
require('../chunk-TDXIBCGY.cjs');
|
|
19
19
|
|
|
20
20
|
// src/schema/deserializer.ts
|
|
@@ -55,7 +55,7 @@ function buildRegistryFromClosures(schema) {
|
|
|
55
55
|
const edgeImplyingClosure = recordToMap(closures.edgeImplyingClosure);
|
|
56
56
|
const nodeKinds = /* @__PURE__ */ new Map();
|
|
57
57
|
const edgeKinds = /* @__PURE__ */ new Map();
|
|
58
|
-
const registry = new
|
|
58
|
+
const registry = new chunkNUIG3BCV_cjs.KindRegistry(nodeKinds, edgeKinds, {
|
|
59
59
|
subClassAncestors,
|
|
60
60
|
subClassDescendants,
|
|
61
61
|
broaderClosure,
|
|
@@ -69,7 +69,7 @@ function buildRegistryFromClosures(schema) {
|
|
|
69
69
|
edgeImplicationsClosure,
|
|
70
70
|
edgeImplyingClosure
|
|
71
71
|
});
|
|
72
|
-
|
|
72
|
+
chunkNUIG3BCV_cjs.validateImpliesEndpointCompatibility(
|
|
73
73
|
buildEdgeEndpointKinds(schema.edges),
|
|
74
74
|
registry
|
|
75
75
|
);
|
|
@@ -95,95 +95,95 @@ function simpleRecordToMap(record) {
|
|
|
95
95
|
|
|
96
96
|
Object.defineProperty(exports, "applyDeprecatedKinds", {
|
|
97
97
|
enumerable: true,
|
|
98
|
-
get: function () { return
|
|
98
|
+
get: function () { return chunkNUIG3BCV_cjs.applyDeprecatedKinds; }
|
|
99
99
|
});
|
|
100
100
|
Object.defineProperty(exports, "assertSchemaCurrent", {
|
|
101
101
|
enumerable: true,
|
|
102
|
-
get: function () { return
|
|
102
|
+
get: function () { return chunkNUIG3BCV_cjs.assertSchemaCurrent; }
|
|
103
103
|
});
|
|
104
104
|
Object.defineProperty(exports, "computeSchemaDiff", {
|
|
105
105
|
enumerable: true,
|
|
106
|
-
get: function () { return
|
|
106
|
+
get: function () { return chunkNUIG3BCV_cjs.computeSchemaDiff; }
|
|
107
107
|
});
|
|
108
108
|
Object.defineProperty(exports, "computeSchemaHash", {
|
|
109
109
|
enumerable: true,
|
|
110
|
-
get: function () { return
|
|
110
|
+
get: function () { return chunkNUIG3BCV_cjs.computeSchemaHash; }
|
|
111
111
|
});
|
|
112
112
|
Object.defineProperty(exports, "deserializeWherePredicate", {
|
|
113
113
|
enumerable: true,
|
|
114
|
-
get: function () { return
|
|
114
|
+
get: function () { return chunkNUIG3BCV_cjs.deserializeWherePredicate; }
|
|
115
115
|
});
|
|
116
116
|
Object.defineProperty(exports, "ensureSchema", {
|
|
117
117
|
enumerable: true,
|
|
118
|
-
get: function () { return
|
|
118
|
+
get: function () { return chunkNUIG3BCV_cjs.ensureSchema; }
|
|
119
119
|
});
|
|
120
120
|
Object.defineProperty(exports, "getActiveSchema", {
|
|
121
121
|
enumerable: true,
|
|
122
|
-
get: function () { return
|
|
122
|
+
get: function () { return chunkNUIG3BCV_cjs.getActiveSchema; }
|
|
123
123
|
});
|
|
124
124
|
Object.defineProperty(exports, "getMigrationActions", {
|
|
125
125
|
enumerable: true,
|
|
126
|
-
get: function () { return
|
|
126
|
+
get: function () { return chunkNUIG3BCV_cjs.getMigrationActions; }
|
|
127
127
|
});
|
|
128
128
|
Object.defineProperty(exports, "getSchemaChanges", {
|
|
129
129
|
enumerable: true,
|
|
130
|
-
get: function () { return
|
|
130
|
+
get: function () { return chunkNUIG3BCV_cjs.getSchemaChanges; }
|
|
131
131
|
});
|
|
132
132
|
Object.defineProperty(exports, "initializeSchema", {
|
|
133
133
|
enumerable: true,
|
|
134
|
-
get: function () { return
|
|
134
|
+
get: function () { return chunkNUIG3BCV_cjs.initializeSchema; }
|
|
135
135
|
});
|
|
136
136
|
Object.defineProperty(exports, "isBackwardsCompatible", {
|
|
137
137
|
enumerable: true,
|
|
138
|
-
get: function () { return
|
|
138
|
+
get: function () { return chunkNUIG3BCV_cjs.isBackwardsCompatible; }
|
|
139
139
|
});
|
|
140
140
|
Object.defineProperty(exports, "isSchemaInitialized", {
|
|
141
141
|
enumerable: true,
|
|
142
|
-
get: function () { return
|
|
142
|
+
get: function () { return chunkNUIG3BCV_cjs.isSchemaInitialized; }
|
|
143
143
|
});
|
|
144
144
|
Object.defineProperty(exports, "loadActiveSchemaWithBootstrap", {
|
|
145
145
|
enumerable: true,
|
|
146
|
-
get: function () { return
|
|
146
|
+
get: function () { return chunkNUIG3BCV_cjs.loadActiveSchemaWithBootstrap; }
|
|
147
147
|
});
|
|
148
148
|
Object.defineProperty(exports, "loadAndMergeGraphExtensionDocument", {
|
|
149
149
|
enumerable: true,
|
|
150
|
-
get: function () { return
|
|
150
|
+
get: function () { return chunkNUIG3BCV_cjs.loadAndMergeGraphExtensionDocument; }
|
|
151
151
|
});
|
|
152
152
|
Object.defineProperty(exports, "migrateSchema", {
|
|
153
153
|
enumerable: true,
|
|
154
|
-
get: function () { return
|
|
154
|
+
get: function () { return chunkNUIG3BCV_cjs.migrateSchema; }
|
|
155
155
|
});
|
|
156
156
|
Object.defineProperty(exports, "parseSerializedSchema", {
|
|
157
157
|
enumerable: true,
|
|
158
|
-
get: function () { return
|
|
158
|
+
get: function () { return chunkNUIG3BCV_cjs.parseSerializedSchema; }
|
|
159
159
|
});
|
|
160
160
|
Object.defineProperty(exports, "rollbackSchema", {
|
|
161
161
|
enumerable: true,
|
|
162
|
-
get: function () { return
|
|
162
|
+
get: function () { return chunkNUIG3BCV_cjs.rollbackSchema; }
|
|
163
163
|
});
|
|
164
164
|
Object.defineProperty(exports, "serializeSchema", {
|
|
165
165
|
enumerable: true,
|
|
166
|
-
get: function () { return
|
|
166
|
+
get: function () { return chunkNUIG3BCV_cjs.serializeSchema; }
|
|
167
167
|
});
|
|
168
168
|
Object.defineProperty(exports, "createValidationError", {
|
|
169
169
|
enumerable: true,
|
|
170
|
-
get: function () { return
|
|
170
|
+
get: function () { return chunk5KEQ74YU_cjs.createValidationError; }
|
|
171
171
|
});
|
|
172
172
|
Object.defineProperty(exports, "validateEdgeProps", {
|
|
173
173
|
enumerable: true,
|
|
174
|
-
get: function () { return
|
|
174
|
+
get: function () { return chunk5KEQ74YU_cjs.validateEdgeProps; }
|
|
175
175
|
});
|
|
176
176
|
Object.defineProperty(exports, "validateNodeProps", {
|
|
177
177
|
enumerable: true,
|
|
178
|
-
get: function () { return
|
|
178
|
+
get: function () { return chunk5KEQ74YU_cjs.validateNodeProps; }
|
|
179
179
|
});
|
|
180
180
|
Object.defineProperty(exports, "validateProps", {
|
|
181
181
|
enumerable: true,
|
|
182
|
-
get: function () { return
|
|
182
|
+
get: function () { return chunk5KEQ74YU_cjs.validateProps; }
|
|
183
183
|
});
|
|
184
184
|
Object.defineProperty(exports, "wrapZodError", {
|
|
185
185
|
enumerable: true,
|
|
186
|
-
get: function () { return
|
|
186
|
+
get: function () { return chunk5KEQ74YU_cjs.wrapZodError; }
|
|
187
187
|
});
|
|
188
188
|
exports.deserializeSchema = deserializeSchema;
|
|
189
189
|
//# sourceMappingURL=index.cjs.map
|
package/dist/schema/index.d.cts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { G as GraphDef, K as KindRegistry } from '../manager-
|
|
2
|
-
export { C as ChangeSeverity, a as ChangeType, D as DeprecatedKindsChange, E as EdgeChange, b as ExtensionChange, I as IndexChange, M as MigrationHookContext, N as NodeChange, O as OntologyChange, S as SchemaDiff, c as SchemaManagerOptions, d as SchemaValidationResult, e as applyDeprecatedKinds, f as assertSchemaCurrent, g as computeSchemaDiff, h as ensureSchema, i as getActiveSchema, j as getMigrationActions, k as getSchemaChanges, l as initializeSchema, m as isBackwardsCompatible, n as isSchemaInitialized, o as loadActiveSchemaWithBootstrap, p as loadAndMergeGraphExtensionDocument, q as migrateSchema, r as parseSerializedSchema, s as rollbackSchema } from '../manager-
|
|
3
|
-
import { s as SerializedSchema, t as SchemaHash, u as SerializedNodeDef, v as SerializedEdgeDef, w as SerializedMetaEdge, x as SerializedOntologyRelation, y as SerializedClosures } from '../fulltext-strategy-
|
|
4
|
-
export { z as JsonSchema, C as SerializedOntology, D as SerializedUniqueConstraint } from '../fulltext-strategy-
|
|
5
|
-
import { a as NullCheckOp, K as KindEntity } from '../extension-types-
|
|
1
|
+
import { G as GraphDef, K as KindRegistry } from '../manager-nU1vTJLy.cjs';
|
|
2
|
+
export { C as ChangeSeverity, a as ChangeType, D as DeprecatedKindsChange, E as EdgeChange, b as ExtensionChange, I as IndexChange, M as MigrationHookContext, N as NodeChange, O as OntologyChange, S as SchemaDiff, c as SchemaManagerOptions, d as SchemaValidationResult, e as applyDeprecatedKinds, f as assertSchemaCurrent, g as computeSchemaDiff, h as ensureSchema, i as getActiveSchema, j as getMigrationActions, k as getSchemaChanges, l as initializeSchema, m as isBackwardsCompatible, n as isSchemaInitialized, o as loadActiveSchemaWithBootstrap, p as loadAndMergeGraphExtensionDocument, q as migrateSchema, r as parseSerializedSchema, s as rollbackSchema } from '../manager-nU1vTJLy.cjs';
|
|
3
|
+
import { s as SerializedSchema, t as SchemaHash, u as SerializedNodeDef, v as SerializedEdgeDef, w as SerializedMetaEdge, x as SerializedOntologyRelation, y as SerializedClosures } from '../fulltext-strategy-C27vXaeB.cjs';
|
|
4
|
+
export { z as JsonSchema, C as SerializedOntology, D as SerializedUniqueConstraint } from '../fulltext-strategy-C27vXaeB.cjs';
|
|
5
|
+
import { a as NullCheckOp, K as KindEntity } from '../extension-types-BM2ACfYO.cjs';
|
|
6
6
|
import { ZodType, ZodError } from 'zod';
|
|
7
|
-
import { V as ValidationIssue, a as ValidationError } from '../index-
|
|
7
|
+
import { V as ValidationIssue, a as ValidationError } from '../index-BPM59vsg.cjs';
|
|
8
8
|
import 'drizzle-orm';
|
|
9
9
|
import 'drizzle-orm/pg-core';
|
|
10
10
|
import 'drizzle-orm/sqlite-core';
|
|
11
|
-
import '../materialize-indexes-
|
|
11
|
+
import '../materialize-indexes-CuR3gAZb.cjs';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Schema serializer for homoiconic storage.
|
package/dist/schema/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { G as GraphDef, K as KindRegistry } from '../manager-
|
|
2
|
-
export { C as ChangeSeverity, a as ChangeType, D as DeprecatedKindsChange, E as EdgeChange, b as ExtensionChange, I as IndexChange, M as MigrationHookContext, N as NodeChange, O as OntologyChange, S as SchemaDiff, c as SchemaManagerOptions, d as SchemaValidationResult, e as applyDeprecatedKinds, f as assertSchemaCurrent, g as computeSchemaDiff, h as ensureSchema, i as getActiveSchema, j as getMigrationActions, k as getSchemaChanges, l as initializeSchema, m as isBackwardsCompatible, n as isSchemaInitialized, o as loadActiveSchemaWithBootstrap, p as loadAndMergeGraphExtensionDocument, q as migrateSchema, r as parseSerializedSchema, s as rollbackSchema } from '../manager-
|
|
3
|
-
import { s as SerializedSchema, t as SchemaHash, u as SerializedNodeDef, v as SerializedEdgeDef, w as SerializedMetaEdge, x as SerializedOntologyRelation, y as SerializedClosures } from '../fulltext-strategy-
|
|
4
|
-
export { z as JsonSchema, C as SerializedOntology, D as SerializedUniqueConstraint } from '../fulltext-strategy-
|
|
5
|
-
import { a as NullCheckOp, K as KindEntity } from '../extension-types-
|
|
1
|
+
import { G as GraphDef, K as KindRegistry } from '../manager-D00_NXvT.js';
|
|
2
|
+
export { C as ChangeSeverity, a as ChangeType, D as DeprecatedKindsChange, E as EdgeChange, b as ExtensionChange, I as IndexChange, M as MigrationHookContext, N as NodeChange, O as OntologyChange, S as SchemaDiff, c as SchemaManagerOptions, d as SchemaValidationResult, e as applyDeprecatedKinds, f as assertSchemaCurrent, g as computeSchemaDiff, h as ensureSchema, i as getActiveSchema, j as getMigrationActions, k as getSchemaChanges, l as initializeSchema, m as isBackwardsCompatible, n as isSchemaInitialized, o as loadActiveSchemaWithBootstrap, p as loadAndMergeGraphExtensionDocument, q as migrateSchema, r as parseSerializedSchema, s as rollbackSchema } from '../manager-D00_NXvT.js';
|
|
3
|
+
import { s as SerializedSchema, t as SchemaHash, u as SerializedNodeDef, v as SerializedEdgeDef, w as SerializedMetaEdge, x as SerializedOntologyRelation, y as SerializedClosures } from '../fulltext-strategy-DebsMrqg.js';
|
|
4
|
+
export { z as JsonSchema, C as SerializedOntology, D as SerializedUniqueConstraint } from '../fulltext-strategy-DebsMrqg.js';
|
|
5
|
+
import { a as NullCheckOp, K as KindEntity } from '../extension-types-BM2ACfYO.js';
|
|
6
6
|
import { ZodType, ZodError } from 'zod';
|
|
7
|
-
import { V as ValidationIssue, a as ValidationError } from '../index-
|
|
7
|
+
import { V as ValidationIssue, a as ValidationError } from '../index-BeacbPoe.js';
|
|
8
8
|
import 'drizzle-orm';
|
|
9
9
|
import 'drizzle-orm/pg-core';
|
|
10
10
|
import 'drizzle-orm/sqlite-core';
|
|
11
|
-
import '../materialize-indexes-
|
|
11
|
+
import '../materialize-indexes-zK2J_flP.js';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Schema serializer for homoiconic storage.
|
package/dist/schema/index.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { KindRegistry, validateImpliesEndpointCompatibility } from '../chunk-
|
|
2
|
-
export { applyDeprecatedKinds, assertSchemaCurrent, computeSchemaDiff, computeSchemaHash, deserializeWherePredicate, ensureSchema, getActiveSchema, getMigrationActions, getSchemaChanges, initializeSchema, isBackwardsCompatible, isSchemaInitialized, loadActiveSchemaWithBootstrap, loadAndMergeGraphExtensionDocument, migrateSchema, parseSerializedSchema, rollbackSchema, serializeSchema } from '../chunk-
|
|
3
|
-
export { createValidationError, validateEdgeProps, validateNodeProps, validateProps, wrapZodError } from '../chunk-
|
|
1
|
+
import { KindRegistry, validateImpliesEndpointCompatibility } from '../chunk-3RWZPJKV.js';
|
|
2
|
+
export { applyDeprecatedKinds, assertSchemaCurrent, computeSchemaDiff, computeSchemaHash, deserializeWherePredicate, ensureSchema, getActiveSchema, getMigrationActions, getSchemaChanges, initializeSchema, isBackwardsCompatible, isSchemaInitialized, loadActiveSchemaWithBootstrap, loadAndMergeGraphExtensionDocument, migrateSchema, parseSerializedSchema, rollbackSchema, serializeSchema } from '../chunk-3RWZPJKV.js';
|
|
3
|
+
export { createValidationError, validateEdgeProps, validateNodeProps, validateProps, wrapZodError } from '../chunk-3SLPDKHQ.js';
|
|
4
4
|
import '../chunk-UR7W5YQK.js';
|
|
5
|
-
import '../chunk-
|
|
5
|
+
import '../chunk-K5UBVGJN.js';
|
|
6
6
|
import '../chunk-W63OVYY4.js';
|
|
7
|
-
import '../chunk-
|
|
8
|
-
import '../chunk-
|
|
9
|
-
import '../chunk-
|
|
10
|
-
import '../chunk-
|
|
11
|
-
import '../chunk-
|
|
7
|
+
import '../chunk-EXU3RASM.js';
|
|
8
|
+
import '../chunk-UGZUAYAR.js';
|
|
9
|
+
import '../chunk-L7HQ2OSI.js';
|
|
10
|
+
import '../chunk-TPF25IG6.js';
|
|
11
|
+
import '../chunk-XGPUQ56G.js';
|
|
12
12
|
import '../chunk-OHMP6N2J.js';
|
|
13
|
-
import '../chunk-
|
|
13
|
+
import '../chunk-PC2UBAUB.js';
|
|
14
14
|
import '../chunk-SNXVDZAJ.js';
|
|
15
15
|
import '../chunk-ITE4IXAK.js';
|
|
16
|
-
import '../chunk-
|
|
16
|
+
import '../chunk-5PNMDJ7J.js';
|
|
17
17
|
import '../chunk-G6Q5UM7U.js';
|
|
18
18
|
|
|
19
19
|
// src/schema/deserializer.ts
|