@nicia-ai/typegraph 0.49.0 → 0.51.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/README.md +12 -0
- package/dist/backend/drizzle/indexes.cjs +11 -9
- package/dist/backend/drizzle/indexes.d.cts +1 -1
- package/dist/backend/drizzle/indexes.d.ts +1 -1
- package/dist/backend/drizzle/indexes.js +7 -5
- package/dist/backend/index.cjs +190 -53
- package/dist/backend/index.d.cts +90 -4
- package/dist/backend/index.d.ts +90 -4
- package/dist/backend/index.js +9 -12
- package/dist/backend/postgres/index.cjs +36 -28
- package/dist/backend/postgres/index.d.cts +7 -7
- package/dist/backend/postgres/index.d.ts +7 -7
- package/dist/backend/postgres/index.js +19 -15
- package/dist/backend/postgres/pglite-store.cjs +7 -62
- package/dist/backend/postgres/pglite-store.cjs.map +1 -1
- package/dist/backend/postgres/pglite-store.d.cts +8 -8
- package/dist/backend/postgres/pglite-store.d.ts +8 -8
- package/dist/backend/postgres/pglite-store.js +7 -62
- package/dist/backend/postgres/pglite-store.js.map +1 -1
- package/dist/backend/postgres/pglite.cjs +21 -17
- package/dist/backend/postgres/pglite.d.cts +3 -3
- package/dist/backend/postgres/pglite.d.ts +3 -3
- package/dist/backend/postgres/pglite.js +20 -16
- package/dist/backend/sqlite/index.cjs +33 -25
- package/dist/backend/sqlite/index.d.cts +7 -7
- package/dist/backend/sqlite/index.d.ts +7 -7
- package/dist/backend/sqlite/index.js +17 -13
- package/dist/backend/sqlite/libsql.cjs +24 -20
- 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 +19 -15
- package/dist/backend/sqlite/libsql.js.map +1 -1
- package/dist/backend/sqlite/local-store.cjs +9 -64
- package/dist/backend/sqlite/local-store.cjs.map +1 -1
- package/dist/backend/sqlite/local-store.d.cts +8 -8
- package/dist/backend/sqlite/local-store.d.ts +8 -8
- package/dist/backend/sqlite/local-store.js +8 -64
- package/dist/backend/sqlite/local-store.js.map +1 -1
- package/dist/backend/sqlite/local.cjs +25 -20
- package/dist/backend/sqlite/local.d.cts +3 -3
- package/dist/backend/sqlite/local.d.ts +3 -3
- package/dist/backend/sqlite/local.js +21 -16
- package/dist/chunk-2CVDZCXH.cjs +1278 -0
- package/dist/chunk-2CVDZCXH.cjs.map +1 -0
- package/dist/{chunk-MYKHJI2J.js → chunk-2DWTBNSH.js} +3 -3
- package/dist/{chunk-MYKHJI2J.js.map → chunk-2DWTBNSH.js.map} +1 -1
- package/dist/{chunk-JB6T4GLL.cjs → chunk-2KCTP3U2.cjs} +870 -528
- package/dist/chunk-2KCTP3U2.cjs.map +1 -0
- package/dist/{chunk-OORXGFL5.cjs → chunk-322TBTOQ.cjs} +48 -48
- package/dist/{chunk-OORXGFL5.cjs.map → chunk-322TBTOQ.cjs.map} +1 -1
- package/dist/{chunk-FA2AFWLP.cjs → chunk-36SX6QXP.cjs} +31 -12
- package/dist/chunk-36SX6QXP.cjs.map +1 -0
- package/dist/{chunk-SDBBMD4N.js → chunk-36VYWVQU.js} +3 -3
- package/dist/{chunk-SDBBMD4N.js.map → chunk-36VYWVQU.js.map} +1 -1
- package/dist/chunk-4DKY6RIU.js +1253 -0
- package/dist/chunk-4DKY6RIU.js.map +1 -0
- package/dist/chunk-4QKOZYMV.js +9 -0
- package/dist/chunk-4QKOZYMV.js.map +1 -0
- package/dist/{chunk-WIC7DRXW.js → chunk-57JM6NW3.js} +9 -19
- package/dist/chunk-57JM6NW3.js.map +1 -0
- package/dist/chunk-5WWEYV4H.cjs +5113 -0
- package/dist/chunk-5WWEYV4H.cjs.map +1 -0
- package/dist/chunk-6KQEICJ6.cjs +12 -0
- package/dist/{chunk-MKJ4KXL5.cjs.map → chunk-6KQEICJ6.cjs.map} +1 -1
- package/dist/{chunk-DZAICA5J.js → chunk-6NKSE5AU.js} +4 -4
- package/dist/{chunk-DZAICA5J.js.map → chunk-6NKSE5AU.js.map} +1 -1
- package/dist/{chunk-KKBDXCLQ.js → chunk-6NLYIMJO.js} +4 -4
- package/dist/{chunk-KKBDXCLQ.js.map → chunk-6NLYIMJO.js.map} +1 -1
- package/dist/{chunk-BFUOME67.cjs → chunk-7B7I7YAW.cjs} +20 -11
- package/dist/chunk-7B7I7YAW.cjs.map +1 -0
- package/dist/{chunk-ZDKTPBGV.js → chunk-7G5IYROL.js} +6 -548
- package/dist/chunk-7G5IYROL.js.map +1 -0
- package/dist/{chunk-3DMMGT6S.js → chunk-7QFRK6PU.js} +4 -8
- package/dist/chunk-7QFRK6PU.js.map +1 -0
- package/dist/chunk-A4C4NJ5U.cjs +12 -0
- package/dist/chunk-A4C4NJ5U.cjs.map +1 -0
- package/dist/{chunk-CHAOFCHV.js → chunk-AH2A74OZ.js} +3 -3
- package/dist/{chunk-CHAOFCHV.js.map → chunk-AH2A74OZ.js.map} +1 -1
- package/dist/{chunk-UGHQV7MP.cjs → chunk-B3MN7EJR.cjs} +228 -162
- package/dist/chunk-B3MN7EJR.cjs.map +1 -0
- package/dist/{chunk-TZEGUG6D.cjs → chunk-BZ5MVITP.cjs} +4 -4
- package/dist/{chunk-TZEGUG6D.cjs.map → chunk-BZ5MVITP.cjs.map} +1 -1
- package/dist/{chunk-YVF2EM7B.js → chunk-CAI6SMP6.js} +3 -3
- package/dist/{chunk-YVF2EM7B.js.map → chunk-CAI6SMP6.js.map} +1 -1
- package/dist/{chunk-JONXFAPO.js → chunk-CBOD7TXH.js} +5 -5
- package/dist/{chunk-JONXFAPO.js.map → chunk-CBOD7TXH.js.map} +1 -1
- package/dist/{chunk-FQPEMEWX.cjs → chunk-CRZ56SZU.cjs} +81 -32
- package/dist/chunk-CRZ56SZU.cjs.map +1 -0
- package/dist/{chunk-DO7SAMEK.cjs → chunk-D3GWARN7.cjs} +47 -47
- package/dist/{chunk-DO7SAMEK.cjs.map → chunk-D3GWARN7.cjs.map} +1 -1
- package/dist/{chunk-QTD6HX4O.js → chunk-D3OUDFU7.js} +5 -5
- package/dist/{chunk-QTD6HX4O.js.map → chunk-D3OUDFU7.js.map} +1 -1
- package/dist/{chunk-2QGYQBS2.cjs → chunk-DWUDZ66O.cjs} +10 -10
- package/dist/{chunk-2QGYQBS2.cjs.map → chunk-DWUDZ66O.cjs.map} +1 -1
- package/dist/chunk-EKG2UXNX.cjs +23 -0
- package/dist/chunk-EKG2UXNX.cjs.map +1 -0
- package/dist/chunk-FMMW3KX7.cjs +148 -0
- package/dist/chunk-FMMW3KX7.cjs.map +1 -0
- package/dist/{chunk-XVWOYKIK.js → chunk-FZHF5UWR.js} +3 -3
- package/dist/{chunk-XVWOYKIK.js.map → chunk-FZHF5UWR.js.map} +1 -1
- package/dist/chunk-H2VWDQWC.cjs +571 -0
- package/dist/chunk-H2VWDQWC.cjs.map +1 -0
- package/dist/chunk-H4FY6OZK.js +13 -0
- package/dist/chunk-H4FY6OZK.js.map +1 -0
- package/dist/{chunk-EDN4Y4ZG.cjs → chunk-H5IJSROF.cjs} +9 -15
- package/dist/chunk-H5IJSROF.cjs.map +1 -0
- package/dist/chunk-HZUB5CON.js +27 -0
- package/dist/chunk-HZUB5CON.js.map +1 -0
- package/dist/{chunk-NACVVDWB.js → chunk-I5IOSA27.js} +103 -105
- package/dist/chunk-I5IOSA27.js.map +1 -0
- package/dist/{chunk-OI2GQ25X.cjs → chunk-I7YAY2VQ.cjs} +7 -7
- package/dist/{chunk-OI2GQ25X.cjs.map → chunk-I7YAY2VQ.cjs.map} +1 -1
- package/dist/chunk-IRCWIA3R.js +20 -0
- package/dist/chunk-IRCWIA3R.js.map +1 -0
- package/dist/chunk-IVQBLXBK.cjs +55 -0
- package/dist/chunk-IVQBLXBK.cjs.map +1 -0
- package/dist/{chunk-7SQSZN2J.js → chunk-IZD4HTCP.js} +5 -5
- package/dist/{chunk-7SQSZN2J.js.map → chunk-IZD4HTCP.js.map} +1 -1
- package/dist/{chunk-3FPR224C.cjs → chunk-JHRUZ73O.cjs} +116 -107
- package/dist/chunk-JHRUZ73O.cjs.map +1 -0
- package/dist/{chunk-EZEEWCFJ.cjs → chunk-JQKMEKKW.cjs} +525 -298
- package/dist/chunk-JQKMEKKW.cjs.map +1 -0
- package/dist/chunk-JVA3KDEA.cjs +691 -0
- package/dist/chunk-JVA3KDEA.cjs.map +1 -0
- package/dist/{chunk-5K2BKEBD.js → chunk-K46SDNQD.js} +10 -4
- package/dist/chunk-K46SDNQD.js.map +1 -0
- package/dist/{chunk-7LZJNLA5.js → chunk-K67P5DLL.js} +108 -42
- package/dist/chunk-K67P5DLL.js.map +1 -0
- package/dist/{chunk-3G5W2U2L.cjs → chunk-KACEYDYV.cjs} +335 -258
- package/dist/chunk-KACEYDYV.cjs.map +1 -0
- package/dist/{chunk-JFRT7S3B.cjs → chunk-L6EVYIID.cjs} +318 -478
- package/dist/chunk-L6EVYIID.cjs.map +1 -0
- package/dist/{chunk-SHFBB23Q.js → chunk-LI4K2KEJ.js} +6 -4
- package/dist/chunk-LI4K2KEJ.js.map +1 -0
- package/dist/chunk-LKZDQ2B4.js +1581 -0
- package/dist/chunk-LKZDQ2B4.js.map +1 -0
- package/dist/{chunk-WODMN3Q2.cjs → chunk-LLFPQOBA.cjs} +27 -27
- package/dist/{chunk-WODMN3Q2.cjs.map → chunk-LLFPQOBA.cjs.map} +1 -1
- package/dist/{chunk-P6YLZTRE.js → chunk-LZMQ3SFK.js} +3 -3
- package/dist/{chunk-P6YLZTRE.js.map → chunk-LZMQ3SFK.js.map} +1 -1
- package/dist/{chunk-HEV35TGT.js → chunk-M3VTS3F6.js} +13 -4
- package/dist/chunk-M3VTS3F6.js.map +1 -0
- package/dist/{chunk-TQHGE7UC.cjs → chunk-M5MSP3BI.cjs} +18 -10
- package/dist/chunk-M5MSP3BI.cjs.map +1 -0
- package/dist/{chunk-D4QLTJSM.js → chunk-NBOS7BY3.js} +63 -23
- package/dist/chunk-NBOS7BY3.js.map +1 -0
- package/dist/chunk-NGQDGL5X.js +140 -0
- package/dist/chunk-NGQDGL5X.js.map +1 -0
- package/dist/{chunk-SIT26LAZ.cjs → chunk-NLX5OWK7.cjs} +33 -5
- package/dist/chunk-NLX5OWK7.cjs.map +1 -0
- package/dist/chunk-NUQ2YFFH.cjs +1637 -0
- package/dist/chunk-NUQ2YFFH.cjs.map +1 -0
- package/dist/{chunk-UMGZDVOA.cjs → chunk-OGL4X4PH.cjs} +206 -208
- package/dist/chunk-OGL4X4PH.cjs.map +1 -0
- package/dist/{chunk-LRQKXRXO.cjs → chunk-OTNTGEXR.cjs} +4 -4
- package/dist/{chunk-LRQKXRXO.cjs.map → chunk-OTNTGEXR.cjs.map} +1 -1
- package/dist/chunk-OTWE63BW.js +53 -0
- package/dist/chunk-OTWE63BW.js.map +1 -0
- package/dist/chunk-PC5NGH5A.js +549 -0
- package/dist/chunk-PC5NGH5A.js.map +1 -0
- package/dist/{chunk-26YKDNUD.cjs → chunk-PS3TUWJM.cjs} +12 -10
- package/dist/chunk-PS3TUWJM.cjs.map +1 -0
- package/dist/{chunk-OMZ37BM2.js → chunk-PVFFH7TL.js} +5 -5
- package/dist/{chunk-OMZ37BM2.js.map → chunk-PVFFH7TL.js.map} +1 -1
- package/dist/chunk-QCD5JKU4.cjs +15 -0
- package/dist/chunk-QCD5JKU4.cjs.map +1 -0
- package/dist/{chunk-UGHG7PGX.js → chunk-QG5VEOKX.js} +30 -4
- package/dist/chunk-QG5VEOKX.js.map +1 -0
- package/dist/{chunk-TUNPBZY3.cjs → chunk-QLLZM5I3.cjs} +4 -4
- package/dist/{chunk-TUNPBZY3.cjs.map → chunk-QLLZM5I3.cjs.map} +1 -1
- package/dist/{chunk-BRRP76WO.js → chunk-RCBG6YMT.js} +781 -375
- package/dist/chunk-RCBG6YMT.js.map +1 -0
- package/dist/{chunk-LTXQOEIC.js → chunk-RI7RJH4G.js} +281 -204
- package/dist/chunk-RI7RJH4G.js.map +1 -0
- package/dist/{chunk-GYEG3ZLZ.cjs → chunk-RJMHU2MG.cjs} +121 -18
- package/dist/chunk-RJMHU2MG.cjs.map +1 -0
- package/dist/{chunk-GLHXM7C4.js → chunk-RVUL2HXY.js} +61 -23
- package/dist/chunk-RVUL2HXY.js.map +1 -0
- package/dist/chunk-RWUWTJQY.cjs +30 -0
- package/dist/chunk-RWUWTJQY.cjs.map +1 -0
- package/dist/{chunk-2O4PCIZ6.cjs → chunk-S5GU4LUN.cjs} +13 -13
- package/dist/{chunk-2O4PCIZ6.cjs.map → chunk-S5GU4LUN.cjs.map} +1 -1
- package/dist/{chunk-JPD2CTC3.js → chunk-SDPWO2Z5.js} +7 -7
- package/dist/{chunk-JPD2CTC3.js.map → chunk-SDPWO2Z5.js.map} +1 -1
- package/dist/{chunk-OVI7IXYX.js → chunk-SLGGT2XD.js} +3 -3
- package/dist/{chunk-OVI7IXYX.js.map → chunk-SLGGT2XD.js.map} +1 -1
- package/dist/{chunk-ROR5ZR6A.cjs → chunk-TIJUA4I6.cjs} +45 -45
- package/dist/{chunk-ROR5ZR6A.cjs.map → chunk-TIJUA4I6.cjs.map} +1 -1
- package/dist/{chunk-AOSSQDVO.cjs → chunk-TM54OBHX.cjs} +13 -13
- package/dist/{chunk-AOSSQDVO.cjs.map → chunk-TM54OBHX.cjs.map} +1 -1
- package/dist/{chunk-KF6K7TGH.js → chunk-TYEYRCXL.js} +766 -433
- package/dist/chunk-TYEYRCXL.js.map +1 -0
- package/dist/{chunk-Z2JCLZFJ.js → chunk-UKOVGCRN.js} +2151 -570
- package/dist/chunk-UKOVGCRN.js.map +1 -0
- package/dist/chunk-UYKDYE5D.cjs +12 -0
- package/dist/{chunk-CICO5GXD.cjs.map → chunk-UYKDYE5D.cjs.map} +1 -1
- package/dist/{chunk-S5TERQVW.js → chunk-VAAC7L57.js} +284 -66
- package/dist/chunk-VAAC7L57.js.map +1 -0
- package/dist/{chunk-7UOLHNWC.cjs → chunk-VKHXYVN7.cjs} +22 -33
- package/dist/chunk-VKHXYVN7.cjs.map +1 -0
- package/dist/{chunk-6NGW27EO.cjs → chunk-VLBTRXA2.cjs} +10 -10
- package/dist/{chunk-6NGW27EO.cjs.map → chunk-VLBTRXA2.cjs.map} +1 -1
- package/dist/{chunk-YIURNGXI.js → chunk-VUQZNUHU.js} +22 -6
- package/dist/chunk-VUQZNUHU.js.map +1 -0
- package/dist/{chunk-YYUHLYM2.cjs → chunk-WDM5WQK4.cjs} +183 -143
- package/dist/chunk-WDM5WQK4.cjs.map +1 -0
- package/dist/{chunk-ZFMCDJGB.js → chunk-WFSYYU4W.js} +70 -220
- package/dist/chunk-WFSYYU4W.js.map +1 -0
- package/dist/{chunk-SR725PWF.cjs → chunk-WRBV2FNH.cjs} +2065 -1659
- package/dist/chunk-WRBV2FNH.cjs.map +1 -0
- package/dist/{chunk-MRDBBHIZ.cjs → chunk-X4GDXBOP.cjs} +2 -2
- package/dist/chunk-X4GDXBOP.cjs.map +1 -0
- package/dist/chunk-XORONCV3.js +202 -0
- package/dist/chunk-XORONCV3.js.map +1 -0
- package/dist/{chunk-D5R42W5D.js → chunk-XZW2CTNO.js} +115 -12
- package/dist/chunk-XZW2CTNO.js.map +1 -0
- package/dist/{chunk-ZLONH2UD.js → chunk-YDEJQWOL.js} +2 -2
- package/dist/chunk-YDEJQWOL.js.map +1 -0
- package/dist/{chunk-2TYSSBU5.js → chunk-YT2IVFAI.js} +30 -21
- package/dist/chunk-YT2IVFAI.js.map +1 -0
- package/dist/chunk-ZGVTNKTX.cjs +217 -0
- package/dist/chunk-ZGVTNKTX.cjs.map +1 -0
- package/dist/core/index.cjs +29 -28
- package/dist/core/index.d.cts +4 -4
- package/dist/core/index.d.ts +4 -4
- package/dist/core/index.js +9 -8
- package/dist/{ddl-D_oW-EVO.d.ts → ddl-BvcbgzHo.d.ts} +3 -3
- package/dist/{ddl-BL1NZLMY.d.cts → ddl-Ufebz5q5.d.cts} +3 -3
- package/dist/graph-extension/index.cjs +21 -20
- package/dist/graph-extension/index.d.cts +2 -4
- package/dist/graph-extension/index.d.ts +2 -4
- package/dist/graph-extension/index.js +5 -4
- package/dist/graph-merge/index.cjs +324 -307
- package/dist/graph-merge/index.cjs.map +1 -1
- package/dist/graph-merge/index.d.cts +8 -9
- package/dist/graph-merge/index.d.ts +8 -9
- package/dist/graph-merge/index.js +51 -34
- package/dist/graph-merge/index.js.map +1 -1
- package/dist/index.cjs +224 -222
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -12
- package/dist/index.d.ts +11 -12
- package/dist/index.js +38 -36
- package/dist/index.js.map +1 -1
- package/dist/indexes/index.cjs +15 -13
- package/dist/indexes/index.d.cts +4 -4
- package/dist/indexes/index.d.ts +4 -4
- package/dist/indexes/index.js +8 -6
- package/dist/{ingestion-import-target-dNeL7iAv.d.ts → ingestion-import-target-CAs1OX-l.d.cts} +1 -1
- package/dist/{ingestion-import-target-XPxZYw89.d.cts → ingestion-import-target-DCQSPfNx.d.ts} +1 -1
- package/dist/interchange/index.cjs +57 -54
- package/dist/interchange/index.cjs.map +1 -1
- package/dist/interchange/index.d.cts +19 -8
- package/dist/interchange/index.d.ts +19 -8
- package/dist/interchange/index.js +21 -18
- package/dist/interchange/index.js.map +1 -1
- package/dist/local-store-impl-6DDTFM32.cjs +77 -0
- package/dist/local-store-impl-6DDTFM32.cjs.map +1 -0
- package/dist/local-store-impl-OXTOVU2J.js +75 -0
- package/dist/local-store-impl-OXTOVU2J.js.map +1 -0
- package/dist/{manager-CYaff3n3.d.cts → manager-B68OrPR2.d.ts} +29 -2
- package/dist/{manager-D9eRT_ns.d.ts → manager-D_t7oK69.d.cts} +29 -2
- package/dist/pglite-store-impl-6EMZGL7K.js +73 -0
- package/dist/pglite-store-impl-6EMZGL7K.js.map +1 -0
- package/dist/pglite-store-impl-GJG3Y7RP.cjs +75 -0
- package/dist/pglite-store-impl-GJG3Y7RP.cjs.map +1 -0
- package/dist/{postgres-CcL4bAHS.d.ts → postgres-BPLSVyHM.d.ts} +279 -2
- package/dist/{postgres-DMj39MEu.d.cts → postgres-CqvtFC2y.d.cts} +279 -2
- package/dist/profiler/index.d.cts +9 -9
- package/dist/profiler/index.d.ts +9 -9
- package/dist/provenance/index.cjs +59 -44
- package/dist/provenance/index.cjs.map +1 -1
- package/dist/provenance/index.d.cts +7 -7
- package/dist/provenance/index.d.ts +7 -7
- package/dist/provenance/index.js +28 -13
- package/dist/provenance/index.js.map +1 -1
- package/dist/{repair-validity-windows-BFNZvd_H.d.cts → repair-validity-windows-DEzCKAdy.d.cts} +7 -3
- package/dist/{repair-validity-windows-DlUSqwCg.d.ts → repair-validity-windows-GMdaS2AH.d.ts} +7 -3
- package/dist/resolve-D_H8MHtq.d.ts +1805 -0
- package/dist/resolve-WEW8gWws.d.cts +1805 -0
- package/dist/schema/index.cjs +48 -46
- package/dist/schema/index.d.cts +4 -6
- package/dist/schema/index.d.ts +4 -6
- package/dist/schema/index.js +21 -19
- package/dist/{searchable-bpE1bBfc.d.ts → searchable-C_UREI9K.d.ts} +1 -1
- package/dist/{searchable-DHJMh_nj.d.cts → searchable-ClgET_i7.d.cts} +1 -1
- package/dist/{sqlite-YppHrNFb.d.cts → sqlite-D1mXO9Kp.d.cts} +310 -2
- package/dist/{sqlite-D7Oz0SQh.d.ts → sqlite-MZA3oZNB.d.ts} +310 -2
- package/dist/{store-bphCSo7z.d.cts → store-CuFX7fCx.d.cts} +117 -31
- package/dist/{store-DRrFCx5x.d.ts → store-D-ZjXQpW.d.ts} +117 -31
- package/dist/{temporal-CbnLzTmM.d.ts → temporal-CpyEiRY8.d.cts} +1 -1
- package/dist/{temporal-5GqpYCk2.d.cts → temporal-y0Aep9Su.d.ts} +1 -1
- package/dist/{types-BqFZTQmV.d.cts → types-6yf0Vv-_.d.cts} +2016 -94
- package/dist/{types-BqFZTQmV.d.ts → types-6yf0Vv-_.d.ts} +2016 -94
- package/dist/{types-Bx74kaTt.d.ts → types-DzJ4dlzk.d.cts} +1 -1
- package/dist/{types-CXAhpW-c.d.cts → types-_vVSB9k-.d.ts} +1 -1
- package/dist/{where-O-k2wgYm.d.ts → where-DuG2LCLe.d.ts} +1 -1
- package/dist/{where-DI_Fqz-X.d.cts → where-Mhf_yyKX.d.cts} +1 -1
- package/package.json +7 -2
- package/dist/chunk-26YKDNUD.cjs.map +0 -1
- package/dist/chunk-2TYSSBU5.js.map +0 -1
- package/dist/chunk-3DMMGT6S.js.map +0 -1
- package/dist/chunk-3FPR224C.cjs.map +0 -1
- package/dist/chunk-3G5W2U2L.cjs.map +0 -1
- package/dist/chunk-3KOY4FH3.cjs +0 -934
- package/dist/chunk-3KOY4FH3.cjs.map +0 -1
- package/dist/chunk-3QNZ5SAJ.cjs +0 -3502
- package/dist/chunk-3QNZ5SAJ.cjs.map +0 -1
- package/dist/chunk-3U5ABFDW.cjs +0 -259
- package/dist/chunk-3U5ABFDW.cjs.map +0 -1
- package/dist/chunk-5K2BKEBD.js.map +0 -1
- package/dist/chunk-5PRKMB24.cjs +0 -124
- package/dist/chunk-5PRKMB24.cjs.map +0 -1
- package/dist/chunk-6LN7FIVU.js +0 -107
- package/dist/chunk-6LN7FIVU.js.map +0 -1
- package/dist/chunk-6SWPJEYN.js +0 -1126
- package/dist/chunk-6SWPJEYN.js.map +0 -1
- package/dist/chunk-7LZJNLA5.js.map +0 -1
- package/dist/chunk-7UOLHNWC.cjs.map +0 -1
- package/dist/chunk-BFUOME67.cjs.map +0 -1
- package/dist/chunk-BRRP76WO.js.map +0 -1
- package/dist/chunk-CICO5GXD.cjs +0 -12
- package/dist/chunk-D4QLTJSM.js.map +0 -1
- package/dist/chunk-D5R42W5D.js.map +0 -1
- package/dist/chunk-EDN4Y4ZG.cjs.map +0 -1
- package/dist/chunk-EZEEWCFJ.cjs.map +0 -1
- package/dist/chunk-FA2AFWLP.cjs.map +0 -1
- package/dist/chunk-FQPEMEWX.cjs.map +0 -1
- package/dist/chunk-GLHXM7C4.js.map +0 -1
- package/dist/chunk-GYEG3ZLZ.cjs.map +0 -1
- package/dist/chunk-HDL2ARHX.cjs +0 -1156
- package/dist/chunk-HDL2ARHX.cjs.map +0 -1
- package/dist/chunk-HEV35TGT.js.map +0 -1
- package/dist/chunk-I4GAZH5Z.js +0 -913
- package/dist/chunk-I4GAZH5Z.js.map +0 -1
- package/dist/chunk-JB6T4GLL.cjs.map +0 -1
- package/dist/chunk-JBQQ7THH.js +0 -20
- package/dist/chunk-JBQQ7THH.js.map +0 -1
- package/dist/chunk-JFRT7S3B.cjs.map +0 -1
- package/dist/chunk-KF6K7TGH.js.map +0 -1
- package/dist/chunk-L3LQNR34.cjs +0 -1254
- package/dist/chunk-L3LQNR34.cjs.map +0 -1
- package/dist/chunk-LTXQOEIC.js.map +0 -1
- package/dist/chunk-MKJ4KXL5.cjs +0 -12
- package/dist/chunk-MRDBBHIZ.cjs.map +0 -1
- package/dist/chunk-NACVVDWB.js.map +0 -1
- package/dist/chunk-NVY5CJFP.js +0 -244
- package/dist/chunk-NVY5CJFP.js.map +0 -1
- package/dist/chunk-PWLJ77UV.cjs +0 -23
- package/dist/chunk-PWLJ77UV.cjs.map +0 -1
- package/dist/chunk-S5TERQVW.js.map +0 -1
- package/dist/chunk-SHFBB23Q.js.map +0 -1
- package/dist/chunk-SIT26LAZ.cjs.map +0 -1
- package/dist/chunk-SR725PWF.cjs.map +0 -1
- package/dist/chunk-TQHGE7UC.cjs.map +0 -1
- package/dist/chunk-UGHG7PGX.js.map +0 -1
- package/dist/chunk-UGHQV7MP.cjs.map +0 -1
- package/dist/chunk-UMGZDVOA.cjs.map +0 -1
- package/dist/chunk-WIC7DRXW.js.map +0 -1
- package/dist/chunk-YIURNGXI.js.map +0 -1
- package/dist/chunk-YYUHLYM2.cjs.map +0 -1
- package/dist/chunk-Z2JCLZFJ.js.map +0 -1
- package/dist/chunk-ZDKTPBGV.js.map +0 -1
- package/dist/chunk-ZFMCDJGB.js.map +0 -1
- package/dist/chunk-ZLONH2UD.js.map +0 -1
- package/dist/index-COs_z6nV.d.cts +0 -1132
- package/dist/index-D7d1u2gr.d.ts +0 -1132
- package/dist/materialize-indexes-DJ3ykH59.d.ts +0 -266
- package/dist/materialize-indexes-DTtAnvfY.d.cts +0 -266
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/errors/index.ts"],"names":[],"mappings":";;;AA0DA,SAAS,YAAY,KAAA,EAAwB;AAC3C,EAAA,IAAI,iBAAiB,KAAA,EAAO;AAC1B,IAAA,OAAO,KAAA,CAAM,SAAS,KAAA,CAAM,OAAA;AAAA,EAC9B;AACA,EAAA,IAAI,OAAO,UAAU,QAAA,EAAU;AAC7B,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,IACE,OAAO,UAAU,QAAA,IACjB,OAAO,UAAU,SAAA,IACjB,OAAO,UAAU,QAAA,EACjB;AACA,IAAA,OAAO,OAAO,KAAK,CAAA;AAAA,EACrB;AACA,EAAA,IAAI,OAAO,UAAU,QAAA,EAAU;AAC7B,IAAA,OAAO,MAAM,WAAA,IAAe,QAAA;AAAA,EAC9B;AACA,EAAA,IAAI,UAAU,MAAA,EAAW;AACvB,IAAA,OAAO,eAAA;AAAA,EACT;AAEA,EAAA,IAAI;AACF,IAAA,OAAO,IAAA,CAAK,UAAU,KAAK,CAAA;AAAA,EAC7B,SAAS,KAAA,EAAO;AACd,IAAA,OAAO,CAAA,sBAAA,EACL,KAAA,YAAiB,KAAA,GAAQ,KAAA,CAAM,UAAU,eAC3C,CAAA,CAAA;AAAA,EACF;AACF;AAYO,IAAM,cAAA,GAAN,cAA6B,KAAA,CAAM;AAAA;AAAA,EAE/B,IAAA;AAAA;AAAA,EAGA,QAAA;AAAA;AAAA,EAGA,OAAA;AAAA;AAAA,EAGA,UAAA;AAAA,EAET,WAAA,CAAY,OAAA,EAAiB,IAAA,EAAc,OAAA,EAAgC;AACzE,IAAA,KAAA,CAAM,OAAA,EAAS,QAAQ,KAAA,GAAQ,EAAE,OAAO,OAAA,CAAQ,KAAA,KAAU,MAAS,CAAA;AACnE,IAAA,IAAA,CAAK,IA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AAa,MAAA,IAAU,KAAA,CAAM,QAAA,KAAa,YAAA;AACzD;AAUO,SAAS,cAAc,KAAA,EAAyB;AACrD,EAAA,OAAO,gBAAA,CAAiB,KAAK,CAAA,IAAK,KAAA,CAAM,QAAA,KAAa,QAAA;AACvD;AAKO,SAAS,kBAAkB,KAAA,EAAyB;AACzD,EAAA,OAAO,gBAAA,CAAiB,KAAK,CAAA,IAAK,KAAA,CAAM,QAAA,KAAa,YAAA;AACvD;AAKO,SAAS,mBAAmB,KAAA,EAAoC;AACrE,EAAA,OAAO,gBAAA,CAAiB,KAAK,CAAA,GAAI,KAAA,CAAM,UAAA,GAAa,MAAA;AACtD","file":"chunk-MRDBBHIZ.cjs","sourcesContent":["/**\n * TypeGraph Error Hierarchy\n *\n * All errors extend TypeGraphError with:\n * - `code`: Machine-readable error code for programmatic handling\n * - `category`: Classification for error handling strategies\n * - `suggestion`: Optional recovery guidance for users\n * - `details`: Structured context about the error\n *\n * @example\n * ```typescript\n * try {\n * await store.nodes.Person.create({ name: \"\" });\n * } catch (error) {\n * if (isTypeGraphError(error)) {\n * console.error(error.toUserMessage());\n * if (isUserRecoverable(error)) {\n * // Show to user for correction\n * }\n * }\n * }\n * ```\n */\n\nimport type { KindEntity } from \"../core/types\";\nimport type { SchemaDiff } from \"../schema/migration\";\n// Type-only import: `materialize-indexes.ts` value-imports\n// `ConfigurationError` from this file, but type-only imports are erased\n// at runtime so this back-edge does not create a value cycle.\nimport type { MaterializeIndexesResult } from \"../store/materialize-indexes\";\n\n// ============================================================\n// Types\n// ============================================================\n\n/**\n * Error category for programmatic handling.\n *\n * - `user`: Caused by invalid input or incorrect usage. Recoverable by fixing input.\n * - `constraint`: Business rule or schema constraint violation. Recoverable by changing data.\n * - `system`: Internal error or infrastructure issue. May require investigation or retry.\n */\nexport type ErrorCategory = \"user\" | \"constraint\" | \"system\";\n\n/**\n * Options for TypeGraphError constructor.\n */\nexport type TypeGraphErrorOptions = Readonly<{\n /** Structured context about the error */\n details?: Record<string, unknown>;\n /** Error category for handling strategies */\n category: ErrorCategory;\n /** Recovery guidance for users */\n suggestion?: string;\n /** Underlying cause of the error */\n cause?: unknown;\n}>;\n\nfunction formatCause(cause: unknown): string {\n if (cause instanceof Error) {\n return cause.stack ?? cause.message;\n }\n if (typeof cause === \"string\") {\n return cause;\n }\n if (\n typeof cause === \"number\" ||\n typeof cause === \"boolean\" ||\n typeof cause === \"bigint\"\n ) {\n return String(cause);\n }\n if (typeof cause === \"symbol\") {\n return cause.description ?? \"Symbol\";\n }\n if (cause === undefined) {\n return \"Unknown cause\";\n }\n\n try {\n return JSON.stringify(cause);\n } catch (error) {\n return `Unserializable cause: ${\n error instanceof Error ? error.message : \"Unknown error\"\n }`;\n }\n}\n\n// ============================================================\n// Base Error\n// ============================================================\n\n/**\n * Base error class for all TypeGraph errors.\n *\n * Provides structured error information for both programmatic handling\n * and user-friendly messages.\n */\nexport class TypeGraphError extends Error {\n /** Machine-readable error code (e.g., \"VALIDATION_ERROR\") */\n readonly code: string;\n\n /** Error category for handling strategies */\n readonly category: ErrorCategory;\n\n /** Structured context about the error */\n readonly details: Readonly<Record<string, unknown>>;\n\n /** Recovery guidance for users */\n readonly suggestion?: string;\n\n constructor(message: string, code: string, options: TypeGraphErrorOptions) {\n super(message, options.cause ? { cause: options.cause } : undefined);\n this.name = \"TypeGraphError\";\n this.code = code;\n this.category = options.category;\n this.details = Object.freeze(options.details ?? {});\n if (options.suggestion !== undefined) {\n this.suggestion = options.suggestion;\n }\n }\n\n /**\n * Returns a user-friendly error message with suggestion if available.\n */\n toUserMessage(): string {\n if (this.suggestion) {\n return `${this.message}\\n\\nSuggestion: ${this.suggestion}`;\n }\n return this.message;\n }\n\n /**\n * Returns a detailed string representation for logging.\n */\n toLogString(): string {\n const lines = [\n `[${this.code}] ${this.message}`,\n ` Category: ${this.category}`,\n ];\n\n if (this.suggestion) {\n lines.push(` Suggestion: ${this.suggestion}`);\n }\n\n const detailKeys = Object.keys(this.details);\n if (detailKeys.length > 0) {\n lines.push(` Details: ${JSON.stringify(this.details)}`);\n }\n\n if (this.cause) {\n lines.push(` Cause: ${formatCause(this.cause)}`);\n }\n\n return lines.join(\"\\n\");\n }\n}\n\n// ============================================================\n// Validation Errors (category: \"user\")\n// ============================================================\n\n/**\n * Validation issue from Zod or custom validation.\n */\nexport type ValidationIssue = Readonly<{\n /** Path to the invalid field (e.g., \"address.city\") */\n path: string;\n /** Human-readable error message */\n message: string;\n /** Zod error code if from Zod validation */\n code?: string;\n /**\n * The identity assertion the issue is about, carried structurally so\n * consumers (e.g. interchange import error reporting) never have to parse\n * the human-readable message for it.\n */\n assertionId?: string;\n}>;\n\n/**\n * The stable {@link ValidationIssue.code} every inverted-validity-window\n * refusal carries, so a caller can recognize that specific failure without\n * matching on the message. `ValidationError`'s own code is the family-wide\n * `VALIDATION_ERROR`, so the discriminator lives on the issue — mirroring the\n * identity-import window refusal (`IDENTITY_IMPORT_INVALID_WINDOW`).\n *\n * A write carrying it was refused because `validTo` precedes the row's\n * effective `validFrom`: the row would have stopped being true before it\n * started, observable at no `asOf` coordinate at all. Zero-width windows\n * (`validTo === validFrom`) are legal and never raise it.\n */\nexport const INVERTED_VALIDITY_WINDOW_CODE = \"INVERTED_VALIDITY_WINDOW\";\n\n/**\n * The stable {@link ValidationIssue.code} carried by a refusal to accept a\n * `validFrom` the write cannot apply: the target row is LIVE, and an in-place\n * update never rewrites a live row's lower bound — that bound is history.\n * `ValidationError`'s own code is the family-wide `VALIDATION_ERROR`, so the\n * discriminator lives on the issue — mirroring\n * {@link INVERTED_VALIDITY_WINDOW_CODE}.\n *\n * Only a bound naming a DIFFERENT instant than the row already stores raises it.\n * Restating the stored bound is legal and writes nothing new, and a resurrection\n * — which does rewrite `valid_from` — applies a stated bound rather than\n * refusing it.\n *\n * The message names both instants: the one stated and the one the row stores, so\n * the caller can restate the stored bound without a second read.\n */\nexport const IMMUTABLE_VALIDITY_LOWER_BOUND_CODE =\n \"IMMUTABLE_VALIDITY_LOWER_BOUND\";\n\n/**\n * Stable {@link ValidationIssue.code} for an edge-id ownership mismatch.\n *\n * Edge ids are graph-global. A collection-scoped write therefore has to prove\n * that the stored row has the collection's kind and, when the caller supplies\n * endpoints, the same immutable endpoints. This refusal prevents a collection\n * from mutating another kind's row and prevents an upsert from silently\n * ignoring an attempted repoint.\n */\nexport const EDGE_IDENTITY_MISMATCH_CODE = \"EDGE_IDENTITY_MISMATCH\";\n\n/**\n * The stable {@link ValidationIssue.code} every \"this id is already taken\"\n * create refusal carries, whichever way the create found out: its own existence\n * probe, or the engine refusing the INSERT. `ValidationError`'s own code is the\n * family-wide `VALIDATION_ERROR`, so the discriminator lives on the issue —\n * mirroring {@link INVERTED_VALIDITY_WINDOW_CODE}.\n *\n * `details.entityType` says whether a node or an edge was refused and\n * `details.kind` names its kind. `details.id` names the taken id, and is absent\n * only when the refused statement inserted MORE THAN ONE row: the engine reports\n * that the statement collided without saying which row did.\n */\nexport const ENTITY_ALREADY_EXISTS_CODE = \"ENTITY_ALREADY_EXISTS\";\n\n/**\n * Details for ValidationError.\n */\nexport type ValidationErrorDetails = Readonly<{\n /** Type of entity being validated */\n entityType?: KindEntity;\n /** Kind/type name of the entity */\n kind?: string;\n /** Operation being performed */\n operation?: \"create\" | \"update\" | \"delete\" | \"hardDelete\";\n /** Entity ID if updating */\n id?: string;\n /** Individual validation issues */\n issues: readonly ValidationIssue[];\n}>;\n\n/**\n * Thrown when schema validation fails during node or edge operations.\n *\n * @example\n * ```typescript\n * try {\n * await store.nodes.Person.create({ email: \"invalid\" });\n * } catch (error) {\n * if (error instanceof ValidationError) {\n * console.log(error.details.issues);\n * // [{ path: \"email\", message: \"Invalid email\" }]\n * }\n * }\n * ```\n */\nexport class ValidationError extends TypeGraphError {\n declare readonly details: ValidationErrorDetails;\n\n constructor(\n message: string,\n details: ValidationErrorDetails,\n options?: { cause?: unknown; suggestion?: string },\n ) {\n const fieldList =\n details.issues.length > 0 ?\n details.issues.map((index) => index.path || \"(root)\").join(\", \")\n : \"unknown\";\n\n super(message, \"VALIDATION_ERROR\", {\n details,\n category: \"user\",\n suggestion:\n options?.suggestion ??\n `Check the following fields: ${fieldList}. See error.details.issues for specific validation failures.`,\n cause: options?.cause,\n });\n this.name = \"ValidationError\";\n }\n}\n\n// ============================================================\n// Not Found Errors (category: \"user\")\n// ============================================================\n\n/**\n * Details for NodeNotFoundError.\n */\nexport type NodeNotFoundErrorDetails = Readonly<{\n kind: string;\n id: string;\n}>;\n\n/**\n * Thrown when a node is not found.\n *\n * @example\n * ```typescript\n * try {\n * await store.nodes.Person.get(\"nonexistent-id\");\n * } catch (error) {\n * if (error instanceof NodeNotFoundError) {\n * console.log(error.details.kind, error.details.id);\n * }\n * }\n * ```\n */\nexport class NodeNotFoundError extends TypeGraphError {\n declare readonly details: NodeNotFoundErrorDetails;\n\n constructor(kind: string, id: string, options?: { cause?: unknown }) {\n super(`Node not found: ${kind}/${id}`, \"NODE_NOT_FOUND\", {\n details: { kind, id },\n category: \"user\",\n suggestion: `Verify the node ID \"${id}\" exists and has not been deleted.`,\n cause: options?.cause,\n });\n this.name = \"NodeNotFoundError\";\n }\n}\n\n/**\n * Details for EdgeNotFoundError.\n */\nexport type EdgeNotFoundErrorDetails = Readonly<{\n kind: string;\n id: string;\n}>;\n\n/**\n * Thrown when an edge is not found.\n */\nexport class EdgeNotFoundError extends TypeGraphError {\n declare readonly details: EdgeNotFoundErrorDetails;\n\n constructor(kind: string, id: string, options?: { cause?: unknown }) {\n super(`Edge not found: ${kind}/${id}`, \"EDGE_NOT_FOUND\", {\n details: { kind, id },\n category: \"user\",\n suggestion: `Verify the edge ID \"${id}\" exists and has not been deleted.`,\n cause: options?.cause,\n });\n this.name = \"EdgeNotFoundError\";\n }\n}\n\n/**\n * Details for KindNotFoundError.\n */\nexport type KindNotFoundErrorDetails = Readonly<{\n kindName: string;\n entity: KindEntity;\n graphId?: string;\n}>;\n\n/**\n * Thrown when an operation references a kind that isn't registered on\n * the graph — `getNodeCollectionOrThrow` against an unknown kind, a\n * `materializeIndexes({ kinds })` filter naming a missing kind, an\n * extension referencing an unresolved endpoint, search facade typos,\n * etc. Carries the offending `kindName` and `entity` plus the host\n * `graphId` so logs are unambiguous when multiple stores share a\n * process.\n */\nexport class KindNotFoundError extends TypeGraphError {\n declare readonly details: KindNotFoundErrorDetails;\n readonly kindName: string;\n readonly entity: KindEntity;\n\n constructor(\n kindName: string,\n entity: KindEntity,\n options?: Readonly<{\n graphId?: string;\n suggestion?: string;\n cause?: unknown;\n }>,\n ) {\n const where =\n options?.graphId === undefined ? \"\" : ` on graph \"${options.graphId}\"`;\n super(\n `${entity === \"node\" ? \"Node\" : \"Edge\"} kind \"${kindName}\" is not registered${where}.`,\n \"KIND_NOT_FOUND\",\n {\n details: {\n kindName,\n entity,\n ...(options?.graphId === undefined ?\n {}\n : { graphId: options.graphId }),\n },\n category: \"user\",\n suggestion:\n options?.suggestion ??\n \"Compile-time kinds come from defineGraph; extension kinds appear after store.evolve() returns. Check store.introspect() for the registered set.\",\n cause: options?.cause,\n },\n );\n this.name = \"KindNotFoundError\";\n this.kindName = kindName;\n this.entity = entity;\n }\n}\n\n/**\n * Details for NodeConstraintNotFoundError.\n */\nexport type NodeConstraintNotFoundErrorDetails = Readonly<{\n constraintName: string;\n kind: string;\n}>;\n\n/**\n * Thrown when a uniqueness constraint name is not found on a node kind.\n */\nexport class NodeConstraintNotFoundError extends TypeGraphError {\n declare readonly details: NodeConstraintNotFoundErrorDetails;\n\n constructor(\n constraintName: string,\n kind: string,\n options?: { cause?: unknown },\n ) {\n super(\n `Constraint not found: \"${constraintName}\" on node kind \"${kind}\"`,\n \"CONSTRAINT_NOT_FOUND\",\n {\n details: { constraintName, kind },\n category: \"user\",\n suggestion: `Verify the constraint name \"${constraintName}\" is defined in the unique constraints for \"${kind}\".`,\n cause: options?.cause,\n },\n );\n this.name = \"NodeConstraintNotFoundError\";\n }\n}\n\n/**\n * Details for NodeIndexNotFoundError.\n */\nexport type NodeIndexNotFoundErrorDetails = Readonly<{\n indexName: string;\n kind: string;\n}>;\n\n/**\n * Thrown when a declared node index name is not found on a node kind.\n */\nexport class NodeIndexNotFoundError extends TypeGraphError {\n declare readonly details: NodeIndexNotFoundErrorDetails;\n\n constructor(indexName: string, kind: string, options?: { cause?: unknown }) {\n super(\n `Index not found: \"${indexName}\" on node kind \"${kind}\"`,\n \"INDEX_NOT_FOUND\",\n {\n details: { indexName, kind },\n category: \"user\",\n suggestion: `Verify the index name \"${indexName}\" is declared via defineNodeIndex for \"${kind}\" and passed to defineGraph({ indexes }).`,\n cause: options?.cause,\n },\n );\n this.name = \"NodeIndexNotFoundError\";\n }\n}\n\n// ============================================================\n// Constraint Errors (category: \"constraint\")\n// ============================================================\n\n/**\n * Details for EndpointNotFoundError.\n */\nexport type EndpointNotFoundErrorDetails = Readonly<{\n edgeKind: string;\n endpoint: \"from\" | \"to\";\n nodeKind: string;\n nodeId: string;\n}>;\n\n/**\n * Thrown when edge endpoint node does not exist or is deleted.\n */\nexport class EndpointNotFoundError extends TypeGraphError {\n declare readonly details: EndpointNotFoundErrorDetails;\n\n constructor(\n details: EndpointNotFoundErrorDetails,\n options?: { cause?: unknown },\n ) {\n super(\n `Endpoint node not found for edge \"${details.edgeKind}\": ${details.nodeKind}/${details.nodeId} (${details.endpoint})`,\n \"ENDPOINT_NOT_FOUND\",\n {\n details,\n category: \"constraint\",\n suggestion: `Ensure the ${details.endpoint} node exists before creating the edge.`,\n cause: options?.cause,\n },\n );\n this.name = \"EndpointNotFoundError\";\n }\n}\n\n/**\n * Details for EndpointError.\n */\nexport type EndpointErrorDetails = Readonly<{\n edgeKind: string;\n endpoint: \"from\" | \"to\";\n actualKind: string;\n expectedKinds: readonly string[];\n}>;\n\n/**\n * Thrown when edge endpoint has wrong node type.\n */\nexport class EndpointError extends TypeGraphError {\n declare readonly details: EndpointErrorDetails;\n\n constructor(details: EndpointErrorDetails, options?: { cause?: unknown }) {\n const expected = details.expectedKinds.join(\" | \");\n super(\n `Invalid ${details.endpoint} endpoint for edge \"${details.edgeKind}\": got \"${details.actualKind}\", expected ${expected}`,\n \"ENDPOINT_ERROR\",\n {\n details,\n category: \"constraint\",\n suggestion: `Use a node of type ${expected} as the ${details.endpoint} endpoint.`,\n cause: options?.cause,\n },\n );\n this.name = \"EndpointError\";\n }\n}\n\n/**\n * Details for UniquenessError.\n */\nexport type UniquenessErrorDetails = Readonly<{\n constraintName: string;\n kind: string;\n existingId: string;\n newId: string;\n fields: readonly string[];\n}>;\n\n/**\n * Thrown when uniqueness constraint is violated.\n */\nexport class UniquenessError extends TypeGraphError {\n declare readonly details: UniquenessErrorDetails;\n\n constructor(details: UniquenessErrorDetails, options?: { cause?: unknown }) {\n const fieldList = details.fields.join(\", \");\n super(\n `Uniqueness violation on \"${details.kind}\": constraint \"${details.constraintName}\" (fields: ${fieldList}) conflicts with existing node ${details.existingId}`,\n \"UNIQUENESS_VIOLATION\",\n {\n details,\n category: \"constraint\",\n suggestion: `Change the values for fields [${fieldList}] to be unique, or update the existing node ${details.existingId} instead.`,\n cause: options?.cause,\n },\n );\n this.name = \"UniquenessError\";\n }\n}\n\n/**\n * Details for CardinalityError.\n */\nexport type CardinalityErrorDetails = Readonly<{\n edgeKind: string;\n fromKind: string;\n fromId: string;\n cardinality: string;\n existingCount: number;\n}>;\n\n/**\n * Thrown when cardinality constraint is violated.\n */\nexport class CardinalityError extends TypeGraphError {\n declare readonly details: CardinalityErrorDetails;\n\n constructor(details: CardinalityErrorDetails, options?: { cause?: unknown }) {\n super(\n `Cardinality violation: \"${details.edgeKind}\" from ${details.fromKind}/${details.fromId} allows \"${details.cardinality}\" but ${details.existingCount} edge(s) already exist`,\n \"CARDINALITY_ERROR\",\n {\n details,\n category: \"constraint\",\n suggestion:\n details.cardinality === \"one\" || details.cardinality === \"unique\" ?\n `Delete the existing edge before creating a new one, or use cardinality \"many\".`\n : `Check if the cardinality constraint \"${details.cardinality}\" is correct for your use case.`,\n cause: options?.cause,\n },\n );\n this.name = \"CardinalityError\";\n }\n}\n\n/**\n * Details for DisjointError.\n */\nexport type DisjointErrorDetails = Readonly<{\n nodeId: string;\n attemptedKind: string;\n conflictingKind: string;\n}>;\n\n/**\n * Thrown when disjointness constraint is violated.\n *\n * Disjoint types cannot share the same ID - a node cannot be both\n * a Person and an Organization if they are declared disjoint.\n */\nexport class DisjointError extends TypeGraphError {\n declare readonly details: DisjointErrorDetails;\n\n constructor(details: DisjointErrorDetails, options?: { cause?: unknown }) {\n super(\n `Disjoint constraint violation: cannot create ${details.attemptedKind} with ID \"${details.nodeId}\" - conflicts with existing ${details.conflictingKind}`,\n \"DISJOINT_ERROR\",\n {\n details,\n category: \"constraint\",\n suggestion: `Use a different ID for the new ${details.attemptedKind} node, or delete the existing ${details.conflictingKind}/${details.nodeId} first.`,\n cause: options?.cause,\n },\n );\n this.name = \"DisjointError\";\n }\n}\n\nexport type IdentityContradictionErrorDetails = Readonly<{\n /**\n * The identity write that could not stand. `merge` is the post-write\n * affected-class assertion a graph merge runs inside its commit\n * transaction, which names the whole merge rather than a single assertion\n * because the contradiction is a property of the state the merge would\n * leave behind.\n */\n operation: \"assertSame\" | \"assertDifferent\" | \"fold\" | \"import\" | \"merge\";\n a: Readonly<{ kind: string; id: string }>;\n b: Readonly<{ kind: string; id: string }>;\n reason: \"different-assertion\" | \"same-class\" | \"disjoint-kinds\";\n conflictingAssertionId?: string;\n conflictingKinds?: readonly [string, string];\n}>;\n\n/** Thrown when an identity mutation would make the ledger contradictory. */\nexport class IdentityContradictionError extends TypeGraphError {\n declare readonly details: IdentityContradictionErrorDetails;\n\n constructor(\n details: IdentityContradictionErrorDetails,\n options?: Readonly<{ cause?: unknown }>,\n ) {\n super(\n `Identity contradiction: ${details.a.kind}/${details.a.id} and ${details.b.kind}/${details.b.id} cannot satisfy ${details.operation}.`,\n \"IDENTITY_CONTRADICTION\",\n {\n details,\n category: \"constraint\",\n suggestion:\n \"Retract the conflicting identity assertion or correct the graph ontology before retrying.\",\n cause: options?.cause,\n },\n );\n this.name = \"IdentityContradictionError\";\n }\n}\n\nexport type IdentityValidityWindowErrorDetails = Readonly<{\n reason:\n | \"future-valid-from\"\n | \"future-valid-to\"\n | \"inverted\"\n | \"overlapping-open-window\";\n validFrom: string;\n validTo?: string;\n operationInstant: string;\n}>;\n\n/** Thrown when an identity assertion validity window cannot be applied. */\nexport class IdentityValidityWindowError extends TypeGraphError {\n declare readonly details: IdentityValidityWindowErrorDetails;\n\n constructor(details: IdentityValidityWindowErrorDetails) {\n const code =\n details.reason === \"future-valid-from\" ? \"IDENTITY_VALIDITY_FUTURE_START\"\n : details.reason === \"future-valid-to\" ? \"IDENTITY_VALIDITY_FUTURE_END\"\n : details.reason === \"inverted\" ? \"IDENTITY_VALIDITY_INVERTED\"\n : \"IDENTITY_VALIDITY_OPEN_WINDOW_CONFLICT\";\n super(\n `Identity assertion validity window cannot be applied: ${details.reason}.`,\n code,\n {\n details,\n category:\n details.reason === \"overlapping-open-window\" ? \"constraint\" : \"user\",\n suggestion:\n details.reason === \"inverted\" ? \"Pass validFrom at or before validTo.\"\n : details.reason === \"overlapping-open-window\" ?\n \"Retract the existing open assertion before creating a different open validity window for the same relation and pair.\"\n : \"Use a boundary at or before the current operation clock; future-scheduled identity transitions are not supported.\",\n },\n );\n this.name = \"IdentityValidityWindowError\";\n }\n}\n\nexport type IdentityEndpointValidityErrorDetails = Readonly<{\n endpoint: Readonly<{ kind: string; id: string }>;\n assertionWindow: Readonly<{ validFrom: string; validTo?: string }>;\n endpointWindow: Readonly<{\n validFrom?: string;\n validTo?: string;\n deletedAt?: string;\n }>;\n}>;\n\n/** Thrown when an identity endpoint does not exist throughout the assertion window. */\nexport class IdentityEndpointValidityError extends TypeGraphError {\n declare readonly details: IdentityEndpointValidityErrorDetails;\n\n constructor(details: IdentityEndpointValidityErrorDetails) {\n super(\n `Identity endpoint ${details.endpoint.kind}/${details.endpoint.id} does not exist throughout the requested assertion validity window.`,\n \"IDENTITY_ENDPOINT_VALIDITY\",\n {\n details,\n category: \"constraint\",\n suggestion:\n \"Choose an assertion window contained by both endpoint validity windows.\",\n },\n );\n this.name = \"IdentityEndpointValidityError\";\n }\n}\n\nexport type IdentitySeparationViolationErrorDetails = Readonly<{\n graphId: string;\n /**\n * `\"database\"` when the CHECK constraint on the separation relation aborted\n * the write — the backstop firing as designed. `\"writer\"` when the write was\n * accepted, which means the relation was provisioned without its constraint\n * and only the writer's own re-check caught the contradiction.\n */\n enforcedBy: \"database\" | \"writer\";\n /** The single class key both endpoints collapsed onto. */\n classKey: string;\n /** The `different` assertion whose endpoints landed in one class. */\n assertionId: string;\n a: Readonly<{ kind: string; id: string }>;\n b: Readonly<{ kind: string; id: string }>;\n}>;\n\n/**\n * Thrown when the derived separation relation refuses a write that would place\n * both endpoints of a current `different` assertion in one identity class.\n *\n * This is the database-level backstop beneath the plan-time simulation and the\n * applier's validation. Reaching it means an earlier layer let a contradiction\n * through: the transaction is aborted rather than committed, but the layer that\n * should have refused it typed and early is worth investigating.\n */\nexport class IdentitySeparationViolationError extends TypeGraphError {\n declare readonly details: IdentitySeparationViolationErrorDetails;\n\n constructor(\n details: IdentitySeparationViolationErrorDetails,\n options?: Readonly<{ cause?: unknown }>,\n ) {\n super(\n `Identity separation violated: ${details.a.kind}/${details.a.id} and ${details.b.kind}/${details.b.id} are held apart by assertion ${details.assertionId}, but this write would put both in identity class ${details.classKey}.`,\n \"IDENTITY_SEPARATION_VIOLATION\",\n {\n details,\n category: \"constraint\",\n suggestion:\n \"Retract the conflicting different assertion before merging these identity classes. If no application call requested this merge, the write reached the ledger through a path that skipped identity validation.\",\n cause: options?.cause,\n },\n );\n this.name = \"IdentitySeparationViolationError\";\n }\n}\n\n/**\n * Details for RestrictedDeleteError.\n */\nexport type RestrictedDeleteErrorDetails = Readonly<{\n nodeKind: string;\n nodeId: string;\n edgeCount: number;\n edgeKinds: readonly string[];\n}>;\n\n/**\n * Thrown when deletion is blocked due to existing edges (restrict behavior).\n */\nexport class RestrictedDeleteError extends TypeGraphError {\n declare readonly details: RestrictedDeleteErrorDetails;\n\n constructor(\n details: RestrictedDeleteErrorDetails,\n options?: { cause?: unknown },\n ) {\n const edgeList = details.edgeKinds.join(\", \");\n super(\n `Cannot delete ${details.nodeKind}/${details.nodeId}: ${details.edgeCount} connected edge(s) exist (${edgeList})`,\n \"RESTRICTED_DELETE\",\n {\n details,\n category: \"constraint\",\n suggestion: `Delete the connected edges first, or change onDelete behavior to \"cascade\" (auto-delete edges) or \"disconnect\" (soft-delete edges).`,\n cause: options?.cause,\n },\n );\n this.name = \"RestrictedDeleteError\";\n }\n}\n\n// ============================================================\n// Concurrency Errors (category: \"system\")\n// ============================================================\n\n/**\n * Details for VersionConflictError.\n */\nexport type VersionConflictErrorDetails = Readonly<{\n kind: string;\n id: string;\n expectedVersion: number;\n actualVersion: number;\n}>;\n\n/**\n * Thrown when optimistic locking detects a concurrent modification.\n *\n * This occurs when two operations try to update the same entity simultaneously.\n * The operation with the stale version fails.\n */\nexport class VersionConflictError extends TypeGraphError {\n declare readonly details: VersionConflictErrorDetails;\n\n constructor(\n details: VersionConflictErrorDetails,\n options?: { cause?: unknown },\n ) {\n super(\n `Version conflict on ${details.kind}/${details.id}: expected version ${details.expectedVersion}, found ${details.actualVersion}`,\n \"VERSION_CONFLICT\",\n {\n details,\n category: \"system\",\n suggestion: `Fetch the latest version of the entity and retry the operation. This error indicates concurrent modification.`,\n cause: options?.cause,\n },\n );\n this.name = \"VersionConflictError\";\n }\n}\n\n// ============================================================\n// Schema Errors (category: \"system\")\n// ============================================================\n\n/**\n * Details for SchemaMismatchError.\n */\nexport type SchemaMismatchErrorDetails = Readonly<{\n graphId: string;\n expectedHash: string;\n actualHash: string;\n}>;\n\n/**\n * Thrown when the schema in code doesn't match the schema in the database.\n */\nexport class SchemaMismatchError extends TypeGraphError {\n declare readonly details: SchemaMismatchErrorDetails;\n\n constructor(\n details: SchemaMismatchErrorDetails,\n options?: { cause?: unknown },\n ) {\n super(\n `Schema mismatch for graph \"${details.graphId}\": code schema differs from database schema`,\n \"SCHEMA_MISMATCH\",\n {\n details,\n category: \"system\",\n suggestion: `Run schema migration to update the database, or use createStoreWithSchema() for automatic migration.`,\n cause: options?.cause,\n },\n );\n this.name = \"SchemaMismatchError\";\n }\n}\n\n/**\n * Details for MigrationError.\n */\n/**\n * Why a migration operation failed. A stable discriminant so callers can\n * branch on the outcome instead of matching the message text, which is free\n * to be reworded in any release.\n */\nexport const MIGRATION_FAILURE_REASONS = [\n /**\n * The persisted schema is behind the code graph. Raised on the\n * least-privilege runtime path, which cannot run DDL — a privileged\n * migrator must advance the schema first. Inspect `details.diff`\n * (`hasBreakingChanges`) to tell an additive change from an incompatible\n * one.\n */\n \"schema-behind\",\n /** Breaking changes were detected while `throwOnBreaking` was set. */\n \"breaking-change\",\n /** No active schema version exists for the graph. */\n \"no-active-version\",\n /** The requested schema version does not exist for the graph. */\n \"version-not-found\",\n /**\n * The schema about to be committed drops node or edge kinds that still\n * hold rows. Committing would make those rows unreachable, and the next\n * `materializeRemovals()` — which re-derives removals from schema history —\n * would delete them. Inspect `details.droppedKinds` for the names. Use\n * `Store.removeKinds()`, the removal path that queues cleanup explicitly,\n * or pass `discardDroppedKindRows` to `migrateSchema` if losing the rows is\n * the intent.\n */\n \"kind-removal\",\n] as const;\n\nexport type MigrationFailureReason = (typeof MIGRATION_FAILURE_REASONS)[number];\n\n/**\n * Structured context for a {@link MigrationError}, discriminated on `reason`.\n *\n * Modelled as a union rather than one shape with optional fields so the\n * payload a reason promises is the payload it must carry: narrowing on\n * `reason === \"kind-removal\"` gives you a non-optional `droppedKinds`, and the\n * constructor cannot be handed a `kind-removal` without one.\n *\n * The common fields are repeated per member rather than factored into a shared\n * base alias, which would be a hoisted-unexported symbol on the public\n * entrypoint.\n */\nexport type MigrationErrorDetails =\n | Readonly<{\n graphId: string;\n fromVersion: number;\n toVersion: number;\n /** Stable discriminant — branch on this, not the message. */\n reason: \"schema-behind\" | \"breaking-change\";\n /**\n * The structured diff behind the failure. Carries per-change `severity`\n * alongside `hasChanges` / `hasBreakingChanges`, so a caller can decide\n * \"additive → proceed, incompatible → ask the user\" without re-querying.\n */\n diff?: SchemaDiff;\n }>\n | Readonly<{\n graphId: string;\n fromVersion: number;\n toVersion: number;\n reason: \"no-active-version\" | \"version-not-found\";\n }>\n | Readonly<{\n graphId: string;\n fromVersion: number;\n toVersion: number;\n reason: \"kind-removal\";\n /**\n * The dropped kinds that still held rows, and so caused the refusal. A\n * kind the commit drops but that is already empty is permitted and does\n * NOT appear here. Both lists are sorted; at least one is non-empty.\n */\n droppedKinds: Readonly<{\n nodes: readonly string[];\n edges: readonly string[];\n }>;\n }>;\n\n/**\n * Thrown when schema migration fails.\n */\nexport class MigrationError extends TypeGraphError {\n declare readonly details: MigrationErrorDetails;\n\n constructor(\n message: string,\n details: MigrationErrorDetails,\n options?: { cause?: unknown },\n ) {\n super(message, \"MIGRATION_ERROR\", {\n details,\n category: \"system\",\n suggestion: `Review the schema changes and ensure they are backwards compatible, or implement a data migration.`,\n cause: options?.cause,\n });\n this.name = \"MigrationError\";\n }\n}\n\n/**\n * Details for EagerMaterializationError.\n */\nexport type EagerMaterializationErrorDetails = Readonly<{\n graphId: string;\n failedIndexNames: readonly string[];\n}>;\n\n/**\n * Thrown by `Store.evolve(extension, { eager })` when the schema\n * commit succeeded but the follow-on `materializeIndexes()` produced\n * one or more failed entries.\n *\n * Recovery: the schema commit is NOT rolled back. The new `Store` is\n * fully constructed and (when `options.ref` was supplied) `ref.current`\n * already points to it — the caller can read the new store via the ref\n * and decide how to handle the failed indexes (retry, skip, alert).\n * The full `MaterializeIndexesResult` is attached as `.materialization`.\n *\n * @example\n * ```ts\n * const ref = { current: store };\n * try {\n * await store.evolve(extension, { ref, eager: {} });\n * } catch (error) {\n * if (error instanceof EagerMaterializationError) {\n * // schema is committed; ref.current is the new store\n * log.warn(\n * { failed: error.failedIndexNames },\n * \"indexes did not materialize; will retry\",\n * );\n * await ref.current.materializeIndexes();\n * } else {\n * throw error;\n * }\n * }\n * ```\n */\nexport class EagerMaterializationError extends TypeGraphError {\n declare readonly details: EagerMaterializationErrorDetails;\n\n /**\n * The full materialization result, including successful and failed\n * entries. Same shape as `Store.materializeIndexes()` returns.\n */\n readonly materialization: MaterializeIndexesResult;\n\n constructor(materialization: MaterializeIndexesResult, graphId: string) {\n const names = collectFailedIndexNames(materialization);\n super(\n `Eager materialization failed for ${names.length} index(es) on graph \"${graphId}\": ${names.join(\", \")}. The schema commit succeeded; the new Store is available via the ref handle (when supplied) and the failed indexes can be retried via store.materializeIndexes().`,\n \"EAGER_MATERIALIZATION_FAILED\",\n {\n details: { graphId, failedIndexNames: names },\n category: \"system\",\n suggestion: `Inspect error.materialization for per-index errors. Each failure preserves any prior successful materialization timestamp; the schema is committed regardless.`,\n },\n );\n this.name = \"EagerMaterializationError\";\n this.materialization = materialization;\n }\n\n /**\n * Names of just the indexes that failed — derived from\n * `materialization.results` so the two views can never disagree.\n */\n get failedIndexNames(): readonly string[] {\n return collectFailedIndexNames(this.materialization);\n }\n}\n\nfunction collectFailedIndexNames(\n materialization: MaterializeIndexesResult,\n): readonly string[] {\n const names: string[] = [];\n for (const entry of materialization.results) {\n if (entry.status === \"failed\") names.push(entry.indexName);\n }\n return names;\n}\n\n/**\n * Details for StaleVersionError. `actual` is the active version the rejecting\n * read observed, and is `0` only when the graph genuinely has no active version\n * (an initial-commit race where another writer initialized first, or a graph\n * whose schema rows were removed out of band). A concurrent advance always\n * reports the newly active version, so `0` is a reliable signal of absence\n * rather than of contention.\n */\nexport type StaleVersionErrorDetails = Readonly<{\n graphId: string;\n expected: number;\n actual: number;\n}>;\n\n/**\n * Thrown by `commitSchemaVersion`, `setActiveVersion`, and the schema write\n * fence a schema-managed Store write takes, when the caller's view of the\n * active schema version is out of date — another writer has already advanced\n * it.\n *\n * Recovery: re-read the active version with `getActiveSchema(graphId)`,\n * recompute against the new baseline, and retry. This is a routine\n * concurrency signal, not a bug.\n */\nexport class StaleVersionError extends TypeGraphError {\n declare readonly details: StaleVersionErrorDetails;\n\n constructor(\n details: StaleVersionErrorDetails,\n options?: { cause?: unknown },\n ) {\n super(\n `Schema version was advanced by another writer for graph \"${details.graphId}\": expected active version ${details.expected}, actual is ${details.actual}`,\n \"STALE_SCHEMA_VERSION\",\n {\n details,\n category: \"system\",\n suggestion: `Re-read the active schema version, recompute the new version against that baseline, and retry the commit.`,\n cause: options?.cause,\n },\n );\n this.name = \"StaleVersionError\";\n }\n}\n\n/**\n * Details for SchemaContentConflictError.\n */\nexport type SchemaContentConflictErrorDetails = Readonly<{\n graphId: string;\n version: number;\n existingHash: string;\n incomingHash: string;\n}>;\n\n/**\n * Thrown by `commitSchemaVersion` when a row already exists at the\n * target version with a *different* schema hash — i.e. two writers\n * committed materially different schemas at the same version number.\n *\n * Distinct from `StaleVersionError`: this is not a refetch-and-retry\n * situation, it's a content disagreement that needs operator\n * intervention. Typically caused by inconsistent application\n * deployments writing schemas that hash differently.\n */\nexport class SchemaContentConflictError extends TypeGraphError {\n declare readonly details: SchemaContentConflictErrorDetails;\n\n constructor(\n details: SchemaContentConflictErrorDetails,\n options?: { cause?: unknown },\n ) {\n super(\n `Schema content conflict for graph \"${details.graphId}\" at version ${details.version}: existing hash ${details.existingHash} differs from incoming hash ${details.incomingHash}`,\n \"SCHEMA_CONTENT_CONFLICT\",\n {\n details,\n category: \"system\",\n suggestion: `Two writers committed different schemas at the same version. Reconcile the application deployments so they produce the same canonical schema, then retry.`,\n cause: options?.cause,\n },\n );\n this.name = \"SchemaContentConflictError\";\n }\n}\n\n// ============================================================\n// Configuration Errors (category: \"user\")\n// ============================================================\n\n/**\n * Thrown when graph configuration is invalid.\n *\n * This includes invalid schema definitions, ontology conflicts,\n * and other configuration issues detected at graph creation time.\n */\nexport class ConfigurationError extends TypeGraphError {\n constructor(\n message: string,\n details: Record<string, unknown> = {},\n options?: { cause?: unknown; suggestion?: string },\n ) {\n super(message, \"CONFIGURATION_ERROR\", {\n details,\n category: \"user\",\n suggestion:\n options?.suggestion ?? `Review your graph definition for errors.`,\n cause: options?.cause,\n });\n this.name = \"ConfigurationError\";\n }\n}\n\n/**\n * Why a destructive contribution rebuild is refused.\n *\n * - `vector-source-unavailable` — the projection is vector storage.\n * TypeGraph stores caller-supplied embeddings and nothing else: the\n * vectors exist only in the table a rebuild would drop, so there is no\n * source to reconstruct them from. Dropping anyway would silently\n * destroy the embeddings and hand back storage that looks healthy and\n * returns nothing. `store.reembedVectorField(kind, fieldPath, {\n * embed })` is the sanctioned destructive path — it takes the callback\n * that can regenerate what the drop destroys.\n * - `no-drop-ddl` — the active strategy declares no `dropDdl` for the\n * contribution, so TypeGraph does not know how to tear its storage\n * down. Synthesizing a `DROP TABLE` from the resolved name would\n * guess at a teardown the strategy never sanctioned.\n * - `no-schema-fence` — the backend exposes no transactional schema\n * fence (`schemaWriteTransaction`), so the drop, recreate, refill, and\n * stamp could not be made atomic. Running them unfenced could leave\n * storage attested but empty, or a concurrent schema writer\n * interleaved with the drop.\n * - `shared-storage-in-use` — the contribution's recorded shape is stale,\n * so only recreating its storage repairs it, but that storage is one\n * table holding other graphs' rows as well. Their content is derived\n * from their own nodes through their own schemas, so this process cannot\n * put it back. A rebuild that dropped anyway would leave every other\n * graph's search silently empty; one that re-stamped this graph's marker\n * without the drop would bless a physical shape nothing verified.\n */\nexport type ContributionRebuildRefusal =\n | \"vector-source-unavailable\"\n | \"no-drop-ddl\"\n | \"no-schema-fence\"\n | \"shared-storage-in-use\";\n\nconst CONTRIBUTION_REBUILD_REFUSAL_MESSAGE: Readonly<\n Record<ContributionRebuildRefusal, string>\n> = {\n \"vector-source-unavailable\":\n \"Vector contributions cannot be rebuilt: TypeGraph stores the vectors \" +\n \"callers supply and never the inputs that produced them, so the \" +\n \"embeddings exist only in the storage a rebuild would drop.\",\n \"no-drop-ddl\":\n \"The active strategy declares no teardown DDL for this contribution, so \" +\n \"its storage cannot be dropped and recreated.\",\n \"no-schema-fence\":\n \"This backend exposes no transactional schema fence, so a rebuild's \" +\n \"drop, recreate, refill, and marker stamp cannot be made atomic.\",\n \"shared-storage-in-use\":\n \"This contribution's storage is provisioned at a different shape than \" +\n \"the current declaration, and the only repair — recreating it — would \" +\n \"destroy fulltext content belonging to other graphs that share the same \" +\n \"table and can only be rebuilt from their own processes.\",\n};\n\nconst CONTRIBUTION_REBUILD_REFUSAL_SUGGESTION: Readonly<\n Record<ContributionRebuildRefusal, string>\n> = {\n \"vector-source-unavailable\":\n \"Run store.reembedVectorField(kind, fieldPath, { embed }) instead: it \" +\n \"recreates the field's storage and takes the callback that regenerates \" +\n \"the embeddings the recreate discards.\",\n \"no-drop-ddl\":\n \"Declare dropDdl on the contribution returned from the strategy's \" +\n \"ownedTables(), or drop and recreate the table out of band and then run \" +\n \"store.repairContributions() to re-stamp its marker.\",\n \"no-schema-fence\":\n \"Use a backend that implements schemaWriteTransaction, or perform the \" +\n \"drop and recreate out of band during a maintenance window and then run \" +\n \"store.repairContributions() followed by store.search.rebuildFulltext().\",\n \"shared-storage-in-use\":\n \"Recreate the shared table during a maintenance window with every graph \" +\n \"that uses it offline: drop it out of band, then run \" +\n 'store.rebuildContribution(\"fulltext\") once per graph on this database. ' +\n \"Each run recreates the table from the current DDL and refills that \" +\n \"graph's rows from its own nodes.\",\n};\n\n/**\n * Thrown when `store.rebuildContribution()` cannot honor a rebuild.\n *\n * A refusal, never a partial attempt: nothing has been dropped when this\n * throws. The point is that the alternative — proceeding — destroys data\n * that cannot be reconstructed, so the operation declines instead of\n * quietly doing less than its name promises.\n */\nexport class ContributionRebuildUnsupportedError extends TypeGraphError {\n readonly reason: ContributionRebuildRefusal;\n\n constructor(\n reason: ContributionRebuildRefusal,\n details: Readonly<Record<string, unknown>> = {},\n options?: { cause?: unknown },\n ) {\n super(\n CONTRIBUTION_REBUILD_REFUSAL_MESSAGE[reason],\n \"CONTRIBUTION_REBUILD_UNSUPPORTED\",\n {\n details: { ...details, reason },\n category: \"user\",\n suggestion: CONTRIBUTION_REBUILD_REFUSAL_SUGGESTION[reason],\n cause: options?.cause,\n },\n );\n this.name = \"ContributionRebuildUnsupportedError\";\n this.reason = reason;\n }\n}\n\n/**\n * Thrown when an iterative graph algorithm exhausts its caller-visible round\n * budget before reaching its convergence predicate.\n */\nexport class GraphAlgorithmConvergenceError extends TypeGraphError {\n constructor(\n algorithm: string,\n maxIterations: number,\n options: Readonly<{ oscillating?: boolean }> = {},\n ) {\n const oscillating = options.oscillating === true;\n super(\n oscillating ?\n `${algorithm} entered a periodic label oscillation and can never converge.`\n : `${algorithm} did not converge within ${maxIterations} iterations.`,\n \"GRAPH_ALGORITHM_CONVERGENCE_ERROR\",\n {\n details: {\n algorithm,\n maxIterations,\n ...(oscillating ? { oscillating } : {}),\n },\n category: \"user\",\n suggestion:\n oscillating ?\n 'Pass onMaxIterations: \"return\" to accept the fixed-round labeling, or exclude the oscillating component from the selection.'\n : \"Increase maxIterations or reduce the selected graph before retrying.\",\n },\n );\n this.name = \"GraphAlgorithmConvergenceError\";\n }\n}\n\n/** Stable reasons a weighted traversal can reject an edge's weight value. */\nexport type InvalidEdgeWeightReason =\n \"missing\" | \"negative\" | \"non_numeric\" | \"out_of_range\";\n\n/** Details for InvalidEdgeWeightError. */\nexport type InvalidEdgeWeightErrorDetails = Readonly<{\n /** Id of the first offending edge, in binary-collation order. */\n edgeId: string;\n /** Kind of the offending edge. */\n edgeKind: string;\n /** The audited weight property. */\n property: string;\n /** Why the weight was rejected. */\n reason: InvalidEdgeWeightReason;\n /** The offending value, when one was present and renderable. */\n value?: string;\n}>;\n\nconst EDGE_WEIGHT_REASONS: Readonly<\n Record<\n InvalidEdgeWeightReason,\n Readonly<{ message: string; suggestion: string }>\n >\n> = {\n missing: {\n message: \"has no value for weight property\",\n suggestion:\n \"Set the property on every selected edge, or provide defaultWeight for edges without it.\",\n },\n negative: {\n message: \"has a negative value for weight property\",\n suggestion:\n \"Weighted traversal requires non-negative weights; repair the edge data before retrying.\",\n },\n non_numeric: {\n message: \"has a non-numeric value for weight property\",\n suggestion:\n \"Store the weight property as a JSON number on every selected edge before retrying.\",\n },\n out_of_range: {\n message: \"has a value outside the supported range for weight property\",\n suggestion:\n \"Keep weight magnitudes within the range weightedShortestPath documents (large enough to be a normal IEEE 754 double, small enough that path sums cannot overflow).\",\n },\n};\n\n/**\n * Thrown when a weighted graph algorithm finds an edge whose weight property\n * violates the weighted-traversal contract (missing without a default,\n * non-numeric, or negative). Raised before any traversal rounds run, so a\n * weighted call either observes a fully valid weight domain or fails fast.\n */\nexport class InvalidEdgeWeightError extends TypeGraphError {\n declare readonly details: InvalidEdgeWeightErrorDetails;\n\n constructor(details: InvalidEdgeWeightErrorDetails) {\n super(\n `Edge '${details.edgeId}' (kind '${details.edgeKind}') ${EDGE_WEIGHT_REASONS[details.reason].message} '${details.property}'${\n details.value === undefined ? \"\" : ` (value: ${details.value})`\n }.`,\n \"INVALID_EDGE_WEIGHT\",\n {\n details: { ...details },\n category: \"user\",\n suggestion: EDGE_WEIGHT_REASONS[details.reason].suggestion,\n },\n );\n this.name = \"InvalidEdgeWeightError\";\n }\n}\n\n/** Thrown when an operation requires a backend capability it does not expose. */\nexport class UnsupportedBackendCapabilityError extends TypeGraphError {\n constructor(\n operation: string,\n capability: string,\n details: Readonly<Record<string, unknown>> = {},\n suggestion?: string,\n ) {\n super(\n `${operation} requires backend capability '${capability}'.`,\n \"UNSUPPORTED_BACKEND_CAPABILITY\",\n {\n details: { operation, capability, ...details },\n category: \"user\",\n suggestion:\n suggestion ??\n \"Use a backend that advertises this capability before invoking the operation.\",\n },\n );\n this.name = \"UnsupportedBackendCapabilityError\";\n }\n}\n\n/** Stable reasons an intentionally trusted initial import can be rejected. */\nexport type TrustedImportErrorReason =\n | \"backend_unsupported\"\n | \"database_not_empty\"\n | \"fulltext_unsupported\"\n | \"history_unsupported\"\n | \"identity_unsupported\"\n | \"invalid_stream\"\n | \"revision_tracking_unsupported\"\n | \"uniqueness_unsupported\"\n | \"vector_unsupported\";\n\n/** Thrown when the trusted initial-import contract is unavailable or violated. */\nexport class TrustedImportError extends TypeGraphError {\n constructor(\n message: string,\n reason: TrustedImportErrorReason,\n details: Readonly<Record<string, unknown>> = {},\n options?: Readonly<{ cause?: unknown; suggestion?: string }>,\n ) {\n super(message, \"TRUSTED_IMPORT_ERROR\", {\n details: { ...details, reason },\n category: \"user\",\n suggestion:\n options?.suggestion ??\n \"Use the validating bulk or interchange import APIs unless every trusted-import precondition is satisfied.\",\n cause: options?.cause,\n });\n this.name = \"TrustedImportError\";\n }\n}\n\n/**\n * Thrown to a graph export stream's consumer when the caller's `AbortSignal`\n * settled the stream instead of it reaching its end.\n *\n * Raised only after the export has given back everything it took, so receiving\n * it means the connection is already usable again. WHAT it took depends on the\n * backend: an export on one reporting `capabilities.transactions` holds a\n * repeatable-read snapshot (and, on a serialized connection, that connection's\n * stream lease), and both are settled before this is thrown; an export on a\n * backend without transactions holds neither, and its remaining reads are\n * simply abandoned — its already-delivered chunks were never one snapshot to\n * begin with. The message says which case applies. `cause` carries the signal's\n * own `reason` when the caller supplied one.\n */\nexport class ExportStreamCancelledError extends TypeGraphError {\n constructor(\n message: string,\n details: Readonly<Record<string, unknown>> = {},\n options?: Readonly<{ cause?: unknown; suggestion?: string }>,\n ) {\n super(message, \"INTERCHANGE_EXPORT_STREAM_ABORTED\", {\n details,\n category: \"user\",\n suggestion:\n options?.suggestion ??\n \"Start a new export; the aborted one released its snapshot transaction and the connection it held.\",\n cause: options?.cause,\n });\n this.name = \"ExportStreamCancelledError\";\n }\n}\n\n/**\n * Thrown when an export stream's consumer leaves a delivered chunk\n * unacknowledged for longer than its configured idle timeout.\n *\n * The timeout measures consumer idleness only: it starts when a chunk is\n * yielded and stops when the consumer asks for the next one. Receiving this\n * error means the timed-out export has settled its snapshot transaction and\n * released any serialized connection lease it held. `details.idleTimeoutMs`\n * carries the configured bound.\n */\nexport class ExportStreamIdleTimeoutError extends TypeGraphError {\n constructor(graphId: string, idleTimeoutMs: number, transactional: boolean) {\n super(\n transactional ?\n `The graph export stream consumer did not request its next chunk within ${idleTimeoutMs}ms: its repeatable-read snapshot has been rolled back and the connection it held released.`\n : `The graph export stream consumer did not request its next chunk within ${idleTimeoutMs}ms: its remaining reads were abandoned. This backend does not support transactions, so the export held no snapshot and no connection.`,\n \"INTERCHANGE_EXPORT_STREAM_IDLE_TIMEOUT\",\n {\n details: { graphId, idleTimeoutMs },\n category: \"user\",\n suggestion:\n transactional ?\n \"Start a new export and consume each chunk within the configured idle timeout, increase idleTimeoutMs, or cancel explicitly with an AbortSignal.\"\n : \"Start a new export and consume each chunk within the configured idle timeout, increase idleTimeoutMs, or cancel explicitly with an AbortSignal; discard the partial export unless mutually-inconsistent chunks are acceptable.\",\n },\n );\n this.name = \"ExportStreamIdleTimeoutError\";\n }\n}\n\n/**\n * The stable `details.code` values raised by the recorded-capture guards on a\n * history- or revision-tracked store. These are the sanctioned branch points\n * for a portable caller that must pick a transaction strategy without\n * substring-matching {@link ConfigurationError} messages.\n *\n * - `RECORDED_CAPTURE_REQUIRES_CALLBACK_TRANSACTION`: `store.withTransaction`\n * was called on a history-enabled store, which has no flush point before the\n * caller commits — use `store.withRecordedTransaction` instead.\n * - `RECORDED_CAPTURE_RAW_SQL_DISABLED`: a raw SQL escape (`tx.sql`,\n * `backend.executeStatement`/`executeDdl`) was reached on a history-enabled\n * store, where it would bypass recorded-time capture.\n * - `REVISION_TRACKING_RAW_SQL_DISABLED`: the same raw SQL escape on a\n * revision-tracked store, where it would bypass the revision anchor.\n *\n * @see isRecordedCaptureGuardError\n */\nexport const RECORDED_CAPTURE_GUARD_CODES = [\n \"RECORDED_CAPTURE_REQUIRES_CALLBACK_TRANSACTION\",\n \"RECORDED_CAPTURE_RAW_SQL_DISABLED\",\n \"REVISION_TRACKING_RAW_SQL_DISABLED\",\n] as const;\n\n/** A stable, branchable code raised by a recorded-capture guard. */\nexport type RecordedCaptureGuardCode =\n (typeof RECORDED_CAPTURE_GUARD_CODES)[number];\n\n/**\n * A {@link ConfigurationError} narrowed to carry a {@link RecordedCaptureGuardCode}\n * in `details.code` — the shape {@link isRecordedCaptureGuardError} guarantees.\n * `C` narrows `details.code` to a single code when the guard was called with a\n * specific one; it defaults to the full union.\n */\nexport type RecordedCaptureGuardError<\n C extends RecordedCaptureGuardCode = RecordedCaptureGuardCode,\n> = ConfigurationError & Readonly<{ details: Readonly<{ code: C }> }>;\n\nfunction isRecordedCaptureGuardCode(\n value: unknown,\n): value is RecordedCaptureGuardCode {\n // Widen the readonly tuple so `includes` accepts an `unknown` needle.\n return (RECORDED_CAPTURE_GUARD_CODES as readonly unknown[]).includes(value);\n}\n\n/**\n * Type guard for the recorded-capture guard errors, so a portable caller can\n * branch on the invariant a store enforced instead of substring-matching the\n * message. Pass `code` to narrow to a single guard; omit it to match any.\n *\n * Distinguishes \"history capture forbids raw SQL here\" from \"this backend has\n * no transactions\" (the latter carries no guard code — see\n * `TransactionContext.sqlAvailability` for the capability discriminant).\n *\n * Passing `code` also narrows `details.code` to that literal on the guarded\n * branch, so a caller can read the payload without re-checking.\n *\n * @example\n * ```typescript\n * // `withTransaction` is a compile error on a history-enabled store, so widen\n * // to the base Store surface to reach the runtime guard this branches on.\n * const store: Store<typeof graph> = historyStore;\n * try {\n * store.withTransaction(externalTx);\n * } catch (error) {\n * if (\n * isRecordedCaptureGuardError(\n * error,\n * \"RECORDED_CAPTURE_REQUIRES_CALLBACK_TRANSACTION\",\n * )\n * ) {\n * // error.details.code is now the literal, not the union.\n * await historyStore.withRecordedTransaction(externalTx, run);\n * } else {\n * throw error;\n * }\n * }\n * ```\n */\nexport function isRecordedCaptureGuardError<C extends RecordedCaptureGuardCode>(\n error: unknown,\n code: C,\n): error is RecordedCaptureGuardError<C>;\nexport function isRecordedCaptureGuardError(\n error: unknown,\n): error is RecordedCaptureGuardError;\nexport function isRecordedCaptureGuardError(\n error: unknown,\n code?: RecordedCaptureGuardCode,\n): error is RecordedCaptureGuardError {\n if (!(error instanceof ConfigurationError)) return false;\n const actual = error.details[\"code\"];\n if (!isRecordedCaptureGuardCode(actual)) return false;\n return code === undefined || actual === code;\n}\n\n/**\n * Why a store's strategy-owned storage is not usable on the current\n * connection. Drives the {@link StoreNotInitializedError} message and\n * is surfaced in `details.reason` for programmatic handling.\n *\n * - `missing`: no durable materialization marker exists — the database\n * was never initialized for this graph's runtime contributions.\n * - `stale`: a marker exists but its recorded signature no longer\n * matches the resolved contribution DDL (strategy swap or DDL drift).\n * The hot path refuses rather than silently re-materializing.\n * - `failed`: the most recent boot-time materialization attempt\n * recorded an error. Boot may retry; the hot path refuses.\n */\nexport type StoreNotInitializedReason = \"missing\" | \"stale\" | \"failed\";\n\nconst STORE_NOT_INITIALIZED_REASON_PHRASE: Readonly<\n Record<StoreNotInitializedReason, string>\n> = {\n missing: \"is not initialized\",\n stale: \"is stale (recorded materialization signature no longer matches)\",\n failed: \"failed its last initialization attempt\",\n};\n\n/**\n * Details for StoreNotInitializedError. `graphId`/`reason` are always\n * present; callers may merge additional context (e.g. `logicalName`) via\n * `options.details`.\n */\nexport type StoreNotInitializedErrorDetails = Readonly<{\n graphId: string;\n reason: StoreNotInitializedReason;\n}> &\n Readonly<Record<string, unknown>>;\n\n/**\n * Thrown when a fulltext- or vector-dependent operation runs against a\n * connection whose strategy-owned storage has not been durably materialized.\n *\n * `createStore()` is a synchronous, zero-I/O attach: it never creates\n * tables, repairs DDL, or writes materialization markers. The durable\n * marker is written exclusively by the async boot path\n * (`createStoreWithSchema`). When a fulltext or embedding read/write — or\n * an adopted/business transaction — observes no valid marker, it refuses\n * loudly here instead of lazily emitting DDL on the hot path.\n */\nexport class StoreNotInitializedError extends TypeGraphError {\n declare readonly details: StoreNotInitializedErrorDetails;\n\n // `graphId`/`reason` are positional and required: both are\n // load-bearing for the message and for programmatic handling via\n // `details.reason`. Caller `details` merge underneath — spread first\n // so `graphId`/`reason` win and can't be clobbered by an\n // accidentally-colliding extra key.\n constructor(\n graphId: string,\n reason: StoreNotInitializedReason,\n options?: {\n cause?: unknown;\n details?: Readonly<Record<string, unknown>> &\n Readonly<{ graphId?: never; reason?: never }>;\n },\n ) {\n super(\n `${storageLabelFromLogicalName(options?.details?.[\"logicalName\"])} for ` +\n `graph \"${graphId}\" ${STORE_NOT_INITIALIZED_REASON_PHRASE[reason]}. ` +\n storeNotInitializedAction(reason, options?.details?.[\"logicalName\"]),\n \"STORE_NOT_INITIALIZED\",\n {\n details: { ...options?.details, graphId, reason },\n category: \"user\",\n suggestion:\n isStaleVectorSlot(reason, options?.details?.[\"logicalName\"]) ?\n \"The field's declared shape (e.g. its dimension) changed after \" +\n \"its storage was provisioned. Run store.reembedVectorField(\" +\n \"kind, fieldPath) to recreate the storage at the new shape and \" +\n \"re-embed.\"\n : \"Call createStoreWithSchema(graph, backend) once at application \" +\n \"startup. createStore() attaches to an already-initialized \" +\n \"database and does not materialize storage itself.\",\n cause: options?.cause,\n },\n );\n this.name = \"StoreNotInitializedError\";\n }\n}\n\nconst VECTOR_LOGICAL_NAME_PREFIX = \"vector:\";\n\n/**\n * A stale VECTOR slot is its own failure mode: the storage exists but was\n * provisioned at a different shape (the declared dimension changed), and\n * the fix is `store.reembedVectorField`, not a re-run of\n * `createStoreWithSchema` (whose boot pass deliberately skips drifted\n * slots). Drives the action sentence and the suggestion.\n */\nfunction isStaleVectorSlot(\n reason: StoreNotInitializedReason,\n logicalName: unknown,\n): boolean {\n return (\n reason === \"stale\" &&\n typeof logicalName === \"string\" &&\n logicalName.startsWith(VECTOR_LOGICAL_NAME_PREFIX)\n );\n}\n\n/** The actionable trailing sentence of the error message, per failure mode. */\nfunction storeNotInitializedAction(\n reason: StoreNotInitializedReason,\n logicalName: unknown,\n): string {\n if (isStaleVectorSlot(reason, logicalName)) {\n return (\n `The declared shape changed after provisioning — run ` +\n `store.reembedVectorField(kind, fieldPath) to recreate the storage ` +\n `at the new shape.`\n );\n }\n return (\n `Run createStoreWithSchema(graph, backend) during application boot, ` +\n `outside request handlers and adopted transactions, before using createStore().`\n );\n}\n\n/** Details for a runtime contribution whose durable marker outlived storage. */\nexport type ContributionUnavailableErrorDetails = Readonly<{\n graphId: string;\n logicalName: \"fulltext\";\n physicalName: string;\n state: \"physical-storage-missing\";\n}>;\n\n/**\n * Thrown when a gated fulltext operation discovers that materialized storage\n * disappeared after its durable marker recorded successful initialization.\n */\nexport class ContributionUnavailableError extends TypeGraphError {\n declare readonly details: ContributionUnavailableErrorDetails;\n\n constructor(\n graphId: string,\n physicalName: string,\n options?: Readonly<{ cause?: unknown }>,\n ) {\n const suggestion =\n 'Run store.rebuildContribution(\"fulltext\") to recreate the lost ' +\n \"storage and repopulate it from the graph's nodes.\";\n super(\n `Fulltext storage \"${physicalName}\" for graph \"${graphId}\" ` +\n `disappeared after initialization. ${suggestion}`,\n \"CONTRIBUTION_UNAVAILABLE\",\n {\n details: {\n graphId,\n logicalName: \"fulltext\",\n physicalName,\n state: \"physical-storage-missing\",\n },\n category: \"user\",\n suggestion,\n cause: options?.cause,\n },\n );\n this.name = \"ContributionUnavailableError\";\n }\n}\n\n/**\n * Human label for the un-materialized storage, derived from the\n * contribution `logicalName`: fulltext keeps \"fulltext storage\"; a vector\n * slot (\"vector:<kind>.<field>\") reads as `vector storage\n * \"<kind>.<field>\"` so the message names the exact embedding\n * field. Falls back to a neutral phrase when no logical name is supplied.\n */\nfunction storageLabelFromLogicalName(logicalName: unknown): string {\n if (typeof logicalName !== \"string\") return \"runtime storage\";\n if (logicalName.startsWith(VECTOR_LOGICAL_NAME_PREFIX)) {\n return `vector storage \"${logicalName.slice(VECTOR_LOGICAL_NAME_PREFIX.length)}\"`;\n }\n if (logicalName === \"fulltext\") return \"fulltext storage\";\n return `\"${logicalName}\" storage`;\n}\n\n// ============================================================\n// Database Errors (category: \"system\")\n// ============================================================\n\n/**\n * Details for DatabaseOperationError.\n */\nexport type DatabaseOperationErrorDetails = Readonly<{\n operation: string;\n entity: string;\n /**\n * `\"duplicate_key\"` means the engine refused the write because the entity's\n * identity is already taken — the shape a concurrent create of the same new id\n * produces on an engine that does not serialize the two writers. It is a\n * *classified* driver failure, so callers that own a better error for the\n * condition (the create paths, which report it as \"already exists\") translate\n * it rather than surfacing it.\n */\n reason?: \"no_row_returned\" | \"duplicate_key\";\n /**\n * The entities the failed statement tried to insert, carried structurally so a\n * translating caller never has to parse the driver's message for them. One\n * element for a single insert; for a batch, every row in the failing chunk —\n * the engine reports the collision without saying which row lost.\n */\n attempted?: readonly Readonly<{ kind: string; id: string }>[];\n}>;\n\n/**\n * Thrown when a database operation fails unexpectedly.\n *\n * This indicates a system-level failure in the database backend,\n * not a user-recoverable error.\n */\nexport class DatabaseOperationError extends TypeGraphError {\n declare readonly details: DatabaseOperationErrorDetails;\n\n constructor(\n message: string,\n details: DatabaseOperationErrorDetails,\n options?: { cause?: unknown },\n ) {\n super(message, \"DATABASE_OPERATION_ERROR\", {\n details,\n category: \"system\",\n suggestion: `This is a system-level database error. Check the database connection and retry the operation. If the problem persists, investigate the underlying cause.`,\n cause: options?.cause,\n });\n this.name = \"DatabaseOperationError\";\n }\n}\n\n// ============================================================\n// Vector / Embedding Errors (category: \"user\")\n// ============================================================\n\n/**\n * Details for EmbeddingDimensionChangedError.\n */\nexport type EmbeddingDimensionChangedErrorDetails = Readonly<{\n kind: string;\n fieldPath: string;\n declaredDimensions?: number;\n storedDimensions?: number;\n}>;\n\n/**\n * Thrown when an embedding field's declared dimension no longer matches the\n * dimension of its materialized per-field storage — i.e. a field's\n * `embedding(N)` was changed to `embedding(M)`. The stored vectors are invalid\n * under the new dimension and cannot be converted, only recomputed, so this is\n * a deliberate app-driven migration: call\n * `store.reembedVectorField(kind, fieldPath, ...)` to recreate the storage at\n * the new dimension and re-embed existing rows.\n */\nexport class EmbeddingDimensionChangedError extends TypeGraphError {\n declare readonly details: EmbeddingDimensionChangedErrorDetails;\n\n constructor(\n message: string,\n details: EmbeddingDimensionChangedErrorDetails,\n options?: { cause?: unknown },\n ) {\n super(message, \"EMBEDDING_DIMENSION_CHANGED\", {\n details,\n category: \"user\",\n suggestion: `Run store.reembedVectorField(\"${details.kind}\", \"${details.fieldPath}\", { embed }) to recreate the field's storage at the new dimension and re-embed existing rows.`,\n cause: options?.cause,\n });\n this.name = \"EmbeddingDimensionChangedError\";\n }\n}\n\n// ============================================================\n// Query Errors (category: \"system\")\n// ============================================================\n\n/**\n * Thrown when a query predicate cannot be compiled for the target database.\n */\nexport class UnsupportedPredicateError extends TypeGraphError {\n constructor(\n message: string,\n details: Readonly<Record<string, unknown>> = {},\n options?: { cause?: unknown; suggestion?: string },\n ) {\n super(message, \"UNSUPPORTED_PREDICATE\", {\n details,\n category: \"system\",\n suggestion:\n options?.suggestion ??\n `This predicate may not be supported by your database backend. Check the documentation for supported predicates.`,\n cause: options?.cause,\n });\n this.name = \"UnsupportedPredicateError\";\n }\n}\n\n// ============================================================\n// Compiler Errors (category: \"system\")\n// ============================================================\n\n/**\n * Thrown when a compiler invariant is violated.\n *\n * This indicates a bug in the query compiler — the compiler reached\n * a state that should be unreachable. These errors are not user-recoverable.\n */\nexport class CompilerInvariantError extends TypeGraphError {\n constructor(\n message: string,\n details?: Readonly<Record<string, unknown>>,\n options?: { cause?: unknown },\n ) {\n super(message, \"COMPILER_INVARIANT_ERROR\", {\n details: details ?? {},\n category: \"system\",\n suggestion: `This is an internal compiler error. Please report it as a bug with the query that triggered it.`,\n cause: options?.cause,\n });\n this.name = \"CompilerInvariantError\";\n }\n}\n\n// ============================================================\n// Lifecycle Errors (category: \"system\")\n// ============================================================\n\n/**\n * Thrown when an operation is attempted on a backend that has been disposed.\n *\n * This typically occurs during runtime teardown — for example, when a\n * Cloudflare Workers test runner resets Durable Object storage while\n * the TypeGraph backend still has queued operations.\n */\nexport class BackendDisposedError extends TypeGraphError {\n constructor(options?: { cause?: unknown }) {\n super(\n \"Backend has been disposed — the underlying database connection is no longer available\",\n \"BACKEND_DISPOSED\",\n {\n category: \"system\",\n suggestion:\n \"Ensure all store operations complete before calling backend.close(). \" +\n \"In test environments, await store teardown before resetting the database.\",\n cause: options?.cause,\n },\n );\n this.name = \"BackendDisposedError\";\n }\n}\n\n/**\n * Thrown when a statement is issued on a transaction-scoped backend after\n * its transaction boundary has already returned.\n *\n * The usual source is a callback that lets work escape it. `Promise.all`\n * rejects on its first rejection while its siblings keep running, so\n *\n * ```typescript\n * await store.transaction(async (tx) => {\n * await Promise.all([tx.nodes.Doc.create(a), tx.nodes.Doc.create(b)]);\n * });\n * ```\n *\n * leaves `b`'s remaining statements in flight when `a` fails. Those\n * statements have nowhere safe to go: the driver is about to emit `ROLLBACK`\n * on the same pinned connection and then hand it back to the pool, where a\n * late arrival would execute inside somebody else's transaction. TypeGraph\n * refuses them here instead.\n *\n * The error is normally invisible — `Promise.all` has already rejected with\n * the original failure, and discards this one.\n */\nexport class TransactionClosedError extends TypeGraphError {\n constructor(options?: { cause?: unknown }) {\n super(\n \"Statement issued on a transaction-scoped backend after its transaction \" +\n \"boundary returned. The connection has been released; the statement was not run.\",\n \"TRANSACTION_CLOSED\",\n {\n category: \"user\",\n suggestion:\n \"Await every write started inside store.transaction(...) before the \" +\n \"callback returns. Prefer awaiting a Promise.allSettled(...) over a \" +\n \"Promise.all(...) whose rejection would orphan its siblings.\",\n cause: options?.cause,\n },\n );\n this.name = \"TransactionClosedError\";\n }\n}\n\n// ============================================================\n// Utility Functions\n// ============================================================\n\n/**\n * Type guard for TypeGraphError.\n *\n * @example\n * ```typescript\n * try {\n * await store.nodes.Person.create({});\n * } catch (error) {\n * if (isTypeGraphError(error)) {\n * console.log(error.code, error.category);\n * }\n * }\n * ```\n */\nexport function isTypeGraphError(error: unknown): error is TypeGraphError {\n return error instanceof TypeGraphError;\n}\n\n/**\n * Check if error is recoverable by user action (user or constraint error).\n *\n * User-recoverable errors can typically be resolved by:\n * - Fixing invalid input data\n * - Using different IDs or values\n * - Deleting conflicting data first\n *\n * @example\n * ```typescript\n * if (isUserRecoverable(error)) {\n * showErrorToUser(error.toUserMessage());\n * } else {\n * logAndAlertOps(error);\n * }\n * ```\n */\nexport function isUserRecoverable(error: unknown): boolean {\n if (!isTypeGraphError(error)) return false;\n return error.category === \"user\" || error.category === \"constraint\";\n}\n\n/**\n * Check if error indicates a system/infrastructure issue.\n *\n * System errors typically require:\n * - Retry logic (for transient failures)\n * - Investigation (for persistent failures)\n * - Ops team notification\n */\nexport function isSystemError(error: unknown): boolean {\n return isTypeGraphError(error) && error.category === \"system\";\n}\n\n/**\n * Check if error is a constraint violation.\n */\nexport function isConstraintError(error: unknown): boolean {\n return isTypeGraphError(error) && error.category === \"constraint\";\n}\n\n/**\n * Extract suggestion from error if available.\n */\nexport function getErrorSuggestion(error: unknown): string | undefined {\n return isTypeGraphError(error) ? error.suggestion : undefined;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/backend/table-names.ts","../src/backend/migrate-recorded-time.ts","../src/backend/repair-validity-windows.ts"],"names":["temporaryTables","finalTables","requireStatements"],"mappings":";;;;;;;;;;AAWA,SAAS,0BACP,QAAA,EACwB;AACxB,EAAA,IAAI,QAAA,KAAa,MAAA,EAAW,OAAO,EAAC;AACpC,EAAA,OAAO,MAAA,CAAO,WAAA;AAAA,IACZ,MAAA,CAAO,OAAA,CAAQ,QAAQ,CAAA,CAAE,MAAA,CAAO,CAAC,GAAG,SAAS,CAAA,KAAM,SAAA,KAAc,MAAS;AAAA,GAC5E;AACF;AAYO,SAAS,kBAAA,CACd,SACA,QAAA,EACuB;AACvB,EAAA,OAAO,eAAA,CAAgB;AAAA,IACrB,GAAG,OAAA,CAAQ,UAAA;AAAA,IACX,GAAG,0BAA0B,QAAQ;AAAA,GACtC,CAAA,CAAE,MAAA;AACL;;;ACXA,IAAM,mBAAA,GAAsB,0BAAA;AAC5B,IAAM,gBAAA,GAAmB,yBAAA;AAEzB,IAAM,qBAAA,GAAwB;AAAA,EAC5B,YAAA;AAAA,EACA,UAAA;AAAA,EACA,MAAA;AAAA,EACA,IAAA;AAAA,EACA,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A;AAAA,UACX,QAAA;AAAA,UACA,MAAA,CAAO,OAAA,KAAY,QAAA,GACjB,MAAM,aAAA;AAAA,YACJ,MAAA;AAAA,YACA,KAAA;AAAA,YACA,2BAAA,CAA4B,QAAQ,OAAO;AAAA,WAC7C,GACA;AAAA,SACJ;AACA,QAAA,QAAA,CAAS,IAAI,QAAA,EAAU,MAAM,cAAc,MAAA,EAAQ,KAAA,EAAO,SAAS,CAAC,CAAA;AAAA,MACtE;AAEA,MAAA,IAAI,OAAA,CAAQ,SAAS,OAAA,EAAS;AAC5B,QAAA,wBAAA,CAAyB,YAAY,CAAA;AACrC,QAAA,KAAA,MAAW,YAAY,SAAA,EAAW;AAChC,UAAA,MAAM,cAAA;AAAA,YACJ,MAAA;AAAA,YACA,aAAA,CAAc,QAAQ,QAAQ,CAAA;AAAA,YAC9B;AAAA,WACF;AAAA,QACF;AAAA,MACF;AAEA,MAAA,OAAO;AAAA,QACL,WAAW,OAAA,CAAQ,SAAA;AAAA,QACnB,MAAA,EAAQ,eAAe,QAAQ,CAAA;AAAA,QAC/B,YAAA,EAAc,eAAe,YAAY,CAAA;AAAA,QACzC,QAAQ,SAAA,CAAU;AAAA,OACpB;AAAA,IACF,CAAA;AAAA,IACA,qBAAA,CAAsB,QAAQ,IAAI;AAAA,GACpC;AACF","file":"chunk-NACVVDWB.js","sourcesContent":["/**\n * The one owner of \"which physical relations does this offline operation\n * touch?\" for the maintenance entrypoints that accept a `tableNames` override.\n */\nimport {\n createSqlSchema,\n type ResolvedSqlTableNames,\n type SqlTableNames,\n} from \"../query/compiler/schema\";\nimport type { GraphBackend } from \"./types\";\n\nfunction definedTableNameOverrides(\n override: Partial<SqlTableNames> | undefined,\n): Partial<SqlTableNames> {\n if (override === undefined) return {};\n return Object.fromEntries(\n Object.entries(override).filter(([, tableName]) => tableName !== undefined),\n );\n}\n\n/**\n * Resolves the relations an offline maintenance call targets.\n *\n * An override is a PATCH over the backend's own names. This matches the\n * `Partial<SqlTableNames>` input contract: naming only `nodes`, for example,\n * must not silently retarget edges and recorded relations to the built-in\n * defaults. `migrateLegacyRecordedTime` and\n * `repairInvertedValidityWindows` share this owner so an offline write can never\n * resolve the same partial override two different ways.\n */\nexport function resolvedTableNames(\n backend: Pick<GraphBackend, \"tableNames\">,\n override: Partial<SqlTableNames> | undefined,\n): ResolvedSqlTableNames {\n return createSqlSchema({\n ...backend.tableNames,\n ...definedTableNameOverrides(override),\n }).tables;\n}\n","/**\n * One-time offline migration from timestamp-only recorded relations to numeric\n * revisions. The durable remap table lets applications translate checkpoints\n * stored outside TypeGraph before deleting the migration metadata.\n */\nimport {\n asRecordedInstant,\n createRecordedInstant,\n RECORDED_MAX_REVISION,\n type RecordedInstant,\n} from \"../core/temporal\";\nimport { ConfigurationError, ValidationError } from \"../errors\";\nimport {\n createSqlSchema,\n type ResolvedSqlTableNames,\n type SqlTableNames,\n} from \"../query/compiler/schema\";\nimport { shortHash } from \"../query/dialect/vector-strategy\";\nimport { sql, type SqlFragment } from \"../query/sql-fragment\";\nimport { asCompiledRowsSql, asCompiledStatementSql } from \"../query/sql-intent\";\nimport { canonicalizeDatabaseTimestamp } from \"../utils/date\";\nimport { postgresContributions, sqliteContributions } from \"./drizzle/ddl\";\nimport { createPostgresTables } from \"./drizzle/schema/postgres\";\nimport { createSqliteTables } from \"./drizzle/schema/sqlite\";\nimport { resolvedTableNames } from \"./table-names\";\nimport { type GraphBackend, type TransactionBackend } from \"./types\";\n\nconst LEGACY_RECORDED_MAX = \"9999-12-31T23:59:59.999Z\";\nconst MIGRATION_SUFFIX = \"legacy_recorded_anchors\";\n\nconst RECORDED_NODE_COLUMNS = [\n \"history_id\",\n \"graph_id\",\n \"kind\",\n \"id\",\n \"props\",\n \"version\",\n \"valid_from\",\n \"valid_to\",\n \"created_at\",\n \"updated_at\",\n \"deleted_at\",\n \"recorded_from\",\n \"recorded_to\",\n \"op\",\n \"schema_version\",\n \"tx_id\",\n \"meta\",\n] as const;\n\nconst RECORDED_EDGE_COLUMNS = [\n \"history_id\",\n \"graph_id\",\n \"id\",\n \"kind\",\n \"from_kind\",\n \"from_id\",\n \"to_kind\",\n \"to_id\",\n \"props\",\n \"valid_from\",\n \"valid_to\",\n \"created_at\",\n \"updated_at\",\n \"deleted_at\",\n \"recorded_from\",\n \"recorded_to\",\n \"op\",\n \"schema_version\",\n \"tx_id\",\n \"meta\",\n] as const;\n\ntype LegacyInstantRow = Readonly<{\n graph_id: unknown;\n recorded_at: unknown;\n}>;\n\ntype MappingRow = Readonly<{\n graphId: string;\n legacyRecordedAt: string;\n recordedAt: string;\n revision: number;\n}>;\n\ntype RemapRow = Readonly<{ recorded_at: unknown; revision: unknown }>;\ntype MappingCountRow = Readonly<{ anchors: unknown; graphs: unknown }>;\ntype MissingMappingRow = Readonly<{ missing: unknown }>;\ntype ColumnRow = Readonly<{ name: unknown }>;\n\nexport type MigrateLegacyRecordedTimeOptions = Readonly<{\n backend: GraphBackend;\n /** Patch selected backend table names; unstated names remain configured. */\n tableNames?: Partial<SqlTableNames> | undefined;\n /** Override the durable legacy-anchor mapping table name. */\n mappingTableName?: string | undefined;\n}>;\n\nexport type MigrateLegacyRecordedTimeResult = Readonly<{\n /** `true` when timestamp columns were rewritten during this call. */\n migrated: boolean;\n /** Number of graphs represented in the legacy commit order. */\n graphs: number;\n /** Number of distinct legacy anchors available for remapping. */\n anchors: number;\n /** Physical table retaining the old-anchor → revision mapping. */\n mappingTableName: string;\n}>;\n\nexport type MigrateRecordedAnchorOptions = Readonly<{\n backend: Pick<GraphBackend, \"dialect\" | \"execute\" | \"tableNames\">;\n graphId: string;\n anchor: string;\n /** Patch selected backend table names; unstated names remain configured. */\n tableNames?: Partial<SqlTableNames> | undefined;\n mappingTableName?: string | undefined;\n}>;\n\nexport type DeleteLegacyRecordedAnchorMapOptions = Readonly<{\n backend: Pick<\n GraphBackend,\n \"dialect\" | \"execute\" | \"executeStatement\" | \"tableNames\" | \"transaction\"\n >;\n graphId: string;\n /** Patch selected backend table names; unstated names remain configured. */\n tableNames?: Partial<SqlTableNames> | undefined;\n mappingTableName?: string | undefined;\n /** Drop the mapping table when this deletion leaves it empty. */\n dropWhenEmpty?: boolean | undefined;\n}>;\n\nfunction shortenedIdentifier(value: string): string {\n if (value.length <= 63) return value;\n return `${value.slice(0, 50)}_${shortHash(value)}`;\n}\n\nfunction mappingTableName(\n tables: ResolvedSqlTableNames,\n override: string | undefined,\n): string {\n const candidate = override ?? `${tables.recordedClock}_${MIGRATION_SUFFIX}`;\n return createSqlSchema({\n recordedClock: shortenedIdentifier(candidate),\n }).tables.recordedClock;\n}\n\nfunction temporaryTableName(tableName: string, role: string): string {\n return shortenedIdentifier(`__tg_${role}_${shortHash(tableName)}`);\n}\n\nfunction requireStatements(\n target: Pick<TransactionBackend, \"dialect\" | \"executeStatement\">,\n): NonNullable<TransactionBackend[\"executeStatement\"]> {\n if (target.executeStatement === undefined) {\n throw new ConfigurationError(\n \"Recorded-time migration requires executeStatement support.\",\n { dialect: target.dialect },\n { suggestion: \"Use a built-in SQLite or PostgreSQL backend.\" },\n );\n }\n return target.executeStatement;\n}\n\nasync function executeStatement(\n target: Pick<TransactionBackend, \"dialect\" | \"executeStatement\">,\n statement: SqlFragment,\n): Promise<void> {\n await requireStatements(target)(asCompiledStatementSql(statement));\n}\n\nasync function executeDdl(\n target: Pick<TransactionBackend, \"dialect\" | \"executeStatement\">,\n ddl: string,\n): Promise<void> {\n await executeStatement(target, sql.raw(ddl));\n}\n\nfunction canonicalLegacyInstant(value: unknown): string {\n const canonical = canonicalizeDatabaseTimestamp(value);\n if (canonical === undefined) {\n throw new ConfigurationError(\n \"Legacy recorded-time relation contained an invalid timestamp.\",\n { value },\n );\n }\n return canonical;\n}\n\nfunction safeRevision(value: unknown): number {\n const revision =\n typeof value === \"bigint\" ? Number(value)\n : typeof value === \"string\" && /^\\d+$/.test(value) ? Number(value)\n : value;\n if (\n typeof revision !== \"number\" ||\n !Number.isSafeInteger(revision) ||\n revision < 1 ||\n revision >= RECORDED_MAX_REVISION\n ) {\n throw new ConfigurationError(\n \"Recorded anchor mapping contained an invalid revision.\",\n { value },\n );\n }\n return revision;\n}\n\nasync function columnNames(\n target: TransactionBackend,\n tableName: string,\n): Promise<ReadonlySet<string>> {\n const rows =\n target.dialect === \"sqlite\" ?\n await target.execute<ColumnRow>(\n asCompiledRowsSql(sql`PRAGMA table_info(${sql.identifier(tableName)})`),\n )\n : await target.execute<ColumnRow>(\n asCompiledRowsSql(sql`\n SELECT column_name AS name\n FROM information_schema.columns\n WHERE table_schema = current_schema()\n AND table_name = ${tableName}\n `),\n );\n return new Set(\n rows.flatMap((row) => (typeof row.name === \"string\" ? [row.name] : [])),\n );\n}\n\nasync function readLegacyInstants(\n target: TransactionBackend,\n tables: ResolvedSqlTableNames,\n): Promise<readonly MappingRow[]> {\n const rows = await target.execute<LegacyInstantRow>(\n asCompiledRowsSql(sql`\n SELECT graph_id, recorded_from AS recorded_at\n FROM ${sql.identifier(tables.recordedNodes)}\n UNION\n SELECT graph_id, recorded_to AS recorded_at\n FROM ${sql.identifier(tables.recordedNodes)}\n WHERE recorded_to <> ${LEGACY_RECORDED_MAX}\n UNION\n SELECT graph_id, recorded_from AS recorded_at\n FROM ${sql.identifier(tables.recordedEdges)}\n UNION\n SELECT graph_id, recorded_to AS recorded_at\n FROM ${sql.identifier(tables.recordedEdges)}\n WHERE recorded_to <> ${LEGACY_RECORDED_MAX}\n UNION\n SELECT graph_id, recorded_at\n FROM ${sql.identifier(tables.recordedClock)}\n `),\n );\n const instants = rows.map((row) => {\n if (typeof row.graph_id !== \"string\") {\n throw new ConfigurationError(\n \"Legacy recorded-time relation contained an invalid graph id.\",\n { graphId: row.graph_id },\n );\n }\n return {\n graphId: row.graph_id,\n recordedAt: canonicalLegacyInstant(row.recorded_at),\n };\n });\n instants.sort((left, right) => {\n if (left.graphId < right.graphId) return -1;\n if (left.graphId > right.graphId) return 1;\n if (left.recordedAt < right.recordedAt) return -1;\n if (left.recordedAt > right.recordedAt) return 1;\n return 0;\n });\n\n const mapping: MappingRow[] = [];\n let graphId: string | undefined;\n let revision = 0;\n let previousInstant: string | undefined;\n for (const instant of instants) {\n if (instant.graphId !== graphId) {\n graphId = instant.graphId;\n revision = 0;\n previousInstant = undefined;\n }\n if (instant.recordedAt === previousInstant) continue;\n revision += 1;\n mapping.push({\n graphId: instant.graphId,\n legacyRecordedAt: instant.recordedAt,\n recordedAt: instant.recordedAt,\n revision,\n });\n previousInstant = instant.recordedAt;\n }\n return mapping;\n}\n\nfunction migrationMapDdl(\n dialect: GraphBackend[\"dialect\"],\n table: string,\n): string {\n const revisionType = dialect === \"postgres\" ? \"BIGINT\" : \"INTEGER\";\n const recordedAtType = dialect === \"postgres\" ? \"TIMESTAMPTZ\" : \"TEXT\";\n return `CREATE TABLE IF NOT EXISTS \"${table}\" (\n graph_id TEXT NOT NULL,\n legacy_recorded_at TEXT NOT NULL,\n revision ${revisionType} NOT NULL,\n recorded_at ${recordedAtType} NOT NULL,\n PRIMARY KEY (graph_id, legacy_recorded_at)\n);`;\n}\n\nasync function writeMappingRows(\n target: TransactionBackend,\n tableName: string,\n rows: readonly MappingRow[],\n): Promise<void> {\n await executeStatement(target, sql`DELETE FROM ${sql.identifier(tableName)}`);\n const rowsPerStatement = Math.max(\n 1,\n Math.floor((target.capabilities.maxBindParameters ?? 900) / 4),\n );\n for (let start = 0; start < rows.length; start += rowsPerStatement) {\n const values = rows\n .slice(start, start + rowsPerStatement)\n .map(\n (row) =>\n sql`(${row.graphId}, ${row.legacyRecordedAt}, ${row.revision}, ${row.recordedAt})`,\n );\n await executeStatement(\n target,\n sql`\n INSERT INTO ${sql.identifier(tableName)}\n (graph_id, legacy_recorded_at, revision, recorded_at)\n VALUES ${sql.join(values, sql`, `)}\n `,\n );\n }\n}\n\nfunction tableDdl(\n dialect: GraphBackend[\"dialect\"],\n tables: ResolvedSqlTableNames,\n temporary: Readonly<{\n recordedClock: string;\n recordedEdges: string;\n recordedNodes: string;\n }>,\n): Readonly<{\n clock: readonly string[];\n edges: readonly string[];\n nodes: readonly string[];\n}> {\n if (dialect === \"sqlite\") {\n const temporaryTables = createSqliteTables(temporary);\n const finalTables = createSqliteTables(tables);\n const temporaryContributions = sqliteContributions(temporaryTables);\n const finalContributions = sqliteContributions(finalTables);\n return ddlForRecordedTables(temporaryContributions, finalContributions);\n }\n const temporaryTables = createPostgresTables(temporary);\n const finalTables = createPostgresTables(tables);\n return ddlForRecordedTables(\n postgresContributions(temporaryTables),\n postgresContributions(finalTables),\n );\n}\n\nfunction ddlForRecordedTables(\n temporary: readonly Readonly<{\n createDdl: readonly string[];\n logicalName: string;\n }>[],\n final: readonly Readonly<{\n createDdl: readonly string[];\n logicalName: string;\n }>[],\n): Readonly<{\n clock: readonly string[];\n edges: readonly string[];\n nodes: readonly string[];\n}> {\n function statements(\n logicalName: \"recordedClock\" | \"recordedEdges\" | \"recordedNodes\",\n ): readonly string[] {\n const temporaryDdl = temporary.find(\n (entry) => entry.logicalName === logicalName,\n )?.createDdl;\n const finalDdl = final.find(\n (entry) => entry.logicalName === logicalName,\n )?.createDdl;\n if (temporaryDdl === undefined || finalDdl === undefined) {\n throw new ConfigurationError(\n `Could not generate migration DDL for ${logicalName}.`,\n );\n }\n const createTable = temporaryDdl[0];\n if (createTable === undefined) {\n throw new ConfigurationError(\n `Could not generate migration table DDL for ${logicalName}.`,\n );\n }\n return [createTable, ...finalDdl.slice(1)];\n }\n return {\n clock: statements(\"recordedClock\"),\n edges: statements(\"recordedEdges\"),\n nodes: statements(\"recordedNodes\"),\n };\n}\n\nfunction migratedColumn(column: string, legacyAlias: string): SqlFragment {\n if (column === \"recorded_from\") return sql`from_map.revision`;\n if (column === \"recorded_to\") {\n return sql`\n CASE\n WHEN ${sql.raw(legacyAlias)}.recorded_to = ${LEGACY_RECORDED_MAX}\n THEN ${RECORDED_MAX_REVISION}\n ELSE to_map.revision\n END\n `;\n }\n return sql`${sql.raw(legacyAlias)}.${sql.identifier(column)}`;\n}\n\nfunction mappingMatch(\n dialect: GraphBackend[\"dialect\"],\n mappingAlias: \"anchor_map\" | \"from_map\" | \"to_map\",\n legacyColumn: \"recorded_at\" | \"recorded_from\" | \"recorded_to\",\n): SqlFragment {\n const mapping = sql.raw(mappingAlias);\n const legacy = sql.raw(`legacy.${legacyColumn}`);\n return dialect === \"postgres\" ?\n sql`${mapping}.recorded_at = ${legacy}`\n : sql`${mapping}.legacy_recorded_at = ${legacy}`;\n}\n\nfunction missingMappingCount(value: unknown, legacyTable: string): number {\n const count = Number(value);\n if (!Number.isSafeInteger(count) || count < 0) {\n throw new ConfigurationError(\n \"Recorded-time migration returned an invalid integrity-check count.\",\n { legacyTable, value },\n );\n }\n return count;\n}\n\nasync function assertRecordedRelationMappings(\n target: TransactionBackend,\n options: Readonly<{ legacyTable: string; mappingTable: string }>,\n): Promise<void> {\n const fromMatch = mappingMatch(target.dialect, \"from_map\", \"recorded_from\");\n const toMatch = mappingMatch(target.dialect, \"to_map\", \"recorded_to\");\n const rows = await target.execute<MissingMappingRow>(\n asCompiledRowsSql(sql`\n SELECT COUNT(*) AS missing\n FROM ${sql.identifier(options.legacyTable)} AS legacy\n LEFT JOIN ${sql.identifier(options.mappingTable)} AS from_map\n ON from_map.graph_id = legacy.graph_id AND ${fromMatch}\n LEFT JOIN ${sql.identifier(options.mappingTable)} AS to_map\n ON to_map.graph_id = legacy.graph_id AND ${toMatch}\n WHERE from_map.revision IS NULL\n OR (\n legacy.recorded_to <> ${LEGACY_RECORDED_MAX}\n AND to_map.revision IS NULL\n )\n `),\n );\n const missing = missingMappingCount(rows[0]?.missing, options.legacyTable);\n if (missing === 0) return;\n throw new ConfigurationError(\n \"Legacy recorded-time boundaries could not be mapped exactly.\",\n { legacyTable: options.legacyTable, missingRows: missing },\n {\n suggestion:\n \"Ensure every legacy boundary is a valid millisecond-precision timestamp produced by the preview recorded clock before retrying the offline migration.\",\n },\n );\n}\n\nasync function assertRecordedClockMappings(\n target: TransactionBackend,\n options: Readonly<{ legacyTable: string; mappingTable: string }>,\n): Promise<void> {\n const match = mappingMatch(target.dialect, \"anchor_map\", \"recorded_at\");\n const rows = await target.execute<MissingMappingRow>(\n asCompiledRowsSql(sql`\n SELECT COUNT(*) AS missing\n FROM ${sql.identifier(options.legacyTable)} AS legacy\n LEFT JOIN ${sql.identifier(options.mappingTable)} AS anchor_map\n ON anchor_map.graph_id = legacy.graph_id AND ${match}\n WHERE anchor_map.revision IS NULL\n `),\n );\n const missing = missingMappingCount(rows[0]?.missing, options.legacyTable);\n if (missing === 0) return;\n throw new ConfigurationError(\n \"Legacy recorded clock values could not be mapped exactly.\",\n { legacyTable: options.legacyTable, missingRows: missing },\n {\n suggestion:\n \"Ensure every legacy clock value is a valid millisecond-precision timestamp produced by the preview recorded clock before retrying the offline migration.\",\n },\n );\n}\n\nasync function copyRecordedRelation(\n target: TransactionBackend,\n options: Readonly<{\n columns: readonly string[];\n legacyTable: string;\n mappingTable: string;\n temporaryTable: string;\n }>,\n): Promise<void> {\n const columnList = options.columns.map((column) => sql.identifier(column));\n const values = options.columns.map((column) =>\n migratedColumn(column, \"legacy\"),\n );\n await assertRecordedRelationMappings(target, options);\n const fromMatch = mappingMatch(target.dialect, \"from_map\", \"recorded_from\");\n const toMatch = mappingMatch(target.dialect, \"to_map\", \"recorded_to\");\n await executeStatement(\n target,\n sql`\n INSERT INTO ${sql.identifier(options.temporaryTable)}\n (${sql.join(columnList, sql`, `)})\n SELECT ${sql.join(values, sql`, `)}\n FROM ${sql.identifier(options.legacyTable)} AS legacy\n -- LEFT JOIN is deliberate: a missing mapping reaches the NOT NULL\n -- revision columns and fails loud instead of silently dropping history.\n LEFT JOIN ${sql.identifier(options.mappingTable)} AS from_map\n ON from_map.graph_id = legacy.graph_id AND ${fromMatch}\n LEFT JOIN ${sql.identifier(options.mappingTable)} AS to_map\n ON to_map.graph_id = legacy.graph_id AND ${toMatch}\n `,\n );\n}\n\nasync function copyRecordedClock(\n target: TransactionBackend,\n options: Readonly<{\n legacyTable: string;\n mappingTable: string;\n temporaryTable: string;\n }>,\n): Promise<void> {\n await assertRecordedClockMappings(target, options);\n const match = mappingMatch(target.dialect, \"anchor_map\", \"recorded_at\");\n await executeStatement(\n target,\n sql`\n INSERT INTO ${sql.identifier(options.temporaryTable)}\n (graph_id, revision, recorded_at)\n SELECT legacy.graph_id, anchor_map.revision, legacy.recorded_at\n FROM ${sql.identifier(options.legacyTable)} AS legacy\n -- Preserve fail-loud behavior if the preflight invariant changes later.\n LEFT JOIN ${sql.identifier(options.mappingTable)} AS anchor_map\n ON anchor_map.graph_id = legacy.graph_id AND ${match}\n `,\n );\n}\n\nasync function replaceLegacyTables(\n target: TransactionBackend,\n tables: ResolvedSqlTableNames,\n mappingTable: string,\n): Promise<void> {\n const temporary = {\n recordedNodes: temporaryTableName(tables.recordedNodes, \"rn\"),\n recordedEdges: temporaryTableName(tables.recordedEdges, \"re\"),\n recordedClock: temporaryTableName(tables.recordedClock, \"rc\"),\n };\n const ddl = tableDdl(target.dialect, tables, temporary);\n for (const table of Object.values(temporary)) {\n await executeStatement(\n target,\n sql`DROP TABLE IF EXISTS ${sql.identifier(table)}`,\n );\n }\n await executeDdl(target, requireCreateTable(ddl.nodes));\n await executeDdl(target, requireCreateTable(ddl.edges));\n await executeDdl(target, requireCreateTable(ddl.clock));\n await copyRecordedRelation(target, {\n columns: RECORDED_NODE_COLUMNS,\n legacyTable: tables.recordedNodes,\n mappingTable,\n temporaryTable: temporary.recordedNodes,\n });\n await copyRecordedRelation(target, {\n columns: RECORDED_EDGE_COLUMNS,\n legacyTable: tables.recordedEdges,\n mappingTable,\n temporaryTable: temporary.recordedEdges,\n });\n await copyRecordedClock(target, {\n legacyTable: tables.recordedClock,\n mappingTable,\n temporaryTable: temporary.recordedClock,\n });\n\n await executeStatement(\n target,\n sql`DROP TABLE ${sql.identifier(tables.recordedNodes)}`,\n );\n await executeStatement(\n target,\n sql`DROP TABLE ${sql.identifier(tables.recordedEdges)}`,\n );\n await executeStatement(\n target,\n sql`DROP TABLE ${sql.identifier(tables.recordedClock)}`,\n );\n await renameTable(target, temporary.recordedNodes, tables.recordedNodes);\n await renameTable(target, temporary.recordedEdges, tables.recordedEdges);\n await renameTable(target, temporary.recordedClock, tables.recordedClock);\n await renamePrimaryKeyConstraint(\n target,\n temporary.recordedNodes,\n tables.recordedNodes,\n );\n await renamePrimaryKeyConstraint(\n target,\n temporary.recordedEdges,\n tables.recordedEdges,\n );\n await renamePrimaryKeyConstraint(\n target,\n temporary.recordedClock,\n tables.recordedClock,\n );\n for (const statement of [\n ...ddl.nodes.slice(1),\n ...ddl.edges.slice(1),\n ...ddl.clock.slice(1),\n ]) {\n await executeDdl(target, statement);\n }\n}\n\nasync function renamePrimaryKeyConstraint(\n target: TransactionBackend,\n temporaryTable: string,\n finalTable: string,\n): Promise<void> {\n if (target.dialect !== \"postgres\") return;\n await executeStatement(\n target,\n sql`\n ALTER TABLE ${sql.identifier(finalTable)}\n RENAME CONSTRAINT ${sql.identifier(`${temporaryTable}_pkey`)}\n TO ${sql.identifier(shortenedIdentifier(`${finalTable}_pkey`))}\n `,\n );\n}\n\nfunction requireCreateTable(statements: readonly string[]): string {\n const statement = statements[0];\n if (statement === undefined) {\n throw new ConfigurationError(\"Recorded migration table DDL was empty.\");\n }\n return statement;\n}\n\nasync function renameTable(\n target: TransactionBackend,\n from: string,\n to: string,\n): Promise<void> {\n try {\n await executeStatement(\n target,\n sql`ALTER TABLE ${sql.identifier(from)} RENAME TO ${sql.identifier(to)}`,\n );\n } catch (error) {\n throw new ConfigurationError(\n \"Could not rename a migrated recorded-time table.\",\n { from, to },\n { cause: error },\n );\n }\n}\n\n/**\n * Rewrites timestamp-only recorded relations to numeric revisions.\n *\n * Run offline before opening a Store with the new schema. The durable mapping\n * table is retained so external checkpoint stores can call\n * {@link migrateRecordedAnchor}; delete each graph's rows after its downstream\n * checkpoints have been rewritten.\n */\nexport async function migrateLegacyRecordedTime(\n options: MigrateLegacyRecordedTimeOptions,\n): Promise<MigrateLegacyRecordedTimeResult> {\n const tables = resolvedTableNames(options.backend, options.tableNames);\n const mapTable = mappingTableName(tables, options.mappingTableName);\n return options.backend.transaction(async (target) => {\n const clockColumns = await columnNames(target, tables.recordedClock);\n if (clockColumns.size === 0) {\n return {\n migrated: false,\n graphs: 0,\n anchors: 0,\n mappingTableName: mapTable,\n };\n }\n if (clockColumns.has(\"revision\")) {\n const mapColumns = await columnNames(target, mapTable);\n if (mapColumns.size === 0) {\n return {\n migrated: false,\n graphs: 0,\n anchors: 0,\n mappingTableName: mapTable,\n };\n }\n const rows = await target.execute<MappingCountRow>(\n asCompiledRowsSql(sql`\n SELECT COUNT(*) AS anchors, COUNT(DISTINCT graph_id) AS graphs\n FROM ${sql.identifier(mapTable)}\n `),\n );\n const anchors = Number(rows[0]?.anchors ?? 0);\n const graphs = Number(rows[0]?.graphs ?? 0);\n return {\n migrated: false,\n graphs: Number.isSafeInteger(graphs) ? graphs : 0,\n anchors: Number.isSafeInteger(anchors) ? anchors : 0,\n mappingTableName: mapTable,\n };\n }\n const nodeColumns = await columnNames(target, tables.recordedNodes);\n const edgeColumns = await columnNames(target, tables.recordedEdges);\n if (\n !nodeColumns.has(\"recorded_from\") ||\n !edgeColumns.has(\"recorded_from\")\n ) {\n throw new ConfigurationError(\n \"Legacy recorded-time schema is incomplete.\",\n { tables },\n );\n }\n\n await executeDdl(target, migrationMapDdl(target.dialect, mapTable));\n const mapping = await readLegacyInstants(target, tables);\n await writeMappingRows(target, mapTable, mapping);\n await replaceLegacyTables(target, tables, mapTable);\n return {\n migrated: true,\n graphs: new Set(mapping.map((row) => row.graphId)).size,\n anchors: mapping.length,\n mappingTableName: mapTable,\n };\n });\n}\n\n/** Remaps one timestamp-only checkpoint after {@link migrateLegacyRecordedTime}. */\nexport async function migrateRecordedAnchor(\n options: MigrateRecordedAnchorOptions,\n): Promise<RecordedInstant> {\n try {\n return asRecordedInstant(options.anchor);\n } catch (error) {\n if (!(error instanceof ValidationError)) throw error;\n }\n const legacyRecordedAt = canonicalLegacyInstant(options.anchor);\n const tables = resolvedTableNames(options.backend, options.tableNames);\n const mapTable = mappingTableName(tables, options.mappingTableName);\n const rows = await options.backend.execute<RemapRow>(\n asCompiledRowsSql(sql`\n SELECT revision, recorded_at\n FROM ${sql.identifier(mapTable)}\n WHERE graph_id = ${options.graphId}\n AND legacy_recorded_at = ${legacyRecordedAt}\n `),\n );\n const row = rows[0];\n if (row === undefined) {\n throw new ConfigurationError(\n \"No migrated recorded anchor matches this graph and legacy timestamp.\",\n { anchor: options.anchor, graphId: options.graphId },\n {\n suggestion:\n \"Run migrateLegacyRecordedTime() before deleting its mapping rows, and pass the graph that produced the checkpoint.\",\n },\n );\n }\n return createRecordedInstant(\n safeRevision(row.revision),\n canonicalLegacyInstant(row.recorded_at),\n );\n}\n\n/**\n * Deletes one graph's legacy remap rows after downstream checkpoints migrate.\n * Set `dropWhenEmpty` to remove the migration table after the final graph.\n */\nexport async function deleteLegacyRecordedAnchorMap(\n options: DeleteLegacyRecordedAnchorMapOptions,\n): Promise<void> {\n if (options.backend.executeStatement === undefined) {\n throw new ConfigurationError(\n \"Deleting a recorded anchor migration map requires executeStatement support.\",\n { dialect: options.backend.dialect },\n );\n }\n const tables = resolvedTableNames(options.backend, options.tableNames);\n const mapTable = mappingTableName(tables, options.mappingTableName);\n await options.backend.transaction(async (target) => {\n await executeStatement(\n target,\n sql`\n DELETE FROM ${sql.identifier(mapTable)}\n WHERE graph_id = ${options.graphId}\n `,\n );\n if (options.dropWhenEmpty !== true) return;\n const rows = await target.execute<MappingCountRow>(\n asCompiledRowsSql(sql`\n SELECT COUNT(*) AS anchors, COUNT(DISTINCT graph_id) AS graphs\n FROM ${sql.identifier(mapTable)}\n `),\n );\n const remaining = missingMappingCount(rows[0]?.anchors, mapTable);\n if (remaining === 0) {\n await executeStatement(\n target,\n sql`DROP TABLE ${sql.identifier(mapTable)}`,\n );\n }\n });\n}\n","/**\n * Offline repair for validity windows that older library versions stored\n * inverted (`valid_from > valid_to`).\n *\n * Such a row is readable at no coordinate at all: `asOf(t)` needs\n * `valid_from <= t < valid_to`, and no `t` satisfies both when the bounds are\n * backwards. The library no longer mints them — a write that stamps a lower\n * bound the caller did not state stores no bound rather than an inverting one —\n * but deploying that fix rewrites nothing, so rows written by an older version\n * (or by direct SQL) stay invisible until an operator repairs them.\n *\n * The repair normalizes those rows to \"ended at T, start unknown\"\n * (`valid_from = NULL`), which is the shape the current write paths store. It\n * deliberately does **not** bump `version`, touch `updated_at`, or mint a\n * recorded revision: it normalizes a storage convention for rows that were\n * never observable at any coordinate, so it is not a logical write — and\n * minting a revision would make the pre-repair recorded state re-materialize\n * the inverted shape at `asOfRecorded` coordinates.\n *\n * Operator consequences, all of them stated in the docs as well:\n *\n * 1. **Run `\"apply\"` with writers stopped.** A concurrent window-bearing update\n * may fence its write on the validity lower bound it read, so a repair that\n * lands in between can make the peer's first `UPDATE` match no row. Store\n * node/edge updates re-read and re-judge against the repaired bound; an\n * interchange update records a per-row target-changed error instead of\n * claiming the row was written. `\"report\"` needs no quiescing — it scans in\n * a read-only transaction, so it cannot write.\n * 2. **Repaired rows become visible** at `asOf` coordinates before their end.\n * That is the point, and it is a read-visibility change to historical\n * queries.\n * 3. **Outstanding `base@V` merge tokens are invalidated** for repaired rows —\n * `valid_from` is part of the base content fingerprint. Quiesce merges,\n * repair, then re-baseline branches.\n * 4. **Prefer `relations: \"live-and-recorded\"`.** Repairing only the live axis\n * leaves the recorded twin carrying the inverted window, which\n * re-materializes the invisible row at any `asOfRecorded` coordinate.\n */\nimport { ConfigurationError } from \"../errors\";\nimport type {\n ResolvedSqlTableNames,\n SqlTableNames,\n} from \"../query/compiler/schema\";\nimport { sql, type SqlFragment } from \"../query/sql-fragment\";\nimport { asCompiledRowsSql, asCompiledStatementSql } from \"../query/sql-intent\";\nimport { resolvedTableNames } from \"./table-names\";\nimport {\n type GraphBackend,\n runOptionallyInTransaction,\n type RunOptionallyInTransactionOptions,\n type TransactionBackend,\n} from \"./types\";\n\n/** A relation whose rows carry a validity window this repair can normalize. */\nexport type RepairRelation =\n \"nodes\" | \"edges\" | \"recordedNodes\" | \"recordedEdges\";\n\n/**\n * Which relations one call scans.\n *\n * `\"live-and-recorded\"` is the recommended scope. `\"live\"` is correct in\n * exactly two cases: the store captures no history and the `recorded_*` tables\n * do not exist, or the operator is deliberately preserving the recorded axis as\n * an audit record of what was stored before the repair — and accepts that\n * historical `asOfRecorded` reads keep returning the invisible shape.\n */\nexport type RepairRelationScope = \"live\" | \"live-and-recorded\";\n\n/** Inputs for detecting or repairing legacy inverted validity windows. */\nexport type RepairInvertedWindowsOptions = Readonly<{\n backend: GraphBackend;\n /** Omit to sweep every graph in the database. */\n graphId?: string | undefined;\n /** Required: the scope is a decision, not a default. */\n relations: RepairRelationScope;\n /**\n * `\"report\"` counts and writes nothing; `\"apply\"` counts and then normalizes\n * the rows it counted.\n */\n mode: \"report\" | \"apply\";\n /**\n * Patch selected backend table names, exactly as migrate-recorded-time does.\n * Unstated names continue to come from `backend.tableNames`; see\n * {@link resolvedTableNames}.\n */\n tableNames?: Partial<SqlTableNames> | undefined;\n}>;\n\n/** Counts and execution guarantees observed by one repair/report call. */\nexport type RepairInvertedWindowsReport = Readonly<{\n /** Echoes the scope actually scanned — a count of 0 and \"not scanned\" are different facts. */\n relations: RepairRelationScope;\n /**\n * Rows whose stored window is inverted: found in `\"report\"` mode, repaired in\n * `\"apply\"` mode. `undefined` means NOT SCANNED, never \"clean\".\n */\n counts: Readonly<Record<RepairRelation, number | undefined>>;\n /**\n * Rows whose stored bounds are not canonical ISO and were therefore not\n * classified. SQLite only in substance: on PostgreSQL the columns are\n * `timestamptz`, so a scanned relation always reports `0` (never `undefined`\n * — that value is reserved for \"not scanned\", on both dialects).\n *\n * `\"apply\"` refuses while any scanned relation reports a non-zero count:\n * classifying those rows needs a timestamp semantics this repair does not\n * own, and skipping them silently would be an accepted option ignored.\n */\n nonCanonical: Readonly<Record<RepairRelation, number | undefined>>;\n /**\n * Whether every statement of this call ran in ONE transaction. `false` on a\n * backend that reports `capabilities.transactions === false`, where the call\n * degrades to per-relation statements.\n *\n * Reported by the seam, not inferred from backend object identity:\n * {@link runOptionallyInTransaction} explicitly tells its callback whether it\n * opened a transaction. \"One snapshot\" and \"four snapshots\" are different\n * facts about a report, and the report must state which occurred even when a\n * custom backend passes the same object into its transaction callback.\n *\n * When `false`, a `\"report\"`'s counts may come from different snapshots and a\n * crash mid-`\"apply\"` can leave the live axis repaired and the recorded axis\n * not. Both are survivable the same way: each relation's statement is\n * idempotent and convergent, so a re-run finishes the job and a later\n * `\"report\"` proves it.\n */\n atomic: boolean;\n}>;\n\nconst LIVE_RELATIONS = [\n \"nodes\",\n \"edges\",\n] as const satisfies readonly RepairRelation[];\n\nconst RECORDED_RELATIONS = [\n \"recordedNodes\",\n \"recordedEdges\",\n] as const satisfies readonly RepairRelation[];\n\n/**\n * Canonical fixed-width UTC ISO 8601, as a SQLite `GLOB` pattern.\n *\n * SQLite stores the bounds as `TEXT` and compares them lexicographically, which\n * equals chronological order only for canonical values. This repair exists to\n * clean up rows written by older paths and by direct SQL, so it cannot assume\n * canonicality — it establishes it per row instead.\n */\nconst CANONICAL_INSTANT_GLOB =\n \"[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]Z\";\n\ntype RepairTarget = GraphBackend | TransactionBackend;\n\ntype CountRow = Readonly<{ matches: unknown }>;\n\nfunction scopedRelations(\n scope: RepairRelationScope,\n): readonly RepairRelation[] {\n return scope === \"live\" ? LIVE_RELATIONS : (\n [...LIVE_RELATIONS, ...RECORDED_RELATIONS]\n );\n}\n\nfunction relationTable(\n tables: ResolvedSqlTableNames,\n relation: RepairRelation,\n): string {\n switch (relation) {\n case \"nodes\": {\n return tables.nodes;\n }\n case \"edges\": {\n return tables.edges;\n }\n case \"recordedNodes\": {\n return tables.recordedNodes;\n }\n case \"recordedEdges\": {\n return tables.recordedEdges;\n }\n }\n}\n\nfunction graphScopeClauses(\n graphId: string | undefined,\n): readonly SqlFragment[] {\n return graphId === undefined ? [] : [sql`graph_id = ${graphId}`];\n}\n\nfunction canonicalBoundsClauses(\n dialect: GraphBackend[\"dialect\"],\n): readonly SqlFragment[] {\n if (dialect !== \"sqlite\") return [];\n return [\n sql`valid_from GLOB ${CANONICAL_INSTANT_GLOB}`,\n sql`valid_to GLOB ${CANONICAL_INSTANT_GLOB}`,\n ];\n}\n\n/**\n * The one spelling of \"this stored window is inverted\".\n *\n * Both modes compile it: `\"report\"` into `SELECT COUNT(*) … WHERE <this>` and\n * `\"apply\"` into `UPDATE … SET valid_from = NULL WHERE <this>`, so the count\n * and the repair cannot disagree about which rows are in scope.\n *\n * The comparison is strict (`>`). A stored zero-width window is a legal shape a\n * caller may have stated in full, and this repair does not second-guess it.\n */\nexport function invertedValidityWindowPredicate(\n options: Readonly<{\n dialect: GraphBackend[\"dialect\"];\n graphId?: string | undefined;\n }>,\n): SqlFragment {\n return sql.join(\n [\n sql`valid_from IS NOT NULL`,\n sql`valid_to IS NOT NULL`,\n ...canonicalBoundsClauses(options.dialect),\n sql`valid_from > valid_to`,\n ...graphScopeClauses(options.graphId),\n ],\n sql` AND `,\n );\n}\n\n/**\n * Rows carrying both bounds where either one is not canonical, and which the\n * inverted predicate therefore refuses to classify. SQLite only: PostgreSQL\n * stores `timestamptz`, where every stored value compares chronologically.\n */\nfunction nonCanonicalWindowPredicate(graphId: string | undefined): SqlFragment {\n return sql.join(\n [\n sql`valid_from IS NOT NULL`,\n sql`valid_to IS NOT NULL`,\n sql`(valid_from NOT GLOB ${CANONICAL_INSTANT_GLOB} OR valid_to NOT GLOB ${CANONICAL_INSTANT_GLOB})`,\n ...graphScopeClauses(graphId),\n ],\n sql` AND `,\n );\n}\n\nfunction safeCount(value: unknown, table: string): number {\n const count = Number(value);\n if (!Number.isSafeInteger(count) || count < 0) {\n throw new ConfigurationError(\n \"Validity-window repair returned an invalid row count.\",\n { table, value },\n );\n }\n return count;\n}\n\nasync function countMatching(\n target: RepairTarget,\n table: string,\n predicate: SqlFragment,\n): Promise<number> {\n const rows = await target.execute<CountRow>(\n asCompiledRowsSql(sql`\n SELECT COUNT(*) AS matches\n FROM ${sql.identifier(table)}\n WHERE ${predicate}\n `),\n );\n return safeCount(rows[0]?.matches, table);\n}\n\n/**\n * `\"apply\"` writes, so it needs the optional non-row-returning statement path.\n * `\"report\"` deliberately does not: `execute` is a required member, so\n * detection stays available on every backend even where repair is not.\n */\nfunction requireStatements(\n target: Pick<RepairTarget, \"dialect\" | \"executeStatement\">,\n): NonNullable<RepairTarget[\"executeStatement\"]> {\n if (target.executeStatement === undefined) {\n throw new ConfigurationError(\n \"Repairing inverted validity windows requires executeStatement support.\",\n { dialect: target.dialect, mode: \"apply\" },\n {\n suggestion:\n 'Use a built-in SQLite or PostgreSQL backend to apply the repair. Detection needs no such support: call this with mode: \"report\" to count the affected rows on any backend.',\n },\n );\n }\n return target.executeStatement;\n}\n\n/**\n * Translates the recorded-capture wrapper's refusal instead of swallowing it.\n *\n * A history-enabled store replaces `executeStatement` with a rejecting stub, so\n * `\"apply\"` against that backend fails with a message about raw SQL rather than\n * about this repair. The remedy is specific enough to be worth naming: hand the\n * repair the raw backend the history store was constructed from. Bypassing\n * capture is the intended behavior here, not a workaround — the repair mints no\n * revision by design.\n */\nfunction translatedCaptureRefusal(error: unknown): unknown {\n if (\n !(error instanceof ConfigurationError) ||\n error.details[\"code\"] !== \"RECORDED_CAPTURE_RAW_SQL_DISABLED\"\n ) {\n return error;\n }\n return new ConfigurationError(\n \"Repairing inverted validity windows cannot run against a history-capturing backend.\",\n { code: \"RECORDED_CAPTURE_RAW_SQL_DISABLED\", mode: \"apply\" },\n {\n cause: error,\n suggestion:\n 'Pass the raw backend you constructed the history store from. The repair deliberately mints no revision — it normalizes storage for rows that were never visible at any coordinate — so bypassing recorded-time capture is the intended behavior, not a workaround. mode: \"report\" needs no such care: it runs against the capture-wrapped backend.',\n },\n );\n}\n\nasync function repairRelation(\n target: RepairTarget,\n table: string,\n predicate: SqlFragment,\n): Promise<void> {\n try {\n await requireStatements(target)(\n asCompiledStatementSql(sql`\n UPDATE ${sql.identifier(table)}\n SET valid_from = NULL\n WHERE ${predicate}\n `),\n );\n } catch (error) {\n throw translatedCaptureRefusal(error);\n }\n}\n\nfunction assertClassifiableBounds(\n nonCanonical: ReadonlyMap<RepairRelation, number>,\n): void {\n const unclassified = [...nonCanonical].filter(([, count]) => count > 0);\n if (unclassified.length === 0) return;\n throw new ConfigurationError(\n \"Refusing to repair validity windows: some scanned rows store non-canonical bounds.\",\n { nonCanonical: Object.fromEntries(unclassified) },\n {\n suggestion:\n 'Normalize those bounds to canonical UTC ISO 8601 (YYYY-MM-DDTHH:MM:SS.mmmZ) and re-run, or narrow the call with graphId. Classifying them here would need a timestamp semantics this repair does not own, and skipping them silently would report a repair it did not make. mode: \"report\" still counts them.',\n },\n );\n}\n\n/**\n * Declares `\"report\"`'s read-only-ness to the ENGINE rather than only to the\n * reader of this file.\n *\n * The docs send an operator to diagnose against the live store's backend and\n * require quiescing only for `\"apply\"`, so the scan must not behave like a\n * writer: on SQLite a default transaction is `BEGIN IMMEDIATE`, which reserves\n * the single writer slot for the duration of up to four full-table `COUNT(*)`\n * scans and can fail `SQLITE_BUSY` against an active writer; `read_only` issues\n * a plain `BEGIN` instead. On PostgreSQL it issues `BEGIN … READ ONLY`, which\n * makes \"report writes nothing\" enforced by the engine and not merely asserted\n * by a test.\n *\n * `\"apply\"` writes, so it takes the default read-write transaction.\n */\nfunction transactionOptionsFor(\n mode: RepairInvertedWindowsOptions[\"mode\"],\n): RunOptionallyInTransactionOptions | undefined {\n return mode === \"report\" ?\n { transaction: { accessMode: \"read_only\" } }\n : undefined;\n}\n\nfunction relationRecord(\n counts: ReadonlyMap<RepairRelation, number>,\n): Readonly<Record<RepairRelation, number | undefined>> {\n return {\n nodes: counts.get(\"nodes\"),\n edges: counts.get(\"edges\"),\n recordedNodes: counts.get(\"recordedNodes\"),\n recordedEdges: counts.get(\"recordedEdges\"),\n };\n}\n\n/**\n * Counts — and, in `\"apply\"` mode, normalizes — rows whose stored validity\n * window is inverted.\n *\n * ```typescript\n * // Diagnose with the store's backend: `report` reads only, so it runs\n * // anywhere, including a capture-wrapped or statement-less backend.\n * const report = await repairInvertedValidityWindows({\n * backend: anyBackend,\n * relations: \"live-and-recorded\",\n * mode: \"report\",\n * });\n *\n * // Repair with the raw one, while writers are stopped.\n * await repairInvertedValidityWindows({\n * backend: rawBackend,\n * relations: \"live-and-recorded\",\n * mode: \"apply\",\n * });\n * ```\n *\n * Idempotent and convergent: a second `\"apply\"` reports zero, because the rows\n * the first one repaired no longer match the predicate.\n *\n * No batching, deliberately. Unlike the recorded-time migration, which rewrites\n * every row, this statement touches only rows the library mis-stored — an empty\n * set on a healthy graph. A deployment that reports a count large enough to\n * worry about should run it per `graphId`.\n *\n * @throws ConfigurationError in `\"apply\"` mode when the backend cannot execute\n * statements, when the backend is a recorded-capture wrapper, or when any\n * scanned relation stores non-canonical bounds.\n */\nexport async function repairInvertedValidityWindows(\n options: RepairInvertedWindowsOptions,\n): Promise<RepairInvertedWindowsReport> {\n const tables = resolvedTableNames(options.backend, options.tableNames);\n const relations = scopedRelations(options.relations);\n // Refuse before opening a transaction: a backend with no statement path can\n // never apply, whatever the scan finds.\n if (options.mode === \"apply\") requireStatements(options.backend);\n\n return runOptionallyInTransaction(\n options.backend,\n async (target, execution) => {\n const predicate = invertedValidityWindowPredicate({\n dialect: target.dialect,\n graphId: options.graphId,\n });\n const inverted = new Map<RepairRelation, number>();\n const nonCanonical = new Map<RepairRelation, number>();\n for (const relation of relations) {\n const table = relationTable(tables, relation);\n nonCanonical.set(\n relation,\n target.dialect === \"sqlite\" ?\n await countMatching(\n target,\n table,\n nonCanonicalWindowPredicate(options.graphId),\n )\n : 0,\n );\n inverted.set(relation, await countMatching(target, table, predicate));\n }\n\n if (options.mode === \"apply\") {\n assertClassifiableBounds(nonCanonical);\n for (const relation of relations) {\n await repairRelation(\n target,\n relationTable(tables, relation),\n predicate,\n );\n }\n }\n\n return {\n relations: options.relations,\n counts: relationRecord(inverted),\n nonCanonical: relationRecord(nonCanonical),\n atomic: execution.atomic,\n };\n },\n transactionOptionsFor(options.mode),\n );\n}\n"]}
|