@remnic/core 10.0.49 → 10.0.51
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 +49 -48
- package/dist/access-authorization-probe.js +50 -49
- package/dist/access-boundary.d.ts +6 -1
- package/dist/access-boundary.d.ts.map +1 -1
- package/dist/access-boundary.js +49 -48
- package/dist/access-cli.js +120 -119
- package/dist/access-cli.js.map +1 -1
- package/dist/access-errors.d.ts.map +1 -1
- package/dist/access-errors.js +1 -1
- package/dist/access-extraction-force-flush.js +49 -48
- package/dist/access-http-briefing.d.ts +2 -0
- package/dist/access-http-briefing.d.ts.map +1 -1
- package/dist/access-http-briefing.js +50 -49
- package/dist/access-http-query.js +51 -50
- package/dist/access-http.d.ts.map +1 -1
- package/dist/access-http.js +70 -69
- package/dist/access-identity-continuity-surface.js +49 -48
- package/dist/access-lcm-surface.js +49 -48
- package/dist/access-mcp.js +60 -59
- package/dist/access-memory-search-fanout.js +2 -2
- package/dist/access-namespace-preflight.js +49 -48
- package/dist/access-observe-write-category.d.ts +1 -1
- package/dist/access-observe-write-category.d.ts.map +1 -1
- package/dist/access-observe-write-category.js +10 -10
- package/dist/access-observe-write-surface.d.ts.map +1 -1
- package/dist/access-observe-write-surface.js +49 -48
- package/dist/access-offline-manifest.js +6 -6
- package/dist/access-operations-batch.js +50 -49
- package/dist/access-operations.js +57 -56
- package/dist/access-recall-concurrency.js +49 -48
- package/dist/access-recall-diagnostics.js +2 -2
- package/dist/access-recall-response.js +49 -48
- package/dist/access-recall-surface.js +49 -48
- package/dist/access-schema.d.ts +245 -773
- package/dist/access-schema.d.ts.map +1 -1
- package/dist/access-schema.js +6 -6
- package/dist/access-service.d.ts +5 -0
- package/dist/access-service.d.ts.map +1 -1
- package/dist/access-service.js +49 -48
- package/dist/access-surface-catalog.js +51 -50
- package/dist/access-surface-catalog.js.map +1 -1
- package/dist/access-token-capabilities.js +2 -2
- package/dist/active-recall.js +16 -16
- package/dist/{auto-sync-BNCBMU6H.js → auto-sync-UQQ6YJSB.js} +3 -3
- package/dist/briefing-deadline.d.ts +7 -0
- package/dist/briefing-deadline.d.ts.map +1 -0
- package/dist/briefing-deadline.js +13 -0
- package/dist/briefing-window.d.ts +12 -4
- package/dist/briefing-window.d.ts.map +1 -1
- package/dist/briefing-window.js +3 -1
- package/dist/briefing.d.ts +2 -0
- package/dist/briefing.d.ts.map +1 -1
- package/dist/briefing.js +12 -11
- package/dist/buffer.js +3 -3
- package/dist/calibration.js +2 -2
- package/dist/{capsule-merge-RNQUP2VL.js → capsule-merge-D4BTIJGK.js} +3 -3
- package/dist/causal-consolidation.js +11 -11
- package/dist/{chunk-ESDOQEJM.js → chunk-2AKIVSHP.js} +2 -2
- package/dist/{chunk-BWF3KNSQ.js → chunk-2EXF6IIB.js} +2 -2
- package/dist/{chunk-AGCEJDG2.js → chunk-2ONKXEC7.js} +3 -3
- package/dist/{chunk-3NYIXVCT.js → chunk-2S6JADBB.js} +2 -2
- package/dist/chunk-2S6JADBB.js.map +1 -0
- package/dist/{chunk-ZSEFGDCI.js → chunk-2TGIKMMZ.js} +2 -2
- package/dist/{chunk-MCS4LIXP.js → chunk-43TUWQNR.js} +2 -2
- package/dist/{chunk-Q6PYCPHO.js → chunk-44EUCSG4.js} +2 -2
- package/dist/{chunk-2J6BIOVN.js → chunk-4FM35YIA.js} +3 -3
- package/dist/{chunk-2NLCDNGA.js → chunk-564YP3DW.js} +2 -2
- package/dist/{chunk-YY6PWFUC.js → chunk-6ZAU7LAR.js} +3 -3
- package/dist/{chunk-HCPVL6SF.js → chunk-72CBJ5VP.js} +3 -3
- package/dist/{chunk-AF4UIHON.js → chunk-74AY3S7U.js} +9 -9
- package/dist/{chunk-N6EM7ESC.js → chunk-75BK4XGV.js} +27 -19
- package/dist/chunk-75BK4XGV.js.map +1 -0
- package/dist/{chunk-5IDQVE4U.js → chunk-A3UFV4K3.js} +6 -6
- package/dist/{chunk-LWRIGKFM.js → chunk-A5L5KGDI.js} +19 -1
- package/dist/chunk-A5L5KGDI.js.map +1 -0
- package/dist/{chunk-RZDDNH63.js → chunk-A6JDT6QF.js} +27 -15
- package/dist/chunk-A6JDT6QF.js.map +1 -0
- package/dist/{chunk-XFND63OB.js → chunk-AHGOOZUC.js} +2 -2
- package/dist/{chunk-A7AISUJI.js → chunk-AJG2TAMR.js} +2 -2
- package/dist/{chunk-2BY56HE6.js → chunk-AZLD4CKG.js} +36 -36
- package/dist/{chunk-E47UQBYW.js → chunk-B35EQQ7L.js} +3 -3
- package/dist/{chunk-E6UNM67F.js → chunk-B6SPPYGJ.js} +2 -2
- package/dist/{chunk-CMOYD5CA.js → chunk-CCL2OXFO.js} +2 -2
- package/dist/{chunk-SVJ5JVZO.js → chunk-CK6GCGMX.js} +4 -4
- package/dist/{chunk-QZK6HG4J.js → chunk-DF6ZF2BN.js} +3 -3
- package/dist/{chunk-CPBYKOTC.js → chunk-DJFULNXK.js} +4 -4
- package/dist/{chunk-VGRBKEBH.js → chunk-DQOGZZJA.js} +3 -3
- package/dist/{chunk-YB3WN6XA.js → chunk-EC2KVA27.js} +12 -12
- package/dist/{chunk-FRXS6SC7.js → chunk-EKUI7I2X.js} +20 -4
- package/dist/chunk-EKUI7I2X.js.map +1 -0
- package/dist/{chunk-YNDLCWXS.js → chunk-EZ25VE3G.js} +4 -4
- package/dist/{chunk-WIBWONL4.js → chunk-EZS6QJNC.js} +2 -2
- package/dist/{chunk-C7WDWD35.js → chunk-FNNGWN3O.js} +5 -5
- package/dist/{chunk-PBWJVRKE.js → chunk-FT75AQ74.js} +3 -3
- package/dist/{chunk-VY6BD5KB.js → chunk-G6A3SGCE.js} +14 -12
- package/dist/chunk-G6A3SGCE.js.map +1 -0
- package/dist/{chunk-O4CA53UY.js → chunk-GBGU5OZP.js} +111 -104
- package/dist/chunk-GBGU5OZP.js.map +1 -0
- package/dist/{chunk-WJCAAVZX.js → chunk-GE3ZX6YK.js} +2 -2
- package/dist/{chunk-3PVKV3XL.js → chunk-HCIRR3BA.js} +3 -3
- package/dist/{chunk-BJTFLP3J.js → chunk-HEF4BRMT.js} +3 -3
- package/dist/{chunk-BMG3SAXA.js → chunk-HQUYENKK.js} +9 -12
- package/dist/chunk-HQUYENKK.js.map +1 -0
- package/dist/{chunk-6UDLN4IA.js → chunk-I6ORDT54.js} +2 -2
- package/dist/{chunk-N5PISU26.js → chunk-IN6U2BS5.js} +2 -2
- package/dist/{chunk-3INLTKTW.js → chunk-IUQXRRJB.js} +4 -4
- package/dist/{chunk-6W3QH3QW.js → chunk-JIJAWTRK.js} +388 -292
- package/dist/chunk-JIJAWTRK.js.map +1 -0
- package/dist/{chunk-4KS4IHKH.js → chunk-JX3E4XCW.js} +2 -2
- package/dist/{chunk-SW3WHVKN.js → chunk-KAJYSO3U.js} +2 -2
- package/dist/{chunk-D76AHITY.js → chunk-KETS5A62.js} +2 -2
- package/dist/{chunk-LCHFINL4.js → chunk-KIWO4327.js} +2 -2
- package/dist/{chunk-FC3ZFEXF.js → chunk-KJ3MDX4V.js} +2 -2
- package/dist/{chunk-7LCGFUMB.js → chunk-KQAFEZQX.js} +4 -4
- package/dist/{chunk-6TIVVOVU.js → chunk-L3EFYRYK.js} +9 -9
- package/dist/{chunk-3MUKQQ7A.js → chunk-LGEH473S.js} +24 -29
- package/dist/chunk-LGEH473S.js.map +1 -0
- package/dist/{chunk-X52SXKVC.js → chunk-LMB47UM6.js} +2 -2
- package/dist/{chunk-A3WXV7YU.js → chunk-LWMLBVGB.js} +2 -2
- package/dist/{chunk-KMTMMBEB.js → chunk-MC7PXJDP.js} +7 -7
- package/dist/{chunk-NMOEOQV4.js → chunk-MUNYUSBU.js} +2 -2
- package/dist/{chunk-VKUMKVEU.js → chunk-OCRLJJOV.js} +5 -5
- package/dist/{chunk-XSJL62LE.js → chunk-ON77FQXH.js} +2 -2
- package/dist/{chunk-C3HRYVGD.js → chunk-POJRFSJM.js} +3 -3
- package/dist/{chunk-LKRXGOQW.js → chunk-QA3Y2O6H.js} +2 -2
- package/dist/{chunk-23ZLN5X6.js → chunk-QT5MGENX.js} +14 -6
- package/dist/chunk-QT5MGENX.js.map +1 -0
- package/dist/{chunk-QFTNWDJ6.js → chunk-RA7YRL6H.js} +2 -2
- package/dist/{chunk-WQFHHJWK.js → chunk-RJDYDF5K.js} +4 -4
- package/dist/{chunk-E3DL3CAL.js → chunk-ROAKLYOL.js} +2 -2
- package/dist/{chunk-YFXRLRKP.js → chunk-S4OZKPBS.js} +7 -11
- package/dist/{chunk-YFXRLRKP.js.map → chunk-S4OZKPBS.js.map} +1 -1
- package/dist/{chunk-NWIT3U2N.js → chunk-S5CQI2KF.js} +2 -2
- package/dist/{chunk-P6P35FY4.js → chunk-SDESKFKT.js} +2 -2
- package/dist/{chunk-OD7ZXCUF.js → chunk-SFRBUBUZ.js} +10 -10
- package/dist/{chunk-7XFQSQYS.js → chunk-SHNM7RIT.js} +5 -4
- package/dist/chunk-SHNM7RIT.js.map +1 -0
- package/dist/{chunk-NH37SP6V.js → chunk-SJD334AG.js} +81 -78
- package/dist/chunk-SJD334AG.js.map +1 -0
- package/dist/{chunk-O7GNSHFF.js → chunk-SPTPBKZX.js} +2 -2
- package/dist/{chunk-HI53EK3Y.js → chunk-TC55M5PO.js} +2 -2
- package/dist/{chunk-SA6P2KS3.js → chunk-TEH5MDX5.js} +33 -17
- package/dist/chunk-TEH5MDX5.js.map +1 -0
- package/dist/{chunk-FOKTW6GY.js → chunk-UCLJTGP3.js} +2 -2
- package/dist/{chunk-FYZXZUGU.js → chunk-UQBOPCDK.js} +2 -2
- package/dist/{chunk-SUKPM6DV.js → chunk-UWMZT2TY.js} +47 -4
- package/dist/chunk-UWMZT2TY.js.map +1 -0
- package/dist/{chunk-754XN6LX.js → chunk-V27FK6D6.js} +2 -2
- package/dist/{chunk-DM6SOROF.js → chunk-V6Z4NAJZ.js} +2 -2
- package/dist/{chunk-5FNZ3G6X.js → chunk-VKQI47DJ.js} +4 -4
- package/dist/{chunk-NUK5XU3P.js → chunk-VUMWVYMR.js} +28 -13
- package/dist/chunk-VUMWVYMR.js.map +1 -0
- package/dist/{chunk-MPJDQC4G.js → chunk-WJCXUE2J.js} +2 -2
- package/dist/{chunk-VCBS5GRQ.js → chunk-WY66J4PI.js} +2 -2
- package/dist/chunk-X2KO4FK5.js +40 -0
- package/dist/chunk-X2KO4FK5.js.map +1 -0
- package/dist/{chunk-OOOX5C4X.js → chunk-XL2EE5W3.js} +4 -4
- package/dist/{chunk-V4GPFCJ7.js → chunk-XWJUFER3.js} +3 -3
- package/dist/{chunk-CZVNOTLR.js → chunk-XXR4A33N.js} +2 -2
- package/dist/{chunk-CRJX4OMN.js → chunk-Y3T5KQCR.js} +2 -2
- package/dist/{chunk-KNCR7APE.js → chunk-Y77FXULH.js} +8 -8
- package/dist/{chunk-2AV2U2SZ.js → chunk-YDIOMDBW.js} +2 -2
- package/dist/{chunk-IG747LRN.js → chunk-YO2JEX2Z.js} +2 -2
- package/dist/{chunk-HDT3DMUF.js → chunk-ZKK3VMWU.js} +2 -2
- package/dist/cli.js +92 -91
- package/dist/coding/export-okf-codegraph.js +9 -9
- package/dist/compounding/engine.js +11 -11
- package/dist/config.js +16 -16
- package/dist/connectors/codex-materialize-runner.js +10 -10
- package/dist/connectors/index.js +14 -14
- package/dist/consolidation-provenance-check.js +4 -4
- package/dist/consolidation-undo.js +2 -2
- package/dist/convergence-refresh.js +12 -12
- package/dist/corpus-watermark.js +14 -14
- package/dist/correction/passive-correction-notifications.d.ts +1 -1
- package/dist/correction/passive-correction-notifications.d.ts.map +1 -1
- package/dist/dashboard-runtime.js +2 -2
- package/dist/deep-recall-config.js +2 -2
- package/dist/deep-recall-http-glue.js +9 -9
- package/dist/{entity-canonical-id-migration-2YOLMOFC.js → entity-canonical-id-migration-F3JVG6K6.js} +3 -3
- package/dist/entity-canonical-id-migration-F3JVG6K6.js.map +1 -0
- package/dist/entity-retrieval.js +11 -11
- package/dist/explicit-capture.js +2 -2
- package/dist/external-wiki-access.js +50 -49
- package/dist/extraction-span-wire.d.ts.map +1 -1
- package/dist/extraction-span-wire.js +1 -1
- package/dist/extraction.js +22 -22
- package/dist/{first-start-migration-QVD22WWS.js → first-start-migration-A6PHIBUQ.js} +4 -4
- package/dist/harmonic-retrieval.js +10 -10
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +143 -135
- 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 +16 -16
- package/dist/location/tagging.d.ts +7 -5
- package/dist/location/tagging.d.ts.map +1 -1
- package/dist/maintenance/memory-governance.js +10 -10
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +10 -10
- package/dist/maintenance/rebuild-memory-projection-runner.js +12 -12
- package/dist/maintenance/rebuild-memory-projection.js +11 -11
- package/dist/memory-browse-http-glue.js +2 -2
- package/dist/memory-browse-operations.js +50 -49
- package/dist/namespaces/migrate.js +11 -11
- package/dist/namespaces/storage.js +10 -10
- package/dist/offline-sync-file-io.d.ts +15 -0
- package/dist/offline-sync-file-io.d.ts.map +1 -1
- package/dist/offline-sync-file-io.js +9 -1
- package/dist/offline-sync-impression-drain.js +2 -2
- package/dist/offline-sync-snapshot-stream.js +4 -4
- package/dist/offline-sync-upload-staging.js +2 -2
- package/dist/offline-sync.d.ts.map +1 -1
- package/dist/offline-sync.js +3 -3
- package/dist/operator-doctor-corpus.js +17 -17
- package/dist/operator-doctor-replica.js +4 -4
- package/dist/operator-toolkit.js +29 -29
- package/dist/orchestration/maintenance.js +25 -25
- package/dist/orchestrator.d.ts +1 -0
- package/dist/orchestrator.d.ts.map +1 -1
- package/dist/orchestrator.js +122 -121
- package/dist/page-versioning.js +2 -2
- package/dist/recall-navigation-http-glue.js +2 -2
- package/dist/recall-navigation-operations.js +50 -49
- package/dist/recall-navigation.js +49 -48
- package/dist/relay/mission.d.ts +731 -3403
- package/dist/relay/mission.d.ts.map +1 -1
- package/dist/replica-divergence.js +3 -3
- package/dist/resume-bundles.js +17 -17
- package/dist/schemas.d.ts +346 -1771
- package/dist/schemas.d.ts.map +1 -1
- package/dist/semantic-consolidation.js +15 -15
- package/dist/semantic-rule-promotion.js +10 -10
- package/dist/semantic-rule-verifier.js +10 -10
- package/dist/shared-context/manager.d.ts +13 -33
- package/dist/shared-context/manager.d.ts.map +1 -1
- package/dist/source-agent-qualifier.js +18 -18
- package/dist/standup/build.js +11 -11
- package/dist/storage/entity-canonical-id-migration-adapter.d.ts +1 -0
- package/dist/storage/entity-canonical-id-migration-adapter.d.ts.map +1 -1
- package/dist/storage/entity-canonical-id-migration.d.ts +7 -0
- package/dist/storage/entity-canonical-id-migration.d.ts.map +1 -1
- package/dist/storage/entity-canonical-id-references.d.ts +2 -0
- package/dist/storage/entity-canonical-id-references.d.ts.map +1 -1
- package/dist/storage/entity-migration-completion-cache.d.ts +46 -0
- package/dist/storage/entity-migration-completion-cache.d.ts.map +1 -0
- package/dist/storage/entity-store.d.ts +1 -8
- package/dist/storage/entity-store.d.ts.map +1 -1
- package/dist/storage/memory-read-store.d.ts +3 -2
- package/dist/storage/memory-read-store.d.ts.map +1 -1
- package/dist/storage/windowed-memory-read.d.ts +6 -0
- package/dist/storage/windowed-memory-read.d.ts.map +1 -1
- package/dist/storage.d.ts +2 -0
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +9 -9
- package/dist/summarizer.js +3 -3
- package/dist/support-passport/access-operations.d.ts +51 -51
- package/dist/support-passport/contracts.d.ts +85 -126
- package/dist/support-passport/contracts.d.ts.map +1 -1
- package/dist/support-passport/generated-batch.d.ts +3 -17
- package/dist/support-passport/generated-batch.d.ts.map +1 -1
- package/dist/support-passport/grant-contracts.d.ts +75 -381
- package/dist/support-passport/grant-contracts.d.ts.map +1 -1
- package/dist/support-passport/index.js +52 -51
- package/dist/support-passport/model-audit.d.ts +17 -82
- package/dist/support-passport/model-audit.d.ts.map +1 -1
- package/dist/support-passport/model-bridge.d.ts +12 -51
- package/dist/support-passport/model-bridge.d.ts.map +1 -1
- package/dist/support-passport/model-contracts.d.ts +53 -192
- package/dist/support-passport/model-contracts.d.ts.map +1 -1
- package/dist/tokens.js +3 -3
- package/dist/transfer/capsule-export.js +2 -2
- package/dist/transfer/capsule-import.js +4 -4
- package/dist/transfer/export-okf.js +10 -10
- package/dist/transfer/types.d.ts +32 -737
- package/dist/transfer/types.d.ts.map +1 -1
- package/dist/verified-recall.js +10 -10
- package/dist/who-knows-cli.js +12 -12
- package/dist/who-knows.js +11 -11
- package/package.json +3 -4
- package/src/access-boundary.test.ts +14 -0
- package/src/access-boundary.ts +48 -42
- package/src/access-category-alias.test.ts +9 -7
- package/src/access-errors.test.ts +21 -9
- package/src/access-errors.ts +45 -31
- package/src/access-http-briefing.ts +4 -0
- package/src/access-http.test.ts +41 -12
- package/src/access-http.ts +6 -0
- package/src/access-observe-write-category.ts +1 -1
- package/src/access-observe-write-surface.ts +24 -19
- package/src/access-operations-batch.ts +18 -2
- package/src/access-schema.ts +13 -17
- package/src/access-service.ts +5 -0
- package/src/briefing-abort.test.ts +173 -0
- package/src/briefing-deadline.test.ts +84 -0
- package/src/briefing-deadline.ts +33 -0
- package/src/briefing-window-abort.test.ts +47 -0
- package/src/briefing-window.ts +33 -4
- package/src/briefing.ts +23 -16
- package/src/correction/passive-correction-notifications-abort.test.ts +42 -0
- package/src/correction/passive-correction-notifications.ts +4 -0
- package/src/entity-lazy-compatibility.test.ts +229 -0
- package/src/entity-migration-completion-notification.test.ts +148 -0
- package/src/extraction-scope-source-agent.test.ts +6 -6
- package/src/extraction-span-wire.test.ts +28 -0
- package/src/extraction-span-wire.ts +34 -6
- package/src/index.ts +1 -1
- package/src/location/tagging.ts +14 -12
- package/src/offline-sync-file-io.ts +61 -2
- package/src/offline-sync.test.ts +313 -20
- package/src/offline-sync.ts +43 -21
- package/src/orchestrator-init.test.ts +49 -1
- package/src/orchestrator.ts +9 -8
- package/src/storage/entity-canonical-id-migration-adapter.ts +16 -1
- package/src/storage/entity-canonical-id-migration.ts +19 -10
- package/src/storage/entity-canonical-id-references.ts +24 -0
- package/src/storage/entity-migration-completion-cache.nofollow.test.ts +223 -0
- package/src/storage/entity-migration-completion-cache.ts +153 -0
- package/src/storage/entity-store.ts +58 -86
- package/src/storage/memory-read-store.ts +9 -3
- package/src/storage/windowed-memory-read.ts +8 -0
- package/src/storage-startup-nonblocking-migration.test.ts +183 -0
- package/src/storage.ts +7 -2
- package/src/testing/subjects/entity-migration-completion-cache.test.ts +90 -0
- package/dist/chunk-23ZLN5X6.js.map +0 -1
- package/dist/chunk-3MUKQQ7A.js.map +0 -1
- package/dist/chunk-3NYIXVCT.js.map +0 -1
- package/dist/chunk-6W3QH3QW.js.map +0 -1
- package/dist/chunk-7XFQSQYS.js.map +0 -1
- package/dist/chunk-BMG3SAXA.js.map +0 -1
- package/dist/chunk-FRXS6SC7.js.map +0 -1
- package/dist/chunk-LWRIGKFM.js.map +0 -1
- package/dist/chunk-N6EM7ESC.js.map +0 -1
- package/dist/chunk-NH37SP6V.js.map +0 -1
- package/dist/chunk-NUK5XU3P.js.map +0 -1
- package/dist/chunk-O4CA53UY.js.map +0 -1
- package/dist/chunk-RZDDNH63.js.map +0 -1
- package/dist/chunk-SA6P2KS3.js.map +0 -1
- package/dist/chunk-SUKPM6DV.js.map +0 -1
- package/dist/chunk-VY6BD5KB.js.map +0 -1
- /package/dist/{auto-sync-BNCBMU6H.js.map → auto-sync-UQQ6YJSB.js.map} +0 -0
- /package/dist/{entity-canonical-id-migration-2YOLMOFC.js.map → briefing-deadline.js.map} +0 -0
- /package/dist/{capsule-merge-RNQUP2VL.js.map → capsule-merge-D4BTIJGK.js.map} +0 -0
- /package/dist/{chunk-ESDOQEJM.js.map → chunk-2AKIVSHP.js.map} +0 -0
- /package/dist/{chunk-BWF3KNSQ.js.map → chunk-2EXF6IIB.js.map} +0 -0
- /package/dist/{chunk-AGCEJDG2.js.map → chunk-2ONKXEC7.js.map} +0 -0
- /package/dist/{chunk-ZSEFGDCI.js.map → chunk-2TGIKMMZ.js.map} +0 -0
- /package/dist/{chunk-MCS4LIXP.js.map → chunk-43TUWQNR.js.map} +0 -0
- /package/dist/{chunk-Q6PYCPHO.js.map → chunk-44EUCSG4.js.map} +0 -0
- /package/dist/{chunk-2J6BIOVN.js.map → chunk-4FM35YIA.js.map} +0 -0
- /package/dist/{chunk-2NLCDNGA.js.map → chunk-564YP3DW.js.map} +0 -0
- /package/dist/{chunk-YY6PWFUC.js.map → chunk-6ZAU7LAR.js.map} +0 -0
- /package/dist/{chunk-HCPVL6SF.js.map → chunk-72CBJ5VP.js.map} +0 -0
- /package/dist/{chunk-AF4UIHON.js.map → chunk-74AY3S7U.js.map} +0 -0
- /package/dist/{chunk-5IDQVE4U.js.map → chunk-A3UFV4K3.js.map} +0 -0
- /package/dist/{chunk-XFND63OB.js.map → chunk-AHGOOZUC.js.map} +0 -0
- /package/dist/{chunk-A7AISUJI.js.map → chunk-AJG2TAMR.js.map} +0 -0
- /package/dist/{chunk-2BY56HE6.js.map → chunk-AZLD4CKG.js.map} +0 -0
- /package/dist/{chunk-E47UQBYW.js.map → chunk-B35EQQ7L.js.map} +0 -0
- /package/dist/{chunk-E6UNM67F.js.map → chunk-B6SPPYGJ.js.map} +0 -0
- /package/dist/{chunk-CMOYD5CA.js.map → chunk-CCL2OXFO.js.map} +0 -0
- /package/dist/{chunk-SVJ5JVZO.js.map → chunk-CK6GCGMX.js.map} +0 -0
- /package/dist/{chunk-QZK6HG4J.js.map → chunk-DF6ZF2BN.js.map} +0 -0
- /package/dist/{chunk-CPBYKOTC.js.map → chunk-DJFULNXK.js.map} +0 -0
- /package/dist/{chunk-VGRBKEBH.js.map → chunk-DQOGZZJA.js.map} +0 -0
- /package/dist/{chunk-YB3WN6XA.js.map → chunk-EC2KVA27.js.map} +0 -0
- /package/dist/{chunk-YNDLCWXS.js.map → chunk-EZ25VE3G.js.map} +0 -0
- /package/dist/{chunk-WIBWONL4.js.map → chunk-EZS6QJNC.js.map} +0 -0
- /package/dist/{chunk-C7WDWD35.js.map → chunk-FNNGWN3O.js.map} +0 -0
- /package/dist/{chunk-PBWJVRKE.js.map → chunk-FT75AQ74.js.map} +0 -0
- /package/dist/{chunk-WJCAAVZX.js.map → chunk-GE3ZX6YK.js.map} +0 -0
- /package/dist/{chunk-3PVKV3XL.js.map → chunk-HCIRR3BA.js.map} +0 -0
- /package/dist/{chunk-BJTFLP3J.js.map → chunk-HEF4BRMT.js.map} +0 -0
- /package/dist/{chunk-6UDLN4IA.js.map → chunk-I6ORDT54.js.map} +0 -0
- /package/dist/{chunk-N5PISU26.js.map → chunk-IN6U2BS5.js.map} +0 -0
- /package/dist/{chunk-3INLTKTW.js.map → chunk-IUQXRRJB.js.map} +0 -0
- /package/dist/{chunk-4KS4IHKH.js.map → chunk-JX3E4XCW.js.map} +0 -0
- /package/dist/{chunk-SW3WHVKN.js.map → chunk-KAJYSO3U.js.map} +0 -0
- /package/dist/{chunk-D76AHITY.js.map → chunk-KETS5A62.js.map} +0 -0
- /package/dist/{chunk-LCHFINL4.js.map → chunk-KIWO4327.js.map} +0 -0
- /package/dist/{chunk-FC3ZFEXF.js.map → chunk-KJ3MDX4V.js.map} +0 -0
- /package/dist/{chunk-7LCGFUMB.js.map → chunk-KQAFEZQX.js.map} +0 -0
- /package/dist/{chunk-6TIVVOVU.js.map → chunk-L3EFYRYK.js.map} +0 -0
- /package/dist/{chunk-X52SXKVC.js.map → chunk-LMB47UM6.js.map} +0 -0
- /package/dist/{chunk-A3WXV7YU.js.map → chunk-LWMLBVGB.js.map} +0 -0
- /package/dist/{chunk-KMTMMBEB.js.map → chunk-MC7PXJDP.js.map} +0 -0
- /package/dist/{chunk-NMOEOQV4.js.map → chunk-MUNYUSBU.js.map} +0 -0
- /package/dist/{chunk-VKUMKVEU.js.map → chunk-OCRLJJOV.js.map} +0 -0
- /package/dist/{chunk-XSJL62LE.js.map → chunk-ON77FQXH.js.map} +0 -0
- /package/dist/{chunk-C3HRYVGD.js.map → chunk-POJRFSJM.js.map} +0 -0
- /package/dist/{chunk-LKRXGOQW.js.map → chunk-QA3Y2O6H.js.map} +0 -0
- /package/dist/{chunk-QFTNWDJ6.js.map → chunk-RA7YRL6H.js.map} +0 -0
- /package/dist/{chunk-WQFHHJWK.js.map → chunk-RJDYDF5K.js.map} +0 -0
- /package/dist/{chunk-E3DL3CAL.js.map → chunk-ROAKLYOL.js.map} +0 -0
- /package/dist/{chunk-NWIT3U2N.js.map → chunk-S5CQI2KF.js.map} +0 -0
- /package/dist/{chunk-P6P35FY4.js.map → chunk-SDESKFKT.js.map} +0 -0
- /package/dist/{chunk-OD7ZXCUF.js.map → chunk-SFRBUBUZ.js.map} +0 -0
- /package/dist/{chunk-O7GNSHFF.js.map → chunk-SPTPBKZX.js.map} +0 -0
- /package/dist/{chunk-HI53EK3Y.js.map → chunk-TC55M5PO.js.map} +0 -0
- /package/dist/{chunk-FOKTW6GY.js.map → chunk-UCLJTGP3.js.map} +0 -0
- /package/dist/{chunk-FYZXZUGU.js.map → chunk-UQBOPCDK.js.map} +0 -0
- /package/dist/{chunk-754XN6LX.js.map → chunk-V27FK6D6.js.map} +0 -0
- /package/dist/{chunk-DM6SOROF.js.map → chunk-V6Z4NAJZ.js.map} +0 -0
- /package/dist/{chunk-5FNZ3G6X.js.map → chunk-VKQI47DJ.js.map} +0 -0
- /package/dist/{chunk-MPJDQC4G.js.map → chunk-WJCXUE2J.js.map} +0 -0
- /package/dist/{chunk-VCBS5GRQ.js.map → chunk-WY66J4PI.js.map} +0 -0
- /package/dist/{chunk-OOOX5C4X.js.map → chunk-XL2EE5W3.js.map} +0 -0
- /package/dist/{chunk-V4GPFCJ7.js.map → chunk-XWJUFER3.js.map} +0 -0
- /package/dist/{chunk-CZVNOTLR.js.map → chunk-XXR4A33N.js.map} +0 -0
- /package/dist/{chunk-CRJX4OMN.js.map → chunk-Y3T5KQCR.js.map} +0 -0
- /package/dist/{chunk-KNCR7APE.js.map → chunk-Y77FXULH.js.map} +0 -0
- /package/dist/{chunk-2AV2U2SZ.js.map → chunk-YDIOMDBW.js.map} +0 -0
- /package/dist/{chunk-IG747LRN.js.map → chunk-YO2JEX2Z.js.map} +0 -0
- /package/dist/{chunk-HDT3DMUF.js.map → chunk-ZKK3VMWU.js.map} +0 -0
- /package/dist/{first-start-migration-QVD22WWS.js.map → first-start-migration-A6PHIBUQ.js.map} +0 -0
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
getFingerprint,
|
|
20
20
|
migrateLegacyEntityCanonicalIds,
|
|
21
21
|
validateRoots
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-G6A3SGCE.js";
|
|
23
23
|
import {
|
|
24
24
|
normalizeQmdResultPath,
|
|
25
25
|
resolveNamespaceResultPath
|
|
@@ -34,13 +34,13 @@ import {
|
|
|
34
34
|
import {
|
|
35
35
|
parseOfflineSyncDigestCache
|
|
36
36
|
} from "./chunk-X3724WL4.js";
|
|
37
|
+
import {
|
|
38
|
+
createMemorySnapshot
|
|
39
|
+
} from "./chunk-S2HLHAZ4.js";
|
|
37
40
|
import {
|
|
38
41
|
rewriteProjectedEntityReferences,
|
|
39
42
|
rewriteProjectedMemoryEntityReference
|
|
40
43
|
} from "./chunk-MRPOZBJC.js";
|
|
41
|
-
import {
|
|
42
|
-
createMemorySnapshot
|
|
43
|
-
} from "./chunk-S2HLHAZ4.js";
|
|
44
44
|
import {
|
|
45
45
|
rotateMarkdownFileToArchive
|
|
46
46
|
} from "./chunk-DM2T26WE.js";
|
|
@@ -70,7 +70,7 @@ import {
|
|
|
70
70
|
invalidationCommitFingerprint,
|
|
71
71
|
parseTombstoneBlockedOfflineSyncMemory,
|
|
72
72
|
withCasCommitReceipt
|
|
73
|
-
} from "./chunk-
|
|
73
|
+
} from "./chunk-WJCXUE2J.js";
|
|
74
74
|
import {
|
|
75
75
|
matchEntitySchemaSection,
|
|
76
76
|
normalizeEntityStructuredSection,
|
|
@@ -91,19 +91,15 @@ import {
|
|
|
91
91
|
import {
|
|
92
92
|
normalizeEntityName
|
|
93
93
|
} from "./chunk-YXZG5TVN.js";
|
|
94
|
-
import {
|
|
95
|
-
checkCorpusReadAbort
|
|
96
|
-
} from "./chunk-P4GUQSK3.js";
|
|
97
94
|
import {
|
|
98
95
|
detectLanguageHint
|
|
99
96
|
} from "./chunk-3WU7XOFN.js";
|
|
100
97
|
import {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
} from "./chunk-G7D6GZ5J.js";
|
|
98
|
+
checkCorpusReadAbort
|
|
99
|
+
} from "./chunk-P4GUQSK3.js";
|
|
104
100
|
import {
|
|
105
101
|
createVersion
|
|
106
|
-
} from "./chunk-
|
|
102
|
+
} from "./chunk-564YP3DW.js";
|
|
107
103
|
import {
|
|
108
104
|
attachInFlightReader,
|
|
109
105
|
beginCoalescedScan,
|
|
@@ -112,24 +108,35 @@ import {
|
|
|
112
108
|
deleteInFlightReadsForDir
|
|
113
109
|
} from "./chunk-RBOJCG4T.js";
|
|
114
110
|
import {
|
|
111
|
+
ENTITY_CANONICAL_ID_MIGRATION_FILE,
|
|
112
|
+
ENTITY_CANONICAL_ID_RECONCILE_CONSUMING_MARKER,
|
|
113
|
+
ENTITY_CANONICAL_ID_RECONCILE_MARKER,
|
|
115
114
|
HistoricalEntityCanonicalIdCache,
|
|
116
115
|
appendCanonicalizedTombstone,
|
|
117
116
|
assertSafeEntityId,
|
|
118
117
|
canonicalizeEntityRefFrontmatter,
|
|
119
118
|
canonicalizeEntityRefOption,
|
|
119
|
+
entityCanonicalIdMigrationCompleted,
|
|
120
120
|
memoizedJournalCompletion,
|
|
121
121
|
reconcileIfJournalMovedSync,
|
|
122
122
|
repairEntityRefAfterJournalMove,
|
|
123
123
|
requestEntityCanonicalIdReconcileSync,
|
|
124
124
|
resolveHistoricalEntityCanonicalId,
|
|
125
125
|
withEntityCanonicalMutationLock
|
|
126
|
-
} from "./chunk-
|
|
126
|
+
} from "./chunk-A5L5KGDI.js";
|
|
127
127
|
import {
|
|
128
128
|
supersessionKeysForFact
|
|
129
129
|
} from "./chunk-5WITETWU.js";
|
|
130
130
|
import {
|
|
131
131
|
entityMentionEpoch
|
|
132
132
|
} from "./chunk-7CT3AI52.js";
|
|
133
|
+
import {
|
|
134
|
+
isConsolidationOperator,
|
|
135
|
+
isValidDerivedFromEntry
|
|
136
|
+
} from "./chunk-G7D6GZ5J.js";
|
|
137
|
+
import {
|
|
138
|
+
scopedCaptureWriteLockLimits
|
|
139
|
+
} from "./chunk-7VLBZKNB.js";
|
|
133
140
|
import {
|
|
134
141
|
buildCapturePathLockIdentity,
|
|
135
142
|
buildExplicitCaptureDedupKey,
|
|
@@ -152,9 +159,6 @@ import {
|
|
|
152
159
|
updateCacheOnDelete,
|
|
153
160
|
updateCacheOnWrite
|
|
154
161
|
} from "./chunk-C64XATK7.js";
|
|
155
|
-
import {
|
|
156
|
-
scopedCaptureWriteLockLimits
|
|
157
|
-
} from "./chunk-7VLBZKNB.js";
|
|
158
162
|
import {
|
|
159
163
|
selectArtifactMatches
|
|
160
164
|
} from "./chunk-HADD45AR.js";
|
|
@@ -241,7 +245,8 @@ import {
|
|
|
241
245
|
} from "./chunk-C5LWPYS3.js";
|
|
242
246
|
import {
|
|
243
247
|
isAbortError,
|
|
244
|
-
raceAbort
|
|
248
|
+
raceAbort,
|
|
249
|
+
throwIfAborted
|
|
245
250
|
} from "./chunk-R2MBW2S4.js";
|
|
246
251
|
import {
|
|
247
252
|
isMacOsReplicationJunkBasename,
|
|
@@ -281,7 +286,7 @@ import {
|
|
|
281
286
|
|
|
282
287
|
// src/storage.ts
|
|
283
288
|
import {
|
|
284
|
-
lstat as
|
|
289
|
+
lstat as lstat5,
|
|
285
290
|
readdir as readdir6,
|
|
286
291
|
readFile,
|
|
287
292
|
realpath as realpath3,
|
|
@@ -317,7 +322,7 @@ function parseDriftProvenance(fm) {
|
|
|
317
322
|
}
|
|
318
323
|
|
|
319
324
|
// src/storage.ts
|
|
320
|
-
import
|
|
325
|
+
import path15 from "path";
|
|
321
326
|
|
|
322
327
|
// src/storage/tombstone-migration-sources.ts
|
|
323
328
|
import { statSync } from "fs";
|
|
@@ -409,6 +414,7 @@ async function readWindowedMemories(store, options, hotCache, rememberMemorySnap
|
|
|
409
414
|
return timestampMs === null || timestampMs >= updatedAfterMs ? memory : null;
|
|
410
415
|
})
|
|
411
416
|
)).filter((memory) => memory !== null);
|
|
417
|
+
throwIfAborted(options.abortSignal, "windowed memory read aborted");
|
|
412
418
|
const memories = orderWindowMemories(selected, hotCache.baseDir);
|
|
413
419
|
return { memories: rememberMemorySnapshots(memories), filePaths: memories.map((memory) => memory.path) };
|
|
414
420
|
}
|
|
@@ -651,7 +657,8 @@ var MemoryReadStore = class {
|
|
|
651
657
|
return tiers.flat();
|
|
652
658
|
}
|
|
653
659
|
async readMemoriesWindow(options = {}) {
|
|
654
|
-
const
|
|
660
|
+
const readOptions = { abortSignal: options.abortSignal };
|
|
661
|
+
const allPaths = await this.deps.collectActiveMemoryPaths(readOptions);
|
|
655
662
|
const sortedPaths = this.deps.orderWindowPaths(allPaths);
|
|
656
663
|
const maxMemories = typeof options.maxMemories === "number" && Number.isFinite(options.maxMemories) ? Math.max(1, Math.floor(options.maxMemories)) : void 0;
|
|
657
664
|
const maxCandidatePaths = maxMemories === void 0 ? void 0 : maxMemories * 2;
|
|
@@ -660,6 +667,7 @@ var MemoryReadStore = class {
|
|
|
660
667
|
const memories = [];
|
|
661
668
|
const selectedPaths = [];
|
|
662
669
|
for (let i = 0; i < sortedPaths.length; i += normalizedBatchSize) {
|
|
670
|
+
checkCorpusReadAbort(readOptions);
|
|
663
671
|
if (maxMemories !== void 0 && (memories.length >= maxMemories || maxCandidatePaths !== void 0 && selectedPaths.length >= maxCandidatePaths)) {
|
|
664
672
|
return { memories, filePaths: selectedPaths };
|
|
665
673
|
}
|
|
@@ -668,13 +676,14 @@ var MemoryReadStore = class {
|
|
|
668
676
|
const remainingSlots = maxMemories === void 0 ? void 0 : Math.max(0, maxMemories - memories.length);
|
|
669
677
|
const remainingInspectionBudget = maxCandidatePaths === void 0 ? void 0 : Math.max(0, maxCandidatePaths - selectedPaths.length);
|
|
670
678
|
const { memories: batchMemories, filePaths: parsedCandidatePaths } = remainingSlots === void 0 ? {
|
|
671
|
-
memories: await this.deps.readParsedMemoriesFromPaths(candidateBatchPaths, normalizedBatchSize),
|
|
679
|
+
memories: await this.deps.readParsedMemoriesFromPaths(candidateBatchPaths, normalizedBatchSize, readOptions),
|
|
672
680
|
filePaths: candidateBatchPaths
|
|
673
681
|
} : await this.deps.readWindowBoundedBatch(
|
|
674
682
|
candidateBatchPaths,
|
|
675
683
|
remainingSlots,
|
|
676
684
|
remainingInspectionBudget ?? remainingSlots,
|
|
677
|
-
normalizedBatchSize
|
|
685
|
+
normalizedBatchSize,
|
|
686
|
+
readOptions
|
|
678
687
|
);
|
|
679
688
|
selectedPaths.push(...parsedCandidatePaths);
|
|
680
689
|
for (const memory of batchMemories) {
|
|
@@ -1758,8 +1767,110 @@ function selfDeps(self) {
|
|
|
1758
1767
|
}
|
|
1759
1768
|
|
|
1760
1769
|
// src/storage/entity-store.ts
|
|
1761
|
-
import { lstat as
|
|
1770
|
+
import { lstat as lstat3, readdir as readdir2, unlink } from "fs/promises";
|
|
1771
|
+
import path6 from "path";
|
|
1772
|
+
|
|
1773
|
+
// src/storage/entity-migration-completion-cache.ts
|
|
1774
|
+
import { lstat as lstat2, realpath as realpath2 } from "fs/promises";
|
|
1762
1775
|
import path5 from "path";
|
|
1776
|
+
async function isTrustedEntitiesRoot(baseDir, entitiesDir) {
|
|
1777
|
+
let rootStat;
|
|
1778
|
+
try {
|
|
1779
|
+
rootStat = await lstat2(entitiesDir);
|
|
1780
|
+
} catch (err) {
|
|
1781
|
+
if (isErrnoCode(err, "ENOENT")) return false;
|
|
1782
|
+
throw err;
|
|
1783
|
+
}
|
|
1784
|
+
if (rootStat.isSymbolicLink() || !rootStat.isDirectory()) return false;
|
|
1785
|
+
let memoryRoot;
|
|
1786
|
+
let entitiesReal;
|
|
1787
|
+
try {
|
|
1788
|
+
memoryRoot = await realpath2(baseDir);
|
|
1789
|
+
entitiesReal = await realpath2(entitiesDir);
|
|
1790
|
+
} catch (err) {
|
|
1791
|
+
if (isErrnoCode(err, "ENOENT")) return false;
|
|
1792
|
+
throw err;
|
|
1793
|
+
}
|
|
1794
|
+
return pathIsInside(memoryRoot, entitiesReal);
|
|
1795
|
+
}
|
|
1796
|
+
var EntityMigrationCompletionCache = class {
|
|
1797
|
+
cache;
|
|
1798
|
+
/** lstat identity for one fingerprint input path; nofollow; missing → stable token. */
|
|
1799
|
+
async inputPathSig(filePath) {
|
|
1800
|
+
try {
|
|
1801
|
+
const s = await lstat2(filePath);
|
|
1802
|
+
return `${s.dev}:${s.ino}:${s.mtimeMs}:${s.ctimeMs}:${s.size}:${s.isSymbolicLink() ? "L" : s.isDirectory() ? "D" : "F"}`;
|
|
1803
|
+
} catch {
|
|
1804
|
+
return "missing";
|
|
1805
|
+
}
|
|
1806
|
+
}
|
|
1807
|
+
/**
|
|
1808
|
+
* Cheap coherence key. entities/ absence is uncacheable (random suffix) so
|
|
1809
|
+
* we never pin a false complete.
|
|
1810
|
+
*/
|
|
1811
|
+
async inputSig(deps) {
|
|
1812
|
+
const stateDir = path5.join(deps.baseDir, "state");
|
|
1813
|
+
const entitiesSig = await this.inputPathSig(deps.entitiesDir);
|
|
1814
|
+
if (entitiesSig === "missing") return `entities-missing:${Math.random()}`;
|
|
1815
|
+
const [aliasesSig, journalSig, reconcileSig, consumingSig] = await Promise.all([
|
|
1816
|
+
this.inputPathSig(path5.join(deps.baseDir, "config", "aliases.json")),
|
|
1817
|
+
this.inputPathSig(path5.join(stateDir, ENTITY_CANONICAL_ID_MIGRATION_FILE)),
|
|
1818
|
+
this.inputPathSig(path5.join(stateDir, ENTITY_CANONICAL_ID_RECONCILE_MARKER)),
|
|
1819
|
+
this.inputPathSig(path5.join(stateDir, ENTITY_CANONICAL_ID_RECONCILE_CONSUMING_MARKER))
|
|
1820
|
+
]);
|
|
1821
|
+
return [entitiesSig, aliasesSig, journalSig, reconcileSig, consumingSig].join("|");
|
|
1822
|
+
}
|
|
1823
|
+
/**
|
|
1824
|
+
* True when journal completion attests to live fingerprint inputs.
|
|
1825
|
+
* Untrusted entities roots (symlink / outside base) never reach getFingerprint.
|
|
1826
|
+
*/
|
|
1827
|
+
async isCompleted(deps) {
|
|
1828
|
+
const version = deps.getEntityMutationVersion();
|
|
1829
|
+
const inputSig = await this.inputSig(deps);
|
|
1830
|
+
const cached = this.cache;
|
|
1831
|
+
if (cached && cached.version === version && cached.inputSig === inputSig) return cached.completed;
|
|
1832
|
+
if (!await isTrustedEntitiesRoot(deps.baseDir, deps.entitiesDir)) {
|
|
1833
|
+
this.cache = { version, inputSig, completed: false };
|
|
1834
|
+
return false;
|
|
1835
|
+
}
|
|
1836
|
+
const completed = await entityCanonicalIdMigrationCompleted(path5.join(deps.baseDir, "state"), () => getFingerprint(deps.baseDir, deps.entitiesDir, () => String(version)));
|
|
1837
|
+
this.cache = { version, inputSig, completed };
|
|
1838
|
+
return completed;
|
|
1839
|
+
}
|
|
1840
|
+
};
|
|
1841
|
+
async function readEntityFileResolvingRename(deps, firstPath, entityId) {
|
|
1842
|
+
try {
|
|
1843
|
+
return { id: entityId, content: await deps.readStorageSecureFile(firstPath) };
|
|
1844
|
+
} catch (err) {
|
|
1845
|
+
if (err instanceof SecureStoreLockedError) throw err;
|
|
1846
|
+
if (isErrnoCode(err, "ELOOP")) return null;
|
|
1847
|
+
if (!isErrnoCode(err, "ENOENT")) throw err;
|
|
1848
|
+
}
|
|
1849
|
+
const historicalIds = deps.currentHistoricalIds();
|
|
1850
|
+
const canonical = resolveHistoricalEntityCanonicalId(entityId, historicalIds);
|
|
1851
|
+
const candidates = /* @__PURE__ */ new Set([canonical]);
|
|
1852
|
+
for (const legacy of Object.keys(historicalIds)) {
|
|
1853
|
+
if (resolveHistoricalEntityCanonicalId(legacy, historicalIds) === canonical) candidates.add(legacy);
|
|
1854
|
+
}
|
|
1855
|
+
candidates.delete(entityId);
|
|
1856
|
+
for (const candidate of candidates) {
|
|
1857
|
+
try {
|
|
1858
|
+
return {
|
|
1859
|
+
id: candidate,
|
|
1860
|
+
content: await deps.readStorageSecureFile(
|
|
1861
|
+
path5.join(deps.entitiesDir, `${candidate}.md`)
|
|
1862
|
+
)
|
|
1863
|
+
};
|
|
1864
|
+
} catch (err) {
|
|
1865
|
+
if (err instanceof SecureStoreLockedError) throw err;
|
|
1866
|
+
if (isErrnoCode(err, "ENOENT") || isErrnoCode(err, "ELOOP")) continue;
|
|
1867
|
+
throw err;
|
|
1868
|
+
}
|
|
1869
|
+
}
|
|
1870
|
+
return null;
|
|
1871
|
+
}
|
|
1872
|
+
|
|
1873
|
+
// src/storage/entity-store.ts
|
|
1763
1874
|
var EntityStore = class {
|
|
1764
1875
|
constructor(deps) {
|
|
1765
1876
|
this.deps = deps;
|
|
@@ -1767,6 +1878,7 @@ var EntityStore = class {
|
|
|
1767
1878
|
deps;
|
|
1768
1879
|
/** Filename → file identity of the last indexable check. Unchanged files are not reread. */
|
|
1769
1880
|
entityIndexableCache = /* @__PURE__ */ new Map();
|
|
1881
|
+
migrationCompletion = new EntityMigrationCompletionCache();
|
|
1770
1882
|
/** Normalize an entity name using this store's alias table. */
|
|
1771
1883
|
normalizeEntityName(raw, type) {
|
|
1772
1884
|
return normalizeEntityName(raw, type, this.deps.userAliases);
|
|
@@ -1779,9 +1891,10 @@ var EntityStore = class {
|
|
|
1779
1891
|
* resolving only the canonical path silently drops the mutation.
|
|
1780
1892
|
*/
|
|
1781
1893
|
async readEntityForMutation(name, method, historicalIds) {
|
|
1894
|
+
assertSafeEntityId(name);
|
|
1782
1895
|
const canonical = resolveHistoricalEntityCanonicalId(name, historicalIds);
|
|
1783
1896
|
for (const candidate of canonical === name ? [name] : [canonical, name]) {
|
|
1784
|
-
const filePath =
|
|
1897
|
+
const filePath = path6.join(this.deps.entitiesDir, `${candidate}.md`);
|
|
1785
1898
|
try {
|
|
1786
1899
|
const entity = parseEntityFile(await this.deps.readStorageSecureFile(filePath), this.deps.entitySchemas);
|
|
1787
1900
|
return { filePath, entity };
|
|
@@ -1806,7 +1919,8 @@ var EntityStore = class {
|
|
|
1806
1919
|
* `mutate` returns false to skip the write. Resolves true when written.
|
|
1807
1920
|
*/
|
|
1808
1921
|
async mutateEntityFile(name, method, mutate) {
|
|
1809
|
-
|
|
1922
|
+
await this.deps.ensureDirectories();
|
|
1923
|
+
const stateDir = path6.join(this.deps.baseDir, "state");
|
|
1810
1924
|
return withEntityCanonicalMutationLock(stateDir, async () => {
|
|
1811
1925
|
for (let attempt = 0; attempt < 3; attempt += 1) {
|
|
1812
1926
|
const idsAtResolve = this.deps.currentHistoricalIds();
|
|
@@ -1861,7 +1975,7 @@ var EntityStore = class {
|
|
|
1861
1975
|
async writeEntity(name, type, facts, options = {}) {
|
|
1862
1976
|
await this.deps.ensureDirectories();
|
|
1863
1977
|
return withEntityCanonicalMutationLock(
|
|
1864
|
-
|
|
1978
|
+
path6.join(this.deps.baseDir, "state"),
|
|
1865
1979
|
() => this.writeEntityUnlocked(name, type, facts, options)
|
|
1866
1980
|
);
|
|
1867
1981
|
}
|
|
@@ -1882,7 +1996,7 @@ var EntityStore = class {
|
|
|
1882
1996
|
log.debug(`fuzzy match: "${normalized}" \u2192 existing "${match}"`);
|
|
1883
1997
|
normalized = match;
|
|
1884
1998
|
}
|
|
1885
|
-
const filePath =
|
|
1999
|
+
const filePath = path6.join(this.deps.entitiesDir, `${normalized}.md`);
|
|
1886
2000
|
let entity = {
|
|
1887
2001
|
name,
|
|
1888
2002
|
type,
|
|
@@ -1978,75 +2092,42 @@ var EntityStore = class {
|
|
|
1978
2092
|
log.debug(`wrote entity ${normalized}`);
|
|
1979
2093
|
return normalized;
|
|
1980
2094
|
}
|
|
1981
|
-
async
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
if (err instanceof SecureStoreLockedError) throw err;
|
|
1986
|
-
if (isErrnoCode(err, "ELOOP")) return null;
|
|
1987
|
-
if (!isErrnoCode(err, "ENOENT")) throw err;
|
|
1988
|
-
}
|
|
1989
|
-
const historicalIds = this.deps.currentHistoricalIds();
|
|
1990
|
-
const canonical = resolveHistoricalEntityCanonicalId(entityId, historicalIds);
|
|
1991
|
-
const candidates = /* @__PURE__ */ new Set([canonical]);
|
|
1992
|
-
for (const legacy of Object.keys(historicalIds)) {
|
|
1993
|
-
if (resolveHistoricalEntityCanonicalId(legacy, historicalIds) === canonical) candidates.add(legacy);
|
|
1994
|
-
}
|
|
1995
|
-
candidates.delete(entityId);
|
|
1996
|
-
for (const candidate of candidates) {
|
|
2095
|
+
async readEntity(name) {
|
|
2096
|
+
const filePath = this.deps.resolveEntityFilePath(name);
|
|
2097
|
+
if (filePath === null) return "";
|
|
2098
|
+
const readDirect = async () => {
|
|
1997
2099
|
try {
|
|
1998
|
-
return
|
|
1999
|
-
path5.join(this.deps.entitiesDir, `${candidate}.md`)
|
|
2000
|
-
) };
|
|
2100
|
+
return await this.deps.readStorageSecureFile(filePath);
|
|
2001
2101
|
} catch (err) {
|
|
2002
2102
|
if (err instanceof SecureStoreLockedError) throw err;
|
|
2003
|
-
if (isErrnoCode(err, "ENOENT") || isErrnoCode(err, "ELOOP"))
|
|
2103
|
+
if (isErrnoCode(err, "ENOENT") || isErrnoCode(err, "ELOOP")) return void 0;
|
|
2004
2104
|
throw err;
|
|
2005
2105
|
}
|
|
2006
|
-
}
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
const
|
|
2011
|
-
if (
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2106
|
+
};
|
|
2107
|
+
const direct = await readDirect();
|
|
2108
|
+
if (direct !== void 0) return direct;
|
|
2109
|
+
if (await this.migrationCompletion.isCompleted(this.deps)) return "";
|
|
2110
|
+
const renamed = await readEntityFileResolvingRename(this.deps, filePath, name);
|
|
2111
|
+
if (renamed !== null) return renamed.content;
|
|
2112
|
+
let legacy;
|
|
2113
|
+
for (const file of await this.readEntityDirectoryNames()) {
|
|
2114
|
+
if (!file.endsWith(".md") || !await this.isContainedRegularEntityFile(file)) continue;
|
|
2115
|
+
let content;
|
|
2015
2116
|
try {
|
|
2016
|
-
|
|
2117
|
+
content = await this.deps.readStorageSecureFile(path6.join(this.deps.entitiesDir, file));
|
|
2017
2118
|
} catch (err) {
|
|
2018
2119
|
if (err instanceof SecureStoreLockedError) throw err;
|
|
2019
|
-
if (isErrnoCode(err, "ENOENT") || isErrnoCode(err, "ELOOP"))
|
|
2120
|
+
if (isErrnoCode(err, "ENOENT") || isErrnoCode(err, "ELOOP")) continue;
|
|
2020
2121
|
throw err;
|
|
2021
2122
|
}
|
|
2123
|
+
if (isMalformedEntityRecord(content)) continue;
|
|
2124
|
+
const entity = parseEntityFile(content, this.deps.entitySchemas);
|
|
2125
|
+
if (!entity.name.trim() || !entity.type.trim()) continue;
|
|
2126
|
+
if (this.deps.normalizeEntityName(entity.name, entity.type) !== name) continue;
|
|
2127
|
+
if (legacy !== void 0) throw new Error(`Ambiguous legacy entity id: ${name}`);
|
|
2128
|
+
legacy = content;
|
|
2022
2129
|
}
|
|
2023
|
-
return
|
|
2024
|
-
}
|
|
2025
|
-
/**
|
|
2026
|
-
* True when `entities/` is a real directory inside this memory root.
|
|
2027
|
-
* `realpath` on a symlinked root would treat the link target as trusted,
|
|
2028
|
-
* so the check uses `lstat` first and refuses the scan when the root
|
|
2029
|
-
* itself is a symlink.
|
|
2030
|
-
*/
|
|
2031
|
-
async isTrustedEntitiesRoot() {
|
|
2032
|
-
let rootStat;
|
|
2033
|
-
try {
|
|
2034
|
-
rootStat = await lstat2(this.deps.entitiesDir);
|
|
2035
|
-
} catch (err) {
|
|
2036
|
-
if (isErrnoCode(err, "ENOENT")) return false;
|
|
2037
|
-
throw err;
|
|
2038
|
-
}
|
|
2039
|
-
if (rootStat.isSymbolicLink() || !rootStat.isDirectory()) return false;
|
|
2040
|
-
let memoryRoot;
|
|
2041
|
-
let entitiesReal;
|
|
2042
|
-
try {
|
|
2043
|
-
memoryRoot = await realpath2(this.deps.baseDir);
|
|
2044
|
-
entitiesReal = await realpath2(this.deps.entitiesDir);
|
|
2045
|
-
} catch (err) {
|
|
2046
|
-
if (isErrnoCode(err, "ENOENT")) return false;
|
|
2047
|
-
throw err;
|
|
2048
|
-
}
|
|
2049
|
-
return pathIsInside(memoryRoot, entitiesReal);
|
|
2130
|
+
return await readDirect() ?? legacy ?? "";
|
|
2050
2131
|
}
|
|
2051
2132
|
/**
|
|
2052
2133
|
* Entity directory listing with macOS replication junk removed.
|
|
@@ -2054,7 +2135,7 @@ var EntityStore = class {
|
|
|
2054
2135
|
* A symlinked entities root yields an empty list and is not read.
|
|
2055
2136
|
*/
|
|
2056
2137
|
async readEntityDirectoryNames() {
|
|
2057
|
-
if (!await this.
|
|
2138
|
+
if (!await isTrustedEntitiesRoot(this.deps.baseDir, this.deps.entitiesDir)) return [];
|
|
2058
2139
|
const entries = await readdir2(this.deps.entitiesDir);
|
|
2059
2140
|
const { kept, ignored } = withoutMacOsReplicationJunk(entries, (name) => name);
|
|
2060
2141
|
warnIgnoredMacOsReplicationJunk(this.deps.entitiesDir, ignored, (message) => {
|
|
@@ -2069,7 +2150,7 @@ var EntityStore = class {
|
|
|
2069
2150
|
*/
|
|
2070
2151
|
async isMissingEntry(file) {
|
|
2071
2152
|
try {
|
|
2072
|
-
await
|
|
2153
|
+
await lstat3(path6.join(this.deps.entitiesDir, file));
|
|
2073
2154
|
return false;
|
|
2074
2155
|
} catch (err) {
|
|
2075
2156
|
if (isErrnoCode(err, "ENOENT")) return true;
|
|
@@ -2077,10 +2158,10 @@ var EntityStore = class {
|
|
|
2077
2158
|
}
|
|
2078
2159
|
}
|
|
2079
2160
|
async isContainedRegularEntityFile(file) {
|
|
2080
|
-
const filePath =
|
|
2161
|
+
const filePath = path6.join(this.deps.entitiesDir, file);
|
|
2081
2162
|
let entryStat;
|
|
2082
2163
|
try {
|
|
2083
|
-
entryStat = await
|
|
2164
|
+
entryStat = await lstat3(filePath);
|
|
2084
2165
|
} catch (err) {
|
|
2085
2166
|
if (isErrnoCode(err, "ENOENT")) return false;
|
|
2086
2167
|
throw err;
|
|
@@ -2094,10 +2175,10 @@ var EntityStore = class {
|
|
|
2094
2175
|
* reread the whole directory on every extraction write.
|
|
2095
2176
|
*/
|
|
2096
2177
|
async isIndexableEntityMarkdown(file) {
|
|
2097
|
-
const filePath =
|
|
2178
|
+
const filePath = path6.join(this.deps.entitiesDir, file);
|
|
2098
2179
|
let entryStat;
|
|
2099
2180
|
try {
|
|
2100
|
-
entryStat = await
|
|
2181
|
+
entryStat = await lstat3(filePath);
|
|
2101
2182
|
} catch (err) {
|
|
2102
2183
|
if (isErrnoCode(err, "ENOENT")) return false;
|
|
2103
2184
|
throw err;
|
|
@@ -2168,19 +2249,26 @@ var EntityStore = class {
|
|
|
2168
2249
|
}
|
|
2169
2250
|
/** Re-serialize every entity file into the compiled-truth timeline shape. */
|
|
2170
2251
|
async migrateEntityFilesToCompiledTruthTimeline() {
|
|
2252
|
+
await this.deps.ensureDirectories();
|
|
2171
2253
|
const entityNames = await this.listEntityNames();
|
|
2172
|
-
const stateDir =
|
|
2254
|
+
const stateDir = path6.join(this.deps.baseDir, "state");
|
|
2173
2255
|
let migrated = 0;
|
|
2174
2256
|
for (const entityName of entityNames) {
|
|
2175
2257
|
const wrote = await withEntityCanonicalMutationLock(stateDir, async () => {
|
|
2176
|
-
const
|
|
2258
|
+
const filePath = this.deps.resolveEntityFilePath(entityName);
|
|
2259
|
+
if (filePath === null) return false;
|
|
2260
|
+
let raw;
|
|
2261
|
+
try {
|
|
2262
|
+
raw = await this.deps.readStorageSecureFile(filePath);
|
|
2263
|
+
} catch (err) {
|
|
2264
|
+
if (err instanceof SecureStoreLockedError || !isErrnoCode(err, "ENOENT")) throw err;
|
|
2265
|
+
return false;
|
|
2266
|
+
}
|
|
2177
2267
|
if (!raw || isMalformedEntityRecord(raw)) return false;
|
|
2178
2268
|
const parsed = parseEntityFile(raw, this.deps.entitySchemas);
|
|
2179
2269
|
if (!parsed.name.trim() || !parsed.type.trim()) return false;
|
|
2180
2270
|
const serialized = serializeEntityFile(parsed, this.deps.entitySchemas, this.deps.okfConformanceEnabled());
|
|
2181
2271
|
if (raw.trimEnd() === serialized.trimEnd()) return false;
|
|
2182
|
-
const filePath = this.deps.resolveEntityFilePath(entityName);
|
|
2183
|
-
if (filePath === null) return false;
|
|
2184
2272
|
await this.deps.writeStorageSecureFile(filePath, serialized);
|
|
2185
2273
|
this.deps.bumpEntityMutationVersion();
|
|
2186
2274
|
return true;
|
|
@@ -2197,23 +2285,16 @@ var EntityStore = class {
|
|
|
2197
2285
|
* Set or rewrite the synthesis layer of an entity file.
|
|
2198
2286
|
*/
|
|
2199
2287
|
async updateEntitySynthesis(name, synthesis, options = {}) {
|
|
2288
|
+
await this.deps.ensureDirectories();
|
|
2200
2289
|
return withEntityCanonicalMutationLock(
|
|
2201
|
-
|
|
2290
|
+
path6.join(this.deps.baseDir, "state"),
|
|
2202
2291
|
() => this.updateEntitySynthesisUnlocked(name, synthesis, options)
|
|
2203
2292
|
);
|
|
2204
2293
|
}
|
|
2205
2294
|
async updateEntitySynthesisUnlocked(name, synthesis, options = {}) {
|
|
2206
|
-
const
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
const content = await this.deps.readStorageSecureFile(filePath);
|
|
2210
|
-
entity = parseEntityFile(content, this.deps.entitySchemas);
|
|
2211
|
-
} catch (err) {
|
|
2212
|
-
if (err instanceof SecureStoreLockedError) throw err;
|
|
2213
|
-
if (!isErrnoCode(err, "ENOENT")) throw err;
|
|
2214
|
-
log.debug(`updateEntitySynthesis: entity file ${name}.md not found`);
|
|
2215
|
-
return;
|
|
2216
|
-
}
|
|
2295
|
+
const located = await this.readEntityForMutation(name, "updateEntitySynthesis", this.deps.currentHistoricalIds());
|
|
2296
|
+
if (!located) return;
|
|
2297
|
+
const { filePath, entity } = located;
|
|
2217
2298
|
const updatedAt = options.updatedAt?.trim() || entity.synthesisUpdatedAt?.trim() || void 0;
|
|
2218
2299
|
const entityUpdatedAt = options.entityUpdatedAt?.trim() || updatedAt || entity.updated || (/* @__PURE__ */ new Date()).toISOString();
|
|
2219
2300
|
const synthesisTimelineCount = Number.isInteger(options.synthesisTimelineCount) && (options.synthesisTimelineCount ?? 0) >= 0 ? options.synthesisTimelineCount : void 0;
|
|
@@ -2250,7 +2331,7 @@ var EntityStore = class {
|
|
|
2250
2331
|
const cached = getCachedEntities(this.deps.baseDir, currentVersion, cacheKey);
|
|
2251
2332
|
if (cached) return cached;
|
|
2252
2333
|
try {
|
|
2253
|
-
if (!await this.
|
|
2334
|
+
if (!await isTrustedEntitiesRoot(this.deps.baseDir, this.deps.entitiesDir)) return [];
|
|
2254
2335
|
const listed = await readdir2(this.deps.entitiesDir);
|
|
2255
2336
|
const { kept: entries, ignored } = withoutMacOsReplicationJunk(listed, (name) => name);
|
|
2256
2337
|
warnIgnoredMacOsReplicationJunk(this.deps.entitiesDir, ignored, (message) => {
|
|
@@ -2268,15 +2349,15 @@ var EntityStore = class {
|
|
|
2268
2349
|
const results = await Promise.all(
|
|
2269
2350
|
batch.map(async (entry) => {
|
|
2270
2351
|
const entityId = entry.slice(0, -".md".length);
|
|
2271
|
-
const entryPath =
|
|
2352
|
+
const entryPath = path6.join(this.deps.entitiesDir, entry);
|
|
2272
2353
|
try {
|
|
2273
2354
|
if (!await this.isContainedRegularEntityFile(entry)) {
|
|
2274
2355
|
if (await this.isMissingEntry(entry)) {
|
|
2275
|
-
return await this.
|
|
2356
|
+
return await readEntityFileResolvingRename(this.deps, entryPath, entityId);
|
|
2276
2357
|
}
|
|
2277
2358
|
return null;
|
|
2278
2359
|
}
|
|
2279
|
-
return await this.
|
|
2360
|
+
return await readEntityFileResolvingRename(this.deps, entryPath, entityId);
|
|
2280
2361
|
} catch (err) {
|
|
2281
2362
|
if (err instanceof SecureStoreLockedError || err instanceof SecureStoreDecryptError) throw err;
|
|
2282
2363
|
log.warn(`entity read isolated failure for ${entry}: ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -2361,8 +2442,9 @@ ${rows.join("\n")}
|
|
|
2361
2442
|
* Returns count of files merged.
|
|
2362
2443
|
*/
|
|
2363
2444
|
async mergeFragmentedEntities() {
|
|
2445
|
+
await this.deps.ensureDirectories();
|
|
2364
2446
|
return withEntityCanonicalMutationLock(
|
|
2365
|
-
|
|
2447
|
+
path6.join(this.deps.baseDir, "state"),
|
|
2366
2448
|
() => this.mergeFragmentedEntitiesUnlocked()
|
|
2367
2449
|
);
|
|
2368
2450
|
}
|
|
@@ -2390,7 +2472,7 @@ ${rows.join("\n")}
|
|
|
2390
2472
|
const canonicalDestinationOccupied = async (canonicalName, members) => {
|
|
2391
2473
|
if (members.includes(canonicalName)) return false;
|
|
2392
2474
|
try {
|
|
2393
|
-
await
|
|
2475
|
+
await lstat3(path6.join(this.deps.entitiesDir, canonicalName));
|
|
2394
2476
|
return true;
|
|
2395
2477
|
} catch (err) {
|
|
2396
2478
|
if (isErrnoCode(err, "ENOENT")) return false;
|
|
@@ -2427,7 +2509,7 @@ ${rows.join("\n")}
|
|
|
2427
2509
|
extraSections: []
|
|
2428
2510
|
};
|
|
2429
2511
|
for (const file of files) {
|
|
2430
|
-
const filePath =
|
|
2512
|
+
const filePath = path6.join(this.deps.entitiesDir, file);
|
|
2431
2513
|
try {
|
|
2432
2514
|
const content = await this.deps.readStorageSecureFile(filePath);
|
|
2433
2515
|
const parsed = parseEntityFile(content, this.deps.entitySchemas);
|
|
@@ -2580,7 +2662,7 @@ ${rows.join("\n")}
|
|
|
2580
2662
|
}
|
|
2581
2663
|
mergedEntity.created = mergedEntity.created || mergedEntity.updated || (/* @__PURE__ */ new Date()).toISOString();
|
|
2582
2664
|
mergedEntity.updated = mergedEntity.updated || (/* @__PURE__ */ new Date()).toISOString();
|
|
2583
|
-
const canonicalPath =
|
|
2665
|
+
const canonicalPath = path6.join(this.deps.entitiesDir, canonicalName);
|
|
2584
2666
|
if (await canonicalDestinationOccupied(canonicalName, files)) {
|
|
2585
2667
|
log.warn(`skipped entity merge into occupied ${canonicalName}`);
|
|
2586
2668
|
continue;
|
|
@@ -2588,7 +2670,7 @@ ${rows.join("\n")}
|
|
|
2588
2670
|
await this.deps.writeStorageSecureFile(canonicalPath, serializeEntityFile(mergedEntity, this.deps.entitySchemas, this.deps.okfConformanceEnabled()));
|
|
2589
2671
|
this.deps.bumpEntityMutationVersion();
|
|
2590
2672
|
for (const file of files) {
|
|
2591
|
-
const filePath =
|
|
2673
|
+
const filePath = path6.join(this.deps.entitiesDir, file);
|
|
2592
2674
|
if (filePath !== canonicalPath) {
|
|
2593
2675
|
try {
|
|
2594
2676
|
await unlink(filePath);
|
|
@@ -2608,7 +2690,7 @@ ${rows.join("\n")}
|
|
|
2608
2690
|
|
|
2609
2691
|
// src/storage/identity-continuity-store.ts
|
|
2610
2692
|
import { readdir as readdir3 } from "fs/promises";
|
|
2611
|
-
import
|
|
2693
|
+
import path7 from "path";
|
|
2612
2694
|
var IdentityContinuityStore = class {
|
|
2613
2695
|
constructor(deps) {
|
|
2614
2696
|
this.deps = deps;
|
|
@@ -2633,7 +2715,7 @@ var IdentityContinuityStore = class {
|
|
|
2633
2715
|
const date = nowIso.slice(0, 10);
|
|
2634
2716
|
const id = this.deps.generateId("incident");
|
|
2635
2717
|
const incident = createContinuityIncidentRecord(id, input, nowIso);
|
|
2636
|
-
const filePath =
|
|
2718
|
+
const filePath = path7.join(this.deps.identityIncidentsDir, `${date}-${id}.md`);
|
|
2637
2719
|
await this.deps.writeStorageSecureFile(filePath, serializeContinuityIncident(incident));
|
|
2638
2720
|
return { ...incident, filePath };
|
|
2639
2721
|
}
|
|
@@ -2646,7 +2728,7 @@ var IdentityContinuityStore = class {
|
|
|
2646
2728
|
const incidents = [];
|
|
2647
2729
|
for (const file of candidates) {
|
|
2648
2730
|
if (incidents.length >= cappedLimit) break;
|
|
2649
|
-
const filePath =
|
|
2731
|
+
const filePath = path7.join(this.deps.identityIncidentsDir, file);
|
|
2650
2732
|
try {
|
|
2651
2733
|
const raw = await this.deps.readStorageSecureFile(filePath);
|
|
2652
2734
|
const parsed = parseContinuityIncident(raw);
|
|
@@ -2677,7 +2759,7 @@ var IdentityContinuityStore = class {
|
|
|
2677
2759
|
await this.deps.ensureDirectories();
|
|
2678
2760
|
const safeKey = this.sanitizeIdentityAuditKey(key);
|
|
2679
2761
|
const dir = period === "weekly" ? this.deps.identityAuditsWeeklyDir : this.deps.identityAuditsMonthlyDir;
|
|
2680
|
-
const filePath =
|
|
2762
|
+
const filePath = path7.join(dir, `${safeKey}.md`);
|
|
2681
2763
|
await this.deps.writeStorageSecureFile(filePath, content);
|
|
2682
2764
|
return filePath;
|
|
2683
2765
|
}
|
|
@@ -2685,7 +2767,7 @@ var IdentityContinuityStore = class {
|
|
|
2685
2767
|
try {
|
|
2686
2768
|
const safeKey = this.sanitizeIdentityAuditKey(key);
|
|
2687
2769
|
const dir = period === "weekly" ? this.deps.identityAuditsWeeklyDir : this.deps.identityAuditsMonthlyDir;
|
|
2688
|
-
return await this.deps.readStorageSecureFile(
|
|
2770
|
+
return await this.deps.readStorageSecureFile(path7.join(dir, `${safeKey}.md`));
|
|
2689
2771
|
} catch (err) {
|
|
2690
2772
|
if (err instanceof Error && err.message === "Invalid identity audit key") return null;
|
|
2691
2773
|
if (!isErrnoCode(err, "ENOENT")) throw err;
|
|
@@ -2741,12 +2823,12 @@ var IdentityContinuityStore = class {
|
|
|
2741
2823
|
const fileNames = await this.readContinuityIncidentFileNames();
|
|
2742
2824
|
const directMatch = fileNames.find((name) => name.endsWith(`-${id}.md`));
|
|
2743
2825
|
if (directMatch) {
|
|
2744
|
-
const directPath =
|
|
2826
|
+
const directPath = path7.join(this.deps.identityIncidentsDir, directMatch);
|
|
2745
2827
|
const parsed = await this.readContinuityIncidentFile(directPath);
|
|
2746
2828
|
if (parsed?.id === id) return directPath;
|
|
2747
2829
|
}
|
|
2748
2830
|
for (const fileName of fileNames) {
|
|
2749
|
-
const filePath =
|
|
2831
|
+
const filePath = path7.join(this.deps.identityIncidentsDir, fileName);
|
|
2750
2832
|
const parsed = await this.readContinuityIncidentFile(filePath);
|
|
2751
2833
|
if (parsed?.id === id) return filePath;
|
|
2752
2834
|
}
|
|
@@ -2868,6 +2950,7 @@ ${before.content}
|
|
|
2868
2950
|
// src/storage/entity-canonical-id-migration-adapter.ts
|
|
2869
2951
|
async function runLegacyEntityCanonicalIdMigration(host, parseEntityFile2, serializeEntityFile2, serializeMemoryWithEntityRef2) {
|
|
2870
2952
|
const readMigrationFingerprint = () => getFingerprint(host.baseDir, host.entitiesDir, () => String(host.getEntityMutationVersion()));
|
|
2953
|
+
let rewroteReferences = false;
|
|
2871
2954
|
const completionFingerprint = await migrateLegacyEntityCanonicalIds({
|
|
2872
2955
|
stateDir: host.stateDir,
|
|
2873
2956
|
entitiesDir: host.entitiesDir,
|
|
@@ -2890,9 +2973,19 @@ async function runLegacyEntityCanonicalIdMigration(host, parseEntityFile2, seria
|
|
|
2890
2973
|
invalidateKnowledgeIndexCache: host.invalidateKnowledgeIndexCache.bind(host),
|
|
2891
2974
|
invalidateAllMemoriesCache: host.invalidateAllMemoriesCache.bind(host),
|
|
2892
2975
|
invalidateColdMemoriesCache: host.invalidateColdMemoriesCache.bind(host),
|
|
2893
|
-
bumpMemoryStatusVersion:
|
|
2976
|
+
bumpMemoryStatusVersion: () => {
|
|
2977
|
+
rewroteReferences = true;
|
|
2978
|
+
host.bumpMemoryStatusVersion();
|
|
2979
|
+
},
|
|
2894
2980
|
readMigrationFingerprint
|
|
2895
2981
|
});
|
|
2982
|
+
if (completionFingerprint !== void 0 && rewroteReferences) {
|
|
2983
|
+
try {
|
|
2984
|
+
host.onEntityMigrationComplete?.();
|
|
2985
|
+
} catch {
|
|
2986
|
+
log.warn("entity migration: search maintenance scheduling failed");
|
|
2987
|
+
}
|
|
2988
|
+
}
|
|
2896
2989
|
return completionFingerprint;
|
|
2897
2990
|
}
|
|
2898
2991
|
|
|
@@ -2920,7 +3013,7 @@ var EntityCanonicalIdMigrationRunner = class {
|
|
|
2920
3013
|
await this.ensure();
|
|
2921
3014
|
return;
|
|
2922
3015
|
}
|
|
2923
|
-
const { readSafeEntityEntries } = await import("./entity-canonical-id-migration-
|
|
3016
|
+
const { readSafeEntityEntries } = await import("./entity-canonical-id-migration-F3JVG6K6.js");
|
|
2924
3017
|
await readSafeEntityEntries(entitiesDir);
|
|
2925
3018
|
}
|
|
2926
3019
|
/**
|
|
@@ -3015,7 +3108,7 @@ import {
|
|
|
3015
3108
|
readFileSync,
|
|
3016
3109
|
realpathSync
|
|
3017
3110
|
} from "fs";
|
|
3018
|
-
import
|
|
3111
|
+
import path8 from "path";
|
|
3019
3112
|
function resolveSafeAliasRoots(baseDir, configDir) {
|
|
3020
3113
|
let baseStat;
|
|
3021
3114
|
try {
|
|
@@ -3042,8 +3135,8 @@ function resolveSafeAliasRoots(baseDir, configDir) {
|
|
|
3042
3135
|
return memoryRoot;
|
|
3043
3136
|
}
|
|
3044
3137
|
function readEntityAliasConfigSync(baseDir) {
|
|
3045
|
-
const configDir =
|
|
3046
|
-
const aliasPath =
|
|
3138
|
+
const configDir = path8.join(baseDir, "config");
|
|
3139
|
+
const aliasPath = path8.join(configDir, "aliases.json");
|
|
3047
3140
|
let memoryRoot = resolveSafeAliasRoots(baseDir, configDir);
|
|
3048
3141
|
if (memoryRoot === void 0) return void 0;
|
|
3049
3142
|
let aliasPreflight;
|
|
@@ -3105,7 +3198,7 @@ function decodeYamlScalar(value) {
|
|
|
3105
3198
|
|
|
3106
3199
|
// src/orchestration/qmd-result-resolver.ts
|
|
3107
3200
|
import { existsSync } from "fs";
|
|
3108
|
-
import
|
|
3201
|
+
import path9 from "path";
|
|
3109
3202
|
var INTERNAL_QMD_ROOTS = /* @__PURE__ */ new Set([
|
|
3110
3203
|
...ALL_CATEGORY_DIRS,
|
|
3111
3204
|
"activity",
|
|
@@ -3127,7 +3220,7 @@ var INTERNAL_QMD_ROOTS = /* @__PURE__ */ new Set([
|
|
|
3127
3220
|
]);
|
|
3128
3221
|
var PRIVATE_RESULT_RESOLUTION_CONCURRENCY = 16;
|
|
3129
3222
|
function qmdCollectionPathParts(resultPath) {
|
|
3130
|
-
if (!resultPath ||
|
|
3223
|
+
if (!resultPath || path9.isAbsolute(resultPath)) return null;
|
|
3131
3224
|
if (resultPath.trim().startsWith("qmd://")) {
|
|
3132
3225
|
try {
|
|
3133
3226
|
const parsed = new URL(resultPath.trim());
|
|
@@ -3152,9 +3245,9 @@ function qmdCollectionPathParts(resultPath) {
|
|
|
3152
3245
|
}
|
|
3153
3246
|
function qmdResultPathCandidates(storageDir, resultPath) {
|
|
3154
3247
|
const candidates = /* @__PURE__ */ new Set();
|
|
3155
|
-
const storageRoot =
|
|
3248
|
+
const storageRoot = path9.resolve(storageDir);
|
|
3156
3249
|
const addCandidate = (candidate) => {
|
|
3157
|
-
const resolved =
|
|
3250
|
+
const resolved = path9.resolve(candidate);
|
|
3158
3251
|
if (isPathInsideStorageRoot(storageRoot, resolved)) {
|
|
3159
3252
|
candidates.add(resolved);
|
|
3160
3253
|
}
|
|
@@ -3162,18 +3255,18 @@ function qmdResultPathCandidates(storageDir, resultPath) {
|
|
|
3162
3255
|
const addRelativeCandidates = (relativePath) => {
|
|
3163
3256
|
const normalized = relativePath.replace(/\\/g, "/").replace(/^\/+/, "");
|
|
3164
3257
|
if (!normalized) return;
|
|
3165
|
-
addCandidate(
|
|
3258
|
+
addCandidate(path9.join(storageRoot, normalized));
|
|
3166
3259
|
if (/^\d{4}-\d{2}-\d{2}\//.test(normalized)) {
|
|
3167
|
-
addCandidate(
|
|
3260
|
+
addCandidate(path9.join(storageRoot, "facts", normalized));
|
|
3168
3261
|
}
|
|
3169
3262
|
};
|
|
3170
|
-
if (
|
|
3263
|
+
if (path9.isAbsolute(resultPath)) {
|
|
3171
3264
|
addCandidate(resultPath);
|
|
3172
|
-
const relative2 =
|
|
3173
|
-
if (relative2 && !relative2.startsWith("..") && !
|
|
3174
|
-
const normalized = relative2.split(
|
|
3265
|
+
const relative2 = path9.relative(storageRoot, path9.resolve(resultPath));
|
|
3266
|
+
if (relative2 && !relative2.startsWith("..") && !path9.isAbsolute(relative2)) {
|
|
3267
|
+
const normalized = relative2.split(path9.sep).join("/");
|
|
3175
3268
|
if (/^\d{4}-\d{2}-\d{2}\//.test(normalized)) {
|
|
3176
|
-
addCandidate(
|
|
3269
|
+
addCandidate(path9.join(storageRoot, "facts", normalized));
|
|
3177
3270
|
}
|
|
3178
3271
|
}
|
|
3179
3272
|
} else {
|
|
@@ -3189,9 +3282,9 @@ function normalizeFlatQmdResults(results, config, collection = config.qmdCollect
|
|
|
3189
3282
|
}));
|
|
3190
3283
|
}
|
|
3191
3284
|
function withHotFactsPath(memoryDir, resolved) {
|
|
3192
|
-
const relative2 =
|
|
3285
|
+
const relative2 = path9.relative(path9.resolve(memoryDir), resolved).split(path9.sep).join("/");
|
|
3193
3286
|
if (!/^\d{4}-\d{2}-\d{2}\//.test(relative2) || existsSync(resolved)) return resolved;
|
|
3194
|
-
const hot =
|
|
3287
|
+
const hot = path9.join(path9.resolve(memoryDir), "facts", relative2);
|
|
3195
3288
|
return existsSync(hot) ? hot : resolved;
|
|
3196
3289
|
}
|
|
3197
3290
|
function storageDirOrNull(storage) {
|
|
@@ -3222,7 +3315,7 @@ var QmdResultResolver = class {
|
|
|
3222
3315
|
const seenStorageDirs = /* @__PURE__ */ new Set();
|
|
3223
3316
|
const addStorage = (storage) => {
|
|
3224
3317
|
const storageDir = storageDirOrNull(storage);
|
|
3225
|
-
const storageKey = storageDir ?
|
|
3318
|
+
const storageKey = storageDir ? path9.resolve(storageDir) : `storage-without-dir-${storages.length}`;
|
|
3226
3319
|
if (seenStorageDirs.has(storageKey)) return;
|
|
3227
3320
|
seenStorageDirs.add(storageKey);
|
|
3228
3321
|
storages.push(storage);
|
|
@@ -3252,7 +3345,7 @@ var QmdResultResolver = class {
|
|
|
3252
3345
|
continue;
|
|
3253
3346
|
}
|
|
3254
3347
|
try {
|
|
3255
|
-
const coldRoot =
|
|
3348
|
+
const coldRoot = path9.join(storageDir, "cold");
|
|
3256
3349
|
for (const candidate of qmdResultPathCandidates(coldRoot, parts.relativePath)) {
|
|
3257
3350
|
const memory = await storage.readMemoryByPath(candidate);
|
|
3258
3351
|
if (memory) return memory;
|
|
@@ -3302,9 +3395,9 @@ var QmdResultResolver = class {
|
|
|
3302
3395
|
error: err.message
|
|
3303
3396
|
});
|
|
3304
3397
|
}
|
|
3305
|
-
if (!
|
|
3398
|
+
if (!path9.isAbsolute(fallbackResultPath)) return null;
|
|
3306
3399
|
}
|
|
3307
|
-
if (
|
|
3400
|
+
if (path9.isAbsolute(fallbackResultPath)) {
|
|
3308
3401
|
if (!fallbackStorageDir) {
|
|
3309
3402
|
return await fallbackStorage.readMemoryByPath(fallbackResultPath);
|
|
3310
3403
|
}
|
|
@@ -3361,17 +3454,17 @@ var QmdResultResolver = class {
|
|
|
3361
3454
|
if (!memory && parts && !collectionIsKnownInternal && !collectionIsConfigured) {
|
|
3362
3455
|
memory = await this.readQmdResultMemory(parts.relativePath, fallbackStorage, namespaces, result.namespace);
|
|
3363
3456
|
}
|
|
3364
|
-
const absoluteInsideMemoryRoot =
|
|
3457
|
+
const absoluteInsideMemoryRoot = path9.isAbsolute(result.path) && isPathInsideStorageRoot(path9.resolve(config.memoryDir), path9.resolve(result.path));
|
|
3365
3458
|
const hasExplicitQmdCollection = result.path.trim().startsWith("qmd://");
|
|
3366
3459
|
const unresolvedInternalPath = !memory && (absoluteInsideMemoryRoot || collectionIsKnownInternal && (!preserveUnresolved || hasExplicitQmdCollection) || hasExplicitQmdCollection && collectionIsConfigured);
|
|
3367
|
-
const unresolvedExternalCollection = !memory && (parts !== null && !collectionIsKnownInternal && !collectionIsConfigured ||
|
|
3460
|
+
const unresolvedExternalCollection = !memory && (parts !== null && !collectionIsKnownInternal && !collectionIsConfigured || path9.isAbsolute(result.path) && !isPathInsideStorageRoot(path9.resolve(config.memoryDir), path9.resolve(result.path)));
|
|
3368
3461
|
return memory !== null && !isSupportPassportPrivateMemory(memory) || !memory && !unresolvedInternalPath && (preserveUnresolved || unresolvedExternalCollection);
|
|
3369
3462
|
}
|
|
3370
3463
|
async resolveColdQmdResultForRecall(result, fallbackStorage, recallNamespaces = []) {
|
|
3371
3464
|
const memory = await this.readQmdResultMemory(result.path, fallbackStorage, recallNamespaces, result.namespace);
|
|
3372
3465
|
if (!memory) return null;
|
|
3373
3466
|
let ownerNamespace = null;
|
|
3374
|
-
if (
|
|
3467
|
+
if (path9.isAbsolute(memory.path)) {
|
|
3375
3468
|
const ownerStorage = await this.storageForAbsoluteQmdResultPath(memory.path, fallbackStorage, recallNamespaces);
|
|
3376
3469
|
ownerNamespace = ownerStorage?.namespace ?? null;
|
|
3377
3470
|
if (!ownerNamespace && resolveNamespaceCapabilities(this.getConfig()).namespaces) return null;
|
|
@@ -3392,17 +3485,17 @@ var QmdResultResolver = class {
|
|
|
3392
3485
|
};
|
|
3393
3486
|
}
|
|
3394
3487
|
async storageForAbsoluteQmdResultPath(resultPath, fallbackStorage, recallNamespaces = []) {
|
|
3395
|
-
const resolvedPath =
|
|
3488
|
+
const resolvedPath = path9.resolve(resultPath);
|
|
3396
3489
|
const config = this.getConfig();
|
|
3397
|
-
const memoryRoot =
|
|
3398
|
-
const namespacesRoot =
|
|
3490
|
+
const memoryRoot = path9.resolve(config.memoryDir);
|
|
3491
|
+
const namespacesRoot = path9.join(memoryRoot, "namespaces");
|
|
3399
3492
|
const fallbackStorageDir = storageDirOrNull(fallbackStorage);
|
|
3400
3493
|
const matches = [];
|
|
3401
3494
|
const seenDirs = /* @__PURE__ */ new Set();
|
|
3402
3495
|
const maybeAddStorage = (storage, namespace) => {
|
|
3403
3496
|
const storageDir = storageDirOrNull(storage);
|
|
3404
3497
|
if (!storageDir) return;
|
|
3405
|
-
const candidateRoot =
|
|
3498
|
+
const candidateRoot = path9.resolve(storageDir);
|
|
3406
3499
|
if (seenDirs.has(candidateRoot)) return;
|
|
3407
3500
|
if (!isPathInsideStorageRoot(candidateRoot, resolvedPath)) return;
|
|
3408
3501
|
if (candidateRoot === memoryRoot && isPathInsideStorageRoot(namespacesRoot, resolvedPath)) {
|
|
@@ -3420,7 +3513,7 @@ var QmdResultResolver = class {
|
|
|
3420
3513
|
candidateNamespaces.add(ns);
|
|
3421
3514
|
}
|
|
3422
3515
|
if (isPathInsideStorageRoot(namespacesRoot, resolvedPath)) {
|
|
3423
|
-
const relativeToNamespaces =
|
|
3516
|
+
const relativeToNamespaces = path9.relative(namespacesRoot, resolvedPath);
|
|
3424
3517
|
const [namespaceSegment] = relativeToNamespaces.split(/[\\/]/);
|
|
3425
3518
|
if (namespaceSegment) {
|
|
3426
3519
|
candidateNamespaces.add(namespaceIdentityFromToken(namespaceSegment) ?? namespaceSegment);
|
|
@@ -4082,7 +4175,7 @@ function fuseDay(date, inputs, options = {}) {
|
|
|
4082
4175
|
|
|
4083
4176
|
// src/wearables/fusion/store.ts
|
|
4084
4177
|
import { createHash as createHash2 } from "crypto";
|
|
4085
|
-
import * as
|
|
4178
|
+
import * as path10 from "path";
|
|
4086
4179
|
var FUSION_KIND = "wearable-fusion";
|
|
4087
4180
|
function hashFusionBody(conversations) {
|
|
4088
4181
|
return createHash2("sha256").update(JSON.stringify(conversations), "utf-8").digest("hex");
|
|
@@ -4269,7 +4362,7 @@ var FusionArtifactStore = class {
|
|
|
4269
4362
|
`invalid wearable fusion date '${String(date)}' \u2014 expected YYYY-MM-DD`
|
|
4270
4363
|
);
|
|
4271
4364
|
}
|
|
4272
|
-
return
|
|
4365
|
+
return path10.join(this.wearablesDir, FUSION_DIR_NAME, `${date}.md`);
|
|
4273
4366
|
}
|
|
4274
4367
|
async writeFusedDay(date, serialized) {
|
|
4275
4368
|
const filePath = this.fusedDayPath(date);
|
|
@@ -4306,7 +4399,7 @@ var FusionArtifactStore = class {
|
|
|
4306
4399
|
}
|
|
4307
4400
|
/** List dates with stored fused artifacts, newest first. */
|
|
4308
4401
|
async listFusedDays() {
|
|
4309
|
-
const fusionDir =
|
|
4402
|
+
const fusionDir = path10.join(this.wearablesDir, FUSION_DIR_NAME);
|
|
4310
4403
|
await this.assertPathContained(fusionDir);
|
|
4311
4404
|
let entries;
|
|
4312
4405
|
try {
|
|
@@ -4350,10 +4443,10 @@ var FusionArtifactStore = class {
|
|
|
4350
4443
|
try {
|
|
4351
4444
|
rootReal = await this.io.realpath(this.memoryDir);
|
|
4352
4445
|
} catch {
|
|
4353
|
-
rootReal =
|
|
4446
|
+
rootReal = path10.resolve(this.memoryDir);
|
|
4354
4447
|
}
|
|
4355
4448
|
await this.assertNoEscape(rootReal, this.wearablesDir);
|
|
4356
|
-
await this.assertNoEscape(rootReal,
|
|
4449
|
+
await this.assertNoEscape(rootReal, path10.dirname(targetPath));
|
|
4357
4450
|
await this.assertNoEscape(rootReal, targetPath);
|
|
4358
4451
|
await this.assertFusionDirNotSymlinked();
|
|
4359
4452
|
}
|
|
@@ -4367,7 +4460,7 @@ var FusionArtifactStore = class {
|
|
|
4367
4460
|
* (a fresh write creates a real directory lexically under the root).
|
|
4368
4461
|
*/
|
|
4369
4462
|
async assertFusionDirNotSymlinked() {
|
|
4370
|
-
const fusionDir =
|
|
4463
|
+
const fusionDir = path10.join(this.wearablesDir, FUSION_DIR_NAME);
|
|
4371
4464
|
let stat4;
|
|
4372
4465
|
try {
|
|
4373
4466
|
stat4 = await this.io.lstat(fusionDir);
|
|
@@ -4503,7 +4596,7 @@ function reconstructFusionInputs(date, dayTranscripts) {
|
|
|
4503
4596
|
|
|
4504
4597
|
// src/meetings/store.ts
|
|
4505
4598
|
import { createHash as createHash3 } from "crypto";
|
|
4506
|
-
import * as
|
|
4599
|
+
import * as path11 from "path";
|
|
4507
4600
|
var MEETINGS_DIR_NAME = "meetings";
|
|
4508
4601
|
var MEETING_KIND = "meeting";
|
|
4509
4602
|
var MEETING_FORMAT_VERSION = 1;
|
|
@@ -4672,7 +4765,7 @@ var MeetingRecordStore = class {
|
|
|
4672
4765
|
constructor(memoryDir, io) {
|
|
4673
4766
|
this.memoryDir = memoryDir;
|
|
4674
4767
|
this.io = io;
|
|
4675
|
-
this.meetingsDir =
|
|
4768
|
+
this.meetingsDir = path11.join(memoryDir, MEETINGS_DIR_NAME);
|
|
4676
4769
|
}
|
|
4677
4770
|
memoryDir;
|
|
4678
4771
|
io;
|
|
@@ -4688,7 +4781,7 @@ var MeetingRecordStore = class {
|
|
|
4688
4781
|
if (idDate !== date) {
|
|
4689
4782
|
throw new Error(`meeting id '${id}' does not belong to date '${date}'`);
|
|
4690
4783
|
}
|
|
4691
|
-
return
|
|
4784
|
+
return path11.join(this.meetingsDir, date, `${id}.md`);
|
|
4692
4785
|
}
|
|
4693
4786
|
/** Idempotently persist a record: skip the write when contentHash is unchanged. */
|
|
4694
4787
|
async saveMeetingRecord(record) {
|
|
@@ -4719,7 +4812,7 @@ var MeetingRecordStore = class {
|
|
|
4719
4812
|
if (!isValidTranscriptDate(date)) {
|
|
4720
4813
|
throw new Error(`invalid meeting date '${String(date)}' \u2014 expected YYYY-MM-DD`);
|
|
4721
4814
|
}
|
|
4722
|
-
const dayDir =
|
|
4815
|
+
const dayDir = path11.join(this.meetingsDir, date);
|
|
4723
4816
|
await this.assertPathContained(dayDir);
|
|
4724
4817
|
let entries;
|
|
4725
4818
|
try {
|
|
@@ -4787,10 +4880,10 @@ var MeetingRecordStore = class {
|
|
|
4787
4880
|
try {
|
|
4788
4881
|
rootReal = await this.io.realpath(this.memoryDir);
|
|
4789
4882
|
} catch {
|
|
4790
|
-
rootReal =
|
|
4883
|
+
rootReal = path11.resolve(this.memoryDir);
|
|
4791
4884
|
}
|
|
4792
4885
|
await this.assertNoEscape(rootReal, this.meetingsDir);
|
|
4793
|
-
await this.assertNoEscape(rootReal,
|
|
4886
|
+
await this.assertNoEscape(rootReal, path11.dirname(targetPath));
|
|
4794
4887
|
await this.assertNoEscape(rootReal, targetPath);
|
|
4795
4888
|
await this.assertNotSymlink(this.meetingsDir, "directory");
|
|
4796
4889
|
const dayDir = this.dayDirWithin(targetPath);
|
|
@@ -4800,11 +4893,11 @@ var MeetingRecordStore = class {
|
|
|
4800
4893
|
/** The `<meetings>/<date>` directory on the path to `targetPath`, or null when
|
|
4801
4894
|
* `targetPath` is the meetings root itself. */
|
|
4802
4895
|
dayDirWithin(targetPath) {
|
|
4803
|
-
const rel =
|
|
4804
|
-
if (rel === "" || rel.startsWith("..") ||
|
|
4805
|
-
const first = rel.split(
|
|
4896
|
+
const rel = path11.relative(this.meetingsDir, targetPath);
|
|
4897
|
+
if (rel === "" || rel.startsWith("..") || path11.isAbsolute(rel)) return null;
|
|
4898
|
+
const first = rel.split(path11.sep)[0];
|
|
4806
4899
|
if (first === void 0 || first.length === 0) return null;
|
|
4807
|
-
return
|
|
4900
|
+
return path11.join(this.meetingsDir, first);
|
|
4808
4901
|
}
|
|
4809
4902
|
async assertNotSymlink(target, kind) {
|
|
4810
4903
|
let stat4;
|
|
@@ -4815,7 +4908,7 @@ var MeetingRecordStore = class {
|
|
|
4815
4908
|
throw err;
|
|
4816
4909
|
}
|
|
4817
4910
|
if (stat4.isSymbolicLink) {
|
|
4818
|
-
const label =
|
|
4911
|
+
const label = path11.relative(this.memoryDir, target) || MEETINGS_DIR_NAME;
|
|
4819
4912
|
throw new Error(
|
|
4820
4913
|
`meetings ${kind} '${label}' is a symbolic link \u2014 refusing to follow it even when it resolves inside the memory dir (AGENTS.md pattern #3)`
|
|
4821
4914
|
);
|
|
@@ -4839,8 +4932,8 @@ var SORT_STR = (a, b) => a < b ? -1 : a > b ? 1 : 0;
|
|
|
4839
4932
|
|
|
4840
4933
|
// src/storage/buffer-session-files.ts
|
|
4841
4934
|
import { createHash as createHash4 } from "crypto";
|
|
4842
|
-
import { lstat as
|
|
4843
|
-
import
|
|
4935
|
+
import { lstat as lstat4, readdir as readdir4, unlink as unlink3 } from "fs/promises";
|
|
4936
|
+
import path12 from "path";
|
|
4844
4937
|
function isMissing(err) {
|
|
4845
4938
|
return err?.code === "ENOENT";
|
|
4846
4939
|
}
|
|
@@ -4883,10 +4976,10 @@ var BufferSessionFiles = class {
|
|
|
4883
4976
|
io;
|
|
4884
4977
|
dirVerified = false;
|
|
4885
4978
|
get dir() {
|
|
4886
|
-
return
|
|
4979
|
+
return path12.join(this.stateDir, "buffer");
|
|
4887
4980
|
}
|
|
4888
4981
|
fileFor(key) {
|
|
4889
|
-
return
|
|
4982
|
+
return path12.join(this.dir, bufferSessionFileName(key));
|
|
4890
4983
|
}
|
|
4891
4984
|
/**
|
|
4892
4985
|
* Refuse a symlinked buffer directory: following it would send buffered
|
|
@@ -4898,7 +4991,7 @@ var BufferSessionFiles = class {
|
|
|
4898
4991
|
if (this.dirVerified) return;
|
|
4899
4992
|
let stat4 = null;
|
|
4900
4993
|
try {
|
|
4901
|
-
stat4 = await
|
|
4994
|
+
stat4 = await lstat4(this.dir);
|
|
4902
4995
|
} catch (err) {
|
|
4903
4996
|
if (!(err instanceof Error) || !isMissing(asFsError(err))) throw err;
|
|
4904
4997
|
}
|
|
@@ -4939,7 +5032,7 @@ var BufferSessionFiles = class {
|
|
|
4939
5032
|
const entries = /* @__PURE__ */ new Map();
|
|
4940
5033
|
for (const name of names) {
|
|
4941
5034
|
try {
|
|
4942
|
-
const body = JSON.parse(await this.io.read(
|
|
5035
|
+
const body = JSON.parse(await this.io.read(path12.join(this.dir, name)));
|
|
4943
5036
|
const parsed = entryFromBody(body);
|
|
4944
5037
|
if (!parsed) throw new Error("invalid buffer session file shape");
|
|
4945
5038
|
if (entries.has(parsed.key)) {
|
|
@@ -4963,7 +5056,7 @@ var BufferSessionFiles = class {
|
|
|
4963
5056
|
async readLegacy(hasSessionFiles) {
|
|
4964
5057
|
let raw;
|
|
4965
5058
|
try {
|
|
4966
|
-
raw = await this.io.read(
|
|
5059
|
+
raw = await this.io.read(path12.join(this.stateDir, "buffer.json"));
|
|
4967
5060
|
} catch (err) {
|
|
4968
5061
|
if (err instanceof SecureStoreLockedError) throw err;
|
|
4969
5062
|
if (err instanceof Error && isMissing(asFsError(err))) return null;
|
|
@@ -4996,7 +5089,7 @@ var BufferSessionFiles = class {
|
|
|
4996
5089
|
await this.save(key, entry);
|
|
4997
5090
|
}
|
|
4998
5091
|
try {
|
|
4999
|
-
await unlink3(
|
|
5092
|
+
await unlink3(path12.join(this.stateDir, "buffer.json"));
|
|
5000
5093
|
} catch (err) {
|
|
5001
5094
|
if (!(err instanceof Error) || !isMissing(asFsError(err))) throw err;
|
|
5002
5095
|
}
|
|
@@ -5025,7 +5118,7 @@ var BufferSessionFiles = class {
|
|
|
5025
5118
|
for (const name of existing) {
|
|
5026
5119
|
if (live.has(name)) continue;
|
|
5027
5120
|
try {
|
|
5028
|
-
await unlink3(
|
|
5121
|
+
await unlink3(path12.join(this.dir, name));
|
|
5029
5122
|
} catch (err) {
|
|
5030
5123
|
if (!(err instanceof Error) || !isMissing(asFsError(err))) throw err;
|
|
5031
5124
|
}
|
|
@@ -5035,7 +5128,7 @@ var BufferSessionFiles = class {
|
|
|
5035
5128
|
|
|
5036
5129
|
// src/storage/supersession-audit.ts
|
|
5037
5130
|
import { readdir as readdir5 } from "fs/promises";
|
|
5038
|
-
import
|
|
5131
|
+
import path13 from "path";
|
|
5039
5132
|
async function hasSupersessionAudit(lookup, oldMemoryId, newMemoryId, auditBody, structuredAttributes) {
|
|
5040
5133
|
let entries;
|
|
5041
5134
|
try {
|
|
@@ -5047,7 +5140,7 @@ async function hasSupersessionAudit(lookup, oldMemoryId, newMemoryId, auditBody,
|
|
|
5047
5140
|
for (const entry of entries) {
|
|
5048
5141
|
if (isMacOsReplicationJunkBasename(entry.name)) continue;
|
|
5049
5142
|
if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
|
|
5050
|
-
const memory = await lookup.readMemoryByPath(
|
|
5143
|
+
const memory = await lookup.readMemoryByPath(path13.join(lookup.correctionsDir, entry.name));
|
|
5051
5144
|
if (memory?.frontmatter.category === "correction" && (memory.frontmatter.sourceMemoryId === oldMemoryId || memory.frontmatter.sourceMemoryId === void 0 && memory.frontmatter.lineage?.includes(oldMemoryId)) && memory.frontmatter.lineage?.includes(newMemoryId) && stripAttributesSuffix(memory.content) === auditBody && (structuredAttributes === void 0 || Object.entries(structuredAttributes).every(
|
|
5052
5145
|
([key, value]) => memory.frontmatter.structuredAttributes?.[key] === value
|
|
5053
5146
|
))) {
|
|
@@ -5139,12 +5232,12 @@ Reason: ${reason}`;
|
|
|
5139
5232
|
// src/storage/dropped-extraction-chunk.ts
|
|
5140
5233
|
import { randomUUID } from "crypto";
|
|
5141
5234
|
import { mkdir } from "fs/promises";
|
|
5142
|
-
import
|
|
5235
|
+
import path14 from "path";
|
|
5143
5236
|
async function saveDroppedExtractionChunk(stateDir, writeSecureFile, bufferKey, reason, turns) {
|
|
5144
|
-
const droppedDir =
|
|
5237
|
+
const droppedDir = path14.join(stateDir, "dropped");
|
|
5145
5238
|
await mkdir(droppedDir, { recursive: true });
|
|
5146
5239
|
const safeKey = bufferKey.replace(/[^a-zA-Z0-9._-]/g, "-").slice(0, 80) || "default";
|
|
5147
|
-
const filePath =
|
|
5240
|
+
const filePath = path14.join(droppedDir, `${Date.now()}-${randomUUID().slice(0, 8)}-${safeKey}.json`);
|
|
5148
5241
|
const payload = { bufferKey, reason, droppedAt: (/* @__PURE__ */ new Date()).toISOString(), turns };
|
|
5149
5242
|
await writeSecureFile(filePath, JSON.stringify(payload, null, 2));
|
|
5150
5243
|
return filePath;
|
|
@@ -6150,17 +6243,17 @@ function inferEntityTypeFromContent(content) {
|
|
|
6150
6243
|
}
|
|
6151
6244
|
var KNOWN_ENTITY_FILENAME_PREFIXES = /* @__PURE__ */ new Set(["company", "other", "person", "place", "project", "tool", "topic"]);
|
|
6152
6245
|
function inferEntityTypeFromFilename(pathRel) {
|
|
6153
|
-
const basename =
|
|
6246
|
+
const basename = path15.basename(pathRel, ".md").toLowerCase();
|
|
6154
6247
|
const separator = basename.indexOf("-");
|
|
6155
6248
|
if (separator <= 0) return void 0;
|
|
6156
6249
|
const candidate = basename.slice(0, separator);
|
|
6157
6250
|
return KNOWN_ENTITY_FILENAME_PREFIXES.has(candidate) ? candidate : void 0;
|
|
6158
6251
|
}
|
|
6159
6252
|
function normalizeFrontmatterForPath(frontmatter, pathRel, content = "") {
|
|
6160
|
-
const normalizedPath = pathRel.split(
|
|
6253
|
+
const normalizedPath = pathRel.split(path15.sep).join("/");
|
|
6161
6254
|
let normalizedFrontmatter = frontmatter;
|
|
6162
6255
|
if (normalizedPath === "entities" || normalizedPath.startsWith("entities/") || normalizedPath.includes("/entities/")) {
|
|
6163
|
-
const basename =
|
|
6256
|
+
const basename = path15.basename(pathRel, ".md");
|
|
6164
6257
|
const inferredType = inferEntityTypeFromContent(content) || inferEntityTypeFromFilename(pathRel) || "entity";
|
|
6165
6258
|
const existingTags = Array.isArray(frontmatter.tags) ? frontmatter.tags : [];
|
|
6166
6259
|
normalizedFrontmatter = {
|
|
@@ -6633,9 +6726,9 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
6633
6726
|
this.entitySchemas = entitySchemas;
|
|
6634
6727
|
this.deletionRevisionStore = new DeletionRevisionStore({
|
|
6635
6728
|
baseDir,
|
|
6636
|
-
deletionRevisionMetadataPath:
|
|
6637
|
-
invalidationCommitMetadataPath:
|
|
6638
|
-
deletionRevisionLockPath:
|
|
6729
|
+
deletionRevisionMetadataPath: path15.join(baseDir, ".offline-sync", "deletion-revisions.v1.json"),
|
|
6730
|
+
invalidationCommitMetadataPath: path15.join(baseDir, ".offline-sync", "invalidation-commits.v1.json"),
|
|
6731
|
+
deletionRevisionLockPath: path15.join(baseDir, ".offline-sync", "deletion-revisions.v1.json.lock"),
|
|
6639
6732
|
assertManagedStoragePath: (filePath, method) => this.assertManagedStoragePath(filePath, method)
|
|
6640
6733
|
});
|
|
6641
6734
|
this.casRevisions = new CasRevisionHost(baseDir);
|
|
@@ -6789,6 +6882,8 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
6789
6882
|
onCatalogWrite;
|
|
6790
6883
|
/** Post-write embedding hook (#2019). Installed by the orchestrator; fire-and-forget. */
|
|
6791
6884
|
onMemoryWrite;
|
|
6885
|
+
/** Request search maintenance after a completed entity replay. */
|
|
6886
|
+
onEntityMigrationComplete;
|
|
6792
6887
|
notifyMemoryWrite(filePath) {
|
|
6793
6888
|
try {
|
|
6794
6889
|
this.onMemoryWrite?.(filePath);
|
|
@@ -6821,8 +6916,8 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
6821
6916
|
}
|
|
6822
6917
|
/** Whether `filePath` resolves to `stateDir` itself or a path contained in it. */
|
|
6823
6918
|
isStateFilePath(filePath) {
|
|
6824
|
-
const rel =
|
|
6825
|
-
return rel === "" || !rel.startsWith("..") && !
|
|
6919
|
+
const rel = path15.relative(this.stateDir, path15.resolve(filePath));
|
|
6920
|
+
return rel === "" || !rel.startsWith("..") && !path15.isAbsolute(rel);
|
|
6826
6921
|
}
|
|
6827
6922
|
// ── Tombstone store (issue #1579) ───────────────────────────────────────
|
|
6828
6923
|
// Instance-scoped (rule 11) + namespace-scoped (rule 42) tombstone index.
|
|
@@ -6937,8 +7032,8 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
6937
7032
|
* /srv/cold/remnic), skipping the patch and stranding a stale hot entry.
|
|
6938
7033
|
*/
|
|
6939
7034
|
isColdOrArchiveTierPath(p) {
|
|
6940
|
-
const rel =
|
|
6941
|
-
return rel === "cold" || rel === "archive" || rel.startsWith(`cold${
|
|
7035
|
+
const rel = path15.relative(this.baseDir, p);
|
|
7036
|
+
return rel === "cold" || rel === "archive" || rel.startsWith(`cold${path15.sep}`) || rel.startsWith(`archive${path15.sep}`);
|
|
6942
7037
|
}
|
|
6943
7038
|
/**
|
|
6944
7039
|
* Mark the secure-store as required for this storage instance.
|
|
@@ -7025,7 +7120,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7025
7120
|
void 0,
|
|
7026
7121
|
this.baseDir
|
|
7027
7122
|
);
|
|
7028
|
-
const rel =
|
|
7123
|
+
const rel = path15.relative(this.baseDir, filePath).split(path15.sep).join("/");
|
|
7029
7124
|
return `${rel}:${version.versionId}`;
|
|
7030
7125
|
} catch (err) {
|
|
7031
7126
|
log.warn(
|
|
@@ -7070,10 +7165,10 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7070
7165
|
_StorageManager.okfConformanceByDir.set(memoryDir, enabled !== false);
|
|
7071
7166
|
}
|
|
7072
7167
|
okfConformanceEnabled() {
|
|
7073
|
-
for (let dir = this.baseDir; ; dir =
|
|
7168
|
+
for (let dir = this.baseDir; ; dir = path15.dirname(dir)) {
|
|
7074
7169
|
const registered = _StorageManager.okfConformanceByDir.get(dir);
|
|
7075
7170
|
if (registered !== void 0) return registered;
|
|
7076
|
-
if (dir ===
|
|
7171
|
+
if (dir === path15.dirname(dir)) return true;
|
|
7077
7172
|
}
|
|
7078
7173
|
}
|
|
7079
7174
|
/**
|
|
@@ -7117,12 +7212,12 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7117
7212
|
}
|
|
7118
7213
|
identityFilePath(workspaceDir, namespace) {
|
|
7119
7214
|
const rawNamespace = typeof namespace === "string" ? namespace.trim() : "";
|
|
7120
|
-
if (!rawNamespace) return
|
|
7215
|
+
if (!rawNamespace) return path15.join(workspaceDir, "IDENTITY.md");
|
|
7121
7216
|
const safeNamespace = rawNamespace.replace(/[^a-zA-Z0-9._-]/g, "-");
|
|
7122
|
-
return
|
|
7217
|
+
return path15.join(workspaceDir, `IDENTITY.${safeNamespace}.md`);
|
|
7123
7218
|
}
|
|
7124
7219
|
versionFilePath(kind) {
|
|
7125
|
-
return
|
|
7220
|
+
return path15.join(this.stateDir, `.${kind}-version.log`);
|
|
7126
7221
|
}
|
|
7127
7222
|
bumpSharedVersion(kind, fallbackMap) {
|
|
7128
7223
|
const filePath = this.versionFilePath(kind);
|
|
@@ -7229,7 +7324,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7229
7324
|
// memories.
|
|
7230
7325
|
// -------------------------------------------------------------------------
|
|
7231
7326
|
get wearablesDir() {
|
|
7232
|
-
return
|
|
7327
|
+
return path15.join(this.baseDir, WEARABLES_DIR_NAME);
|
|
7233
7328
|
}
|
|
7234
7329
|
/**
|
|
7235
7330
|
* Resolve the on-disk path for a source/day transcript. Throws on
|
|
@@ -7245,7 +7340,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7245
7340
|
if (!isValidTranscriptDate(date)) {
|
|
7246
7341
|
throw new Error(`invalid wearable transcript date '${String(date)}' \u2014 expected YYYY-MM-DD`);
|
|
7247
7342
|
}
|
|
7248
|
-
return
|
|
7343
|
+
return path15.join(this.wearablesDir, sourceId, `${date}.md`);
|
|
7249
7344
|
}
|
|
7250
7345
|
async writeWearableDayTranscript(sourceId, date, serialized) {
|
|
7251
7346
|
const targetPath = this.wearableTranscriptPath(sourceId, date);
|
|
@@ -7274,7 +7369,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7274
7369
|
readDir: (d) => readdir6(d),
|
|
7275
7370
|
deleteFile: (p) => unlink4(p),
|
|
7276
7371
|
realpath: (p) => realpath3(p),
|
|
7277
|
-
lstat: (p) =>
|
|
7372
|
+
lstat: (p) => lstat5(p).then((st) => ({ isSymbolicLink: st.isSymbolicLink() }))
|
|
7278
7373
|
});
|
|
7279
7374
|
}
|
|
7280
7375
|
_meetingRecordStore;
|
|
@@ -7292,7 +7387,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7292
7387
|
readDir: (d) => readdir6(d),
|
|
7293
7388
|
deleteFile: (p) => unlink4(p),
|
|
7294
7389
|
realpath: (p) => realpath3(p),
|
|
7295
|
-
lstat: (p) =>
|
|
7390
|
+
lstat: (p) => lstat5(p).then((st) => ({ isSymbolicLink: st.isSymbolicLink() }))
|
|
7296
7391
|
});
|
|
7297
7392
|
}
|
|
7298
7393
|
/**
|
|
@@ -7359,25 +7454,25 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7359
7454
|
});
|
|
7360
7455
|
}
|
|
7361
7456
|
get factsDir() {
|
|
7362
|
-
return
|
|
7457
|
+
return path15.join(this.baseDir, "facts");
|
|
7363
7458
|
}
|
|
7364
7459
|
get correctionsDir() {
|
|
7365
|
-
return
|
|
7460
|
+
return path15.join(this.baseDir, "corrections");
|
|
7366
7461
|
}
|
|
7367
7462
|
get proceduresDir() {
|
|
7368
|
-
return
|
|
7463
|
+
return path15.join(this.baseDir, "procedures");
|
|
7369
7464
|
}
|
|
7370
7465
|
get reasoningTracesDir() {
|
|
7371
|
-
return
|
|
7466
|
+
return path15.join(this.baseDir, "reasoning-traces");
|
|
7372
7467
|
}
|
|
7373
7468
|
get entitiesDir() {
|
|
7374
|
-
return
|
|
7469
|
+
return path15.join(this.baseDir, "entities");
|
|
7375
7470
|
}
|
|
7376
7471
|
resolveEntityFilePath(name) {
|
|
7377
7472
|
if (typeof name !== "string") return null;
|
|
7378
|
-
const filePath =
|
|
7379
|
-
const relative2 =
|
|
7380
|
-
if (relative2 === "" || relative2.startsWith("..") ||
|
|
7473
|
+
const filePath = path15.resolve(this.entitiesDir, `${name}.md`);
|
|
7474
|
+
const relative2 = path15.relative(this.entitiesDir, filePath);
|
|
7475
|
+
if (relative2 === "" || relative2.startsWith("..") || path15.isAbsolute(relative2)) {
|
|
7381
7476
|
return null;
|
|
7382
7477
|
}
|
|
7383
7478
|
return filePath;
|
|
@@ -7388,7 +7483,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7388
7483
|
async readDependencyPropagationQueueFile(filePath) {
|
|
7389
7484
|
const target = await resolveSafeStoragePath(
|
|
7390
7485
|
this.baseDir,
|
|
7391
|
-
|
|
7486
|
+
path15.relative(
|
|
7392
7487
|
this.baseDir,
|
|
7393
7488
|
this.assertManagedStoragePath(filePath, "storage.readDependencyPropagationQueueFile")
|
|
7394
7489
|
)
|
|
@@ -7398,7 +7493,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7398
7493
|
async writeDependencyPropagationQueueFile(filePath, content) {
|
|
7399
7494
|
const target = await resolveSafeStoragePath(
|
|
7400
7495
|
this.baseDir,
|
|
7401
|
-
|
|
7496
|
+
path15.relative(
|
|
7402
7497
|
this.baseDir,
|
|
7403
7498
|
this.assertManagedStoragePath(filePath, "storage.writeDependencyPropagationQueueFile")
|
|
7404
7499
|
)
|
|
@@ -7413,10 +7508,10 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7413
7508
|
});
|
|
7414
7509
|
}
|
|
7415
7510
|
assertManagedStoragePath(filePath, method) {
|
|
7416
|
-
const resolved =
|
|
7417
|
-
const base =
|
|
7418
|
-
const rel =
|
|
7419
|
-
if (rel === "" || rel === ".." || rel.startsWith(`..${
|
|
7511
|
+
const resolved = path15.resolve(filePath);
|
|
7512
|
+
const base = path15.resolve(this.baseDir);
|
|
7513
|
+
const rel = path15.relative(base, resolved);
|
|
7514
|
+
if (rel === "" || rel === ".." || rel.startsWith(`..${path15.sep}`) || path15.isAbsolute(rel)) {
|
|
7420
7515
|
throw new Error(`${method}: file path escapes memory dir`);
|
|
7421
7516
|
}
|
|
7422
7517
|
return resolved;
|
|
@@ -7453,7 +7548,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7453
7548
|
async digestOfflineSyncFile(filePath) {
|
|
7454
7549
|
const target = this.assertManagedStoragePath(filePath, "storage.digestOfflineSyncFile");
|
|
7455
7550
|
const st = await stat3(target);
|
|
7456
|
-
const relPath =
|
|
7551
|
+
const relPath = path15.relative(this.baseDir, target).split(path15.sep).join("/");
|
|
7457
7552
|
const cache = await this.loadOfflineSyncDigestCache();
|
|
7458
7553
|
const cached = cache.get(relPath);
|
|
7459
7554
|
if (cached && cached.statBytes === st.size && cached.mtimeMs === st.mtimeMs && cached.ctimeMs === st.ctimeMs && !cached.encrypted) {
|
|
@@ -7538,7 +7633,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7538
7633
|
const cache = this.offlineSyncDigestCache;
|
|
7539
7634
|
if (!cache) return;
|
|
7540
7635
|
const entries = [...cache.entries()].sort(([a], [b]) => a.localeCompare(b)).map(([entryPath, entry]) => ({ path: entryPath, ...entry }));
|
|
7541
|
-
await mkdir2(
|
|
7636
|
+
await mkdir2(path15.dirname(this.offlineSyncDigestCachePath), { recursive: true });
|
|
7542
7637
|
await writeFile(this.offlineSyncDigestCachePath, `${JSON.stringify({ version: 1, entries })}
|
|
7543
7638
|
`, "utf-8");
|
|
7544
7639
|
}).catch((err) => {
|
|
@@ -7639,7 +7734,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7639
7734
|
}
|
|
7640
7735
|
async appendStorageSecureFileUnlocked(filePath, content) {
|
|
7641
7736
|
const writeKey = this.resolveWriteKey();
|
|
7642
|
-
await mkdir2(
|
|
7737
|
+
await mkdir2(path15.dirname(filePath), { recursive: true });
|
|
7643
7738
|
if (writeKey === null) {
|
|
7644
7739
|
try {
|
|
7645
7740
|
if (await this.isEncryptedFileHeader(filePath)) {
|
|
@@ -7665,13 +7760,13 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7665
7760
|
this.notifyCatalogWriteForPath(filePath);
|
|
7666
7761
|
}
|
|
7667
7762
|
get stateDir() {
|
|
7668
|
-
return
|
|
7763
|
+
return path15.join(this.baseDir, "state");
|
|
7669
7764
|
}
|
|
7670
7765
|
get offlineSyncDigestCachePath() {
|
|
7671
|
-
return
|
|
7766
|
+
return path15.join(this.baseDir, ".offline-sync", "digest-cache.v1.json");
|
|
7672
7767
|
}
|
|
7673
7768
|
get entitySynthesisQueuePath() {
|
|
7674
|
-
return
|
|
7769
|
+
return path15.join(this.stateDir, "entity-synthesis-queue.json");
|
|
7675
7770
|
}
|
|
7676
7771
|
// ── Tombstone store access (issue #1579) ─────────────────────────────────
|
|
7677
7772
|
/**
|
|
@@ -7681,7 +7776,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7681
7776
|
* helpers are injected into the store).
|
|
7682
7777
|
*/
|
|
7683
7778
|
get tombstonesPath() {
|
|
7684
|
-
return
|
|
7779
|
+
return path15.join(this.stateDir, "tombstones.jsonl");
|
|
7685
7780
|
}
|
|
7686
7781
|
/**
|
|
7687
7782
|
* Configure the tombstone invariant for this storage instance. Installed
|
|
@@ -7994,55 +8089,55 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7994
8089
|
return legacyMatches.length > 0 ? [...new Set(legacyMatches.map((content) => ContentHashIndex.computeHash(content)))] : [persistedHash];
|
|
7995
8090
|
}
|
|
7996
8091
|
get questionsDir() {
|
|
7997
|
-
return
|
|
8092
|
+
return path15.join(this.baseDir, "questions");
|
|
7998
8093
|
}
|
|
7999
8094
|
get artifactsDir() {
|
|
8000
|
-
return
|
|
8095
|
+
return path15.join(this.baseDir, "artifacts");
|
|
8001
8096
|
}
|
|
8002
8097
|
get identityDir() {
|
|
8003
|
-
return
|
|
8098
|
+
return path15.join(this.baseDir, "identity");
|
|
8004
8099
|
}
|
|
8005
8100
|
get identityAnchorPath() {
|
|
8006
|
-
return
|
|
8101
|
+
return path15.join(this.identityDir, "identity-anchor.md");
|
|
8007
8102
|
}
|
|
8008
8103
|
get identityIncidentsDir() {
|
|
8009
|
-
return
|
|
8104
|
+
return path15.join(this.identityDir, "incidents");
|
|
8010
8105
|
}
|
|
8011
8106
|
get identityAuditsWeeklyDir() {
|
|
8012
|
-
return
|
|
8107
|
+
return path15.join(this.identityDir, "audits", "weekly");
|
|
8013
8108
|
}
|
|
8014
8109
|
get identityAuditsMonthlyDir() {
|
|
8015
|
-
return
|
|
8110
|
+
return path15.join(this.identityDir, "audits", "monthly");
|
|
8016
8111
|
}
|
|
8017
8112
|
get identityImprovementLoopsPath() {
|
|
8018
|
-
return
|
|
8113
|
+
return path15.join(this.identityDir, "improvement-loops.md");
|
|
8019
8114
|
}
|
|
8020
8115
|
get identityReflectionsPath() {
|
|
8021
|
-
return
|
|
8116
|
+
return path15.join(this.identityDir, "reflections.md");
|
|
8022
8117
|
}
|
|
8023
8118
|
get profilePath() {
|
|
8024
|
-
return
|
|
8119
|
+
return path15.join(this.baseDir, "profile.md");
|
|
8025
8120
|
}
|
|
8026
8121
|
get memoryActionsPath() {
|
|
8027
|
-
return
|
|
8122
|
+
return path15.join(this.stateDir, "memory-actions.jsonl");
|
|
8028
8123
|
}
|
|
8029
8124
|
get memoryLifecycleLedgerPath() {
|
|
8030
|
-
return
|
|
8125
|
+
return path15.join(this.stateDir, "memory-lifecycle-ledger.jsonl");
|
|
8031
8126
|
}
|
|
8032
8127
|
get compressionGuidelinesPath() {
|
|
8033
|
-
return
|
|
8128
|
+
return path15.join(this.stateDir, "compression-guidelines.md");
|
|
8034
8129
|
}
|
|
8035
8130
|
get compressionGuidelineDraftPath() {
|
|
8036
|
-
return
|
|
8131
|
+
return path15.join(this.stateDir, "compression-guidelines.draft.md");
|
|
8037
8132
|
}
|
|
8038
8133
|
get compressionGuidelineStatePath() {
|
|
8039
|
-
return
|
|
8134
|
+
return path15.join(this.stateDir, "compression-guideline-state.json");
|
|
8040
8135
|
}
|
|
8041
8136
|
get compressionGuidelineDraftStatePath() {
|
|
8042
|
-
return
|
|
8137
|
+
return path15.join(this.stateDir, "compression-guideline-draft-state.json");
|
|
8043
8138
|
}
|
|
8044
8139
|
get behaviorSignalsPath() {
|
|
8045
|
-
return
|
|
8140
|
+
return path15.join(this.stateDir, "behavior-signals.jsonl");
|
|
8046
8141
|
}
|
|
8047
8142
|
/**
|
|
8048
8143
|
* In-memory dedup key set for behavior-signals appends (issue #1909),
|
|
@@ -8074,7 +8169,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
8074
8169
|
* governance sweeps can treat it uniformly.
|
|
8075
8170
|
*/
|
|
8076
8171
|
get bufferSurpriseLedgerPath() {
|
|
8077
|
-
return
|
|
8172
|
+
return path15.join(this.stateDir, "buffer-surprise-ledger.jsonl");
|
|
8078
8173
|
}
|
|
8079
8174
|
/**
|
|
8080
8175
|
* Entity alias table loaded from THIS store's config/aliases.json.
|
|
@@ -8137,7 +8232,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
8137
8232
|
this.loadAliasesSync();
|
|
8138
8233
|
}
|
|
8139
8234
|
loadAliasesSync() {
|
|
8140
|
-
const aliasPath =
|
|
8235
|
+
const aliasPath = path15.join(this.baseDir, "config", "aliases.json");
|
|
8141
8236
|
this.userAliases = {};
|
|
8142
8237
|
const raw = readEntityAliasConfigSync(this.baseDir);
|
|
8143
8238
|
if (raw === void 0) return;
|
|
@@ -8175,9 +8270,9 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
8175
8270
|
await mkdir2(this.baseDir, { recursive: true });
|
|
8176
8271
|
await validateRoots(this.baseDir, this.entitiesDir, this.stateDir, this.archiveDir);
|
|
8177
8272
|
const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
8178
|
-
await mkdir2(
|
|
8179
|
-
await mkdir2(
|
|
8180
|
-
await mkdir2(
|
|
8273
|
+
await mkdir2(path15.join(this.factsDir, today), { recursive: true });
|
|
8274
|
+
await mkdir2(path15.join(this.proceduresDir, today), { recursive: true });
|
|
8275
|
+
await mkdir2(path15.join(this.reasoningTracesDir, today), { recursive: true });
|
|
8181
8276
|
await mkdir2(this.correctionsDir, { recursive: true });
|
|
8182
8277
|
await mkdir2(this.entitiesDir, { recursive: true });
|
|
8183
8278
|
await mkdir2(this.stateDir, { recursive: true });
|
|
@@ -8187,7 +8282,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
8187
8282
|
await mkdir2(this.identityIncidentsDir, { recursive: true });
|
|
8188
8283
|
await mkdir2(this.identityAuditsWeeklyDir, { recursive: true });
|
|
8189
8284
|
await mkdir2(this.identityAuditsMonthlyDir, { recursive: true });
|
|
8190
|
-
await mkdir2(
|
|
8285
|
+
await mkdir2(path15.join(this.baseDir, "config"), { recursive: true });
|
|
8191
8286
|
await this.entityCanonicalIdMigration.begin(options.waitForEntityMigration !== false, this.entitiesDir);
|
|
8192
8287
|
if (this.hotMemoriesCacheEnabled && this.getMemoryCorpusVersion() === 0) {
|
|
8193
8288
|
this.bumpMemoryCorpusVersion();
|
|
@@ -8210,11 +8305,11 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
8210
8305
|
async resolveCategoryWritePath(category, id, today) {
|
|
8211
8306
|
if (category === "correction") {
|
|
8212
8307
|
await mkdir2(this.correctionsDir, { recursive: true });
|
|
8213
|
-
return
|
|
8308
|
+
return path15.join(this.correctionsDir, `${id}.md`);
|
|
8214
8309
|
}
|
|
8215
|
-
const datedDir =
|
|
8310
|
+
const datedDir = path15.join(getCategoryDir(this.baseDir, category), today);
|
|
8216
8311
|
await mkdir2(datedDir, { recursive: true });
|
|
8217
|
-
return
|
|
8312
|
+
return path15.join(datedDir, `${id}.md`);
|
|
8218
8313
|
}
|
|
8219
8314
|
async findExistingTombstoneBlockedMemory(content, category, sourceConnector) {
|
|
8220
8315
|
const identity = buildExplicitCaptureDedupKey(content, category, sourceConnector);
|
|
@@ -8593,7 +8688,7 @@ ${sanitized.text}
|
|
|
8593
8688
|
await this.ensureDirectories();
|
|
8594
8689
|
const now = /* @__PURE__ */ new Date();
|
|
8595
8690
|
const day = now.toISOString().slice(0, 10);
|
|
8596
|
-
const dir =
|
|
8691
|
+
const dir = path15.join(this.artifactsDir, day);
|
|
8597
8692
|
await mkdir2(dir, { recursive: true });
|
|
8598
8693
|
const id = `artifact-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`;
|
|
8599
8694
|
const fm = {
|
|
@@ -8620,7 +8715,7 @@ ${sanitized.text}
|
|
|
8620
8715
|
log.warn(`artifact content rejected for ${id}; violations=${sanitized.violations.join(", ")}`);
|
|
8621
8716
|
return "";
|
|
8622
8717
|
}
|
|
8623
|
-
const filePath =
|
|
8718
|
+
const filePath = path15.join(dir, `${id}.md`);
|
|
8624
8719
|
await this.writeStorageSecureFile(filePath, `${serializeFrontmatter(this.withOkfType(fm))}
|
|
8625
8720
|
|
|
8626
8721
|
${sanitized.text}
|
|
@@ -8914,7 +9009,7 @@ ${sanitized.text}
|
|
|
8914
9009
|
* per-process in-memory cache safe across process boundaries.
|
|
8915
9010
|
*/
|
|
8916
9011
|
invalidateColdMemoriesCache() {
|
|
8917
|
-
const coldRoot =
|
|
9012
|
+
const coldRoot = path15.join(this.baseDir, "cold");
|
|
8918
9013
|
_StorageManager.coldMemoriesCache.delete(coldRoot);
|
|
8919
9014
|
this.bumpColdWriteVersion();
|
|
8920
9015
|
invalidateAllForDir(this.baseDir);
|
|
@@ -9032,7 +9127,7 @@ ${sanitized.text}
|
|
|
9032
9127
|
const correctionPaths = [];
|
|
9033
9128
|
const factPaths = [];
|
|
9034
9129
|
for (const filePath of filePaths) {
|
|
9035
|
-
if (filePath === this.correctionsDir || filePath.startsWith(`${this.correctionsDir}${
|
|
9130
|
+
if (filePath === this.correctionsDir || filePath.startsWith(`${this.correctionsDir}${path15.sep}`)) {
|
|
9036
9131
|
correctionPaths.push(filePath);
|
|
9037
9132
|
} else {
|
|
9038
9133
|
factPaths.push(filePath);
|
|
@@ -9052,11 +9147,12 @@ ${sanitized.text}
|
|
|
9052
9147
|
}
|
|
9053
9148
|
return ordered;
|
|
9054
9149
|
}
|
|
9055
|
-
async readWindowBoundedBatch(candidateBatchPaths, remainingSlots, remainingInspectionBudget, readBatchSize) {
|
|
9150
|
+
async readWindowBoundedBatch(candidateBatchPaths, remainingSlots, remainingInspectionBudget, readBatchSize, options) {
|
|
9056
9151
|
const memories = [];
|
|
9057
9152
|
const filePaths = [];
|
|
9058
9153
|
const normalizedReadBatchSize = this.normalizeMemoryReadBatchSize(readBatchSize);
|
|
9059
9154
|
for (let index = 0; index < candidateBatchPaths.length; ) {
|
|
9155
|
+
checkCorpusReadAbort(options);
|
|
9060
9156
|
if (memories.length >= remainingSlots || filePaths.length >= remainingInspectionBudget) break;
|
|
9061
9157
|
const availableSlots = remainingSlots - memories.length;
|
|
9062
9158
|
const availableInspectionBudget = remainingInspectionBudget - filePaths.length;
|
|
@@ -9068,7 +9164,7 @@ ${sanitized.text}
|
|
|
9068
9164
|
index += candidatePaths.length;
|
|
9069
9165
|
if (candidatePaths.length === 0) break;
|
|
9070
9166
|
filePaths.push(...candidatePaths);
|
|
9071
|
-
const parsedMemories = await this.readParsedMemoriesFromPaths(candidatePaths, candidatePaths.length);
|
|
9167
|
+
const parsedMemories = await this.readParsedMemoriesFromPaths(candidatePaths, candidatePaths.length, options);
|
|
9072
9168
|
if (parsedMemories.length === 0) continue;
|
|
9073
9169
|
memories.push(...parsedMemories.slice(0, availableSlots));
|
|
9074
9170
|
}
|
|
@@ -9098,7 +9194,7 @@ ${sanitized.text}
|
|
|
9098
9194
|
const entries = (await readdir6(dir, { withFileTypes: true })).filter((e) => !isMacOsReplicationJunkBasename(e.name));
|
|
9099
9195
|
for (const entry of entries) {
|
|
9100
9196
|
checkCorpusReadAbort(options);
|
|
9101
|
-
const fullPath =
|
|
9197
|
+
const fullPath = path15.join(dir, entry.name);
|
|
9102
9198
|
if (entry.isDirectory()) {
|
|
9103
9199
|
await readDir(fullPath);
|
|
9104
9200
|
} else if (entry.name.endsWith(".md")) {
|
|
@@ -9138,7 +9234,7 @@ ${sanitized.text}
|
|
|
9138
9234
|
return this.rememberMemorySnapshot(await this.memoryReadStore.readMemoryByPath(filePath));
|
|
9139
9235
|
}
|
|
9140
9236
|
resolveTierRootDir(tier) {
|
|
9141
|
-
return tier === "cold" ?
|
|
9237
|
+
return tier === "cold" ? path15.join(this.baseDir, "cold") : this.baseDir;
|
|
9142
9238
|
}
|
|
9143
9239
|
resolveMemoryDateDir(memory) {
|
|
9144
9240
|
const preferred = memory.frontmatter.created || memory.frontmatter.updated;
|
|
@@ -9153,13 +9249,13 @@ ${sanitized.text}
|
|
|
9153
9249
|
buildTierMemoryPath(memory, tier) {
|
|
9154
9250
|
const root = this.resolveTierRootDir(tier);
|
|
9155
9251
|
if (this.isArtifactMemory(memory)) {
|
|
9156
|
-
return
|
|
9252
|
+
return path15.join(root, "artifacts", this.resolveMemoryDateDir(memory), `${memory.frontmatter.id}.md`);
|
|
9157
9253
|
}
|
|
9158
9254
|
if (memory.frontmatter.category === "correction") {
|
|
9159
|
-
return
|
|
9255
|
+
return path15.join(root, "corrections", `${memory.frontmatter.id}.md`);
|
|
9160
9256
|
}
|
|
9161
9257
|
const dir = categoryDirName(memory.frontmatter.category);
|
|
9162
|
-
return
|
|
9258
|
+
return path15.join(root, dir, this.resolveMemoryDateDir(memory), `${memory.frontmatter.id}.md`);
|
|
9163
9259
|
}
|
|
9164
9260
|
async writeMemoryFileAtomic(targetPath, memory) {
|
|
9165
9261
|
assertNotOkfReservedBasename(targetPath);
|
|
@@ -9238,8 +9334,8 @@ ${memory.content}
|
|
|
9238
9334
|
memory.frontmatter.entityRef = current.frontmatter.entityRef;
|
|
9239
9335
|
}
|
|
9240
9336
|
durable = true;
|
|
9241
|
-
const sourcePath =
|
|
9242
|
-
const destPath =
|
|
9337
|
+
const sourcePath = path15.resolve(current.path);
|
|
9338
|
+
const destPath = path15.resolve(targetPath);
|
|
9243
9339
|
if (sourcePath !== destPath) {
|
|
9244
9340
|
await recordArchiveDelete2(this.baseDir, current.path, () => this.deleteManagedStorageFile(current.path));
|
|
9245
9341
|
this.invalidateAllMemoriesCache();
|
|
@@ -9263,8 +9359,8 @@ ${memory.content}
|
|
|
9263
9359
|
}
|
|
9264
9360
|
async migrateMemoryToTier(memory, targetTier) {
|
|
9265
9361
|
const targetPath = this.buildTierMemoryPath(memory, targetTier);
|
|
9266
|
-
const sourcePath =
|
|
9267
|
-
const destPath =
|
|
9362
|
+
const sourcePath = path15.resolve(memory.path);
|
|
9363
|
+
const destPath = path15.resolve(targetPath);
|
|
9268
9364
|
if (sourcePath === destPath) {
|
|
9269
9365
|
return { changed: false, targetPath };
|
|
9270
9366
|
}
|
|
@@ -9274,7 +9370,7 @@ ${memory.content}
|
|
|
9274
9370
|
return { changed, targetPath };
|
|
9275
9371
|
}
|
|
9276
9372
|
get archiveDir() {
|
|
9277
|
-
return
|
|
9373
|
+
return path15.join(this.baseDir, "archive");
|
|
9278
9374
|
}
|
|
9279
9375
|
/**
|
|
9280
9376
|
* Archive a memory by moving it from facts/ to archive/YYYY-MM-DD/.
|
|
@@ -9287,7 +9383,7 @@ ${memory.content}
|
|
|
9287
9383
|
try {
|
|
9288
9384
|
const now = lifecycle?.at ?? /* @__PURE__ */ new Date();
|
|
9289
9385
|
const today = now.toISOString().slice(0, 10);
|
|
9290
|
-
const destDir =
|
|
9386
|
+
const destDir = path15.join(this.archiveDir, today);
|
|
9291
9387
|
await mkdir2(destDir, { recursive: true });
|
|
9292
9388
|
const refIdsAtWrite = this.currentHistoricalIds();
|
|
9293
9389
|
const updatedFm = canonicalizeEntityRefOption(
|
|
@@ -9303,7 +9399,7 @@ ${memory.content}
|
|
|
9303
9399
|
|
|
9304
9400
|
${current.content}
|
|
9305
9401
|
`;
|
|
9306
|
-
const destPath =
|
|
9402
|
+
const destPath = path15.join(destDir, path15.basename(current.path));
|
|
9307
9403
|
const priorDest = await this.readStorageSecureFile(destPath).catch(() => null);
|
|
9308
9404
|
await recordArchiveWrite(this.baseDir, destPath, () => this.writeStorageSecureFile(destPath, fileContent));
|
|
9309
9405
|
if (typeof current.frontmatter.entityRef === "string") {
|
|
@@ -9537,7 +9633,7 @@ ${memory.content}
|
|
|
9537
9633
|
`;
|
|
9538
9634
|
await this.writeTombstoneBlockedFrontmatter(memory, fileContent, updated, async () => {
|
|
9539
9635
|
this.invalidateAllMemoriesCache();
|
|
9540
|
-
if (memory.path.includes(`${
|
|
9636
|
+
if (memory.path.includes(`${path15.sep}cold${path15.sep}`)) {
|
|
9541
9637
|
this.invalidateColdMemoriesCache();
|
|
9542
9638
|
}
|
|
9543
9639
|
});
|
|
@@ -9549,7 +9645,7 @@ ${memory.content}
|
|
|
9549
9645
|
}
|
|
9550
9646
|
if (mentionReentry && !entityMentionEpoch.neutral(memory.frontmatter, updated)) entityMentionEpoch.bump(this.baseDir);
|
|
9551
9647
|
await this.patchHotMemoriesCache({ addedPath: memory.path });
|
|
9552
|
-
if (memory.path.includes(`${
|
|
9648
|
+
if (memory.path.includes(`${path15.sep}cold${path15.sep}`)) {
|
|
9553
9649
|
this.invalidateColdMemoriesCache();
|
|
9554
9650
|
}
|
|
9555
9651
|
try {
|
|
@@ -9651,7 +9747,7 @@ ${memory.content}
|
|
|
9651
9747
|
return saveDroppedExtractionChunk(this.stateDir, (file, content) => this.writeStorageSecureFile(file, content), bufferKey, reason, turns);
|
|
9652
9748
|
}
|
|
9653
9749
|
async loadMeta() {
|
|
9654
|
-
const metaPath =
|
|
9750
|
+
const metaPath = path15.join(this.stateDir, "meta.json");
|
|
9655
9751
|
try {
|
|
9656
9752
|
const raw = await this.readStorageSecureFile(metaPath);
|
|
9657
9753
|
const parsed = JSON.parse(raw);
|
|
@@ -9684,7 +9780,7 @@ ${memory.content}
|
|
|
9684
9780
|
}
|
|
9685
9781
|
async saveMeta(state) {
|
|
9686
9782
|
await this.ensureDirectories();
|
|
9687
|
-
await this.writeStorageSecureFile(
|
|
9783
|
+
await this.writeStorageSecureFile(path15.join(this.stateDir, "meta.json"), JSON.stringify(state, null, 2));
|
|
9688
9784
|
}
|
|
9689
9785
|
async appendMemoryActionEvents(events) {
|
|
9690
9786
|
if (events.length === 0) return 0;
|
|
@@ -9753,7 +9849,7 @@ ${memory.content}
|
|
|
9753
9849
|
},
|
|
9754
9850
|
(payload) => this.appendStorageSecureFile(target, payload),
|
|
9755
9851
|
async () => {
|
|
9756
|
-
await mkdir2(
|
|
9852
|
+
await mkdir2(path15.dirname(target), { recursive: true });
|
|
9757
9853
|
}
|
|
9758
9854
|
);
|
|
9759
9855
|
}
|
|
@@ -9851,7 +9947,7 @@ ${memory.content}
|
|
|
9851
9947
|
async appendReextractJobs(events) {
|
|
9852
9948
|
if (events.length === 0) return 0;
|
|
9853
9949
|
await this.ensureDirectories();
|
|
9854
|
-
const filePath =
|
|
9950
|
+
const filePath = path15.join(this.stateDir, "reextract-jobs.jsonl");
|
|
9855
9951
|
const lines = events.map((event) => JSON.stringify(event)).join("\n") + "\n";
|
|
9856
9952
|
try {
|
|
9857
9953
|
await this.appendStorageSecureFile(filePath, lines);
|
|
@@ -9864,7 +9960,7 @@ ${memory.content}
|
|
|
9864
9960
|
}
|
|
9865
9961
|
async readReextractJobs(limit = 200) {
|
|
9866
9962
|
const safeLimit = Number.isFinite(limit) ? Math.max(1, Math.min(1e3, Math.floor(limit))) : 200;
|
|
9867
|
-
const filePath =
|
|
9963
|
+
const filePath = path15.join(this.stateDir, "reextract-jobs.jsonl");
|
|
9868
9964
|
try {
|
|
9869
9965
|
const raw = await this.readStorageSecureFile(filePath);
|
|
9870
9966
|
const lines = raw.split("\n").filter((line) => line.trim().length > 0);
|
|
@@ -10099,7 +10195,7 @@ ${question}
|
|
|
10099
10195
|
|
|
10100
10196
|
**Context:** ${context}
|
|
10101
10197
|
`;
|
|
10102
|
-
const filePath =
|
|
10198
|
+
const filePath = path15.join(this.questionsDir, `${id}.md`);
|
|
10103
10199
|
await this.writeStorageSecureFile(filePath, content);
|
|
10104
10200
|
log.debug(`wrote question ${id} to ${filePath}`);
|
|
10105
10201
|
this.invalidateQuestionsCache();
|
|
@@ -10158,11 +10254,11 @@ ${question}
|
|
|
10158
10254
|
} catch {
|
|
10159
10255
|
}
|
|
10160
10256
|
const hygiene = opts?.hygiene;
|
|
10161
|
-
const rotateEnabled = hygiene?.enabled === true && hygiene.rotateEnabled === true && Array.isArray(hygiene.rotatePaths) && hygiene.rotatePaths.includes(
|
|
10257
|
+
const rotateEnabled = hygiene?.enabled === true && hygiene.rotateEnabled === true && Array.isArray(hygiene.rotatePaths) && hygiene.rotatePaths.includes(path15.basename(identityPath));
|
|
10162
10258
|
if (rotateEnabled) {
|
|
10163
10259
|
const maxBytes = hygiene.rotateMaxBytes;
|
|
10164
10260
|
if (existing.length > maxBytes) {
|
|
10165
|
-
const archiveDir =
|
|
10261
|
+
const archiveDir = path15.join(workspaceDir, hygiene.archiveDir);
|
|
10166
10262
|
const { newContent } = await rotateMarkdownFileToArchive({
|
|
10167
10263
|
filePath: identityPath,
|
|
10168
10264
|
archiveDir,
|
|
@@ -10422,7 +10518,7 @@ ${reflection}
|
|
|
10422
10518
|
if (entries.length === 0) return 0;
|
|
10423
10519
|
const memories = await this.readAllMemories();
|
|
10424
10520
|
const memoryMap = new Map(memories.map((m) => [m.frontmatter.id, m]));
|
|
10425
|
-
const memoryPathMap = new Map(memories.map((m) => [
|
|
10521
|
+
const memoryPathMap = new Map(memories.map((m) => [path15.resolve(m.path), m]));
|
|
10426
10522
|
let updated = 0;
|
|
10427
10523
|
const prevVersion = this.getMemoryCorpusVersion();
|
|
10428
10524
|
let entityRefMoved = false;
|
|
@@ -10430,7 +10526,7 @@ ${reflection}
|
|
|
10430
10526
|
const warm = this.hotMemoriesCacheEnabled && getCachedMemories(this.baseDir, prevVersion, keyId, this.hotCacheTtlMs()) !== null;
|
|
10431
10527
|
const appliedPatches = /* @__PURE__ */ new Map();
|
|
10432
10528
|
for (const entry of entries) {
|
|
10433
|
-
const memory = entry.memoryPath ? memoryPathMap.get(
|
|
10529
|
+
const memory = entry.memoryPath ? memoryPathMap.get(path15.resolve(entry.memoryPath)) : memoryMap.get(entry.memoryId);
|
|
10434
10530
|
if (!memory) continue;
|
|
10435
10531
|
try {
|
|
10436
10532
|
const applied = await this.withTombstoneBlockedMemoryPathLock(memory.path, async (current) => {
|
|
@@ -10462,7 +10558,7 @@ ${current.content}
|
|
|
10462
10558
|
if (warm) {
|
|
10463
10559
|
updateCacheOnWrite(this.baseDir, { ...applied.current, frontmatter: applied.newFm }, keyId);
|
|
10464
10560
|
}
|
|
10465
|
-
appliedPatches.set(
|
|
10561
|
+
appliedPatches.set(path15.resolve(memory.path), {
|
|
10466
10562
|
accessCount: entry.newCount,
|
|
10467
10563
|
lastAccessed: entry.lastAccessed
|
|
10468
10564
|
});
|
|
@@ -10480,7 +10576,7 @@ ${current.content}
|
|
|
10480
10576
|
const cur = getCachedMemories(this.baseDir, prevVersion, keyId);
|
|
10481
10577
|
if (cur) {
|
|
10482
10578
|
const reapplied = cur.map((m) => {
|
|
10483
|
-
const patch = appliedPatches.get(
|
|
10579
|
+
const patch = appliedPatches.get(path15.resolve(m.path));
|
|
10484
10580
|
return patch ? {
|
|
10485
10581
|
...m,
|
|
10486
10582
|
frontmatter: { ...m.frontmatter, accessCount: patch.accessCount, lastAccessed: patch.lastAccessed }
|
|
@@ -10510,7 +10606,7 @@ ${current.content}
|
|
|
10510
10606
|
const pathsById = /* @__PURE__ */ new Map();
|
|
10511
10607
|
const filePathsById = /* @__PURE__ */ new Map();
|
|
10512
10608
|
for (const filePath of filePaths) {
|
|
10513
|
-
const memoryId =
|
|
10609
|
+
const memoryId = path15.basename(filePath, ".md");
|
|
10514
10610
|
if (!wantedIds.has(memoryId)) continue;
|
|
10515
10611
|
const paths = filePathsById.get(memoryId) ?? [];
|
|
10516
10612
|
paths.push(filePath);
|
|
@@ -10522,7 +10618,7 @@ ${current.content}
|
|
|
10522
10618
|
const preferredMatches = [];
|
|
10523
10619
|
for (const preferredPath of preferred) {
|
|
10524
10620
|
const directCandidates = new Set(qmdResultPathCandidates(this.baseDir, preferredPath));
|
|
10525
|
-
const directMatch = existingPaths.find((filePath) => directCandidates.has(
|
|
10621
|
+
const directMatch = existingPaths.find((filePath) => directCandidates.has(path15.resolve(filePath)));
|
|
10526
10622
|
if (directMatch) {
|
|
10527
10623
|
preferredMatches.push(directMatch);
|
|
10528
10624
|
continue;
|
|
@@ -10534,7 +10630,7 @@ ${current.content}
|
|
|
10534
10630
|
candidates.add(candidate);
|
|
10535
10631
|
}
|
|
10536
10632
|
}
|
|
10537
|
-
const match = existingPaths.find((filePath) => candidates.has(
|
|
10633
|
+
const match = existingPaths.find((filePath) => candidates.has(path15.resolve(filePath)));
|
|
10538
10634
|
if (match) preferredMatches.push(match);
|
|
10539
10635
|
}
|
|
10540
10636
|
if (preferredMatches.length > 0) {
|
|
@@ -10856,11 +10952,11 @@ ${current.content}
|
|
|
10856
10952
|
}
|
|
10857
10953
|
}
|
|
10858
10954
|
get summariesDir() {
|
|
10859
|
-
return
|
|
10955
|
+
return path15.join(this.baseDir, "summaries");
|
|
10860
10956
|
}
|
|
10861
10957
|
async writeSummary(summary) {
|
|
10862
10958
|
await mkdir2(this.summariesDir, { recursive: true });
|
|
10863
|
-
const filePath =
|
|
10959
|
+
const filePath = path15.join(this.summariesDir, `${summary.id}.json`);
|
|
10864
10960
|
await this.writeStorageSecureFile(filePath, JSON.stringify(summary, null, 2));
|
|
10865
10961
|
log.debug(`wrote summary ${summary.id}`);
|
|
10866
10962
|
}
|
|
@@ -10870,7 +10966,7 @@ ${current.content}
|
|
|
10870
10966
|
const summaries = [];
|
|
10871
10967
|
for (const file of files) {
|
|
10872
10968
|
if (isMacOsReplicationJunkBasename(file) || !file.endsWith(".json")) continue;
|
|
10873
|
-
const filePath =
|
|
10969
|
+
const filePath = path15.join(this.summariesDir, file);
|
|
10874
10970
|
const raw = await this.readStorageSecureFile(filePath);
|
|
10875
10971
|
summaries.push(JSON.parse(raw));
|
|
10876
10972
|
}
|
|
@@ -10940,13 +11036,13 @@ ${current.content}
|
|
|
10940
11036
|
return archived;
|
|
10941
11037
|
}
|
|
10942
11038
|
async saveTopics(topics) {
|
|
10943
|
-
const metaPath =
|
|
11039
|
+
const metaPath = path15.join(this.stateDir, "topics.json");
|
|
10944
11040
|
await mkdir2(this.stateDir, { recursive: true });
|
|
10945
11041
|
await this.writeStorageSecureFile(metaPath, JSON.stringify({ topics, updatedAt: (/* @__PURE__ */ new Date()).toISOString() }, null, 2));
|
|
10946
11042
|
log.debug(`saved ${topics.length} topic scores`);
|
|
10947
11043
|
}
|
|
10948
11044
|
async loadTopics() {
|
|
10949
|
-
const metaPath =
|
|
11045
|
+
const metaPath = path15.join(this.stateDir, "topics.json");
|
|
10950
11046
|
try {
|
|
10951
11047
|
const raw = await this.readStorageSecureFile(metaPath);
|
|
10952
11048
|
return JSON.parse(raw);
|
|
@@ -11066,4 +11162,4 @@ export {
|
|
|
11066
11162
|
isValidBufferSurpriseEvent,
|
|
11067
11163
|
StorageManager3 as StorageManager
|
|
11068
11164
|
};
|
|
11069
|
-
//# sourceMappingURL=chunk-
|
|
11165
|
+
//# sourceMappingURL=chunk-JIJAWTRK.js.map
|