@remnic/core 9.69.87 → 9.69.89
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/access-admin-ops-surface.js +56 -49
- package/dist/access-authorization-probe.js +57 -50
- package/dist/access-boundary.js +56 -49
- package/dist/access-citation-namespace.js +2 -2
- package/dist/access-cli.js +129 -122
- package/dist/access-cli.js.map +1 -1
- package/dist/access-extraction-force-flush.js +56 -49
- package/dist/access-http-briefing.js +57 -50
- package/dist/access-http-offline-stream.d.ts.map +1 -1
- package/dist/access-http-offline-stream.js +1 -1
- package/dist/access-http-query.js +58 -51
- package/dist/access-http.js +78 -71
- package/dist/access-identity-continuity-surface.js +56 -49
- package/dist/access-lcm-surface.js +56 -49
- package/dist/access-mcp-output-schemas.d.ts.map +1 -1
- package/dist/access-mcp-output-schemas.js +1 -1
- package/dist/access-mcp.js +69 -62
- package/dist/access-namespace-preflight.js +56 -49
- package/dist/access-observe-write-category.js +20 -13
- package/dist/access-observe-write-surface.js +56 -49
- package/dist/access-offline-manifest.js +16 -10
- package/dist/access-operations-batch.js +60 -53
- package/dist/access-operations.js +67 -60
- package/dist/access-recall-concurrency.js +56 -49
- package/dist/access-recall-response.js +56 -49
- package/dist/access-recall-surface.js +56 -49
- package/dist/access-schema.js +16 -7
- package/dist/access-service.d.ts.map +1 -1
- package/dist/access-service.js +56 -49
- package/dist/access-surface-catalog.js +58 -51
- package/dist/access-surface-catalog.js.map +1 -1
- package/dist/active-recall.js +24 -18
- package/dist/active-recall.js.map +1 -1
- package/dist/{auto-sync-6IPX2BAC.js → auto-sync-U5N3CB5Y.js} +7 -7
- package/dist/briefing.js +11 -11
- package/dist/buffer.js +7 -7
- package/dist/{capsule-crypto-7FJQINUR.js → capsule-crypto-GWVG7LGC.js} +2 -2
- package/dist/{capsule-merge-3MNURAQ3.js → capsule-merge-ZCXUPLNJ.js} +2 -2
- package/dist/causal-behavior.js +2 -2
- package/dist/causal-chain.js +2 -2
- package/dist/causal-consolidation.js +14 -14
- package/dist/causal-retrieval.js +2 -2
- package/dist/causal-trajectory-graph.js +2 -2
- package/dist/causal-trajectory.js +1 -1
- package/dist/{chunk-JE334SIA.js → chunk-22DYJLFN.js} +2 -2
- package/dist/{chunk-YTQGGO3K.js → chunk-22LMCQ5B.js} +85 -82
- package/dist/{chunk-YTQGGO3K.js.map → chunk-22LMCQ5B.js.map} +1 -1
- package/dist/{chunk-JGSQ6P4D.js → chunk-2FX374UI.js} +2 -2
- package/dist/{chunk-SY5KDWGU.js → chunk-2WLMWP2T.js} +2 -2
- package/dist/{chunk-6TT6HRE4.js → chunk-3AGHSQPM.js} +2 -2
- package/dist/{chunk-P6WFK4ZJ.js → chunk-3O5BB45T.js} +4 -4
- package/dist/{chunk-3C3J243X.js → chunk-3QKO4QN7.js} +3 -3
- package/dist/{chunk-KFCMMDHH.js → chunk-3YD44CH2.js} +2 -2
- package/dist/{chunk-FRCESVV6.js → chunk-4HUCP4R4.js} +18 -18
- package/dist/chunk-4HUCP4R4.js.map +1 -0
- package/dist/chunk-4NSLQ7EU.js +137 -0
- package/dist/chunk-4NSLQ7EU.js.map +1 -0
- package/dist/{chunk-7DE2NOON.js → chunk-4O4XCBOS.js} +3 -3
- package/dist/{chunk-GDYU6VF4.js → chunk-5AYUHSAU.js} +2 -2
- package/dist/{chunk-ICZQG4XE.js → chunk-5FAGCOZD.js} +4 -4
- package/dist/{chunk-VKQI47DJ.js → chunk-5FNZ3G6X.js} +4 -4
- package/dist/{chunk-CK5KOVHW.js → chunk-5R627MYY.js} +3 -2
- package/dist/{chunk-CK5KOVHW.js.map → chunk-5R627MYY.js.map} +1 -1
- package/dist/{chunk-VQNONC4E.js → chunk-5STPRPE7.js} +2 -2
- package/dist/{chunk-52II7PB6.js → chunk-645WOU5I.js} +4 -4
- package/dist/{chunk-SRZW7FNU.js → chunk-64ZUALXK.js} +2 -2
- package/dist/{chunk-4BZP2B4U.js → chunk-6MNKDTDI.js} +2 -2
- package/dist/{chunk-DUJYRVUD.js → chunk-6O2VUWV6.js} +3 -3
- package/dist/chunk-75PT4N7Q.js +75 -0
- package/dist/chunk-75PT4N7Q.js.map +1 -0
- package/dist/{chunk-HESDNYRB.js → chunk-76M5OK7V.js} +2 -2
- package/dist/{chunk-FAN73COB.js → chunk-7D7OUO5W.js} +2 -2
- package/dist/{chunk-DZ525SNQ.js → chunk-7QE46QXI.js} +1 -1
- package/dist/{chunk-VX6GCKBS.js → chunk-7WBSMXGC.js} +4 -4
- package/dist/{chunk-VVDWZRZG.js → chunk-A6RVIHHK.js} +3 -3
- package/dist/{chunk-M536WNTQ.js → chunk-AEJ3TE5H.js} +2 -2
- package/dist/{chunk-72JNNJJJ.js → chunk-AXC4WSF3.js} +3 -3
- package/dist/chunk-AXGJMDBS.js +684 -0
- package/dist/chunk-AXGJMDBS.js.map +1 -0
- package/dist/{chunk-UA5DX5C3.js → chunk-AZIOEOK4.js} +2 -2
- package/dist/{chunk-N4S4NUX5.js → chunk-B3O3IRZN.js} +1 -1
- package/dist/{chunk-XTYX6V52.js → chunk-BJVO4H5C.js} +2 -2
- package/dist/{chunk-7LCGFUMB.js → chunk-BUKK5SWA.js} +4 -4
- package/dist/{chunk-TM3RXL4G.js → chunk-BUQKSQXL.js} +2 -2
- package/dist/chunk-C6HPNPNK.js +64 -0
- package/dist/chunk-C6HPNPNK.js.map +1 -0
- package/dist/{chunk-RB776UH3.js → chunk-C7V3KPKJ.js} +235 -93
- package/dist/chunk-C7V3KPKJ.js.map +1 -0
- package/dist/{chunk-FOH7AMMI.js → chunk-CALBQ2NG.js} +71 -72
- package/dist/chunk-CALBQ2NG.js.map +1 -0
- package/dist/{chunk-37S3IMYB.js → chunk-DGS34QSY.js} +2 -2
- package/dist/{chunk-4IEOGIPB.js → chunk-DO4C4AXD.js} +2 -2
- package/dist/{chunk-SPSRGEDQ.js → chunk-EAQQ2FD3.js} +9 -9
- package/dist/{chunk-3BTFBQLO.js → chunk-EFHNFTWB.js} +49 -3
- package/dist/chunk-EFHNFTWB.js.map +1 -0
- package/dist/{chunk-C3QXITIP.js → chunk-EQUD7FP4.js} +2 -2
- package/dist/chunk-ETUZFFPU.js +218 -0
- package/dist/chunk-ETUZFFPU.js.map +1 -0
- package/dist/{chunk-YNDLCWXS.js → chunk-EZ25VE3G.js} +4 -4
- package/dist/{chunk-YITN5WXI.js → chunk-FC52YWAO.js} +2 -2
- package/dist/{chunk-ZI7QA4MK.js → chunk-FEIXG5FA.js} +2 -2
- package/dist/{chunk-CLXTDOKV.js → chunk-FUNBJQYR.js} +2 -2
- package/dist/{chunk-CLSYE5OZ.js → chunk-G2STTRYB.js} +2 -2
- package/dist/{chunk-TDYAIXHK.js → chunk-H36X4NRH.js} +5 -5
- package/dist/{chunk-3GQC3NMB.js → chunk-H56VY4BY.js} +5 -5
- package/dist/{chunk-PUKTBULQ.js → chunk-HWLIMQE2.js} +2 -2
- package/dist/{chunk-V2ES4WCZ.js → chunk-IIARQTZ2.js} +2 -2
- package/dist/{chunk-QEV26L2F.js → chunk-IKDRGVVJ.js} +2 -2
- package/dist/{chunk-WQZZDN5M.js → chunk-IVEHY2VT.js} +254 -377
- package/dist/chunk-IVEHY2VT.js.map +1 -0
- package/dist/{chunk-LS3XH3UE.js → chunk-IYIBGSHJ.js} +2 -2
- package/dist/{chunk-YSJTCOHR.js → chunk-J27JML5O.js} +2 -2
- package/dist/{chunk-AQK54Q7O.js → chunk-JB56XYHP.js} +2 -2
- package/dist/{chunk-NE6PHPLG.js → chunk-JBH26P62.js} +10 -10
- package/dist/{chunk-CWHV574S.js → chunk-JUT3OR2L.js} +6 -6
- package/dist/{chunk-6ET2VII7.js → chunk-JYG2334B.js} +2 -2
- package/dist/{chunk-LF5IGOOD.js → chunk-JYM4Y6SO.js} +16 -16
- package/dist/{chunk-FB64XE3R.js → chunk-JZ4TJHR2.js} +2 -2
- package/dist/{chunk-EHS5MJEF.js → chunk-KTKHO3UI.js} +3 -3
- package/dist/{chunk-WIKO4SCR.js → chunk-LHRQBMJN.js} +2 -2
- package/dist/{chunk-K4J4E7WV.js → chunk-LO4UKPKX.js} +2 -2
- package/dist/{chunk-JN72EPOE.js → chunk-MAAL6OZV.js} +7 -7
- package/dist/chunk-MAAL6OZV.js.map +1 -0
- package/dist/{chunk-MY2PLXSM.js → chunk-MCTM4YPL.js} +2 -1
- package/dist/{chunk-MY2PLXSM.js.map → chunk-MCTM4YPL.js.map} +1 -1
- package/dist/{chunk-6NQ4LSMS.js → chunk-MGZMC6WN.js} +47 -47
- package/dist/chunk-MSAI3Q7D.js +372 -0
- package/dist/chunk-MSAI3Q7D.js.map +1 -0
- package/dist/{chunk-BMYZTZ5D.js → chunk-MY7B3HYC.js} +2 -2
- package/dist/{chunk-NB3LRY4T.js → chunk-N4PYB235.js} +2 -2
- package/dist/{chunk-S3YM4SZQ.js → chunk-N7QV3CMX.js} +2 -2
- package/dist/{chunk-L6UZEAID.js → chunk-NJVR724O.js} +4 -4
- package/dist/{chunk-VLLD4TOB.js → chunk-NMZVDRVP.js} +2 -2
- package/dist/{chunk-P2WZHLUF.js → chunk-NOL7SEWN.js} +2 -2
- package/dist/{chunk-2NLLXCJG.js → chunk-OWHERGF2.js} +2 -2
- package/dist/{chunk-6L3PBSAR.js → chunk-PMNLL2TL.js} +2 -2
- package/dist/{chunk-VYCOJKSX.js → chunk-PO7NXNGC.js} +2 -2
- package/dist/{chunk-4IIMMZZK.js → chunk-PULDSMCJ.js} +10 -10
- package/dist/{chunk-G6SVZWPB.js → chunk-PZX3AQLF.js} +44 -1
- package/dist/chunk-PZX3AQLF.js.map +1 -0
- package/dist/{chunk-HBBHL4YF.js → chunk-QOXNTKXB.js} +2 -2
- package/dist/{chunk-CUCWX3MO.js → chunk-QZLCVO2V.js} +2 -2
- package/dist/{chunk-NE7I2RCT.js → chunk-R3X2T2LP.js} +2 -2
- package/dist/{chunk-S7GCT7NU.js → chunk-RBITPCMK.js} +8 -8
- package/dist/{chunk-EVBI7S4J.js → chunk-RMDGAAZF.js} +4 -4
- package/dist/{chunk-BJRAELDH.js → chunk-SCXURCVT.js} +3 -3
- package/dist/{chunk-EQ6YOIKO.js → chunk-ST2RQUXC.js} +3 -3
- package/dist/{chunk-CS52MFDV.js → chunk-SZG4WFAG.js} +2 -2
- package/dist/{chunk-BFO3IR56.js → chunk-TPEZ2SHV.js} +2 -2
- package/dist/chunk-TYT4TEQV.js +45 -0
- package/dist/chunk-TYT4TEQV.js.map +1 -0
- package/dist/{chunk-YRLHEEQT.js → chunk-U6VC6RP3.js} +2 -2
- package/dist/chunk-UCPGOUDZ.js +726 -0
- package/dist/chunk-UCPGOUDZ.js.map +1 -0
- package/dist/{chunk-MOQPEFLN.js → chunk-UP75KL3L.js} +2 -2
- package/dist/{chunk-W4AOR52H.js → chunk-UQDC3W77.js} +2 -2
- package/dist/{chunk-X7Y7WX73.js → chunk-UVYI6VIX.js} +1 -1
- package/dist/{chunk-D5F7TKMH.js → chunk-V4JZCTMK.js} +2 -2
- package/dist/{chunk-MQJL6CDZ.js → chunk-VA4O3U7U.js} +4 -4
- package/dist/{chunk-4CDYONWO.js → chunk-VDO32NLK.js} +3 -3
- package/dist/{chunk-SOZUJCME.js → chunk-VHDKPGMG.js} +6 -6
- package/dist/{chunk-QWW2JDDX.js → chunk-WNRTXEWW.js} +6 -6
- package/dist/{chunk-NR2ASHBL.js → chunk-XOV7NRY5.js} +2 -2
- package/dist/{chunk-KP7SANCF.js → chunk-YPI4RQWV.js} +2 -2
- package/dist/{chunk-JKMHZF3Q.js → chunk-YSWJXOOL.js} +2 -2
- package/dist/{chunk-LQG5O5EP.js → chunk-Z3O53WZR.js} +2 -2
- package/dist/{chunk-QVS22WTO.js → chunk-ZG5DWWKK.js} +2 -2
- package/dist/cli.js +99 -92
- package/dist/coding/export-okf-codegraph.js +12 -12
- package/dist/coding/pre-action-gate.js +2 -2
- package/dist/compounding/engine.js +12 -12
- package/dist/config.js +24 -18
- package/dist/connectors/codex-materialize-runner.js +11 -11
- package/dist/connectors/index.js +11 -11
- package/dist/console/state.d.ts +30 -0
- package/dist/console/state.d.ts.map +1 -1
- package/dist/contradiction/index.js +5 -5
- package/dist/convergence-refresh.js +13 -13
- package/dist/corpus-watermark.js +13 -13
- package/dist/dashboard-runtime.js +2 -2
- package/dist/deep-recall-http-glue.js +16 -8
- package/dist/embedding-fallback.d.ts +41 -31
- package/dist/embedding-fallback.d.ts.map +1 -1
- package/dist/embedding-fallback.js +9 -1
- package/dist/embedding-generation-lock.d.ts +49 -0
- package/dist/embedding-generation-lock.d.ts.map +1 -0
- package/dist/embedding-generation-lock.js +19 -0
- package/dist/embedding-index-storage.d.ts +276 -0
- package/dist/embedding-index-storage.d.ts.map +1 -0
- package/dist/embedding-index-storage.js +28 -0
- package/dist/entity-retrieval.js +12 -12
- package/dist/event-order-recall.js +3 -3
- package/dist/explicit-capture.js +6 -6
- package/dist/external-wiki-access.js +57 -50
- package/dist/extraction.js +17 -17
- package/dist/{first-start-migration-7OATHJKB.js → first-start-migration-GAT7G733.js} +4 -4
- package/dist/{graph-edge-decay-KQGS3L3B.js → graph-edge-decay-MKIRZ762.js} +5 -5
- package/dist/graph-jsonl.js +3 -3
- package/dist/graph-snapshot.js +3 -3
- package/dist/graph.js +2 -2
- package/dist/harmonic-retrieval.js +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +195 -164
- package/dist/lcm/engine.js +2 -2
- package/dist/lcm/index.js +5 -5
- package/dist/local-llm.js +2 -2
- package/dist/location/index.js +14 -14
- package/dist/maintenance/memory-governance.js +11 -11
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +11 -11
- package/dist/maintenance/rebuild-memory-projection.js +12 -12
- package/dist/memory-browse-operations.js +57 -50
- package/dist/memory-subject.js +3 -3
- package/dist/namespaces/migrate.js +12 -12
- package/dist/namespaces/storage.js +11 -11
- package/dist/offline-sync-changeset-generations.d.ts +82 -0
- package/dist/offline-sync-changeset-generations.d.ts.map +1 -0
- package/dist/offline-sync-changeset-generations.js +21 -0
- package/dist/offline-sync-embedding-generation.d.ts +257 -0
- package/dist/offline-sync-embedding-generation.d.ts.map +1 -0
- package/dist/offline-sync-embedding-generation.js +44 -0
- package/dist/offline-sync-embedding-generation.js.map +1 -0
- package/dist/offline-sync-exclude-globs.d.ts +15 -0
- package/dist/offline-sync-exclude-globs.d.ts.map +1 -1
- package/dist/offline-sync-exclude-globs.js +11 -3
- package/dist/offline-sync-file-io.d.ts +7 -0
- package/dist/offline-sync-file-io.d.ts.map +1 -1
- package/dist/offline-sync-file-io.js +14 -2
- package/dist/offline-sync-impression-drain.js +3 -3
- package/dist/offline-sync-runtime-state.d.ts +5 -0
- package/dist/offline-sync-runtime-state.d.ts.map +1 -0
- package/dist/offline-sync-runtime-state.js +14 -0
- package/dist/offline-sync-runtime-state.js.map +1 -0
- package/dist/offline-sync-snapshot-stream.d.ts +26 -0
- package/dist/offline-sync-snapshot-stream.d.ts.map +1 -0
- package/dist/offline-sync-snapshot-stream.js +29 -0
- package/dist/offline-sync-snapshot-stream.js.map +1 -0
- package/dist/offline-sync-upload-staging.d.ts +34 -0
- package/dist/offline-sync-upload-staging.d.ts.map +1 -0
- package/dist/offline-sync-upload-staging.js +26 -0
- package/dist/offline-sync-upload-staging.js.map +1 -0
- package/dist/offline-sync.d.ts +58 -28
- package/dist/offline-sync.d.ts.map +1 -1
- package/dist/offline-sync.js +22 -8
- package/dist/operator-doctor-corpus.js +14 -14
- package/dist/operator-toolkit.js +35 -29
- package/dist/orchestration/maintenance.js +22 -22
- package/dist/orchestrator.d.ts.map +1 -1
- package/dist/orchestrator.js +129 -122
- package/dist/recall-navigation-operations.js +57 -50
- package/dist/recall-navigation.js +56 -49
- package/dist/reconcile/manifest.js +4 -4
- package/dist/{resolution-DNX7FO7A.js → resolution-K4A3VPKZ.js} +6 -6
- package/dist/resolution-K4A3VPKZ.js.map +1 -0
- package/dist/resume-bundles.js +25 -19
- package/dist/salvage-envelope.js +5 -5
- package/dist/secure-store/index.js +2 -2
- package/dist/secure-store/secure-fs.d.ts +14 -1
- package/dist/secure-store/secure-fs.d.ts.map +1 -1
- package/dist/semantic-consolidation.js +12 -12
- package/dist/semantic-rule-promotion.js +11 -11
- package/dist/semantic-rule-verifier.js +11 -11
- package/dist/source-agent-qualifier.js +14 -14
- package/dist/standup/build.js +11 -11
- package/dist/{state-ITXJKXRE.js → state-JB47KHYV.js} +2 -2
- package/dist/state-JB47KHYV.js.map +1 -0
- package/dist/storage.d.ts +9 -3
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +10 -10
- package/dist/subject-config.js +4 -4
- package/dist/summarizer.js +3 -3
- package/dist/support-passport/index.js +59 -52
- package/dist/support-passport/offline-sync-guard.d.ts +6 -2
- package/dist/support-passport/offline-sync-guard.d.ts.map +1 -1
- package/dist/{trace-ZFVRH4GO.js → trace-LXXCMZJA.js} +3 -3
- package/dist/transfer/backup.js +2 -2
- package/dist/transfer/capsule-export.js +2 -2
- package/dist/transfer/capsule-import.js +3 -3
- package/dist/transfer/export-okf.js +12 -12
- package/dist/{tui-55UJMJX7.js → tui-2Z5WOV7L.js} +3 -3
- package/dist/tui-2Z5WOV7L.js.map +1 -0
- package/dist/verified-recall.js +11 -11
- package/dist/who-knows-cli.js +12 -12
- package/dist/who-knows.js +11 -11
- package/dist/write-envelope.js +4 -4
- package/package.json +2 -2
- package/src/access-http-offline-stream.ts +3 -0
- package/src/access-mcp-output-schemas.ts +1 -0
- package/src/access-service.ts +7 -18
- package/src/console/state.test.ts +56 -0
- package/src/console/state.ts +83 -0
- package/src/embedding-fallback.ts +325 -141
- package/src/embedding-generation-lock.ts +141 -0
- package/src/embedding-index-storage.test.ts +245 -0
- package/src/embedding-index-storage.ts +1068 -0
- package/src/index.ts +3 -3
- package/src/offline-sync-changeset-generations.test.ts +962 -0
- package/src/offline-sync-changeset-generations.ts +549 -0
- package/src/offline-sync-embedding-generation.test.ts +2173 -0
- package/src/offline-sync-embedding-generation.ts +1153 -0
- package/src/offline-sync-exclude-globs.ts +112 -0
- package/src/offline-sync-file-io.ts +48 -0
- package/src/offline-sync-runtime-state.ts +48 -0
- package/src/offline-sync-snapshot-stream.ts +99 -0
- package/src/offline-sync-upload-staging.ts +291 -0
- package/src/offline-sync.test.ts +164 -1
- package/src/offline-sync.ts +372 -454
- package/src/orchestrator.ts +2 -1
- package/src/secure-store/secure-fs.ts +26 -6
- package/src/storage.ts +11 -6
- package/src/support-passport/offline-sync-guard.ts +16 -2
- package/dist/chunk-3BTFBQLO.js.map +0 -1
- package/dist/chunk-AREGMX2J.js +0 -50
- package/dist/chunk-AREGMX2J.js.map +0 -1
- package/dist/chunk-FOH7AMMI.js.map +0 -1
- package/dist/chunk-FRCESVV6.js.map +0 -1
- package/dist/chunk-G6SVZWPB.js.map +0 -1
- package/dist/chunk-JN72EPOE.js.map +0 -1
- package/dist/chunk-RB776UH3.js.map +0 -1
- package/dist/chunk-WQZZDN5M.js.map +0 -1
- /package/dist/{auto-sync-6IPX2BAC.js.map → auto-sync-U5N3CB5Y.js.map} +0 -0
- /package/dist/{capsule-crypto-7FJQINUR.js.map → capsule-crypto-GWVG7LGC.js.map} +0 -0
- /package/dist/{capsule-merge-3MNURAQ3.js.map → capsule-merge-ZCXUPLNJ.js.map} +0 -0
- /package/dist/{chunk-JE334SIA.js.map → chunk-22DYJLFN.js.map} +0 -0
- /package/dist/{chunk-JGSQ6P4D.js.map → chunk-2FX374UI.js.map} +0 -0
- /package/dist/{chunk-SY5KDWGU.js.map → chunk-2WLMWP2T.js.map} +0 -0
- /package/dist/{chunk-6TT6HRE4.js.map → chunk-3AGHSQPM.js.map} +0 -0
- /package/dist/{chunk-P6WFK4ZJ.js.map → chunk-3O5BB45T.js.map} +0 -0
- /package/dist/{chunk-3C3J243X.js.map → chunk-3QKO4QN7.js.map} +0 -0
- /package/dist/{chunk-KFCMMDHH.js.map → chunk-3YD44CH2.js.map} +0 -0
- /package/dist/{chunk-7DE2NOON.js.map → chunk-4O4XCBOS.js.map} +0 -0
- /package/dist/{chunk-GDYU6VF4.js.map → chunk-5AYUHSAU.js.map} +0 -0
- /package/dist/{chunk-ICZQG4XE.js.map → chunk-5FAGCOZD.js.map} +0 -0
- /package/dist/{chunk-VKQI47DJ.js.map → chunk-5FNZ3G6X.js.map} +0 -0
- /package/dist/{chunk-VQNONC4E.js.map → chunk-5STPRPE7.js.map} +0 -0
- /package/dist/{chunk-52II7PB6.js.map → chunk-645WOU5I.js.map} +0 -0
- /package/dist/{chunk-SRZW7FNU.js.map → chunk-64ZUALXK.js.map} +0 -0
- /package/dist/{chunk-4BZP2B4U.js.map → chunk-6MNKDTDI.js.map} +0 -0
- /package/dist/{chunk-DUJYRVUD.js.map → chunk-6O2VUWV6.js.map} +0 -0
- /package/dist/{chunk-HESDNYRB.js.map → chunk-76M5OK7V.js.map} +0 -0
- /package/dist/{chunk-FAN73COB.js.map → chunk-7D7OUO5W.js.map} +0 -0
- /package/dist/{chunk-DZ525SNQ.js.map → chunk-7QE46QXI.js.map} +0 -0
- /package/dist/{chunk-VX6GCKBS.js.map → chunk-7WBSMXGC.js.map} +0 -0
- /package/dist/{chunk-VVDWZRZG.js.map → chunk-A6RVIHHK.js.map} +0 -0
- /package/dist/{chunk-M536WNTQ.js.map → chunk-AEJ3TE5H.js.map} +0 -0
- /package/dist/{chunk-72JNNJJJ.js.map → chunk-AXC4WSF3.js.map} +0 -0
- /package/dist/{chunk-UA5DX5C3.js.map → chunk-AZIOEOK4.js.map} +0 -0
- /package/dist/{chunk-N4S4NUX5.js.map → chunk-B3O3IRZN.js.map} +0 -0
- /package/dist/{chunk-XTYX6V52.js.map → chunk-BJVO4H5C.js.map} +0 -0
- /package/dist/{chunk-7LCGFUMB.js.map → chunk-BUKK5SWA.js.map} +0 -0
- /package/dist/{chunk-TM3RXL4G.js.map → chunk-BUQKSQXL.js.map} +0 -0
- /package/dist/{chunk-37S3IMYB.js.map → chunk-DGS34QSY.js.map} +0 -0
- /package/dist/{chunk-4IEOGIPB.js.map → chunk-DO4C4AXD.js.map} +0 -0
- /package/dist/{chunk-SPSRGEDQ.js.map → chunk-EAQQ2FD3.js.map} +0 -0
- /package/dist/{chunk-C3QXITIP.js.map → chunk-EQUD7FP4.js.map} +0 -0
- /package/dist/{chunk-YNDLCWXS.js.map → chunk-EZ25VE3G.js.map} +0 -0
- /package/dist/{chunk-YITN5WXI.js.map → chunk-FC52YWAO.js.map} +0 -0
- /package/dist/{chunk-ZI7QA4MK.js.map → chunk-FEIXG5FA.js.map} +0 -0
- /package/dist/{chunk-CLXTDOKV.js.map → chunk-FUNBJQYR.js.map} +0 -0
- /package/dist/{chunk-CLSYE5OZ.js.map → chunk-G2STTRYB.js.map} +0 -0
- /package/dist/{chunk-TDYAIXHK.js.map → chunk-H36X4NRH.js.map} +0 -0
- /package/dist/{chunk-3GQC3NMB.js.map → chunk-H56VY4BY.js.map} +0 -0
- /package/dist/{chunk-PUKTBULQ.js.map → chunk-HWLIMQE2.js.map} +0 -0
- /package/dist/{chunk-V2ES4WCZ.js.map → chunk-IIARQTZ2.js.map} +0 -0
- /package/dist/{chunk-QEV26L2F.js.map → chunk-IKDRGVVJ.js.map} +0 -0
- /package/dist/{chunk-LS3XH3UE.js.map → chunk-IYIBGSHJ.js.map} +0 -0
- /package/dist/{chunk-YSJTCOHR.js.map → chunk-J27JML5O.js.map} +0 -0
- /package/dist/{chunk-AQK54Q7O.js.map → chunk-JB56XYHP.js.map} +0 -0
- /package/dist/{chunk-NE6PHPLG.js.map → chunk-JBH26P62.js.map} +0 -0
- /package/dist/{chunk-CWHV574S.js.map → chunk-JUT3OR2L.js.map} +0 -0
- /package/dist/{chunk-6ET2VII7.js.map → chunk-JYG2334B.js.map} +0 -0
- /package/dist/{chunk-LF5IGOOD.js.map → chunk-JYM4Y6SO.js.map} +0 -0
- /package/dist/{chunk-FB64XE3R.js.map → chunk-JZ4TJHR2.js.map} +0 -0
- /package/dist/{chunk-EHS5MJEF.js.map → chunk-KTKHO3UI.js.map} +0 -0
- /package/dist/{chunk-WIKO4SCR.js.map → chunk-LHRQBMJN.js.map} +0 -0
- /package/dist/{chunk-K4J4E7WV.js.map → chunk-LO4UKPKX.js.map} +0 -0
- /package/dist/{chunk-6NQ4LSMS.js.map → chunk-MGZMC6WN.js.map} +0 -0
- /package/dist/{chunk-BMYZTZ5D.js.map → chunk-MY7B3HYC.js.map} +0 -0
- /package/dist/{chunk-NB3LRY4T.js.map → chunk-N4PYB235.js.map} +0 -0
- /package/dist/{chunk-S3YM4SZQ.js.map → chunk-N7QV3CMX.js.map} +0 -0
- /package/dist/{chunk-L6UZEAID.js.map → chunk-NJVR724O.js.map} +0 -0
- /package/dist/{chunk-VLLD4TOB.js.map → chunk-NMZVDRVP.js.map} +0 -0
- /package/dist/{chunk-P2WZHLUF.js.map → chunk-NOL7SEWN.js.map} +0 -0
- /package/dist/{chunk-2NLLXCJG.js.map → chunk-OWHERGF2.js.map} +0 -0
- /package/dist/{chunk-6L3PBSAR.js.map → chunk-PMNLL2TL.js.map} +0 -0
- /package/dist/{chunk-VYCOJKSX.js.map → chunk-PO7NXNGC.js.map} +0 -0
- /package/dist/{chunk-4IIMMZZK.js.map → chunk-PULDSMCJ.js.map} +0 -0
- /package/dist/{chunk-HBBHL4YF.js.map → chunk-QOXNTKXB.js.map} +0 -0
- /package/dist/{chunk-CUCWX3MO.js.map → chunk-QZLCVO2V.js.map} +0 -0
- /package/dist/{chunk-NE7I2RCT.js.map → chunk-R3X2T2LP.js.map} +0 -0
- /package/dist/{chunk-S7GCT7NU.js.map → chunk-RBITPCMK.js.map} +0 -0
- /package/dist/{chunk-EVBI7S4J.js.map → chunk-RMDGAAZF.js.map} +0 -0
- /package/dist/{chunk-BJRAELDH.js.map → chunk-SCXURCVT.js.map} +0 -0
- /package/dist/{chunk-EQ6YOIKO.js.map → chunk-ST2RQUXC.js.map} +0 -0
- /package/dist/{chunk-CS52MFDV.js.map → chunk-SZG4WFAG.js.map} +0 -0
- /package/dist/{chunk-BFO3IR56.js.map → chunk-TPEZ2SHV.js.map} +0 -0
- /package/dist/{chunk-YRLHEEQT.js.map → chunk-U6VC6RP3.js.map} +0 -0
- /package/dist/{chunk-MOQPEFLN.js.map → chunk-UP75KL3L.js.map} +0 -0
- /package/dist/{chunk-W4AOR52H.js.map → chunk-UQDC3W77.js.map} +0 -0
- /package/dist/{chunk-X7Y7WX73.js.map → chunk-UVYI6VIX.js.map} +0 -0
- /package/dist/{chunk-D5F7TKMH.js.map → chunk-V4JZCTMK.js.map} +0 -0
- /package/dist/{chunk-MQJL6CDZ.js.map → chunk-VA4O3U7U.js.map} +0 -0
- /package/dist/{chunk-4CDYONWO.js.map → chunk-VDO32NLK.js.map} +0 -0
- /package/dist/{chunk-SOZUJCME.js.map → chunk-VHDKPGMG.js.map} +0 -0
- /package/dist/{chunk-QWW2JDDX.js.map → chunk-WNRTXEWW.js.map} +0 -0
- /package/dist/{chunk-NR2ASHBL.js.map → chunk-XOV7NRY5.js.map} +0 -0
- /package/dist/{chunk-KP7SANCF.js.map → chunk-YPI4RQWV.js.map} +0 -0
- /package/dist/{chunk-JKMHZF3Q.js.map → chunk-YSWJXOOL.js.map} +0 -0
- /package/dist/{chunk-LQG5O5EP.js.map → chunk-Z3O53WZR.js.map} +0 -0
- /package/dist/{chunk-QVS22WTO.js.map → chunk-ZG5DWWKK.js.map} +0 -0
- /package/dist/{graph-edge-decay-KQGS3L3B.js.map → embedding-generation-lock.js.map} +0 -0
- /package/dist/{resolution-DNX7FO7A.js.map → embedding-index-storage.js.map} +0 -0
- /package/dist/{first-start-migration-7OATHJKB.js.map → first-start-migration-GAT7G733.js.map} +0 -0
- /package/dist/{state-ITXJKXRE.js.map → graph-edge-decay-MKIRZ762.js.map} +0 -0
- /package/dist/{tui-55UJMJX7.js.map → offline-sync-changeset-generations.js.map} +0 -0
- /package/dist/{trace-ZFVRH4GO.js.map → trace-LXXCMZJA.js.map} +0 -0
|
@@ -0,0 +1,684 @@
|
|
|
1
|
+
import {
|
|
2
|
+
EMBEDDING_SHARD_FILE_PATTERN
|
|
3
|
+
} from "./chunk-TYT4TEQV.js";
|
|
4
|
+
import {
|
|
5
|
+
matchesOfflineSyncDefaultExclude
|
|
6
|
+
} from "./chunk-4NSLQ7EU.js";
|
|
7
|
+
import {
|
|
8
|
+
resolveSafeArchiveTarget
|
|
9
|
+
} from "./chunk-GCGJW34D.js";
|
|
10
|
+
import {
|
|
11
|
+
assertEmbeddingGenerationLockHeld,
|
|
12
|
+
embeddingGenerationLockPath,
|
|
13
|
+
withEmbeddingGenerationLock
|
|
14
|
+
} from "./chunk-75PT4N7Q.js";
|
|
15
|
+
import {
|
|
16
|
+
EmbeddingIndexFileStore,
|
|
17
|
+
EmbeddingIndexStorageError,
|
|
18
|
+
parseEmbeddingIndexDocument,
|
|
19
|
+
serializeEmbeddingShard,
|
|
20
|
+
shardEntriesForIndex,
|
|
21
|
+
validateShardMembership
|
|
22
|
+
} from "./chunk-UCPGOUDZ.js";
|
|
23
|
+
import {
|
|
24
|
+
log
|
|
25
|
+
} from "./chunk-3WCASNQZ.js";
|
|
26
|
+
|
|
27
|
+
// src/offline-sync-embedding-generation.ts
|
|
28
|
+
import { createHash, randomBytes } from "crypto";
|
|
29
|
+
import { lstat, mkdir, readFile, readdir, rm, writeFile } from "fs/promises";
|
|
30
|
+
import path from "path";
|
|
31
|
+
var EMBEDDING_MARKER_BASENAME = "embeddings.json";
|
|
32
|
+
var EMBEDDING_SHARD_DIR_BASENAME = "embeddings";
|
|
33
|
+
function canonicalStateDirPrefix(parts) {
|
|
34
|
+
if (parts[0] === "state") return "state";
|
|
35
|
+
if (parts[0] === "namespaces" && parts.length >= 4 && parts[2] === "state") {
|
|
36
|
+
return `namespaces/${parts[1]}/state`;
|
|
37
|
+
}
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
function embeddingShardDirOf(relPath) {
|
|
41
|
+
const parts = relPath.split("/");
|
|
42
|
+
if (parts.length < 3) return null;
|
|
43
|
+
if (!EMBEDDING_SHARD_FILE_PATTERN.test(parts[parts.length - 1] ?? "")) return null;
|
|
44
|
+
if (parts[parts.length - 2] !== EMBEDDING_SHARD_DIR_BASENAME) return null;
|
|
45
|
+
if (canonicalStateDirPrefix(parts) === null) return null;
|
|
46
|
+
return parts.slice(0, -1).join("/");
|
|
47
|
+
}
|
|
48
|
+
function isEmbeddingGenerationDirPath(dirPath) {
|
|
49
|
+
const membership = embeddingGenerationMembership(`${dirPath}/shard-0000.json`);
|
|
50
|
+
return membership !== null && membership.shardDir === dirPath;
|
|
51
|
+
}
|
|
52
|
+
function embeddingMarkerDirOf(relPath) {
|
|
53
|
+
const parts = relPath.split("/");
|
|
54
|
+
if ((parts[parts.length - 1] ?? "") !== EMBEDDING_MARKER_BASENAME) return null;
|
|
55
|
+
if (canonicalStateDirPrefix(parts) === null) return null;
|
|
56
|
+
return parts.slice(0, -1).join("/");
|
|
57
|
+
}
|
|
58
|
+
function embeddingGenerationMembership(relPath) {
|
|
59
|
+
const shardDir = embeddingShardDirOf(relPath);
|
|
60
|
+
if (shardDir) return { kind: "shard", shardDir };
|
|
61
|
+
const markerDir = embeddingMarkerDirOf(relPath);
|
|
62
|
+
if (markerDir) return { kind: "marker", shardDir: `${markerDir}/${EMBEDDING_SHARD_DIR_BASENAME}` };
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
function detectIncomingEmbeddingGenerations(incomingPaths) {
|
|
66
|
+
const shardDirs = /* @__PURE__ */ new Set();
|
|
67
|
+
const legacyMarkerDirs = /* @__PURE__ */ new Set();
|
|
68
|
+
for (const relPath of incomingPaths) {
|
|
69
|
+
const membership = embeddingGenerationMembership(relPath);
|
|
70
|
+
if (!membership) continue;
|
|
71
|
+
if (membership.kind === "shard") shardDirs.add(membership.shardDir);
|
|
72
|
+
else legacyMarkerDirs.add(membership.shardDir);
|
|
73
|
+
}
|
|
74
|
+
return { shardDirs, legacyMarkerDirs };
|
|
75
|
+
}
|
|
76
|
+
function shardRelPath(shardDirRel, shardIndex) {
|
|
77
|
+
return `${shardDirRel}/shard-${String(shardIndex).padStart(4, "0")}.json`;
|
|
78
|
+
}
|
|
79
|
+
function describeIndexReadFailure(read) {
|
|
80
|
+
if (read.outcome === "unreadable") return read.reason;
|
|
81
|
+
if (read.outcome === "foreign") return "unrecognized index format";
|
|
82
|
+
return "generation document is absent";
|
|
83
|
+
}
|
|
84
|
+
function sha256Hex(buffer) {
|
|
85
|
+
return createHash("sha256").update(buffer).digest("hex");
|
|
86
|
+
}
|
|
87
|
+
async function pathExists(absPath) {
|
|
88
|
+
try {
|
|
89
|
+
await lstat(absPath);
|
|
90
|
+
return true;
|
|
91
|
+
} catch (err) {
|
|
92
|
+
if (err.code === "ENOENT") return false;
|
|
93
|
+
throw err;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
async function hydratedIncomingBuffer(io, root, relPath, expectedSha256, incoming) {
|
|
97
|
+
if (incoming) return incoming;
|
|
98
|
+
const filePath = await resolveSafeArchiveTarget(root, relPath);
|
|
99
|
+
const local = io.readFile ? await io.readFile({ root: root.abs, path: relPath, filePath }) : await readFile(filePath);
|
|
100
|
+
if (sha256Hex(local) !== expectedSha256) {
|
|
101
|
+
throw new EmbeddingIndexStorageError(
|
|
102
|
+
`cannot hydrate unchanged embedding index file ${relPath}: local digest does not match the incoming record; local generation preserved`
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
return local;
|
|
106
|
+
}
|
|
107
|
+
function baseStatesForGeneration(base, shardDirRel) {
|
|
108
|
+
return new Map([...base ?? []].filter(([relPath]) => embeddingGenerationMembership(relPath)?.shardDir === shardDirRel));
|
|
109
|
+
}
|
|
110
|
+
async function censusGenerationState(io, root, markerRel, markerAbs, shardDirAbs, shardDirRel) {
|
|
111
|
+
const census = /* @__PURE__ */ new Map();
|
|
112
|
+
const readSha = async (relPath, filePath) => sha256Hex(io.readFile ? await io.readFile({ root: root.abs, path: relPath, filePath }) : await readFile(filePath));
|
|
113
|
+
if (await pathExists(markerAbs)) census.set(markerRel, await readSha(markerRel, markerAbs));
|
|
114
|
+
const names = await readdir(shardDirAbs).catch((err) => {
|
|
115
|
+
if (err.code === "ENOENT") return [];
|
|
116
|
+
throw err;
|
|
117
|
+
});
|
|
118
|
+
for (const name of names.filter((candidate) => EMBEDDING_SHARD_FILE_PATTERN.test(candidate)).sort()) {
|
|
119
|
+
const relPath = `${shardDirRel}/${name}`;
|
|
120
|
+
census.set(relPath, await readSha(relPath, path.join(shardDirAbs, name)));
|
|
121
|
+
}
|
|
122
|
+
return census;
|
|
123
|
+
}
|
|
124
|
+
function incomingGenerationStates(input) {
|
|
125
|
+
const states = input.incomingShardPaths.map((relPath) => ({
|
|
126
|
+
path: relPath,
|
|
127
|
+
sha256: input.incomingShardStates.get(relPath)?.sha256 ?? sha256Hex(input.incomingBuffers.get(relPath) ?? Buffer.alloc(0))
|
|
128
|
+
}));
|
|
129
|
+
if (input.incomingMarker) {
|
|
130
|
+
states.push({ path: input.incomingMarker.path, sha256: input.incomingMarker.sha256 });
|
|
131
|
+
}
|
|
132
|
+
return states;
|
|
133
|
+
}
|
|
134
|
+
async function applyEmbeddingGenerationTransaction(input) {
|
|
135
|
+
const { root, shardDirRel, io } = input;
|
|
136
|
+
const stateDirRel = shardDirRel.slice(0, -`/${EMBEDDING_SHARD_DIR_BASENAME}`.length);
|
|
137
|
+
const stateDirAbs = await resolveSafeArchiveTarget(root, stateDirRel);
|
|
138
|
+
return await withEmbeddingGenerationLock(stateDirAbs, async (section) => {
|
|
139
|
+
const lockPath = embeddingGenerationLockPath(stateDirAbs);
|
|
140
|
+
const fence = () => assertEmbeddingGenerationLockHeld(lockPath, section);
|
|
141
|
+
const markerRel = `${stateDirRel}/${EMBEDDING_MARKER_BASENAME}`;
|
|
142
|
+
const shardDirAbs = await resolveSafeArchiveTarget(root, shardDirRel);
|
|
143
|
+
const markerAbs = await resolveSafeArchiveTarget(root, markerRel);
|
|
144
|
+
const store = new EmbeddingIndexFileStore(
|
|
145
|
+
markerAbs,
|
|
146
|
+
shardDirAbs,
|
|
147
|
+
await resolveSafeArchiveTarget(root, `${stateDirRel}/embedding-fallback-status.json`)
|
|
148
|
+
);
|
|
149
|
+
const backupRel = `${stateDirRel}/embeddings.pre-replace.tmp`;
|
|
150
|
+
await resolveSafeArchiveTarget(root, backupRel);
|
|
151
|
+
if (await store.recoverIfInterrupted(fence)) {
|
|
152
|
+
await resolveSafeArchiveTarget(root, shardDirRel);
|
|
153
|
+
}
|
|
154
|
+
const justifiedRemovals = input.justifiedRemovals ?? /* @__PURE__ */ new Set();
|
|
155
|
+
const baseStates = baseStatesForGeneration(input.baseStates, shardDirRel);
|
|
156
|
+
if (baseStates.size > 0) {
|
|
157
|
+
const localCensus = await censusGenerationState(io, root, markerRel, markerAbs, shardDirAbs, shardDirRel);
|
|
158
|
+
const baseArr = [...baseStates].map(([relPath, state]) => ({ path: relPath, sha256: state.sha256 }));
|
|
159
|
+
const censusArr = [...localCensus].map(([relPath, sha256]) => ({ path: relPath, sha256 }));
|
|
160
|
+
const deferrals = divergedEmbeddingGenerationDeferrals({
|
|
161
|
+
incomingFiles: incomingGenerationStates(input),
|
|
162
|
+
// A pre-authorized removal keeps its base entry only while still on
|
|
163
|
+
// disk (digest auth): present members are compared normally — a
|
|
164
|
+
// daemon rewrite still defers — while an absent member is already
|
|
165
|
+
// applied and must not diverge the retry (#3150 review).
|
|
166
|
+
baseFiles: baseArr.filter((member) => !justifiedRemovals.has(member.path) || localCensus.has(member.path)),
|
|
167
|
+
currentFiles: censusArr
|
|
168
|
+
});
|
|
169
|
+
const incomingShardPaths = new Set(input.incomingShardPaths);
|
|
170
|
+
const addedOrRemovedSinceBase = censusArr.some((member) => !baseStates.has(member.path) && !justifiedRemovals.has(member.path) && // An incoming member found in the census is the apply's own
|
|
171
|
+
// already-published work (response-loss retry), not a local
|
|
172
|
+
// addition; its bytes were verified above.
|
|
173
|
+
!incomingShardPaths.has(member.path)) || baseArr.some((member) => !localCensus.has(member.path) && !justifiedRemovals.has(member.path));
|
|
174
|
+
if (deferrals.length > 0 || addedOrRemovedSinceBase) {
|
|
175
|
+
const handled = new Set(input.incomingShardPaths);
|
|
176
|
+
if (input.incomingMarker) handled.add(input.incomingMarker.path);
|
|
177
|
+
if (input.incomingMarkerPresent) handled.add(markerRel);
|
|
178
|
+
for (const relPath of localCensus.keys()) handled.add(relPath);
|
|
179
|
+
log.warn(
|
|
180
|
+
`embedding generation ${shardDirRel} deferred: disk diverged from the shared base under the mutation lock (${deferrals.length > 0 ? deferrals.join(", ") : "generation membership changed since base"}); nothing published, nothing removed`
|
|
181
|
+
);
|
|
182
|
+
return {
|
|
183
|
+
shardDirRel,
|
|
184
|
+
upserted: 0,
|
|
185
|
+
deleted: 0,
|
|
186
|
+
writtenStates: /* @__PURE__ */ new Map(),
|
|
187
|
+
removedPaths: /* @__PURE__ */ new Set(),
|
|
188
|
+
handledPaths: handled,
|
|
189
|
+
deferredLocalDivergence: true
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
} else if (input.freshCreateClaim) {
|
|
193
|
+
const localCensus = await censusGenerationState(io, root, markerRel, markerAbs, shardDirAbs, shardDirRel);
|
|
194
|
+
if (localCensus.size > 0) {
|
|
195
|
+
const incomingArr = incomingGenerationStates(input).sort((left, right) => left.path.localeCompare(right.path));
|
|
196
|
+
const censusArr = [...localCensus].map(([relPath, sha256]) => ({ path: relPath, sha256 })).sort((left, right) => left.path.localeCompare(right.path));
|
|
197
|
+
const identical = censusArr.length === incomingArr.length && censusArr.every((member, index) => member.path === incomingArr[index]?.path && member.sha256 === incomingArr[index]?.sha256);
|
|
198
|
+
if (!identical) {
|
|
199
|
+
const handled = new Set(input.incomingShardPaths);
|
|
200
|
+
if (input.incomingMarker) handled.add(input.incomingMarker.path);
|
|
201
|
+
if (input.incomingMarkerPresent) handled.add(markerRel);
|
|
202
|
+
for (const relPath of localCensus.keys()) handled.add(relPath);
|
|
203
|
+
log.warn(
|
|
204
|
+
`embedding generation ${shardDirRel} deferred: base-less creation does not match the existing local generation under the mutation lock; nothing published, nothing removed`
|
|
205
|
+
);
|
|
206
|
+
return {
|
|
207
|
+
shardDirRel,
|
|
208
|
+
upserted: 0,
|
|
209
|
+
deleted: 0,
|
|
210
|
+
writtenStates: /* @__PURE__ */ new Map(),
|
|
211
|
+
removedPaths: /* @__PURE__ */ new Set(),
|
|
212
|
+
handledPaths: handled,
|
|
213
|
+
deferredLocalDivergence: true
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
const published = /* @__PURE__ */ new Map();
|
|
219
|
+
let identity = null;
|
|
220
|
+
if (input.incomingMarker) {
|
|
221
|
+
const markerBuffer = await hydratedIncomingBuffer(
|
|
222
|
+
io,
|
|
223
|
+
root,
|
|
224
|
+
input.incomingMarker.path,
|
|
225
|
+
input.incomingMarker.sha256,
|
|
226
|
+
input.incomingMarker.buffer
|
|
227
|
+
);
|
|
228
|
+
const read = parseEmbeddingIndexDocument(markerBuffer.toString("utf-8"));
|
|
229
|
+
if (read.outcome !== "ok") {
|
|
230
|
+
throw new EmbeddingIndexStorageError(
|
|
231
|
+
`refusing incoming embedding index generation ${markerRel}: ${describeIndexReadFailure(read)}; local generation preserved`
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
identity = { provider: read.file.provider, model: read.file.model };
|
|
235
|
+
const groups = shardEntriesForIndex(read.file);
|
|
236
|
+
for (const [shardIndex, entries] of groups) {
|
|
237
|
+
if (Object.keys(entries).length === 0) continue;
|
|
238
|
+
published.set(
|
|
239
|
+
shardRelPath(shardDirRel, shardIndex),
|
|
240
|
+
Buffer.from(serializeEmbeddingShard(read.file, shardIndex, entries), "utf-8")
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
} else {
|
|
244
|
+
for (const relPath of input.incomingShardPaths) {
|
|
245
|
+
const state = input.incomingShardStates.get(relPath);
|
|
246
|
+
const buffer = await hydratedIncomingBuffer(
|
|
247
|
+
io,
|
|
248
|
+
root,
|
|
249
|
+
relPath,
|
|
250
|
+
state?.sha256 ?? "",
|
|
251
|
+
input.incomingBuffers.get(relPath)
|
|
252
|
+
);
|
|
253
|
+
const read = parseEmbeddingIndexDocument(buffer.toString("utf-8"));
|
|
254
|
+
if (read.outcome !== "ok") {
|
|
255
|
+
throw new EmbeddingIndexStorageError(
|
|
256
|
+
`refusing incoming embedding index shard ${relPath}: ${describeIndexReadFailure(read)}; local generation preserved`
|
|
257
|
+
);
|
|
258
|
+
}
|
|
259
|
+
validateShardMembership(relPath.split("/").pop() ?? "", read.file);
|
|
260
|
+
const shardIdentity = { provider: read.file.provider, model: read.file.model };
|
|
261
|
+
if (!identity) identity = shardIdentity;
|
|
262
|
+
if (identity.provider !== shardIdentity.provider || identity.model !== shardIdentity.model) {
|
|
263
|
+
throw new EmbeddingIndexStorageError(
|
|
264
|
+
`refusing mixed-identity incoming embedding index generation in ${shardDirRel}: ${relPath} is ${shardIdentity.provider}/${shardIdentity.model} but the generation is ${identity.provider}/${identity.model}; local generation preserved`
|
|
265
|
+
);
|
|
266
|
+
}
|
|
267
|
+
published.set(relPath, buffer);
|
|
268
|
+
}
|
|
269
|
+
if (published.size === 0) {
|
|
270
|
+
throw new EmbeddingIndexStorageError(
|
|
271
|
+
`incoming embedding index generation ${shardDirRel} is empty; local generation preserved`
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
const stagingRel = `${stateDirRel}/embeddings.staging.tmp-sync-${process.pid}-${input.now}-${randomBytes(8).toString("hex")}`;
|
|
276
|
+
const stagingAbs = await resolveSafeArchiveTarget(root, stagingRel);
|
|
277
|
+
try {
|
|
278
|
+
await mkdir(stagingAbs, { recursive: true });
|
|
279
|
+
for (const [relPath, buffer] of published) {
|
|
280
|
+
const stagedRel = `${stagingRel}/${path.basename(relPath)}`;
|
|
281
|
+
const stagedAbs = await resolveSafeArchiveTarget(root, stagedRel);
|
|
282
|
+
const finalAbs = await resolveSafeArchiveTarget(root, relPath);
|
|
283
|
+
if (io.writeStagingFile) {
|
|
284
|
+
await io.writeStagingFile({
|
|
285
|
+
root: root.abs,
|
|
286
|
+
path: stagedRel,
|
|
287
|
+
filePath: stagedAbs,
|
|
288
|
+
content: buffer,
|
|
289
|
+
finalAadFilePath: finalAbs
|
|
290
|
+
});
|
|
291
|
+
} else {
|
|
292
|
+
await writeFile(stagedAbs, buffer, { mode: 384 });
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
for (const [relPath, buffer] of published) {
|
|
296
|
+
const stagedRel = `${stagingRel}/${path.basename(relPath)}`;
|
|
297
|
+
const stagedAbs = await resolveSafeArchiveTarget(root, stagedRel);
|
|
298
|
+
const staged = io.readStagingFile ? await io.readStagingFile({
|
|
299
|
+
root: root.abs,
|
|
300
|
+
path: stagedRel,
|
|
301
|
+
filePath: stagedAbs,
|
|
302
|
+
finalAadFilePath: await resolveSafeArchiveTarget(root, relPath)
|
|
303
|
+
}) : await readFile(stagedAbs);
|
|
304
|
+
if (!staged.equals(buffer)) {
|
|
305
|
+
throw new EmbeddingIndexStorageError(
|
|
306
|
+
`staged embedding index file ${stagedRel} does not match the incoming content; local generation preserved`
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
const localShardRels = (await readdir(shardDirAbs).catch((err) => {
|
|
311
|
+
if (err.code === "ENOENT") return [];
|
|
312
|
+
throw err;
|
|
313
|
+
})).filter((name) => EMBEDDING_SHARD_FILE_PATTERN.test(name)).map((name) => `${shardDirRel}/${name}`).sort();
|
|
314
|
+
await store.publishSwappedGeneration(stagingAbs, fence);
|
|
315
|
+
const writtenStates = /* @__PURE__ */ new Map();
|
|
316
|
+
for (const [relPath, buffer] of published) {
|
|
317
|
+
writtenStates.set(relPath, {
|
|
318
|
+
path: relPath,
|
|
319
|
+
sha256: sha256Hex(buffer),
|
|
320
|
+
bytes: buffer.length,
|
|
321
|
+
mtimeMs: input.now
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
const removedPaths = new Set(localShardRels.filter((rel) => !published.has(rel)));
|
|
325
|
+
let deleted = removedPaths.size;
|
|
326
|
+
let markerCleanupFailed = false;
|
|
327
|
+
if (await pathExists(markerAbs) && !input.incomingMarker && !input.incomingMarkerPresent) {
|
|
328
|
+
try {
|
|
329
|
+
if (io.deleteFile) await io.deleteFile({ root: root.abs, path: markerRel, filePath: markerAbs });
|
|
330
|
+
else await rm(markerAbs, { force: true });
|
|
331
|
+
removedPaths.add(markerRel);
|
|
332
|
+
deleted += 1;
|
|
333
|
+
} catch (err) {
|
|
334
|
+
markerCleanupFailed = true;
|
|
335
|
+
log.warn(`embedding generation ${shardDirRel}: marker cleanup deferred after publish: ${err}`);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
if (input.deletionMtimeByPath !== void 0 && io.deleteFile) {
|
|
339
|
+
let firstTombstoneError = null;
|
|
340
|
+
for (const relPath of removedPaths) {
|
|
341
|
+
try {
|
|
342
|
+
await io.deleteFile({
|
|
343
|
+
root: root.abs,
|
|
344
|
+
path: relPath,
|
|
345
|
+
filePath: await resolveSafeArchiveTarget(root, relPath),
|
|
346
|
+
mtimeMs: input.deletionMtimeByPath.get(relPath) ?? input.now
|
|
347
|
+
});
|
|
348
|
+
} catch (err) {
|
|
349
|
+
firstTombstoneError ??= err;
|
|
350
|
+
log.warn(`embedding generation ${shardDirRel}: tombstone recording failed for ${relPath}: ${err instanceof Error ? err.message : String(err)}`);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
if (firstTombstoneError) throw firstTombstoneError;
|
|
354
|
+
}
|
|
355
|
+
return {
|
|
356
|
+
shardDirRel,
|
|
357
|
+
upserted: published.size,
|
|
358
|
+
deleted,
|
|
359
|
+
writtenStates,
|
|
360
|
+
removedPaths,
|
|
361
|
+
handledPaths: /* @__PURE__ */ new Set([...published.keys(), ...removedPaths, ...markerCleanupFailed ? [markerRel] : []])
|
|
362
|
+
};
|
|
363
|
+
} catch (err) {
|
|
364
|
+
await rm(stagingAbs, { recursive: true, force: true }).catch(() => void 0);
|
|
365
|
+
throw err;
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
async function computeOmittedEmbeddingGenerationPaths(options) {
|
|
370
|
+
const omittedPaths = /* @__PURE__ */ new Set();
|
|
371
|
+
const omittedDirs = [];
|
|
372
|
+
const stateDirs = ["state"];
|
|
373
|
+
let namespaceNames = [];
|
|
374
|
+
try {
|
|
375
|
+
namespaceNames = (await readdir(path.join(options.rootAbs, "namespaces"), { withFileTypes: true })).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
376
|
+
} catch {
|
|
377
|
+
}
|
|
378
|
+
for (const ns of namespaceNames) stateDirs.push(`namespaces/${ns}/state`);
|
|
379
|
+
const isExcluded = options.isExcludedRelPath ?? ((relPath) => matchesOfflineSyncDefaultExclude(relPath) || Boolean(options.userExcludeRegexps?.some((re) => re.test(relPath))));
|
|
380
|
+
for (const stateDir of stateDirs) {
|
|
381
|
+
const markerRel = `${stateDir}/${EMBEDDING_MARKER_BASENAME}`;
|
|
382
|
+
const shardDirRel = `${stateDir}/${EMBEDDING_SHARD_DIR_BASENAME}`;
|
|
383
|
+
const shardDirAbs = path.join(options.rootAbs, ...shardDirRel.split("/"));
|
|
384
|
+
const memberRels = [];
|
|
385
|
+
if (await pathExists(path.join(options.rootAbs, ...markerRel.split("/")))) {
|
|
386
|
+
memberRels.push(markerRel);
|
|
387
|
+
}
|
|
388
|
+
let shardNames = [];
|
|
389
|
+
try {
|
|
390
|
+
shardNames = (await readdir(shardDirAbs, { withFileTypes: true })).filter((entry) => entry.isFile() && EMBEDDING_SHARD_FILE_PATTERN.test(entry.name)).map((entry) => entry.name);
|
|
391
|
+
} catch (err) {
|
|
392
|
+
if (err.code !== "ENOENT") throw err;
|
|
393
|
+
}
|
|
394
|
+
for (const name of shardNames) memberRels.push(`${shardDirRel}/${name}`);
|
|
395
|
+
for (const tombstoned of options.tombstonedPaths ?? []) {
|
|
396
|
+
const membership = embeddingGenerationMembership(tombstoned);
|
|
397
|
+
if (membership?.shardDir === shardDirRel && !memberRels.includes(tombstoned)) {
|
|
398
|
+
memberRels.push(tombstoned);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
if (memberRels.length === 0) continue;
|
|
402
|
+
const excludedMembers = [];
|
|
403
|
+
for (const relPath of memberRels) {
|
|
404
|
+
let excluded = isExcluded(relPath);
|
|
405
|
+
if (!excluded && options.excludeFile) {
|
|
406
|
+
excluded = await options.excludeFile({
|
|
407
|
+
root: options.rootAbs,
|
|
408
|
+
path: relPath,
|
|
409
|
+
filePath: path.join(options.rootAbs, ...relPath.split("/"))
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
if (excluded) excludedMembers.push(relPath);
|
|
413
|
+
}
|
|
414
|
+
if (excludedMembers.length === 0) continue;
|
|
415
|
+
omittedDirs.push(shardDirRel);
|
|
416
|
+
omittedPaths.add(shardDirRel);
|
|
417
|
+
for (const relPath of memberRels) omittedPaths.add(relPath);
|
|
418
|
+
}
|
|
419
|
+
return { omittedPaths, omittedDirs };
|
|
420
|
+
}
|
|
421
|
+
async function assertEmbeddingGenerationStillIncluded(rootAbs, shardDirRel, excludeFile, isExcludedRelPath, tombstonedPaths) {
|
|
422
|
+
const current = await computeOmittedEmbeddingGenerationPaths({ rootAbs, excludeFile, isExcludedRelPath, tombstonedPaths });
|
|
423
|
+
if (current.omittedDirs.includes(shardDirRel)) {
|
|
424
|
+
throw new EmbeddingIndexStorageError(
|
|
425
|
+
`embedding generation ${shardDirRel} became partially excluded during snapshot capture; retry with a fresh omission header`
|
|
426
|
+
);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
function isPathInOmittedEmbeddingGeneration(relPath, omittedDirs) {
|
|
430
|
+
const membership = embeddingGenerationMembership(relPath);
|
|
431
|
+
return membership !== null && omittedDirs.has(membership.shardDir);
|
|
432
|
+
}
|
|
433
|
+
async function resolvePushEmbeddingGenerationState(options) {
|
|
434
|
+
const omission = await computeOmittedEmbeddingGenerationPaths({
|
|
435
|
+
rootAbs: options.rootAbs,
|
|
436
|
+
userExcludeRegexps: options.userExcludeRegexps,
|
|
437
|
+
excludeFile: options.excludeFile,
|
|
438
|
+
// RAW pre-filter tombstones: a deleted member's exclusion must omit the
|
|
439
|
+
// whole generation even though the member is already absent on disk.
|
|
440
|
+
tombstonedPaths: options.deletions.map((deletion) => deletion.path),
|
|
441
|
+
isExcludedRelPath: (relPath) => matchesOfflineSyncDefaultExclude(relPath) || Boolean(options.userExcludeRegexps?.some((re) => re.test(relPath)))
|
|
442
|
+
});
|
|
443
|
+
const omittedDirs = new Set(omission.omittedDirs);
|
|
444
|
+
const deletions = options.deletions.filter((deletion) => {
|
|
445
|
+
if (matchesOfflineSyncDefaultExclude(deletion.path)) return false;
|
|
446
|
+
if (options.userExcludeRegexps?.some((re) => re.test(deletion.path))) return false;
|
|
447
|
+
const membership = embeddingGenerationMembership(deletion.path);
|
|
448
|
+
if (membership && omittedDirs.has(membership.shardDir)) return false;
|
|
449
|
+
return true;
|
|
450
|
+
});
|
|
451
|
+
return { omittedDirs: omission.omittedDirs, omittedPaths: omission.omittedPaths, deletions };
|
|
452
|
+
}
|
|
453
|
+
function storageBackedIndexStoreIo(storage) {
|
|
454
|
+
return {
|
|
455
|
+
readUtf8: async (filePath) => (await storage.readOfflineSyncFile(filePath)).toString("utf-8"),
|
|
456
|
+
writeUtf8: (filePath, contents, opts) => storage.writeOfflineSyncStagingFile(
|
|
457
|
+
filePath,
|
|
458
|
+
Buffer.from(contents, "utf-8"),
|
|
459
|
+
opts?.finalAadFilePath === void 0 ? void 0 : { aadFilePath: opts.finalAadFilePath }
|
|
460
|
+
)
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
async function applyEmbeddingGenerationRemoval(input) {
|
|
464
|
+
const { root, shardDirRel, io } = input;
|
|
465
|
+
const stateDirRel = shardDirRel.slice(0, -`/${EMBEDDING_SHARD_DIR_BASENAME}`.length);
|
|
466
|
+
const stateDirAbs = await resolveSafeArchiveTarget(root, stateDirRel);
|
|
467
|
+
return await withEmbeddingGenerationLock(stateDirAbs, async (section) => {
|
|
468
|
+
const lockPath = embeddingGenerationLockPath(stateDirAbs);
|
|
469
|
+
const fence = () => assertEmbeddingGenerationLockHeld(lockPath, section);
|
|
470
|
+
const markerRel = `${stateDirRel}/${EMBEDDING_MARKER_BASENAME}`;
|
|
471
|
+
const shardDirAbs = await resolveSafeArchiveTarget(root, shardDirRel);
|
|
472
|
+
const markerAbs = await resolveSafeArchiveTarget(root, markerRel);
|
|
473
|
+
const store = new EmbeddingIndexFileStore(
|
|
474
|
+
markerAbs,
|
|
475
|
+
shardDirAbs,
|
|
476
|
+
await resolveSafeArchiveTarget(root, `${stateDirRel}/embedding-fallback-status.json`)
|
|
477
|
+
);
|
|
478
|
+
await store.recoverIfInterrupted(fence);
|
|
479
|
+
const baseStates = baseStatesForGeneration(input.baseStates, shardDirRel);
|
|
480
|
+
if (baseStates.size > 0) {
|
|
481
|
+
const localCensus = await censusGenerationState(io, root, markerRel, markerAbs, shardDirAbs, shardDirRel);
|
|
482
|
+
const baseArr = [...baseStates].map(([relPath, state]) => ({ path: relPath, sha256: state.sha256 }));
|
|
483
|
+
const censusArr = [...localCensus].map(([relPath, sha256]) => ({ path: relPath, sha256 }));
|
|
484
|
+
const changedSinceBase = censusArr.some((member) => {
|
|
485
|
+
const baseSha = baseStates.get(member.path)?.sha256;
|
|
486
|
+
return baseSha === void 0 || baseSha !== member.sha256;
|
|
487
|
+
}) || baseArr.some((member) => !localCensus.has(member.path));
|
|
488
|
+
if (changedSinceBase) {
|
|
489
|
+
const removedPaths2 = /* @__PURE__ */ new Set([...localCensus.keys()]);
|
|
490
|
+
log.warn(
|
|
491
|
+
`embedding generation removal ${shardDirRel} deferred: disk diverged from the shared base under the mutation lock; local generation preserved`
|
|
492
|
+
);
|
|
493
|
+
return {
|
|
494
|
+
shardDirRel,
|
|
495
|
+
upserted: 0,
|
|
496
|
+
deleted: 0,
|
|
497
|
+
writtenStates: /* @__PURE__ */ new Map(),
|
|
498
|
+
removedPaths: removedPaths2,
|
|
499
|
+
handledPaths: new Set(removedPaths2),
|
|
500
|
+
deferredLocalDivergence: true
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
const localShardRels = (await readdir(shardDirAbs).catch((err) => {
|
|
505
|
+
if (err.code === "ENOENT") return [];
|
|
506
|
+
throw err;
|
|
507
|
+
})).filter((name) => EMBEDDING_SHARD_FILE_PATTERN.test(name)).map((name) => `${shardDirRel}/${name}`).sort();
|
|
508
|
+
await store.removePublishedGeneration(fence);
|
|
509
|
+
const removedPaths = new Set(localShardRels);
|
|
510
|
+
let deleted = removedPaths.size;
|
|
511
|
+
const markerPresent = await pathExists(markerAbs);
|
|
512
|
+
if (markerPresent) {
|
|
513
|
+
removedPaths.add(markerRel);
|
|
514
|
+
deleted += 1;
|
|
515
|
+
}
|
|
516
|
+
let firstError = null;
|
|
517
|
+
for (const relPath of removedPaths) {
|
|
518
|
+
const memberAbs = relPath === markerRel ? markerAbs : await resolveSafeArchiveTarget(root, relPath);
|
|
519
|
+
const mtimeMs = input.deletionMtimeByPath?.get(relPath) ?? input.now;
|
|
520
|
+
if (io.deleteFile) {
|
|
521
|
+
try {
|
|
522
|
+
await io.deleteFile({
|
|
523
|
+
root: root.abs,
|
|
524
|
+
path: relPath,
|
|
525
|
+
filePath: await resolveSafeArchiveTarget(root, relPath),
|
|
526
|
+
mtimeMs
|
|
527
|
+
});
|
|
528
|
+
} catch (err) {
|
|
529
|
+
firstError ??= err;
|
|
530
|
+
log.warn(`embedding generation removal: tombstone recording failed for ${relPath}: ${err instanceof Error ? err.message : String(err)}`);
|
|
531
|
+
}
|
|
532
|
+
} else if (relPath === markerRel && markerPresent) {
|
|
533
|
+
await rm(markerAbs, { force: true });
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
if (firstError) throw firstError;
|
|
537
|
+
return {
|
|
538
|
+
shardDirRel,
|
|
539
|
+
upserted: 0,
|
|
540
|
+
deleted,
|
|
541
|
+
writtenStates: /* @__PURE__ */ new Map(),
|
|
542
|
+
removedPaths,
|
|
543
|
+
handledPaths: new Set(removedPaths)
|
|
544
|
+
};
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
function divergedEmbeddingGenerationDeferrals(options) {
|
|
548
|
+
const base = new Map(options.baseFiles.map((f) => [f.path, f.sha256]));
|
|
549
|
+
const current = new Map(options.currentFiles.map((f) => [f.path, f.sha256]));
|
|
550
|
+
const incomingByPath = new Map(options.incomingFiles.map((f) => [f.path, f.sha256]));
|
|
551
|
+
const sharedDirs = new Set(options.baseFiles.map((f) => embeddingGenerationMembership(f.path)?.shardDir));
|
|
552
|
+
const conflictedDirs = /* @__PURE__ */ new Set();
|
|
553
|
+
for (const relPath of /* @__PURE__ */ new Set([...base.keys(), ...current.keys(), ...incomingByPath.keys()])) {
|
|
554
|
+
const membership = embeddingGenerationMembership(relPath);
|
|
555
|
+
if (!membership || !sharedDirs.has(membership.shardDir)) continue;
|
|
556
|
+
const currentSha = current.get(relPath);
|
|
557
|
+
if (currentSha !== base.get(relPath) && currentSha !== incomingByPath.get(relPath)) {
|
|
558
|
+
conflictedDirs.add(membership.shardDir);
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
if (conflictedDirs.size === 0) return [];
|
|
562
|
+
const deferred = [];
|
|
563
|
+
for (const relPath of /* @__PURE__ */ new Set([...base.keys(), ...current.keys(), ...incomingByPath.keys()])) {
|
|
564
|
+
const membership = embeddingGenerationMembership(relPath);
|
|
565
|
+
if (membership && conflictedDirs.has(membership.shardDir)) deferred.push(relPath);
|
|
566
|
+
}
|
|
567
|
+
return deferred.sort((left, right) => left.localeCompare(right));
|
|
568
|
+
}
|
|
569
|
+
async function applyIncomingEmbeddingGenerations(options) {
|
|
570
|
+
const incomingGenerations = detectIncomingEmbeddingGenerations(options.incomingMap.keys());
|
|
571
|
+
const generationDirs = /* @__PURE__ */ new Set([
|
|
572
|
+
...incomingGenerations.shardDirs,
|
|
573
|
+
...incomingGenerations.legacyMarkerDirs
|
|
574
|
+
]);
|
|
575
|
+
const deferredGenerationDirs = /* @__PURE__ */ new Set();
|
|
576
|
+
for (const deferredPath of options.deferredPaths) {
|
|
577
|
+
const membership = embeddingGenerationMembership(deferredPath);
|
|
578
|
+
if (membership) deferredGenerationDirs.add(membership.shardDir);
|
|
579
|
+
}
|
|
580
|
+
const transactionResults = [];
|
|
581
|
+
for (const shardDir of generationDirs) {
|
|
582
|
+
if (options.omittedGenerationDirs.has(shardDir)) {
|
|
583
|
+
throw new EmbeddingIndexStorageError(
|
|
584
|
+
`offline sync snapshot both includes and omits embedding generation ${shardDir}; refusing to apply`
|
|
585
|
+
);
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
if (generationDirs.size > 0 && options.customIoPresent && !(options.io.writeStagingFile && options.io.readStagingFile)) {
|
|
589
|
+
throw new EmbeddingIndexStorageError(
|
|
590
|
+
"refusing to replace embedding generation: custom storage IO requires both writeStagingFile and readStagingFile hooks; unencrypted raw staging would plaintext-downgrade the index"
|
|
591
|
+
);
|
|
592
|
+
}
|
|
593
|
+
for (const shardDir of generationDirs) {
|
|
594
|
+
if (deferredGenerationDirs.has(shardDir)) continue;
|
|
595
|
+
if (incomingGenerations.legacyMarkerDirs.has(shardDir) && !incomingGenerations.shardDirs.has(shardDir)) {
|
|
596
|
+
const markerRel = [...options.incomingMap.keys()].find(
|
|
597
|
+
(relPath) => embeddingMarkerDirOf(relPath) === shardDir.slice(0, -`/${EMBEDDING_SHARD_DIR_BASENAME}`.length)
|
|
598
|
+
);
|
|
599
|
+
if (!markerRel) continue;
|
|
600
|
+
transactionResults.push(await applyEmbeddingGenerationTransaction({
|
|
601
|
+
root: options.root,
|
|
602
|
+
shardDirRel: shardDir,
|
|
603
|
+
incomingShardPaths: [],
|
|
604
|
+
incomingMarker: {
|
|
605
|
+
path: markerRel,
|
|
606
|
+
sha256: options.incomingMap.get(markerRel).sha256,
|
|
607
|
+
buffer: options.incomingBuffers.get(markerRel) ?? null
|
|
608
|
+
},
|
|
609
|
+
incomingMarkerPresent: false,
|
|
610
|
+
incomingShardStates: /* @__PURE__ */ new Map(),
|
|
611
|
+
incomingBuffers: options.incomingBuffers,
|
|
612
|
+
baseStates: options.baseMap,
|
|
613
|
+
io: options.io,
|
|
614
|
+
now: options.now
|
|
615
|
+
}));
|
|
616
|
+
continue;
|
|
617
|
+
}
|
|
618
|
+
transactionResults.push(await applyEmbeddingGenerationTransaction({
|
|
619
|
+
root: options.root,
|
|
620
|
+
shardDirRel: shardDir,
|
|
621
|
+
incomingShardPaths: [...options.incomingMap.keys()].filter((relPath) => embeddingShardDirOf(relPath) === shardDir).sort(),
|
|
622
|
+
incomingMarker: null,
|
|
623
|
+
incomingMarkerPresent: Boolean(
|
|
624
|
+
incomingGenerations.legacyMarkerDirs.has(shardDir)
|
|
625
|
+
),
|
|
626
|
+
incomingShardStates: new Map(
|
|
627
|
+
[...options.incomingMap.values()].filter((state) => embeddingShardDirOf(state.path) === shardDir).map((state) => [state.path, state])
|
|
628
|
+
),
|
|
629
|
+
incomingBuffers: options.incomingBuffers,
|
|
630
|
+
baseStates: options.baseMap,
|
|
631
|
+
io: options.io,
|
|
632
|
+
now: options.now
|
|
633
|
+
}));
|
|
634
|
+
}
|
|
635
|
+
const localGenerationDirs = /* @__PURE__ */ new Set();
|
|
636
|
+
for (const relPath of options.currentMap.keys()) {
|
|
637
|
+
const membership = embeddingGenerationMembership(relPath);
|
|
638
|
+
if (membership?.kind === "shard") localGenerationDirs.add(membership.shardDir);
|
|
639
|
+
}
|
|
640
|
+
for (const shardDir of localGenerationDirs) {
|
|
641
|
+
if (generationDirs.has(shardDir) || deferredGenerationDirs.has(shardDir) || options.omittedGenerationDirs.has(shardDir)) {
|
|
642
|
+
continue;
|
|
643
|
+
}
|
|
644
|
+
const localMembers = [...options.currentMap.keys()].filter(
|
|
645
|
+
(relPath) => embeddingGenerationMembership(relPath)?.shardDir === shardDir
|
|
646
|
+
);
|
|
647
|
+
if (localMembers.length === 0) continue;
|
|
648
|
+
const baseMembers = localMembers.filter((relPath) => options.baseMap.has(relPath));
|
|
649
|
+
const tombstonedMembers = options.deletionMtimeByPath === void 0 ? [] : [...options.deletionMtimeByPath.keys()].filter(
|
|
650
|
+
(relPath) => embeddingGenerationMembership(relPath)?.shardDir === shardDir
|
|
651
|
+
);
|
|
652
|
+
const tombstoneCovered = tombstonedMembers.length > 0;
|
|
653
|
+
const baseEvidenced = baseMembers.length > 0 && baseMembers.every((relPath) => !options.incomingMap.has(relPath));
|
|
654
|
+
if (!tombstoneCovered && !baseEvidenced) continue;
|
|
655
|
+
transactionResults.push(await applyEmbeddingGenerationRemoval({
|
|
656
|
+
root: options.root,
|
|
657
|
+
shardDirRel: shardDir,
|
|
658
|
+
io: { deleteFile: options.io.deleteFile, readFile: options.io.readFile },
|
|
659
|
+
deletionMtimeByPath: options.deletionMtimeByPath,
|
|
660
|
+
baseStates: options.baseMap,
|
|
661
|
+
now: options.now
|
|
662
|
+
}));
|
|
663
|
+
}
|
|
664
|
+
return { transactionResults, deferredGenerationDirs };
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
export {
|
|
668
|
+
EMBEDDING_SHARD_DIR_BASENAME,
|
|
669
|
+
embeddingShardDirOf,
|
|
670
|
+
isEmbeddingGenerationDirPath,
|
|
671
|
+
embeddingMarkerDirOf,
|
|
672
|
+
embeddingGenerationMembership,
|
|
673
|
+
detectIncomingEmbeddingGenerations,
|
|
674
|
+
applyEmbeddingGenerationTransaction,
|
|
675
|
+
computeOmittedEmbeddingGenerationPaths,
|
|
676
|
+
assertEmbeddingGenerationStillIncluded,
|
|
677
|
+
isPathInOmittedEmbeddingGeneration,
|
|
678
|
+
resolvePushEmbeddingGenerationState,
|
|
679
|
+
storageBackedIndexStoreIo,
|
|
680
|
+
applyEmbeddingGenerationRemoval,
|
|
681
|
+
divergedEmbeddingGenerationDeferrals,
|
|
682
|
+
applyIncomingEmbeddingGenerations
|
|
683
|
+
};
|
|
684
|
+
//# sourceMappingURL=chunk-AXGJMDBS.js.map
|